PluginProbe
Gutenberg / 23.4.0
Gutenberg v23.4.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 / widgets / quick-draft / render.js

render.js in Gutenberg 23.4.0, at build/widgets/quick-draft/render.js

31,641 lines 1.1 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/autop
32 var require_autop = __commonJS({
33 "package-external:@wordpress/autop"(exports, module) {
34 module.exports = window.wp.autop;
35 }
36 });
37
38 // package-external:@wordpress/core-data
39 var require_core_data = __commonJS({
40 "package-external:@wordpress/core-data"(exports, module) {
41 module.exports = window.wp.coreData;
42 }
43 });
44
45 // package-external:@wordpress/data
46 var require_data = __commonJS({
47 "package-external:@wordpress/data"(exports, module) {
48 module.exports = window.wp.data;
49 }
50 });
51
52 // package-external:@wordpress/element
53 var require_element = __commonJS({
54 "package-external:@wordpress/element"(exports, module) {
55 module.exports = window.wp.element;
56 }
57 });
58
59 // package-external:@wordpress/compose
60 var require_compose = __commonJS({
61 "package-external:@wordpress/compose"(exports, module) {
62 module.exports = window.wp.compose;
63 }
64 });
65
66 // vendor-external:react
67 var require_react = __commonJS({
68 "vendor-external:react"(exports, module) {
69 module.exports = window.React;
70 }
71 });
72
73 // vendor-external:react/jsx-runtime
74 var require_jsx_runtime = __commonJS({
75 "vendor-external:react/jsx-runtime"(exports, module) {
76 module.exports = window.ReactJSXRuntime;
77 }
78 });
79
80 // vendor-external:react-dom
81 var require_react_dom = __commonJS({
82 "vendor-external:react-dom"(exports, module) {
83 module.exports = window.ReactDOM;
84 }
85 });
86
87 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
88 var require_use_sync_external_store_shim_development = __commonJS({
89 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
90 "use strict";
91 (function() {
92 function is(x2, y2) {
93 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
94 }
95 function useSyncExternalStore$2(subscribe2, getSnapshot) {
96 didWarnOld18Alpha || void 0 === React61.startTransition || (didWarnOld18Alpha = true, console.error(
97 "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."
98 ));
99 var value = getSnapshot();
100 if (!didWarnUncachedGetSnapshot) {
101 var cachedValue = getSnapshot();
102 objectIs(value, cachedValue) || (console.error(
103 "The result of getSnapshot should be cached to avoid an infinite loop"
104 ), didWarnUncachedGetSnapshot = true);
105 }
106 cachedValue = useState47({
107 inst: { value, getSnapshot }
108 });
109 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
110 useLayoutEffect5(
111 function() {
112 inst.value = value;
113 inst.getSnapshot = getSnapshot;
114 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
115 },
116 [subscribe2, value, getSnapshot]
117 );
118 useEffect40(
119 function() {
120 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
121 return subscribe2(function() {
122 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
123 });
124 },
125 [subscribe2]
126 );
127 useDebugValue2(value);
128 return value;
129 }
130 function checkIfSnapshotChanged(inst) {
131 var latestGetSnapshot = inst.getSnapshot;
132 inst = inst.value;
133 try {
134 var nextValue = latestGetSnapshot();
135 return !objectIs(inst, nextValue);
136 } catch (error2) {
137 return true;
138 }
139 }
140 function useSyncExternalStore$1(subscribe2, getSnapshot) {
141 return getSnapshot();
142 }
143 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
144 var React61 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState47 = React61.useState, useEffect40 = React61.useEffect, useLayoutEffect5 = React61.useLayoutEffect, useDebugValue2 = React61.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
145 exports.useSyncExternalStore = void 0 !== React61.useSyncExternalStore ? React61.useSyncExternalStore : shim;
146 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
147 })();
148 }
149 });
150
151 // node_modules/use-sync-external-store/shim/index.js
152 var require_shim = __commonJS({
153 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
154 "use strict";
155 if (false) {
156 module.exports = null;
157 } else {
158 module.exports = require_use_sync_external_store_shim_development();
159 }
160 }
161 });
162
163 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
164 var require_with_selector_development = __commonJS({
165 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
166 "use strict";
167 (function() {
168 function is(x2, y2) {
169 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
170 }
171 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
172 var React61 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef55 = React61.useRef, useEffect40 = React61.useEffect, useMemo53 = React61.useMemo, useDebugValue2 = React61.useDebugValue;
173 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
174 var instRef = useRef55(null);
175 if (null === instRef.current) {
176 var inst = { hasValue: false, value: null };
177 instRef.current = inst;
178 } else inst = instRef.current;
179 instRef = useMemo53(
180 function() {
181 function memoizedSelector(nextSnapshot) {
182 if (!hasMemo) {
183 hasMemo = true;
184 memoizedSnapshot = nextSnapshot;
185 nextSnapshot = selector2(nextSnapshot);
186 if (void 0 !== isEqual && inst.hasValue) {
187 var currentSelection = inst.value;
188 if (isEqual(currentSelection, nextSnapshot))
189 return memoizedSelection = currentSelection;
190 }
191 return memoizedSelection = nextSnapshot;
192 }
193 currentSelection = memoizedSelection;
194 if (objectIs(memoizedSnapshot, nextSnapshot))
195 return currentSelection;
196 var nextSelection = selector2(nextSnapshot);
197 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
198 return memoizedSnapshot = nextSnapshot, currentSelection;
199 memoizedSnapshot = nextSnapshot;
200 return memoizedSelection = nextSelection;
201 }
202 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
203 return [
204 function() {
205 return memoizedSelector(getSnapshot());
206 },
207 null === maybeGetServerSnapshot ? void 0 : function() {
208 return memoizedSelector(maybeGetServerSnapshot());
209 }
210 ];
211 },
212 [getSnapshot, getServerSnapshot, selector2, isEqual]
213 );
214 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
215 useEffect40(
216 function() {
217 inst.hasValue = true;
218 inst.value = value;
219 },
220 [value]
221 );
222 useDebugValue2(value);
223 return value;
224 };
225 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
226 })();
227 }
228 });
229
230 // node_modules/use-sync-external-store/shim/with-selector.js
231 var require_with_selector = __commonJS({
232 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
233 "use strict";
234 if (false) {
235 module.exports = null;
236 } else {
237 module.exports = require_with_selector_development();
238 }
239 }
240 });
241
242 // package-external:@wordpress/i18n
243 var require_i18n = __commonJS({
244 "package-external:@wordpress/i18n"(exports, module) {
245 module.exports = window.wp.i18n;
246 }
247 });
248
249 // package-external:@wordpress/primitives
250 var require_primitives = __commonJS({
251 "package-external:@wordpress/primitives"(exports, module) {
252 module.exports = window.wp.primitives;
253 }
254 });
255
256 // package-external:@wordpress/theme
257 var require_theme = __commonJS({
258 "package-external:@wordpress/theme"(exports, module) {
259 module.exports = window.wp.theme;
260 }
261 });
262
263 // package-external:@wordpress/private-apis
264 var require_private_apis = __commonJS({
265 "package-external:@wordpress/private-apis"(exports, module) {
266 module.exports = window.wp.privateApis;
267 }
268 });
269
270 // package-external:@wordpress/components
271 var require_components = __commonJS({
272 "package-external:@wordpress/components"(exports, module) {
273 module.exports = window.wp.components;
274 }
275 });
276
277 // package-external:@wordpress/keycodes
278 var require_keycodes = __commonJS({
279 "package-external:@wordpress/keycodes"(exports, module) {
280 module.exports = window.wp.keycodes;
281 }
282 });
283
284 // node_modules/remove-accents/index.js
285 var require_remove_accents = __commonJS({
286 "node_modules/remove-accents/index.js"(exports, module) {
287 var characterMap = {
288 "\xC0": "A",
289 "\xC1": "A",
290 "\xC2": "A",
291 "\xC3": "A",
292 "\xC4": "A",
293 "\xC5": "A",
294 "\u1EA4": "A",
295 "\u1EAE": "A",
296 "\u1EB2": "A",
297 "\u1EB4": "A",
298 "\u1EB6": "A",
299 "\xC6": "AE",
300 "\u1EA6": "A",
301 "\u1EB0": "A",
302 "\u0202": "A",
303 "\u1EA2": "A",
304 "\u1EA0": "A",
305 "\u1EA8": "A",
306 "\u1EAA": "A",
307 "\u1EAC": "A",
308 "\xC7": "C",
309 "\u1E08": "C",
310 "\xC8": "E",
311 "\xC9": "E",
312 "\xCA": "E",
313 "\xCB": "E",
314 "\u1EBE": "E",
315 "\u1E16": "E",
316 "\u1EC0": "E",
317 "\u1E14": "E",
318 "\u1E1C": "E",
319 "\u0206": "E",
320 "\u1EBA": "E",
321 "\u1EBC": "E",
322 "\u1EB8": "E",
323 "\u1EC2": "E",
324 "\u1EC4": "E",
325 "\u1EC6": "E",
326 "\xCC": "I",
327 "\xCD": "I",
328 "\xCE": "I",
329 "\xCF": "I",
330 "\u1E2E": "I",
331 "\u020A": "I",
332 "\u1EC8": "I",
333 "\u1ECA": "I",
334 "\xD0": "D",
335 "\xD1": "N",
336 "\xD2": "O",
337 "\xD3": "O",
338 "\xD4": "O",
339 "\xD5": "O",
340 "\xD6": "O",
341 "\xD8": "O",
342 "\u1ED0": "O",
343 "\u1E4C": "O",
344 "\u1E52": "O",
345 "\u020E": "O",
346 "\u1ECE": "O",
347 "\u1ECC": "O",
348 "\u1ED4": "O",
349 "\u1ED6": "O",
350 "\u1ED8": "O",
351 "\u1EDC": "O",
352 "\u1EDE": "O",
353 "\u1EE0": "O",
354 "\u1EDA": "O",
355 "\u1EE2": "O",
356 "\xD9": "U",
357 "\xDA": "U",
358 "\xDB": "U",
359 "\xDC": "U",
360 "\u1EE6": "U",
361 "\u1EE4": "U",
362 "\u1EEC": "U",
363 "\u1EEE": "U",
364 "\u1EF0": "U",
365 "\xDD": "Y",
366 "\xE0": "a",
367 "\xE1": "a",
368 "\xE2": "a",
369 "\xE3": "a",
370 "\xE4": "a",
371 "\xE5": "a",
372 "\u1EA5": "a",
373 "\u1EAF": "a",
374 "\u1EB3": "a",
375 "\u1EB5": "a",
376 "\u1EB7": "a",
377 "\xE6": "ae",
378 "\u1EA7": "a",
379 "\u1EB1": "a",
380 "\u0203": "a",
381 "\u1EA3": "a",
382 "\u1EA1": "a",
383 "\u1EA9": "a",
384 "\u1EAB": "a",
385 "\u1EAD": "a",
386 "\xE7": "c",
387 "\u1E09": "c",
388 "\xE8": "e",
389 "\xE9": "e",
390 "\xEA": "e",
391 "\xEB": "e",
392 "\u1EBF": "e",
393 "\u1E17": "e",
394 "\u1EC1": "e",
395 "\u1E15": "e",
396 "\u1E1D": "e",
397 "\u0207": "e",
398 "\u1EBB": "e",
399 "\u1EBD": "e",
400 "\u1EB9": "e",
401 "\u1EC3": "e",
402 "\u1EC5": "e",
403 "\u1EC7": "e",
404 "\xEC": "i",
405 "\xED": "i",
406 "\xEE": "i",
407 "\xEF": "i",
408 "\u1E2F": "i",
409 "\u020B": "i",
410 "\u1EC9": "i",
411 "\u1ECB": "i",
412 "\xF0": "d",
413 "\xF1": "n",
414 "\xF2": "o",
415 "\xF3": "o",
416 "\xF4": "o",
417 "\xF5": "o",
418 "\xF6": "o",
419 "\xF8": "o",
420 "\u1ED1": "o",
421 "\u1E4D": "o",
422 "\u1E53": "o",
423 "\u020F": "o",
424 "\u1ECF": "o",
425 "\u1ECD": "o",
426 "\u1ED5": "o",
427 "\u1ED7": "o",
428 "\u1ED9": "o",
429 "\u1EDD": "o",
430 "\u1EDF": "o",
431 "\u1EE1": "o",
432 "\u1EDB": "o",
433 "\u1EE3": "o",
434 "\xF9": "u",
435 "\xFA": "u",
436 "\xFB": "u",
437 "\xFC": "u",
438 "\u1EE7": "u",
439 "\u1EE5": "u",
440 "\u1EED": "u",
441 "\u1EEF": "u",
442 "\u1EF1": "u",
443 "\xFD": "y",
444 "\xFF": "y",
445 "\u0100": "A",
446 "\u0101": "a",
447 "\u0102": "A",
448 "\u0103": "a",
449 "\u0104": "A",
450 "\u0105": "a",
451 "\u0106": "C",
452 "\u0107": "c",
453 "\u0108": "C",
454 "\u0109": "c",
455 "\u010A": "C",
456 "\u010B": "c",
457 "\u010C": "C",
458 "\u010D": "c",
459 "C\u0306": "C",
460 "c\u0306": "c",
461 "\u010E": "D",
462 "\u010F": "d",
463 "\u0110": "D",
464 "\u0111": "d",
465 "\u0112": "E",
466 "\u0113": "e",
467 "\u0114": "E",
468 "\u0115": "e",
469 "\u0116": "E",
470 "\u0117": "e",
471 "\u0118": "E",
472 "\u0119": "e",
473 "\u011A": "E",
474 "\u011B": "e",
475 "\u011C": "G",
476 "\u01F4": "G",
477 "\u011D": "g",
478 "\u01F5": "g",
479 "\u011E": "G",
480 "\u011F": "g",
481 "\u0120": "G",
482 "\u0121": "g",
483 "\u0122": "G",
484 "\u0123": "g",
485 "\u0124": "H",
486 "\u0125": "h",
487 "\u0126": "H",
488 "\u0127": "h",
489 "\u1E2A": "H",
490 "\u1E2B": "h",
491 "\u0128": "I",
492 "\u0129": "i",
493 "\u012A": "I",
494 "\u012B": "i",
495 "\u012C": "I",
496 "\u012D": "i",
497 "\u012E": "I",
498 "\u012F": "i",
499 "\u0130": "I",
500 "\u0131": "i",
501 "\u0132": "IJ",
502 "\u0133": "ij",
503 "\u0134": "J",
504 "\u0135": "j",
505 "\u0136": "K",
506 "\u0137": "k",
507 "\u1E30": "K",
508 "\u1E31": "k",
509 "K\u0306": "K",
510 "k\u0306": "k",
511 "\u0139": "L",
512 "\u013A": "l",
513 "\u013B": "L",
514 "\u013C": "l",
515 "\u013D": "L",
516 "\u013E": "l",
517 "\u013F": "L",
518 "\u0140": "l",
519 "\u0141": "l",
520 "\u0142": "l",
521 "\u1E3E": "M",
522 "\u1E3F": "m",
523 "M\u0306": "M",
524 "m\u0306": "m",
525 "\u0143": "N",
526 "\u0144": "n",
527 "\u0145": "N",
528 "\u0146": "n",
529 "\u0147": "N",
530 "\u0148": "n",
531 "\u0149": "n",
532 "N\u0306": "N",
533 "n\u0306": "n",
534 "\u014C": "O",
535 "\u014D": "o",
536 "\u014E": "O",
537 "\u014F": "o",
538 "\u0150": "O",
539 "\u0151": "o",
540 "\u0152": "OE",
541 "\u0153": "oe",
542 "P\u0306": "P",
543 "p\u0306": "p",
544 "\u0154": "R",
545 "\u0155": "r",
546 "\u0156": "R",
547 "\u0157": "r",
548 "\u0158": "R",
549 "\u0159": "r",
550 "R\u0306": "R",
551 "r\u0306": "r",
552 "\u0212": "R",
553 "\u0213": "r",
554 "\u015A": "S",
555 "\u015B": "s",
556 "\u015C": "S",
557 "\u015D": "s",
558 "\u015E": "S",
559 "\u0218": "S",
560 "\u0219": "s",
561 "\u015F": "s",
562 "\u0160": "S",
563 "\u0161": "s",
564 "\u0162": "T",
565 "\u0163": "t",
566 "\u021B": "t",
567 "\u021A": "T",
568 "\u0164": "T",
569 "\u0165": "t",
570 "\u0166": "T",
571 "\u0167": "t",
572 "T\u0306": "T",
573 "t\u0306": "t",
574 "\u0168": "U",
575 "\u0169": "u",
576 "\u016A": "U",
577 "\u016B": "u",
578 "\u016C": "U",
579 "\u016D": "u",
580 "\u016E": "U",
581 "\u016F": "u",
582 "\u0170": "U",
583 "\u0171": "u",
584 "\u0172": "U",
585 "\u0173": "u",
586 "\u0216": "U",
587 "\u0217": "u",
588 "V\u0306": "V",
589 "v\u0306": "v",
590 "\u0174": "W",
591 "\u0175": "w",
592 "\u1E82": "W",
593 "\u1E83": "w",
594 "X\u0306": "X",
595 "x\u0306": "x",
596 "\u0176": "Y",
597 "\u0177": "y",
598 "\u0178": "Y",
599 "Y\u0306": "Y",
600 "y\u0306": "y",
601 "\u0179": "Z",
602 "\u017A": "z",
603 "\u017B": "Z",
604 "\u017C": "z",
605 "\u017D": "Z",
606 "\u017E": "z",
607 "\u017F": "s",
608 "\u0192": "f",
609 "\u01A0": "O",
610 "\u01A1": "o",
611 "\u01AF": "U",
612 "\u01B0": "u",
613 "\u01CD": "A",
614 "\u01CE": "a",
615 "\u01CF": "I",
616 "\u01D0": "i",
617 "\u01D1": "O",
618 "\u01D2": "o",
619 "\u01D3": "U",
620 "\u01D4": "u",
621 "\u01D5": "U",
622 "\u01D6": "u",
623 "\u01D7": "U",
624 "\u01D8": "u",
625 "\u01D9": "U",
626 "\u01DA": "u",
627 "\u01DB": "U",
628 "\u01DC": "u",
629 "\u1EE8": "U",
630 "\u1EE9": "u",
631 "\u1E78": "U",
632 "\u1E79": "u",
633 "\u01FA": "A",
634 "\u01FB": "a",
635 "\u01FC": "AE",
636 "\u01FD": "ae",
637 "\u01FE": "O",
638 "\u01FF": "o",
639 "\xDE": "TH",
640 "\xFE": "th",
641 "\u1E54": "P",
642 "\u1E55": "p",
643 "\u1E64": "S",
644 "\u1E65": "s",
645 "X\u0301": "X",
646 "x\u0301": "x",
647 "\u0403": "\u0413",
648 "\u0453": "\u0433",
649 "\u040C": "\u041A",
650 "\u045C": "\u043A",
651 "A\u030B": "A",
652 "a\u030B": "a",
653 "E\u030B": "E",
654 "e\u030B": "e",
655 "I\u030B": "I",
656 "i\u030B": "i",
657 "\u01F8": "N",
658 "\u01F9": "n",
659 "\u1ED2": "O",
660 "\u1ED3": "o",
661 "\u1E50": "O",
662 "\u1E51": "o",
663 "\u1EEA": "U",
664 "\u1EEB": "u",
665 "\u1E80": "W",
666 "\u1E81": "w",
667 "\u1EF2": "Y",
668 "\u1EF3": "y",
669 "\u0200": "A",
670 "\u0201": "a",
671 "\u0204": "E",
672 "\u0205": "e",
673 "\u0208": "I",
674 "\u0209": "i",
675 "\u020C": "O",
676 "\u020D": "o",
677 "\u0210": "R",
678 "\u0211": "r",
679 "\u0214": "U",
680 "\u0215": "u",
681 "B\u030C": "B",
682 "b\u030C": "b",
683 "\u010C\u0323": "C",
684 "\u010D\u0323": "c",
685 "\xCA\u030C": "E",
686 "\xEA\u030C": "e",
687 "F\u030C": "F",
688 "f\u030C": "f",
689 "\u01E6": "G",
690 "\u01E7": "g",
691 "\u021E": "H",
692 "\u021F": "h",
693 "J\u030C": "J",
694 "\u01F0": "j",
695 "\u01E8": "K",
696 "\u01E9": "k",
697 "M\u030C": "M",
698 "m\u030C": "m",
699 "P\u030C": "P",
700 "p\u030C": "p",
701 "Q\u030C": "Q",
702 "q\u030C": "q",
703 "\u0158\u0329": "R",
704 "\u0159\u0329": "r",
705 "\u1E66": "S",
706 "\u1E67": "s",
707 "V\u030C": "V",
708 "v\u030C": "v",
709 "W\u030C": "W",
710 "w\u030C": "w",
711 "X\u030C": "X",
712 "x\u030C": "x",
713 "Y\u030C": "Y",
714 "y\u030C": "y",
715 "A\u0327": "A",
716 "a\u0327": "a",
717 "B\u0327": "B",
718 "b\u0327": "b",
719 "\u1E10": "D",
720 "\u1E11": "d",
721 "\u0228": "E",
722 "\u0229": "e",
723 "\u0190\u0327": "E",
724 "\u025B\u0327": "e",
725 "\u1E28": "H",
726 "\u1E29": "h",
727 "I\u0327": "I",
728 "i\u0327": "i",
729 "\u0197\u0327": "I",
730 "\u0268\u0327": "i",
731 "M\u0327": "M",
732 "m\u0327": "m",
733 "O\u0327": "O",
734 "o\u0327": "o",
735 "Q\u0327": "Q",
736 "q\u0327": "q",
737 "U\u0327": "U",
738 "u\u0327": "u",
739 "X\u0327": "X",
740 "x\u0327": "x",
741 "Z\u0327": "Z",
742 "z\u0327": "z",
743 "\u0439": "\u0438",
744 "\u0419": "\u0418",
745 "\u0451": "\u0435",
746 "\u0401": "\u0415"
747 };
748 var chars = Object.keys(characterMap).join("|");
749 var allAccents = new RegExp(chars, "g");
750 var firstAccent = new RegExp(chars, "");
751 function matcher(match2) {
752 return characterMap[match2];
753 }
754 var removeAccents2 = function(string) {
755 return string.replace(allAccents, matcher);
756 };
757 var hasAccents = function(string) {
758 return !!string.match(firstAccent);
759 };
760 module.exports = removeAccents2;
761 module.exports.has = hasAccents;
762 module.exports.remove = removeAccents2;
763 }
764 });
765
766 // node_modules/fast-deep-equal/es6/index.js
767 var require_es6 = __commonJS({
768 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
769 "use strict";
770 module.exports = function equal(a2, b2) {
771 if (a2 === b2) return true;
772 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
773 if (a2.constructor !== b2.constructor) return false;
774 var length, i2, keys;
775 if (Array.isArray(a2)) {
776 length = a2.length;
777 if (length != b2.length) return false;
778 for (i2 = length; i2-- !== 0; )
779 if (!equal(a2[i2], b2[i2])) return false;
780 return true;
781 }
782 if (a2 instanceof Map && b2 instanceof Map) {
783 if (a2.size !== b2.size) return false;
784 for (i2 of a2.entries())
785 if (!b2.has(i2[0])) return false;
786 for (i2 of a2.entries())
787 if (!equal(i2[1], b2.get(i2[0]))) return false;
788 return true;
789 }
790 if (a2 instanceof Set && b2 instanceof Set) {
791 if (a2.size !== b2.size) return false;
792 for (i2 of a2.entries())
793 if (!b2.has(i2[0])) return false;
794 return true;
795 }
796 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
797 length = a2.length;
798 if (length != b2.length) return false;
799 for (i2 = length; i2-- !== 0; )
800 if (a2[i2] !== b2[i2]) return false;
801 return true;
802 }
803 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
804 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
805 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
806 keys = Object.keys(a2);
807 length = keys.length;
808 if (length !== Object.keys(b2).length) return false;
809 for (i2 = length; i2-- !== 0; )
810 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
811 for (i2 = length; i2-- !== 0; ) {
812 var key = keys[i2];
813 if (!equal(a2[key], b2[key])) return false;
814 }
815 return true;
816 }
817 return a2 !== a2 && b2 !== b2;
818 };
819 }
820 });
821
822 // package-external:@wordpress/date
823 var require_date = __commonJS({
824 "package-external:@wordpress/date"(exports, module) {
825 module.exports = window.wp.date;
826 }
827 });
828
829 // package-external:@wordpress/warning
830 var require_warning = __commonJS({
831 "package-external:@wordpress/warning"(exports, module) {
832 module.exports = window.wp.warning;
833 }
834 });
835
836 // node_modules/deepmerge/dist/cjs.js
837 var require_cjs = __commonJS({
838 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
839 "use strict";
840 var isMergeableObject = function isMergeableObject2(value) {
841 return isNonNullObject(value) && !isSpecial(value);
842 };
843 function isNonNullObject(value) {
844 return !!value && typeof value === "object";
845 }
846 function isSpecial(value) {
847 var stringValue = Object.prototype.toString.call(value);
848 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
849 }
850 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
851 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
852 function isReactElement(value) {
853 return value.$$typeof === REACT_ELEMENT_TYPE;
854 }
855 function emptyTarget(val) {
856 return Array.isArray(val) ? [] : {};
857 }
858 function cloneUnlessOtherwiseSpecified(value, options) {
859 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
860 }
861 function defaultArrayMerge(target, source, options) {
862 return target.concat(source).map(function(element) {
863 return cloneUnlessOtherwiseSpecified(element, options);
864 });
865 }
866 function getMergeFunction(key, options) {
867 if (!options.customMerge) {
868 return deepmerge;
869 }
870 var customMerge = options.customMerge(key);
871 return typeof customMerge === "function" ? customMerge : deepmerge;
872 }
873 function getEnumerableOwnPropertySymbols(target) {
874 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
875 return Object.propertyIsEnumerable.call(target, symbol3);
876 }) : [];
877 }
878 function getKeys2(target) {
879 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
880 }
881 function propertyIsOnObject(object, property) {
882 try {
883 return property in object;
884 } catch (_) {
885 return false;
886 }
887 }
888 function propertyIsUnsafe(target, key) {
889 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
890 }
891 function mergeObject(target, source, options) {
892 var destination = {};
893 if (options.isMergeableObject(target)) {
894 getKeys2(target).forEach(function(key) {
895 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
896 });
897 }
898 getKeys2(source).forEach(function(key) {
899 if (propertyIsUnsafe(target, key)) {
900 return;
901 }
902 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
903 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
904 } else {
905 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
906 }
907 });
908 return destination;
909 }
910 function deepmerge(target, source, options) {
911 options = options || {};
912 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
913 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
914 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
915 var sourceIsArray = Array.isArray(source);
916 var targetIsArray = Array.isArray(target);
917 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
918 if (!sourceAndTargetTypesMatch) {
919 return cloneUnlessOtherwiseSpecified(source, options);
920 } else if (sourceIsArray) {
921 return options.arrayMerge(target, source, options);
922 } else {
923 return mergeObject(target, source, options);
924 }
925 }
926 deepmerge.all = function deepmergeAll(array, options) {
927 if (!Array.isArray(array)) {
928 throw new Error("first argument should be an array");
929 }
930 return array.reduce(function(prev, next) {
931 return deepmerge(prev, next, options);
932 }, {});
933 };
934 var deepmerge_1 = deepmerge;
935 module.exports = deepmerge_1;
936 }
937 });
938
939 // package-external:@wordpress/escape-html
940 var require_escape_html = __commonJS({
941 "package-external:@wordpress/escape-html"(exports, module) {
942 module.exports = window.wp.escapeHtml;
943 }
944 });
945
946 // package-external:@wordpress/html-entities
947 var require_html_entities = __commonJS({
948 "package-external:@wordpress/html-entities"(exports, module) {
949 module.exports = window.wp.htmlEntities;
950 }
951 });
952
953 // package-external:@wordpress/url
954 var require_url = __commonJS({
955 "package-external:@wordpress/url"(exports, module) {
956 module.exports = window.wp.url;
957 }
958 });
959
960 // node_modules/clsx/dist/clsx.mjs
961 function r(e2) {
962 var t2, f2, n2 = "";
963 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
964 else if ("object" == typeof e2) if (Array.isArray(e2)) {
965 var o2 = e2.length;
966 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
967 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
968 return n2;
969 }
970 function clsx() {
971 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
972 return n2;
973 }
974 var clsx_default = clsx;
975
976 // widgets/quick-draft/render.tsx
977 var import_autop = __toESM(require_autop());
978 var import_core_data2 = __toESM(require_core_data());
979 var import_data7 = __toESM(require_data());
980
981 // packages/dataviews/build-module/dataviews/index.mjs
982 var import_element99 = __toESM(require_element(), 1);
983 var import_compose13 = __toESM(require_compose(), 1);
984
985 // packages/ui/build-module/badge/badge.mjs
986 var import_element11 = __toESM(require_element(), 1);
987
988 // node_modules/@base-ui/utils/esm/useControlled.js
989 var React = __toESM(require_react(), 1);
990
991 // node_modules/@base-ui/utils/esm/error.js
992 var set;
993 if (true) {
994 set = /* @__PURE__ */ new Set();
995 }
996 function error(...messages) {
997 if (true) {
998 const messageKey = messages.join(" ");
999 if (!set.has(messageKey)) {
1000 set.add(messageKey);
1001 console.error(`Base UI: ${messageKey}`);
1002 }
1003 }
1004 }
1005
1006 // node_modules/@base-ui/utils/esm/useControlled.js
1007 function useControlled({
1008 controlled,
1009 default: defaultProp,
1010 name,
1011 state = "value"
1012 }) {
1013 const {
1014 current: isControlled
1015 } = React.useRef(controlled !== void 0);
1016 const [valueState, setValue] = React.useState(defaultProp);
1017 const value = isControlled ? controlled : valueState;
1018 if (true) {
1019 React.useEffect(() => {
1020 if (isControlled !== (controlled !== void 0)) {
1021 error([`A component is changing the ${isControlled ? "" : "un"}controlled ${state} state of ${name} to be ${isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${name} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n"));
1022 }
1023 }, [state, name, controlled]);
1024 const {
1025 current: defaultValue2
1026 } = React.useRef(defaultProp);
1027 React.useEffect(() => {
1028 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
1029 error([`A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. To suppress this warning opt to use a controlled ${name}.`].join("\n"));
1030 }
1031 }, [defaultProp]);
1032 }
1033 const setValueIfUncontrolled = React.useCallback((newValue) => {
1034 if (!isControlled) {
1035 setValue(newValue);
1036 }
1037 }, []);
1038 return [value, setValueIfUncontrolled];
1039 }
1040 function serializeToDevModeString(input) {
1041 let nextId = 0;
1042 const seen = /* @__PURE__ */ new WeakMap();
1043 try {
1044 const result = JSON.stringify(input, function replacer(key, value) {
1045 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
1046 return void 0;
1047 }
1048 if (typeof value === "bigint") {
1049 return `__bigint__:${value}`;
1050 }
1051 if (value !== null && typeof value === "object") {
1052 const id = seen.get(value);
1053 if (id !== void 0) {
1054 return `__object__:${id}`;
1055 }
1056 seen.set(value, nextId);
1057 nextId += 1;
1058 }
1059 return value;
1060 });
1061 return result ?? `__top__:${typeof input}`;
1062 } catch {
1063 return "__unserializable__";
1064 }
1065 }
1066
1067 // node_modules/@base-ui/utils/esm/safeReact.js
1068 var React2 = __toESM(require_react(), 1);
1069 var SafeReact = {
1070 ...React2
1071 };
1072
1073 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1074 var React3 = __toESM(require_react(), 1);
1075 var UNINITIALIZED = {};
1076 function useRefWithInit(init2, initArg) {
1077 const ref = React3.useRef(UNINITIALIZED);
1078 if (ref.current === UNINITIALIZED) {
1079 ref.current = init2(initArg);
1080 }
1081 return ref;
1082 }
1083
1084 // node_modules/@base-ui/utils/esm/useStableCallback.js
1085 var useInsertionEffect = SafeReact.useInsertionEffect;
1086 var useSafeInsertionEffect = (
1087 // React 17 doesn't have useInsertionEffect.
1088 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1089 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1090 );
1091 function useStableCallback(callback) {
1092 const stable = useRefWithInit(createStableCallback).current;
1093 stable.next = callback;
1094 useSafeInsertionEffect(stable.effect);
1095 return stable.trampoline;
1096 }
1097 function createStableCallback() {
1098 const stable = {
1099 next: void 0,
1100 callback: assertNotCalled,
1101 trampoline: (...args) => stable.callback?.(...args),
1102 effect: () => {
1103 stable.callback = stable.next;
1104 }
1105 };
1106 return stable;
1107 }
1108 function assertNotCalled() {
1109 if (true) {
1110 throw (
1111 /* minify-error-disabled */
1112 new Error("Base UI: Cannot call an event handler while rendering.")
1113 );
1114 }
1115 }
1116
1117 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1118 var React4 = __toESM(require_react(), 1);
1119 var noop = () => {
1120 };
1121 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1122
1123 // node_modules/@base-ui/utils/esm/warn.js
1124 var set2;
1125 if (true) {
1126 set2 = /* @__PURE__ */ new Set();
1127 }
1128 function warn(...messages) {
1129 if (true) {
1130 const messageKey = messages.join(" ");
1131 if (!set2.has(messageKey)) {
1132 set2.add(messageKey);
1133 console.warn(`Base UI: ${messageKey}`);
1134 }
1135 }
1136 }
1137
1138 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1139 var React5 = __toESM(require_react(), 1);
1140 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1141 if (true) DirectionContext.displayName = "DirectionContext";
1142 function useDirection() {
1143 const context = React5.useContext(DirectionContext);
1144 return context?.direction ?? "ltr";
1145 }
1146
1147 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1148 var React8 = __toESM(require_react(), 1);
1149
1150 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1151 function useMergedRefs(a2, b2, c2, d2) {
1152 const forkRef = useRefWithInit(createForkRef).current;
1153 if (didChange(forkRef, a2, b2, c2, d2)) {
1154 update(forkRef, [a2, b2, c2, d2]);
1155 }
1156 return forkRef.callback;
1157 }
1158 function useMergedRefsN(refs) {
1159 const forkRef = useRefWithInit(createForkRef).current;
1160 if (didChangeN(forkRef, refs)) {
1161 update(forkRef, refs);
1162 }
1163 return forkRef.callback;
1164 }
1165 function createForkRef() {
1166 return {
1167 callback: null,
1168 cleanup: null,
1169 refs: []
1170 };
1171 }
1172 function didChange(forkRef, a2, b2, c2, d2) {
1173 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1174 }
1175 function didChangeN(forkRef, newRefs) {
1176 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1177 }
1178 function update(forkRef, refs) {
1179 forkRef.refs = refs;
1180 if (refs.every((ref) => ref == null)) {
1181 forkRef.callback = null;
1182 return;
1183 }
1184 forkRef.callback = (instance) => {
1185 if (forkRef.cleanup) {
1186 forkRef.cleanup();
1187 forkRef.cleanup = null;
1188 }
1189 if (instance != null) {
1190 const cleanupCallbacks = Array(refs.length).fill(null);
1191 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1192 const ref = refs[i2];
1193 if (ref == null) {
1194 continue;
1195 }
1196 switch (typeof ref) {
1197 case "function": {
1198 const refCleanup = ref(instance);
1199 if (typeof refCleanup === "function") {
1200 cleanupCallbacks[i2] = refCleanup;
1201 }
1202 break;
1203 }
1204 case "object": {
1205 ref.current = instance;
1206 break;
1207 }
1208 default:
1209 }
1210 }
1211 forkRef.cleanup = () => {
1212 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1213 const ref = refs[i2];
1214 if (ref == null) {
1215 continue;
1216 }
1217 switch (typeof ref) {
1218 case "function": {
1219 const cleanupCallback = cleanupCallbacks[i2];
1220 if (typeof cleanupCallback === "function") {
1221 cleanupCallback();
1222 } else {
1223 ref(null);
1224 }
1225 break;
1226 }
1227 case "object": {
1228 ref.current = null;
1229 break;
1230 }
1231 default:
1232 }
1233 }
1234 };
1235 }
1236 };
1237 }
1238
1239 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1240 var React7 = __toESM(require_react(), 1);
1241
1242 // node_modules/@base-ui/utils/esm/reactVersion.js
1243 var React6 = __toESM(require_react(), 1);
1244 var majorVersion = parseInt(React6.version, 10);
1245 function isReactVersionAtLeast(reactVersionToCheck) {
1246 return majorVersion >= reactVersionToCheck;
1247 }
1248
1249 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1250 function getReactElementRef(element) {
1251 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1252 return null;
1253 }
1254 const reactElement = element;
1255 const propsWithRef = reactElement.props;
1256 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1257 }
1258
1259 // node_modules/@base-ui/utils/esm/mergeObjects.js
1260 function mergeObjects(a2, b2) {
1261 if (a2 && !b2) {
1262 return a2;
1263 }
1264 if (!a2 && b2) {
1265 return b2;
1266 }
1267 if (a2 || b2) {
1268 return {
1269 ...a2,
1270 ...b2
1271 };
1272 }
1273 return void 0;
1274 }
1275
1276 // node_modules/@base-ui/utils/esm/empty.js
1277 function NOOP() {
1278 }
1279 var EMPTY_ARRAY = Object.freeze([]);
1280 var EMPTY_OBJECT = Object.freeze({});
1281
1282 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1283 function getStateAttributesProps(state, customMapping) {
1284 const props = {};
1285 for (const key in state) {
1286 const value = state[key];
1287 if (customMapping?.hasOwnProperty(key)) {
1288 const customProps = customMapping[key](value);
1289 if (customProps != null) {
1290 Object.assign(props, customProps);
1291 }
1292 continue;
1293 }
1294 if (value === true) {
1295 props[`data-${key.toLowerCase()}`] = "";
1296 } else if (value) {
1297 props[`data-${key.toLowerCase()}`] = value.toString();
1298 }
1299 }
1300 return props;
1301 }
1302
1303 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1304 function resolveClassName(className, state) {
1305 return typeof className === "function" ? className(state) : className;
1306 }
1307
1308 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1309 function resolveStyle(style, state) {
1310 return typeof style === "function" ? style(state) : style;
1311 }
1312
1313 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1314 var EMPTY_PROPS = {};
1315 function mergeProps(a2, b2, c2, d2, e2) {
1316 if (!c2 && !d2 && !e2 && !a2) {
1317 return createInitialMergedProps(b2);
1318 }
1319 let merged = createInitialMergedProps(a2);
1320 if (b2) {
1321 merged = mergeInto(merged, b2);
1322 }
1323 if (c2) {
1324 merged = mergeInto(merged, c2);
1325 }
1326 if (d2) {
1327 merged = mergeInto(merged, d2);
1328 }
1329 if (e2) {
1330 merged = mergeInto(merged, e2);
1331 }
1332 return merged;
1333 }
1334 function mergePropsN(props) {
1335 if (props.length === 0) {
1336 return EMPTY_PROPS;
1337 }
1338 if (props.length === 1) {
1339 return createInitialMergedProps(props[0]);
1340 }
1341 let merged = createInitialMergedProps(props[0]);
1342 for (let i2 = 1; i2 < props.length; i2 += 1) {
1343 merged = mergeInto(merged, props[i2]);
1344 }
1345 return merged;
1346 }
1347 function createInitialMergedProps(inputProps) {
1348 if (isPropsGetter(inputProps)) {
1349 return {
1350 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1351 };
1352 }
1353 return copyInitialProps(inputProps);
1354 }
1355 function mergeInto(merged, inputProps) {
1356 if (isPropsGetter(inputProps)) {
1357 return resolvePropsGetter(inputProps, merged);
1358 }
1359 return mutablyMergeInto(merged, inputProps);
1360 }
1361 function copyInitialProps(inputProps) {
1362 const copiedProps = {
1363 ...inputProps
1364 };
1365 for (const propName in copiedProps) {
1366 const propValue = copiedProps[propName];
1367 if (isEventHandler(propName, propValue)) {
1368 copiedProps[propName] = wrapEventHandler(propValue);
1369 }
1370 }
1371 return copiedProps;
1372 }
1373 function mutablyMergeInto(mergedProps, externalProps) {
1374 if (!externalProps) {
1375 return mergedProps;
1376 }
1377 for (const propName in externalProps) {
1378 const externalPropValue = externalProps[propName];
1379 switch (propName) {
1380 case "style": {
1381 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1382 break;
1383 }
1384 case "className": {
1385 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1386 break;
1387 }
1388 default: {
1389 if (isEventHandler(propName, externalPropValue)) {
1390 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1391 } else {
1392 mergedProps[propName] = externalPropValue;
1393 }
1394 }
1395 }
1396 }
1397 return mergedProps;
1398 }
1399 function isEventHandler(key, value) {
1400 const code0 = key.charCodeAt(0);
1401 const code1 = key.charCodeAt(1);
1402 const code2 = key.charCodeAt(2);
1403 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1404 }
1405 function isPropsGetter(inputProps) {
1406 return typeof inputProps === "function";
1407 }
1408 function resolvePropsGetter(inputProps, previousProps) {
1409 if (isPropsGetter(inputProps)) {
1410 return inputProps(previousProps);
1411 }
1412 return inputProps ?? EMPTY_PROPS;
1413 }
1414 function mergeEventHandlers(ourHandler, theirHandler) {
1415 if (!theirHandler) {
1416 return ourHandler;
1417 }
1418 if (!ourHandler) {
1419 return wrapEventHandler(theirHandler);
1420 }
1421 return (...args) => {
1422 const event = args[0];
1423 if (isSyntheticEvent(event)) {
1424 const baseUIEvent = event;
1425 makeEventPreventable(baseUIEvent);
1426 const result2 = theirHandler(...args);
1427 if (!baseUIEvent.baseUIHandlerPrevented) {
1428 ourHandler?.(...args);
1429 }
1430 return result2;
1431 }
1432 const result = theirHandler(...args);
1433 ourHandler?.(...args);
1434 return result;
1435 };
1436 }
1437 function wrapEventHandler(handler) {
1438 if (!handler) {
1439 return handler;
1440 }
1441 return (...args) => {
1442 const event = args[0];
1443 if (isSyntheticEvent(event)) {
1444 makeEventPreventable(event);
1445 }
1446 return handler(...args);
1447 };
1448 }
1449 function makeEventPreventable(event) {
1450 event.preventBaseUIHandler = () => {
1451 event.baseUIHandlerPrevented = true;
1452 };
1453 return event;
1454 }
1455 function mergeClassNames(ourClassName, theirClassName) {
1456 if (theirClassName) {
1457 if (ourClassName) {
1458 return theirClassName + " " + ourClassName;
1459 }
1460 return theirClassName;
1461 }
1462 return ourClassName;
1463 }
1464 function isSyntheticEvent(event) {
1465 return event != null && typeof event === "object" && "nativeEvent" in event;
1466 }
1467
1468 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1469 var import_react = __toESM(require_react(), 1);
1470 function useRenderElement(element, componentProps, params = {}) {
1471 const renderProp = componentProps.render;
1472 const outProps = useRenderElementProps(componentProps, params);
1473 if (params.enabled === false) {
1474 return null;
1475 }
1476 const state = params.state ?? EMPTY_OBJECT;
1477 return evaluateRenderProp(element, renderProp, outProps, state);
1478 }
1479 function useRenderElementProps(componentProps, params = {}) {
1480 const {
1481 className: classNameProp,
1482 style: styleProp,
1483 render: renderProp
1484 } = componentProps;
1485 const {
1486 state = EMPTY_OBJECT,
1487 ref,
1488 props,
1489 stateAttributesMapping: stateAttributesMapping4,
1490 enabled = true
1491 } = params;
1492 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1493 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1494 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping4) : EMPTY_OBJECT;
1495 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1496 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1497 if (typeof document !== "undefined") {
1498 if (!enabled) {
1499 useMergedRefs(null, null);
1500 } else if (Array.isArray(ref)) {
1501 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1502 } else {
1503 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1504 }
1505 }
1506 if (!enabled) {
1507 return EMPTY_OBJECT;
1508 }
1509 if (className !== void 0) {
1510 outProps.className = mergeClassNames(outProps.className, className);
1511 }
1512 if (style !== void 0) {
1513 outProps.style = mergeObjects(outProps.style, style);
1514 }
1515 return outProps;
1516 }
1517 function resolveRenderFunctionProps(props) {
1518 if (Array.isArray(props)) {
1519 return mergePropsN(props);
1520 }
1521 return mergeProps(void 0, props);
1522 }
1523 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1524 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1525 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1526 function evaluateRenderProp(element, render4, props, state) {
1527 if (render4) {
1528 if (typeof render4 === "function") {
1529 if (true) {
1530 warnIfRenderPropLooksLikeComponent(render4);
1531 }
1532 return render4(props, state);
1533 }
1534 const mergedProps = mergeProps(props, render4.props);
1535 mergedProps.ref = props.ref;
1536 let newElement = render4;
1537 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1538 const children = React8.Children.toArray(render4);
1539 newElement = children[0];
1540 }
1541 if (true) {
1542 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1543 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"));
1544 }
1545 }
1546 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1547 }
1548 if (element) {
1549 if (typeof element === "string") {
1550 return renderTag(element, props);
1551 }
1552 }
1553 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1554 }
1555 function warnIfRenderPropLooksLikeComponent(renderFn) {
1556 const functionName = renderFn.name;
1557 if (functionName.length === 0) {
1558 return;
1559 }
1560 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1561 return;
1562 }
1563 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1564 return;
1565 }
1566 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");
1567 }
1568 function renderTag(Tag, props) {
1569 if (Tag === "button") {
1570 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1571 type: "button",
1572 ...props,
1573 key: props.key
1574 });
1575 }
1576 if (Tag === "img") {
1577 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1578 alt: "",
1579 ...props,
1580 key: props.key
1581 });
1582 }
1583 return /* @__PURE__ */ React8.createElement(Tag, props);
1584 }
1585
1586 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1587 var reason_parts_exports = {};
1588 __export(reason_parts_exports, {
1589 cancelOpen: () => cancelOpen,
1590 chipRemovePress: () => chipRemovePress,
1591 clearPress: () => clearPress,
1592 closePress: () => closePress,
1593 closeWatcher: () => closeWatcher,
1594 decrementPress: () => decrementPress,
1595 disabled: () => disabled,
1596 drag: () => drag,
1597 escapeKey: () => escapeKey,
1598 focusOut: () => focusOut,
1599 imperativeAction: () => imperativeAction,
1600 incrementPress: () => incrementPress,
1601 initial: () => initial,
1602 inputBlur: () => inputBlur,
1603 inputChange: () => inputChange,
1604 inputClear: () => inputClear,
1605 inputPaste: () => inputPaste,
1606 inputPress: () => inputPress,
1607 itemPress: () => itemPress,
1608 keyboard: () => keyboard,
1609 linkPress: () => linkPress,
1610 listNavigation: () => listNavigation,
1611 missing: () => missing,
1612 none: () => none,
1613 outsidePress: () => outsidePress,
1614 pointer: () => pointer,
1615 scrub: () => scrub,
1616 siblingOpen: () => siblingOpen,
1617 swipe: () => swipe,
1618 trackPress: () => trackPress,
1619 triggerFocus: () => triggerFocus,
1620 triggerHover: () => triggerHover,
1621 triggerPress: () => triggerPress,
1622 wheel: () => wheel,
1623 windowResize: () => windowResize
1624 });
1625 var none = "none";
1626 var triggerPress = "trigger-press";
1627 var triggerHover = "trigger-hover";
1628 var triggerFocus = "trigger-focus";
1629 var outsidePress = "outside-press";
1630 var itemPress = "item-press";
1631 var closePress = "close-press";
1632 var linkPress = "link-press";
1633 var clearPress = "clear-press";
1634 var chipRemovePress = "chip-remove-press";
1635 var trackPress = "track-press";
1636 var incrementPress = "increment-press";
1637 var decrementPress = "decrement-press";
1638 var inputChange = "input-change";
1639 var inputClear = "input-clear";
1640 var inputBlur = "input-blur";
1641 var inputPaste = "input-paste";
1642 var inputPress = "input-press";
1643 var focusOut = "focus-out";
1644 var escapeKey = "escape-key";
1645 var closeWatcher = "close-watcher";
1646 var listNavigation = "list-navigation";
1647 var keyboard = "keyboard";
1648 var pointer = "pointer";
1649 var drag = "drag";
1650 var wheel = "wheel";
1651 var scrub = "scrub";
1652 var cancelOpen = "cancel-open";
1653 var siblingOpen = "sibling-open";
1654 var disabled = "disabled";
1655 var missing = "missing";
1656 var initial = "initial";
1657 var imperativeAction = "imperative-action";
1658 var swipe = "swipe";
1659 var windowResize = "window-resize";
1660
1661 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1662 function createChangeEventDetails(reason, event, trigger, customProperties) {
1663 let canceled = false;
1664 let allowPropagation = false;
1665 const custom = customProperties ?? EMPTY_OBJECT;
1666 const details = {
1667 reason,
1668 event: event ?? new Event("base-ui"),
1669 cancel() {
1670 canceled = true;
1671 },
1672 allowPropagation() {
1673 allowPropagation = true;
1674 },
1675 get isCanceled() {
1676 return canceled;
1677 },
1678 get isPropagationAllowed() {
1679 return allowPropagation;
1680 },
1681 trigger,
1682 ...custom
1683 };
1684 return details;
1685 }
1686
1687 // node_modules/@base-ui/utils/esm/useId.js
1688 var React9 = __toESM(require_react(), 1);
1689 var globalId = 0;
1690 function useGlobalId(idOverride, prefix = "mui") {
1691 const [defaultId, setDefaultId] = React9.useState(idOverride);
1692 const id = idOverride || defaultId;
1693 React9.useEffect(() => {
1694 if (defaultId == null) {
1695 globalId += 1;
1696 setDefaultId(`${prefix}-${globalId}`);
1697 }
1698 }, [defaultId, prefix]);
1699 return id;
1700 }
1701 var maybeReactUseId = SafeReact.useId;
1702 function useId(idOverride, prefix) {
1703 if (maybeReactUseId !== void 0) {
1704 const reactId = maybeReactUseId();
1705 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1706 }
1707 return useGlobalId(idOverride, prefix);
1708 }
1709
1710 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1711 function useBaseUiId(idOverride) {
1712 return useId(idOverride, "base-ui");
1713 }
1714
1715 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1716 var React12 = __toESM(require_react(), 1);
1717
1718 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1719 var React11 = __toESM(require_react(), 1);
1720
1721 // node_modules/@base-ui/utils/esm/useOnMount.js
1722 var React10 = __toESM(require_react(), 1);
1723 var EMPTY = [];
1724 function useOnMount(fn) {
1725 React10.useEffect(fn, EMPTY);
1726 }
1727
1728 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1729 var EMPTY2 = null;
1730 var LAST_RAF = globalThis.requestAnimationFrame;
1731 var Scheduler = class {
1732 /* This implementation uses an array as a backing data-structure for frame callbacks.
1733 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1734 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1735 * be much more efficient if there is a call pattern that alterns as
1736 * "request-cancel-request-cancel-…".
1737 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1738 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1739 callbacks = [];
1740 callbacksCount = 0;
1741 nextId = 1;
1742 startId = 1;
1743 isScheduled = false;
1744 tick = (timestamp) => {
1745 this.isScheduled = false;
1746 const currentCallbacks = this.callbacks;
1747 const currentCallbacksCount = this.callbacksCount;
1748 this.callbacks = [];
1749 this.callbacksCount = 0;
1750 this.startId = this.nextId;
1751 if (currentCallbacksCount > 0) {
1752 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1753 currentCallbacks[i2]?.(timestamp);
1754 }
1755 }
1756 };
1757 request(fn) {
1758 const id = this.nextId;
1759 this.nextId += 1;
1760 this.callbacks.push(fn);
1761 this.callbacksCount += 1;
1762 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1763 if (!this.isScheduled || didRAFChange) {
1764 requestAnimationFrame(this.tick);
1765 this.isScheduled = true;
1766 }
1767 return id;
1768 }
1769 cancel(id) {
1770 const index2 = id - this.startId;
1771 if (index2 < 0 || index2 >= this.callbacks.length) {
1772 return;
1773 }
1774 this.callbacks[index2] = null;
1775 this.callbacksCount -= 1;
1776 }
1777 };
1778 var scheduler = new Scheduler();
1779 var AnimationFrame = class _AnimationFrame {
1780 static create() {
1781 return new _AnimationFrame();
1782 }
1783 static request(fn) {
1784 return scheduler.request(fn);
1785 }
1786 static cancel(id) {
1787 return scheduler.cancel(id);
1788 }
1789 currentId = EMPTY2;
1790 /**
1791 * Executes `fn` after `delay`, clearing any previously scheduled call.
1792 */
1793 request(fn) {
1794 this.cancel();
1795 this.currentId = scheduler.request(() => {
1796 this.currentId = EMPTY2;
1797 fn();
1798 });
1799 }
1800 cancel = () => {
1801 if (this.currentId !== EMPTY2) {
1802 scheduler.cancel(this.currentId);
1803 this.currentId = EMPTY2;
1804 }
1805 };
1806 disposeEffect = () => {
1807 return this.cancel;
1808 };
1809 };
1810 function useAnimationFrame() {
1811 const timeout = useRefWithInit(AnimationFrame.create).current;
1812 useOnMount(timeout.disposeEffect);
1813 return timeout;
1814 }
1815
1816 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1817 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1818 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1819 const [mounted, setMounted] = React11.useState(open);
1820 if (open && !mounted) {
1821 setMounted(true);
1822 setTransitionStatus("starting");
1823 }
1824 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1825 setTransitionStatus("ending");
1826 }
1827 if (!open && !mounted && transitionStatus === "ending") {
1828 setTransitionStatus(void 0);
1829 }
1830 useIsoLayoutEffect(() => {
1831 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1832 const frame = AnimationFrame.request(() => {
1833 setTransitionStatus("ending");
1834 });
1835 return () => {
1836 AnimationFrame.cancel(frame);
1837 };
1838 }
1839 return void 0;
1840 }, [open, mounted, transitionStatus, deferEndingState]);
1841 useIsoLayoutEffect(() => {
1842 if (!open || enableIdleState) {
1843 return void 0;
1844 }
1845 const frame = AnimationFrame.request(() => {
1846 setTransitionStatus(void 0);
1847 });
1848 return () => {
1849 AnimationFrame.cancel(frame);
1850 };
1851 }, [enableIdleState, open]);
1852 useIsoLayoutEffect(() => {
1853 if (!open || !enableIdleState) {
1854 return void 0;
1855 }
1856 if (open && mounted && transitionStatus !== "idle") {
1857 setTransitionStatus("starting");
1858 }
1859 const frame = AnimationFrame.request(() => {
1860 setTransitionStatus("idle");
1861 });
1862 return () => {
1863 AnimationFrame.cancel(frame);
1864 };
1865 }, [enableIdleState, open, mounted, transitionStatus]);
1866 return {
1867 mounted,
1868 setMounted,
1869 transitionStatus
1870 };
1871 }
1872
1873 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1874 function useCollapsibleRoot(parameters) {
1875 const {
1876 open: openParam,
1877 defaultOpen,
1878 onOpenChange,
1879 disabled: disabled2
1880 } = parameters;
1881 const [open, setOpen] = useControlled({
1882 controlled: openParam,
1883 default: defaultOpen,
1884 name: "Collapsible",
1885 state: "open"
1886 });
1887 const {
1888 mounted,
1889 setMounted,
1890 transitionStatus
1891 } = useTransitionStatus(open, true, true);
1892 const defaultPanelId = useBaseUiId();
1893 const [panelIdState, setPanelIdState] = React12.useState();
1894 const panelId = panelIdState ?? defaultPanelId;
1895 const handleTrigger = useStableCallback((event) => {
1896 const nextOpen = !open;
1897 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
1898 onOpenChange(nextOpen, eventDetails);
1899 if (eventDetails.isCanceled) {
1900 return;
1901 }
1902 setOpen(nextOpen);
1903 });
1904 return React12.useMemo(() => ({
1905 disabled: disabled2,
1906 handleTrigger,
1907 mounted,
1908 open,
1909 panelId,
1910 setMounted,
1911 setOpen,
1912 setPanelIdState,
1913 transitionStatus
1914 }), [disabled2, handleTrigger, mounted, open, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]);
1915 }
1916
1917 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js
1918 var React13 = __toESM(require_react(), 1);
1919 var CollapsibleRootContext = /* @__PURE__ */ React13.createContext(void 0);
1920 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
1921 function useCollapsibleRootContext() {
1922 const context = React13.useContext(CollapsibleRootContext);
1923 if (context === void 0) {
1924 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
1925 }
1926 return context;
1927 }
1928
1929 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1930 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1931 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1932 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1933 return TransitionStatusDataAttributes2;
1934 })({});
1935 var STARTING_HOOK = {
1936 [TransitionStatusDataAttributes.startingStyle]: ""
1937 };
1938 var ENDING_HOOK = {
1939 [TransitionStatusDataAttributes.endingStyle]: ""
1940 };
1941 var transitionStatusMapping = {
1942 transitionStatus(value) {
1943 if (value === "starting") {
1944 return STARTING_HOOK;
1945 }
1946 if (value === "ending") {
1947 return ENDING_HOOK;
1948 }
1949 return null;
1950 }
1951 };
1952
1953 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js
1954 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
1955 CollapsiblePanelDataAttributes2["open"] = "data-open";
1956 CollapsiblePanelDataAttributes2["closed"] = "data-closed";
1957 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
1958 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
1959 return CollapsiblePanelDataAttributes2;
1960 })({});
1961
1962 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js
1963 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
1964 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
1965 return CollapsibleTriggerDataAttributes2;
1966 })({});
1967
1968 // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js
1969 var PANEL_OPEN_HOOK = {
1970 [CollapsiblePanelDataAttributes.open]: ""
1971 };
1972 var PANEL_CLOSED_HOOK = {
1973 [CollapsiblePanelDataAttributes.closed]: ""
1974 };
1975 var triggerOpenStateMapping = {
1976 open(value) {
1977 if (value) {
1978 return {
1979 [CollapsibleTriggerDataAttributes.panelOpen]: ""
1980 };
1981 }
1982 return null;
1983 }
1984 };
1985 var collapsibleOpenStateMapping = {
1986 open(value) {
1987 if (value) {
1988 return PANEL_OPEN_HOOK;
1989 }
1990 return PANEL_CLOSED_HOOK;
1991 }
1992 };
1993
1994 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
1995 var React16 = __toESM(require_react(), 1);
1996
1997 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1998 function hasWindow() {
1999 return typeof window !== "undefined";
2000 }
2001 function getNodeName(node) {
2002 if (isNode(node)) {
2003 return (node.nodeName || "").toLowerCase();
2004 }
2005 return "#document";
2006 }
2007 function getWindow(node) {
2008 var _node$ownerDocument;
2009 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2010 }
2011 function getDocumentElement(node) {
2012 var _ref;
2013 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2014 }
2015 function isNode(value) {
2016 if (!hasWindow()) {
2017 return false;
2018 }
2019 return value instanceof Node || value instanceof getWindow(value).Node;
2020 }
2021 function isElement(value) {
2022 if (!hasWindow()) {
2023 return false;
2024 }
2025 return value instanceof Element || value instanceof getWindow(value).Element;
2026 }
2027 function isHTMLElement(value) {
2028 if (!hasWindow()) {
2029 return false;
2030 }
2031 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2032 }
2033 function isShadowRoot(value) {
2034 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2035 return false;
2036 }
2037 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2038 }
2039 function isOverflowElement(element) {
2040 const {
2041 overflow,
2042 overflowX,
2043 overflowY,
2044 display
2045 } = getComputedStyle2(element);
2046 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2047 }
2048 function isTableElement(element) {
2049 return /^(table|td|th)$/.test(getNodeName(element));
2050 }
2051 function isTopLayer(element) {
2052 try {
2053 if (element.matches(":popover-open")) {
2054 return true;
2055 }
2056 } catch (_e) {
2057 }
2058 try {
2059 return element.matches(":modal");
2060 } catch (_e) {
2061 return false;
2062 }
2063 }
2064 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2065 var containRe = /paint|layout|strict|content/;
2066 var isNotNone = (value) => !!value && value !== "none";
2067 var isWebKitValue;
2068 function isContainingBlock(elementOrCss) {
2069 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2070 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 || "");
2071 }
2072 function getContainingBlock(element) {
2073 let currentNode = getParentNode(element);
2074 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2075 if (isContainingBlock(currentNode)) {
2076 return currentNode;
2077 } else if (isTopLayer(currentNode)) {
2078 return null;
2079 }
2080 currentNode = getParentNode(currentNode);
2081 }
2082 return null;
2083 }
2084 function isWebKit() {
2085 if (isWebKitValue == null) {
2086 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2087 }
2088 return isWebKitValue;
2089 }
2090 function isLastTraversableNode(node) {
2091 return /^(html|body|#document)$/.test(getNodeName(node));
2092 }
2093 function getComputedStyle2(element) {
2094 return getWindow(element).getComputedStyle(element);
2095 }
2096 function getNodeScroll(element) {
2097 if (isElement(element)) {
2098 return {
2099 scrollLeft: element.scrollLeft,
2100 scrollTop: element.scrollTop
2101 };
2102 }
2103 return {
2104 scrollLeft: element.scrollX,
2105 scrollTop: element.scrollY
2106 };
2107 }
2108 function getParentNode(node) {
2109 if (getNodeName(node) === "html") {
2110 return node;
2111 }
2112 const result = (
2113 // Step into the shadow DOM of the parent of a slotted node.
2114 node.assignedSlot || // DOM Element detected.
2115 node.parentNode || // ShadowRoot detected.
2116 isShadowRoot(node) && node.host || // Fallback.
2117 getDocumentElement(node)
2118 );
2119 return isShadowRoot(result) ? result.host : result;
2120 }
2121 function getNearestOverflowAncestor(node) {
2122 const parentNode = getParentNode(node);
2123 if (isLastTraversableNode(parentNode)) {
2124 return node.ownerDocument ? node.ownerDocument.body : node.body;
2125 }
2126 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2127 return parentNode;
2128 }
2129 return getNearestOverflowAncestor(parentNode);
2130 }
2131 function getOverflowAncestors(node, list, traverseIframes) {
2132 var _node$ownerDocument2;
2133 if (list === void 0) {
2134 list = [];
2135 }
2136 if (traverseIframes === void 0) {
2137 traverseIframes = true;
2138 }
2139 const scrollableAncestor = getNearestOverflowAncestor(node);
2140 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2141 const win = getWindow(scrollableAncestor);
2142 if (isBody) {
2143 const frameElement = getFrameElement(win);
2144 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2145 } else {
2146 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2147 }
2148 }
2149 function getFrameElement(win) {
2150 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2151 }
2152
2153 // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js
2154 var React14 = __toESM(require_react(), 1);
2155 var CompositeRootContext = /* @__PURE__ */ React14.createContext(void 0);
2156 if (true) CompositeRootContext.displayName = "CompositeRootContext";
2157 function useCompositeRootContext(optional = false) {
2158 const context = React14.useContext(CompositeRootContext);
2159 if (context === void 0 && !optional) {
2160 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
2161 }
2162 return context;
2163 }
2164
2165 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js
2166 var React15 = __toESM(require_react(), 1);
2167 function useFocusableWhenDisabled(parameters) {
2168 const {
2169 focusableWhenDisabled,
2170 disabled: disabled2,
2171 composite = false,
2172 tabIndex: tabIndexProp = 0,
2173 isNativeButton
2174 } = parameters;
2175 const isFocusableComposite = composite && focusableWhenDisabled !== false;
2176 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
2177 const props = React15.useMemo(() => {
2178 const additionalProps = {
2179 // allow Tabbing away from focusableWhenDisabled elements
2180 onKeyDown(event) {
2181 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
2182 event.preventDefault();
2183 }
2184 }
2185 };
2186 if (!composite) {
2187 additionalProps.tabIndex = tabIndexProp;
2188 if (!isNativeButton && disabled2) {
2189 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
2190 }
2191 }
2192 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
2193 additionalProps["aria-disabled"] = disabled2;
2194 }
2195 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
2196 additionalProps.disabled = disabled2;
2197 }
2198 return additionalProps;
2199 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
2200 return {
2201 props
2202 };
2203 }
2204
2205 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
2206 function useButton(parameters = {}) {
2207 const {
2208 disabled: disabled2 = false,
2209 focusableWhenDisabled,
2210 tabIndex = 0,
2211 native: isNativeButton = true,
2212 composite: compositeProp
2213 } = parameters;
2214 const elementRef = React16.useRef(null);
2215 const compositeRootContext = useCompositeRootContext(true);
2216 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2217 const {
2218 props: focusableWhenDisabledProps
2219 } = useFocusableWhenDisabled({
2220 focusableWhenDisabled,
2221 disabled: disabled2,
2222 composite: isCompositeItem,
2223 tabIndex,
2224 isNativeButton
2225 });
2226 if (true) {
2227 React16.useEffect(() => {
2228 if (!elementRef.current) {
2229 return;
2230 }
2231 const isButtonTag = isButtonElement(elementRef.current);
2232 if (isNativeButton) {
2233 if (!isButtonTag) {
2234 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2235 const message2 = "A component that acts as a button expected a native <button> because the `nativeButton` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the `render` prop, or set `nativeButton` to `false`.";
2236 error(`${message2}${ownerStackMessage}`);
2237 }
2238 } else if (isButtonTag) {
2239 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2240 const message2 = "A component that acts as a button expected a non-<button> because the `nativeButton` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set `nativeButton` to `true`.";
2241 error(`${message2}${ownerStackMessage}`);
2242 }
2243 }, [isNativeButton]);
2244 }
2245 const updateDisabled = React16.useCallback(() => {
2246 const element = elementRef.current;
2247 if (!isButtonElement(element)) {
2248 return;
2249 }
2250 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2251 element.disabled = false;
2252 }
2253 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2254 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2255 const getButtonProps = React16.useCallback((externalProps = {}) => {
2256 const {
2257 onClick: externalOnClick,
2258 onMouseDown: externalOnMouseDown,
2259 onKeyUp: externalOnKeyUp,
2260 onKeyDown: externalOnKeyDown,
2261 onPointerDown: externalOnPointerDown,
2262 ...otherExternalProps
2263 } = externalProps;
2264 return mergeProps({
2265 onClick(event) {
2266 if (disabled2) {
2267 event.preventDefault();
2268 return;
2269 }
2270 externalOnClick?.(event);
2271 },
2272 onMouseDown(event) {
2273 if (!disabled2) {
2274 externalOnMouseDown?.(event);
2275 }
2276 },
2277 onKeyDown(event) {
2278 if (disabled2) {
2279 return;
2280 }
2281 makeEventPreventable(event);
2282 externalOnKeyDown?.(event);
2283 if (event.baseUIHandlerPrevented) {
2284 return;
2285 }
2286 const isCurrentTarget = event.target === event.currentTarget;
2287 const currentTarget = event.currentTarget;
2288 const isButton2 = isButtonElement(currentTarget);
2289 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2290 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2291 const isEnterKey = event.key === "Enter";
2292 const isSpaceKey = event.key === " ";
2293 const role = currentTarget.getAttribute("role");
2294 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2295 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2296 if (event.defaultPrevented && isTextNavigationRole) {
2297 return;
2298 }
2299 event.preventDefault();
2300 if (isLink || isNativeButton && isButton2) {
2301 currentTarget.click();
2302 event.preventBaseUIHandler();
2303 } else if (shouldClick) {
2304 externalOnClick?.(event);
2305 event.preventBaseUIHandler();
2306 }
2307 return;
2308 }
2309 if (shouldClick) {
2310 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2311 event.preventDefault();
2312 }
2313 if (!isNativeButton && isEnterKey) {
2314 externalOnClick?.(event);
2315 }
2316 }
2317 },
2318 onKeyUp(event) {
2319 if (disabled2) {
2320 return;
2321 }
2322 makeEventPreventable(event);
2323 externalOnKeyUp?.(event);
2324 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2325 event.preventDefault();
2326 return;
2327 }
2328 if (event.baseUIHandlerPrevented) {
2329 return;
2330 }
2331 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2332 externalOnClick?.(event);
2333 }
2334 },
2335 onPointerDown(event) {
2336 if (disabled2) {
2337 event.preventDefault();
2338 return;
2339 }
2340 externalOnPointerDown?.(event);
2341 }
2342 }, isNativeButton ? {
2343 type: "button"
2344 } : {
2345 role: "button"
2346 }, focusableWhenDisabledProps, otherExternalProps);
2347 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2348 const buttonRef = useStableCallback((element) => {
2349 elementRef.current = element;
2350 updateDisabled();
2351 });
2352 return {
2353 getButtonProps,
2354 buttonRef
2355 };
2356 }
2357 function isButtonElement(elem) {
2358 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2359 }
2360 function isValidLinkElement(elem) {
2361 return Boolean(elem?.tagName === "A" && elem?.href);
2362 }
2363
2364 // node_modules/@base-ui/utils/esm/detectBrowser.js
2365 var hasNavigator = typeof navigator !== "undefined";
2366 var nav = getNavigatorData();
2367 var platform = getPlatform();
2368 var userAgent = getUserAgent();
2369 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2370 var isIOS = (
2371 // iPads can claim to be MacIntel
2372 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2373 );
2374 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2375 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2376 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2377 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2378 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2379 var isJSDOM = userAgent.includes("jsdom/");
2380 function getNavigatorData() {
2381 if (!hasNavigator) {
2382 return {
2383 platform: "",
2384 maxTouchPoints: -1
2385 };
2386 }
2387 const uaData = navigator.userAgentData;
2388 if (uaData?.platform) {
2389 return {
2390 platform: uaData.platform,
2391 maxTouchPoints: navigator.maxTouchPoints
2392 };
2393 }
2394 return {
2395 platform: navigator.platform ?? "",
2396 maxTouchPoints: navigator.maxTouchPoints ?? -1
2397 };
2398 }
2399 function getUserAgent() {
2400 if (!hasNavigator) {
2401 return "";
2402 }
2403 const uaData = navigator.userAgentData;
2404 if (uaData && Array.isArray(uaData.brands)) {
2405 return uaData.brands.map(({
2406 brand,
2407 version: version2
2408 }) => `${brand}/${version2}`).join(" ");
2409 }
2410 return navigator.userAgent;
2411 }
2412 function getPlatform() {
2413 if (!hasNavigator) {
2414 return "";
2415 }
2416 const uaData = navigator.userAgentData;
2417 if (uaData?.platform) {
2418 return uaData.platform;
2419 }
2420 return navigator.platform ?? "";
2421 }
2422
2423 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2424 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2425 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2426
2427 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2428 function activeElement(doc) {
2429 let element = doc.activeElement;
2430 while (element?.shadowRoot?.activeElement != null) {
2431 element = element.shadowRoot.activeElement;
2432 }
2433 return element;
2434 }
2435 function contains(parent, child) {
2436 if (!parent || !child) {
2437 return false;
2438 }
2439 const rootNode = child.getRootNode?.();
2440 if (parent.contains(child)) {
2441 return true;
2442 }
2443 if (rootNode && isShadowRoot(rootNode)) {
2444 let next = child;
2445 while (next) {
2446 if (parent === next) {
2447 return true;
2448 }
2449 next = next.parentNode || next.host;
2450 }
2451 }
2452 return false;
2453 }
2454 function getTarget(event) {
2455 if ("composedPath" in event) {
2456 return event.composedPath()[0];
2457 }
2458 return event.target;
2459 }
2460
2461 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2462 function isTargetInsideEnabledTrigger(target, triggerElements) {
2463 if (!isElement(target)) {
2464 return false;
2465 }
2466 const targetElement = target;
2467 if (triggerElements.hasElement(targetElement)) {
2468 return !targetElement.hasAttribute("data-trigger-disabled");
2469 }
2470 for (const [, trigger] of triggerElements.entries()) {
2471 if (contains(trigger, targetElement)) {
2472 return !trigger.hasAttribute("data-trigger-disabled");
2473 }
2474 }
2475 return false;
2476 }
2477 function isEventTargetWithin(event, node) {
2478 if (node == null) {
2479 return false;
2480 }
2481 if ("composedPath" in event) {
2482 return event.composedPath().includes(node);
2483 }
2484 const eventAgain = event;
2485 return eventAgain.target != null && node.contains(eventAgain.target);
2486 }
2487 function isRootElement(element) {
2488 return element.matches("html,body");
2489 }
2490 function isTypeableElement(element) {
2491 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2492 }
2493 function isInteractiveElement(element) {
2494 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2495 }
2496 function matchesFocusVisible(element) {
2497 if (!element || isJSDOM) {
2498 return true;
2499 }
2500 try {
2501 return element.matches(":focus-visible");
2502 } catch (_e) {
2503 return true;
2504 }
2505 }
2506
2507 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2508 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2509 const directChildren = nodes.filter((node) => node.parentId === id);
2510 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2511 }
2512
2513 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2514 function isReactEvent(event) {
2515 return "nativeEvent" in event;
2516 }
2517 function isMouseLikePointerType(pointerType, strict) {
2518 const values = ["mouse", "pen"];
2519 if (!strict) {
2520 values.push("", void 0);
2521 }
2522 return values.includes(pointerType);
2523 }
2524 function isClickLikeEvent(event) {
2525 const type = event.type;
2526 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2527 }
2528
2529 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2530 var sides = ["top", "right", "bottom", "left"];
2531 var min = Math.min;
2532 var max = Math.max;
2533 var round = Math.round;
2534 var floor = Math.floor;
2535 var createCoords = (v2) => ({
2536 x: v2,
2537 y: v2
2538 });
2539 var oppositeSideMap = {
2540 left: "right",
2541 right: "left",
2542 bottom: "top",
2543 top: "bottom"
2544 };
2545 function clamp(start, value, end) {
2546 return max(start, min(value, end));
2547 }
2548 function evaluate(value, param) {
2549 return typeof value === "function" ? value(param) : value;
2550 }
2551 function getSide(placement) {
2552 return placement.split("-")[0];
2553 }
2554 function getAlignment(placement) {
2555 return placement.split("-")[1];
2556 }
2557 function getOppositeAxis(axis) {
2558 return axis === "x" ? "y" : "x";
2559 }
2560 function getAxisLength(axis) {
2561 return axis === "y" ? "height" : "width";
2562 }
2563 function getSideAxis(placement) {
2564 const firstChar = placement[0];
2565 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2566 }
2567 function getAlignmentAxis(placement) {
2568 return getOppositeAxis(getSideAxis(placement));
2569 }
2570 function getAlignmentSides(placement, rects, rtl) {
2571 if (rtl === void 0) {
2572 rtl = false;
2573 }
2574 const alignment = getAlignment(placement);
2575 const alignmentAxis = getAlignmentAxis(placement);
2576 const length = getAxisLength(alignmentAxis);
2577 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2578 if (rects.reference[length] > rects.floating[length]) {
2579 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2580 }
2581 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2582 }
2583 function getExpandedPlacements(placement) {
2584 const oppositePlacement = getOppositePlacement(placement);
2585 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2586 }
2587 function getOppositeAlignmentPlacement(placement) {
2588 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2589 }
2590 var lrPlacement = ["left", "right"];
2591 var rlPlacement = ["right", "left"];
2592 var tbPlacement = ["top", "bottom"];
2593 var btPlacement = ["bottom", "top"];
2594 function getSideList(side, isStart, rtl) {
2595 switch (side) {
2596 case "top":
2597 case "bottom":
2598 if (rtl) return isStart ? rlPlacement : lrPlacement;
2599 return isStart ? lrPlacement : rlPlacement;
2600 case "left":
2601 case "right":
2602 return isStart ? tbPlacement : btPlacement;
2603 default:
2604 return [];
2605 }
2606 }
2607 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2608 const alignment = getAlignment(placement);
2609 let list = getSideList(getSide(placement), direction === "start", rtl);
2610 if (alignment) {
2611 list = list.map((side) => side + "-" + alignment);
2612 if (flipAlignment) {
2613 list = list.concat(list.map(getOppositeAlignmentPlacement));
2614 }
2615 }
2616 return list;
2617 }
2618 function getOppositePlacement(placement) {
2619 const side = getSide(placement);
2620 return oppositeSideMap[side] + placement.slice(side.length);
2621 }
2622 function expandPaddingObject(padding) {
2623 return {
2624 top: 0,
2625 right: 0,
2626 bottom: 0,
2627 left: 0,
2628 ...padding
2629 };
2630 }
2631 function getPaddingObject(padding) {
2632 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2633 top: padding,
2634 right: padding,
2635 bottom: padding,
2636 left: padding
2637 };
2638 }
2639 function rectToClientRect(rect) {
2640 const {
2641 x: x2,
2642 y: y2,
2643 width,
2644 height
2645 } = rect;
2646 return {
2647 width,
2648 height,
2649 top: y2,
2650 left: x2,
2651 right: x2 + width,
2652 bottom: y2 + height,
2653 x: x2,
2654 y: y2
2655 };
2656 }
2657
2658 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2659 function isHiddenByStyles(styles) {
2660 return styles.visibility === "hidden" || styles.visibility === "collapse";
2661 }
2662 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2663 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2664 return false;
2665 }
2666 if (typeof element.checkVisibility === "function") {
2667 return element.checkVisibility();
2668 }
2669 return styles.display !== "none" && styles.display !== "contents";
2670 }
2671
2672 // node_modules/@base-ui/utils/esm/owner.js
2673 function ownerDocument(node) {
2674 return node?.ownerDocument || document;
2675 }
2676
2677 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2678 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2679 function getParentElement(element) {
2680 const assignedSlot = element.assignedSlot;
2681 if (assignedSlot) {
2682 return assignedSlot;
2683 }
2684 if (element.parentElement) {
2685 return element.parentElement;
2686 }
2687 const rootNode = element.getRootNode();
2688 return isShadowRoot(rootNode) ? rootNode.host : null;
2689 }
2690 function getDetailsSummary(details) {
2691 for (const child of Array.from(details.children)) {
2692 if (getNodeName(child) === "summary") {
2693 return child;
2694 }
2695 }
2696 return null;
2697 }
2698 function isWithinOpenDetailsSummary(element, details) {
2699 const summary = getDetailsSummary(details);
2700 return !!summary && (element === summary || contains(summary, element));
2701 }
2702 function isFocusableCandidate(element) {
2703 const nodeName = element ? getNodeName(element) : "";
2704 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");
2705 }
2706 function isFocusableElement(element) {
2707 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2708 return false;
2709 }
2710 for (let current = element; current; current = getParentElement(current)) {
2711 const isAncestor = current !== element;
2712 const isSlot = getNodeName(current) === "slot";
2713 if (current.hasAttribute("inert")) {
2714 return false;
2715 }
2716 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2717 return false;
2718 }
2719 }
2720 return true;
2721 }
2722 function isVisibleInTabbableTree(element, isAncestor) {
2723 const styles = getComputedStyle2(element);
2724 if (!isAncestor) {
2725 return isElementVisible(element, styles);
2726 }
2727 return styles.display !== "none";
2728 }
2729 function getTabIndex(element) {
2730 const tabIndex = element.tabIndex;
2731 if (tabIndex < 0) {
2732 const nodeName = getNodeName(element);
2733 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2734 return 0;
2735 }
2736 }
2737 return tabIndex;
2738 }
2739 function getNamedRadioInput(element) {
2740 if (getNodeName(element) !== "input") {
2741 return null;
2742 }
2743 const input = element;
2744 return input.type === "radio" && input.name !== "" ? input : null;
2745 }
2746 function isTabbableRadio(element, candidates) {
2747 const input = getNamedRadioInput(element);
2748 if (!input) {
2749 return true;
2750 }
2751 const checkedRadio = candidates.find((candidate) => {
2752 const radio = getNamedRadioInput(candidate);
2753 return radio?.name === input.name && radio.form === input.form && radio.checked;
2754 });
2755 if (checkedRadio) {
2756 return checkedRadio === input;
2757 }
2758 return candidates.find((candidate) => {
2759 const radio = getNamedRadioInput(candidate);
2760 return radio?.name === input.name && radio.form === input.form;
2761 }) === input;
2762 }
2763 function getComposedChildren(container) {
2764 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2765 const assignedElements = container.assignedElements({
2766 flatten: true
2767 });
2768 if (assignedElements.length > 0) {
2769 return assignedElements;
2770 }
2771 }
2772 if (isHTMLElement(container) && container.shadowRoot) {
2773 return Array.from(container.shadowRoot.children);
2774 }
2775 return Array.from(container.children);
2776 }
2777 function appendCandidates(container, list) {
2778 getComposedChildren(container).forEach((child) => {
2779 if (isFocusableCandidate(child)) {
2780 list.push(child);
2781 }
2782 appendCandidates(child, list);
2783 });
2784 }
2785 function appendMatchingElements(container, selector2, list) {
2786 getComposedChildren(container).forEach((child) => {
2787 if (isHTMLElement(child) && child.matches(selector2)) {
2788 list.push(child);
2789 }
2790 appendMatchingElements(child, selector2, list);
2791 });
2792 }
2793 function focusable(container) {
2794 const candidates = [];
2795 appendCandidates(container, candidates);
2796 return candidates.filter(isFocusableElement);
2797 }
2798 function tabbable(container) {
2799 const candidates = focusable(container);
2800 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2801 }
2802 function getTabbableIn(container, dir) {
2803 const list = tabbable(container);
2804 const len = list.length;
2805 if (len === 0) {
2806 return void 0;
2807 }
2808 const active = activeElement(ownerDocument(container));
2809 const index2 = list.indexOf(active);
2810 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2811 return list[nextIndex];
2812 }
2813 function getNextTabbable(referenceElement) {
2814 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2815 }
2816 function getPreviousTabbable(referenceElement) {
2817 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2818 }
2819 function isOutsideEvent(event, container) {
2820 const containerElement = container || event.currentTarget;
2821 const relatedTarget = event.relatedTarget;
2822 return !relatedTarget || !contains(containerElement, relatedTarget);
2823 }
2824 function disableFocusInside(container) {
2825 const tabbableElements = tabbable(container);
2826 tabbableElements.forEach((element) => {
2827 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2828 element.setAttribute("tabindex", "-1");
2829 });
2830 }
2831 function enableFocusInside(container) {
2832 const elements = [];
2833 appendMatchingElements(container, "[data-tabindex]", elements);
2834 elements.forEach((element) => {
2835 const tabindex = element.dataset.tabindex;
2836 delete element.dataset.tabindex;
2837 if (tabindex) {
2838 element.setAttribute("tabindex", tabindex);
2839 } else {
2840 element.removeAttribute("tabindex");
2841 }
2842 });
2843 }
2844
2845 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2846 var React18 = __toESM(require_react(), 1);
2847
2848 // node_modules/@base-ui/utils/esm/addEventListener.js
2849 function addEventListener(target, type, listener, options) {
2850 target.addEventListener(type, listener, options);
2851 return () => {
2852 target.removeEventListener(type, listener, options);
2853 };
2854 }
2855
2856 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2857 function useValueAsRef(value) {
2858 const latest = useRefWithInit(createLatestRef, value).current;
2859 latest.next = value;
2860 useIsoLayoutEffect(latest.effect);
2861 return latest;
2862 }
2863 function createLatestRef(value) {
2864 const latest = {
2865 current: value,
2866 next: value,
2867 effect: () => {
2868 latest.current = latest.next;
2869 }
2870 };
2871 return latest;
2872 }
2873
2874 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2875 var React17 = __toESM(require_react(), 1);
2876
2877 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2878 var ReactDOM = __toESM(require_react_dom(), 1);
2879
2880 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2881 function resolveRef(maybeRef) {
2882 if (maybeRef == null) {
2883 return maybeRef;
2884 }
2885 return "current" in maybeRef ? maybeRef.current : maybeRef;
2886 }
2887
2888 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2889 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2890 const frame = useAnimationFrame();
2891 return useStableCallback((fnToExecute, signal = null) => {
2892 frame.cancel();
2893 const element = resolveRef(elementOrRef);
2894 if (element == null) {
2895 return;
2896 }
2897 const resolvedElement = element;
2898 const done = () => {
2899 ReactDOM.flushSync(fnToExecute);
2900 };
2901 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2902 fnToExecute();
2903 return;
2904 }
2905 function exec() {
2906 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2907 if (!signal?.aborted) {
2908 done();
2909 }
2910 }).catch(() => {
2911 if (treatAbortedAsFinished) {
2912 if (!signal?.aborted) {
2913 done();
2914 }
2915 return;
2916 }
2917 const currentAnimations = resolvedElement.getAnimations();
2918 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2919 exec();
2920 }
2921 });
2922 }
2923 if (waitForStartingStyleRemoved) {
2924 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2925 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2926 frame.request(exec);
2927 return;
2928 }
2929 const attributeObserver = new MutationObserver(() => {
2930 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2931 attributeObserver.disconnect();
2932 exec();
2933 }
2934 });
2935 attributeObserver.observe(resolvedElement, {
2936 attributes: true,
2937 attributeFilter: [startingStyleAttribute]
2938 });
2939 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2940 once: true
2941 });
2942 return;
2943 }
2944 frame.request(exec);
2945 });
2946 }
2947
2948 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2949 function useOpenChangeComplete(parameters) {
2950 const {
2951 enabled = true,
2952 open,
2953 ref,
2954 onComplete: onCompleteParam
2955 } = parameters;
2956 const onComplete = useStableCallback(onCompleteParam);
2957 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2958 React17.useEffect(() => {
2959 if (!enabled) {
2960 return void 0;
2961 }
2962 const abortController = new AbortController();
2963 runOnceAnimationsFinish(onComplete, abortController.signal);
2964 return () => {
2965 abortController.abort();
2966 };
2967 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2968 }
2969
2970 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2971 var EMPTY_DIMENSIONS = {
2972 height: void 0,
2973 width: void 0
2974 };
2975 function useCollapsiblePanel(parameters) {
2976 const {
2977 externalRef,
2978 hiddenUntilFound,
2979 id: idParam,
2980 keepMounted,
2981 mounted,
2982 onOpenChange,
2983 open,
2984 setMounted,
2985 setOpen,
2986 transitionStatus
2987 } = parameters;
2988 const panelRef = React18.useRef(null);
2989 const animationTypeRef = React18.useRef(null);
2990 const [dimensions, setDimensionsUnwrapped] = React18.useState(EMPTY_DIMENSIONS);
2991 const lastMeasuredDimensionsRef = React18.useRef(EMPTY_DIMENSIONS);
2992 const shouldSkipNextOpenRef = React18.useRef(false);
2993 const shouldPreventMountAnimationRef = React18.useRef(open);
2994 const shouldPreventActivityResumeAnimationRef = React18.useRef(false);
2995 const [forcePanelIdle, setForcePanelIdle] = React18.useState(false);
2996 const pendingTemporaryStyleRestoreRef = React18.useRef(null);
2997 const mergedPanelRef = useMergedRefs(externalRef, panelRef);
2998 const latestStateRef = useValueAsRef({
2999 mounted,
3000 open
3001 });
3002 const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef, false, false);
3003 const hidden = !open && !mounted;
3004 const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus;
3005 const shouldPreventOpenAnimation = open && // These 2 refs are safe to read in render, they are only written from committed
3006 // layout/effect paths and gate one-shot motion suppression for the next open
3007 // lifecycle. They intentionally expose the last committed motion snapshot.
3008 (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current);
3009 const renderedDimensions = !open && mounted && // These 2 refs are also safe to read in render, both hold the last committed
3010 // animation mode and measurement. This fallback only restores a previously
3011 // measured pixel size after the live dimensions state has been reset back to `auto`.
3012 animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions;
3013 const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation";
3014 const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => {
3015 if (shouldCacheMeasurement) {
3016 lastMeasuredDimensionsRef.current = nextDimensions;
3017 }
3018 setDimensionsUnwrapped(nextDimensions);
3019 });
3020 const restorePendingTemporaryStyle = useStableCallback(() => {
3021 pendingTemporaryStyleRestoreRef.current?.();
3022 pendingTemporaryStyleRestoreRef.current = null;
3023 });
3024 const setPendingTemporaryStyleRestore = useStableCallback((restore) => {
3025 restorePendingTemporaryStyle();
3026 pendingTemporaryStyleRestoreRef.current = () => {
3027 pendingTemporaryStyleRestoreRef.current = null;
3028 restore();
3029 };
3030 });
3031 const markActivityResumeAnimationSuppressed = useStableCallback(() => {
3032 if (open && mounted && animationTypeRef.current === "css-animation") {
3033 shouldPreventActivityResumeAnimationRef.current = true;
3034 }
3035 });
3036 useIsoLayoutEffect(() => {
3037 if (!forcePanelIdle || transitionStatus === "starting") {
3038 return;
3039 }
3040 setForcePanelIdle(false);
3041 }, [forcePanelIdle, transitionStatus]);
3042 React18.useEffect(() => {
3043 return () => {
3044 markActivityResumeAnimationSuppressed();
3045 restorePendingTemporaryStyle();
3046 };
3047 }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]);
3048 useIsoLayoutEffect(() => {
3049 const panel = panelRef.current;
3050 if (!panel) {
3051 return void 0;
3052 }
3053 if (!open && pendingTemporaryStyleRestoreRef.current) {
3054 restorePendingTemporaryStyle();
3055 }
3056 const animationType = getAnimationType(panel, shouldPreventOpenAnimation);
3057 animationTypeRef.current = animationType;
3058 if (open && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") {
3059 lastMeasuredDimensionsRef.current = getDimensions(panel);
3060 return void 0;
3061 }
3062 if (open && transitionStatus === "starting") {
3063 const skipNextOpen = shouldSkipNextOpenRef.current;
3064 shouldSkipNextOpenRef.current = false;
3065 if (animationType === "none") {
3066 setDimensions(getDimensions(panel));
3067 setForcePanelIdle(true);
3068 return void 0;
3069 }
3070 if (animationType === "css-transition") {
3071 const restoreLayoutStyles = resetLayoutStyles(panel);
3072 setDimensions(getDimensions(panel));
3073 if (!skipNextOpen) {
3074 return restoreLayoutStyles;
3075 }
3076 const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s");
3077 setPendingTemporaryStyleRestore(restoreTransitionDuration);
3078 setForcePanelIdle(true);
3079 return restoreLayoutStyles;
3080 }
3081 if (animationType === "css-animation") {
3082 setDimensions(getDimensions(panel));
3083 if (!skipNextOpen) {
3084 const restoreAnimationName2 = setTemporaryStyle(panel, "animation-name", "none");
3085 restoreAnimationName2();
3086 return void 0;
3087 }
3088 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
3089 const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s");
3090 restoreAnimationName();
3091 setPendingTemporaryStyleRestore(restoreAnimationDuration);
3092 setForcePanelIdle(true);
3093 return void 0;
3094 }
3095 }
3096 if (!open && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) {
3097 if (animationType === "none") {
3098 setDimensions(EMPTY_DIMENSIONS, false);
3099 setMounted(false);
3100 return void 0;
3101 }
3102 if (animationType === "css-animation") {
3103 shouldPreventMountAnimationRef.current = false;
3104 shouldPreventActivityResumeAnimationRef.current = false;
3105 }
3106 setDimensions(getDimensions(panel));
3107 return void 0;
3108 }
3109 if (transitionStatus !== "ending") {
3110 return void 0;
3111 }
3112 if (animationType === "none") {
3113 setMounted(false);
3114 return void 0;
3115 }
3116 const nextDimensions = getDimensions(panel);
3117 const hasMeasuredSize = (nextDimensions.height ?? 0) > 0 || (nextDimensions.width ?? 0) > 0;
3118 if (!hasMeasuredSize) {
3119 setMounted(false);
3120 return void 0;
3121 }
3122 setDimensions(nextDimensions);
3123 if (animationType === "css-animation") {
3124 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
3125 restoreAnimationName();
3126 }
3127 return void 0;
3128 }, [mounted, open, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]);
3129 useOpenChangeComplete({
3130 enabled: open && mounted && panelTransitionStatus === "idle",
3131 open: true,
3132 ref: panelRef,
3133 onComplete() {
3134 if (!open) {
3135 return;
3136 }
3137 setDimensions(EMPTY_DIMENSIONS, false);
3138 }
3139 });
3140 React18.useEffect(() => {
3141 if (open || !mounted || panelTransitionStatus !== "ending") {
3142 return void 0;
3143 }
3144 const panel = panelRef.current;
3145 if (!panel) {
3146 return void 0;
3147 }
3148 const abortController = new AbortController();
3149 let endingStyleFrame = -1;
3150 function handleComplete() {
3151 if (latestStateRef.current.open) {
3152 return;
3153 }
3154 setMounted(false);
3155 setDimensions(EMPTY_DIMENSIONS, false);
3156 }
3157 endingStyleFrame = AnimationFrame.request(() => {
3158 if (!abortController.signal.aborted) {
3159 runOnceCloseAnimationsFinish(handleComplete, abortController.signal);
3160 }
3161 });
3162 return () => {
3163 AnimationFrame.cancel(endingStyleFrame);
3164 abortController.abort();
3165 };
3166 }, [latestStateRef, mounted, open, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]);
3167 useIsoLayoutEffect(() => {
3168 const panel = panelRef.current;
3169 if (!panel || !hiddenUntilFound || !hidden) {
3170 return;
3171 }
3172 panel.setAttribute("hidden", "until-found");
3173 }, [hidden, hiddenUntilFound]);
3174 React18.useEffect(function registerBeforeMatchListener() {
3175 const panel = panelRef.current;
3176 if (!panel) {
3177 return void 0;
3178 }
3179 function handleBeforeMatch(event) {
3180 shouldSkipNextOpenRef.current = true;
3181 setOpen(true);
3182 onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event));
3183 }
3184 return addEventListener(panel, "beforematch", handleBeforeMatch);
3185 }, [onOpenChange, setOpen]);
3186 const shouldRender = keepMounted || hiddenUntilFound || mounted || open;
3187 return {
3188 height: renderedDimensions.height,
3189 props: {
3190 ...shouldPersistHiddenTransitionStyles ? {
3191 [CollapsiblePanelDataAttributes.startingStyle]: ""
3192 } : void 0,
3193 hidden,
3194 id: idParam
3195 },
3196 ref: mergedPanelRef,
3197 shouldPreventOpenAnimation,
3198 shouldRender,
3199 transitionStatus: panelTransitionStatus,
3200 width: renderedDimensions.width
3201 };
3202 }
3203 function getDimensions(element) {
3204 return {
3205 height: element.scrollHeight,
3206 width: element.scrollWidth
3207 };
3208 }
3209 function getAnimationType(element, hasSuppressedMountAnimation = false) {
3210 const panelStyles = getWindow(element).getComputedStyle(element);
3211 const hasAnimation = (panelStyles.animationName.split(",").map((name) => name.trim()).some((name) => name !== "" && name !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration);
3212 const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration);
3213 if (hasAnimation && hasTransition) {
3214 if (true) {
3215 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
3216 }
3217 return "css-transition";
3218 }
3219 if (hasTransition) {
3220 return "css-transition";
3221 }
3222 if (hasAnimation) {
3223 return "css-animation";
3224 }
3225 return "none";
3226 }
3227 function hasNonZeroDuration(value) {
3228 return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0);
3229 }
3230 function setTemporaryStyle(element, property, value) {
3231 const previousValue = element.style.getPropertyValue(property);
3232 const previousPriority = element.style.getPropertyPriority(property);
3233 element.style.setProperty(property, value);
3234 return () => {
3235 if (previousValue === "") {
3236 element.style.removeProperty(property);
3237 return;
3238 }
3239 element.style.setProperty(property, previousValue, previousPriority);
3240 };
3241 }
3242 function resetLayoutStyles(element) {
3243 const originalLayoutStyles = {
3244 "justify-content": element.style.justifyContent,
3245 "align-items": element.style.alignItems,
3246 "align-content": element.style.alignContent,
3247 "justify-items": element.style.justifyItems
3248 };
3249 Object.keys(originalLayoutStyles).forEach((key) => {
3250 element.style.setProperty(key, "initial", "important");
3251 });
3252 function restoreLayoutStyles() {
3253 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
3254 if (value === "") {
3255 element.style.removeProperty(key);
3256 return;
3257 }
3258 element.style.setProperty(key, value);
3259 });
3260 }
3261 const frame = AnimationFrame.request(restoreLayoutStyles);
3262 return () => {
3263 AnimationFrame.cancel(frame);
3264 restoreLayoutStyles();
3265 };
3266 }
3267
3268 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
3269 var React19 = __toESM(require_react(), 1);
3270 function useOnFirstRender(fn) {
3271 const ref = React19.useRef(true);
3272 if (ref.current) {
3273 ref.current = false;
3274 fn();
3275 }
3276 }
3277
3278 // node_modules/@base-ui/utils/esm/useTimeout.js
3279 var EMPTY3 = 0;
3280 var Timeout = class _Timeout {
3281 static create() {
3282 return new _Timeout();
3283 }
3284 currentId = EMPTY3;
3285 /**
3286 * Executes `fn` after `delay`, clearing any previously scheduled call.
3287 */
3288 start(delay, fn) {
3289 this.clear();
3290 this.currentId = setTimeout(() => {
3291 this.currentId = EMPTY3;
3292 fn();
3293 }, delay);
3294 }
3295 isStarted() {
3296 return this.currentId !== EMPTY3;
3297 }
3298 clear = () => {
3299 if (this.currentId !== EMPTY3) {
3300 clearTimeout(this.currentId);
3301 this.currentId = EMPTY3;
3302 }
3303 };
3304 disposeEffect = () => {
3305 return this.clear;
3306 };
3307 };
3308 function useTimeout() {
3309 const timeout = useRefWithInit(Timeout.create).current;
3310 useOnMount(timeout.disposeEffect);
3311 return timeout;
3312 }
3313
3314 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3315 var React20 = __toESM(require_react(), 1);
3316
3317 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
3318 function resolveValue(value, pointerType) {
3319 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3320 return 0;
3321 }
3322 if (typeof value === "function") {
3323 return value();
3324 }
3325 return value;
3326 }
3327 function getDelay(value, prop, pointerType) {
3328 const result = resolveValue(value, pointerType);
3329 if (typeof result === "number") {
3330 return result;
3331 }
3332 return result?.[prop];
3333 }
3334 function getRestMs(value) {
3335 if (typeof value === "function") {
3336 return value();
3337 }
3338 return value;
3339 }
3340 function isClickLikeOpenEvent(openEventType, interactedInside) {
3341 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3342 }
3343 function isHoverOpenEvent(openEventType) {
3344 return openEventType?.includes("mouse") && openEventType !== "mousedown";
3345 }
3346
3347 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3348 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
3349 var FloatingDelayGroupContext = /* @__PURE__ */ React20.createContext({
3350 hasProvider: false,
3351 timeoutMs: 0,
3352 delayRef: {
3353 current: 0
3354 },
3355 initialDelayRef: {
3356 current: 0
3357 },
3358 timeout: new Timeout(),
3359 currentIdRef: {
3360 current: null
3361 },
3362 currentContextRef: {
3363 current: null
3364 }
3365 });
3366 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3367 function FloatingDelayGroup(props) {
3368 const {
3369 children,
3370 delay,
3371 timeoutMs = 0
3372 } = props;
3373 const delayRef = React20.useRef(delay);
3374 const initialDelayRef = React20.useRef(delay);
3375 const currentIdRef = React20.useRef(null);
3376 const currentContextRef = React20.useRef(null);
3377 const timeout = useTimeout();
3378 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
3379 value: React20.useMemo(() => ({
3380 hasProvider: true,
3381 delayRef,
3382 initialDelayRef,
3383 currentIdRef,
3384 timeoutMs,
3385 currentContextRef,
3386 timeout
3387 }), [timeoutMs, timeout]),
3388 children
3389 });
3390 }
3391 function useDelayGroup(context, options = {
3392 open: false
3393 }) {
3394 const {
3395 open
3396 } = options;
3397 const store = "rootStore" in context ? context.rootStore : context;
3398 const floatingId = store.useState("floatingId");
3399 const groupContext = React20.useContext(FloatingDelayGroupContext);
3400 const {
3401 currentIdRef,
3402 delayRef,
3403 timeoutMs,
3404 initialDelayRef,
3405 currentContextRef,
3406 hasProvider,
3407 timeout
3408 } = groupContext;
3409 const [isInstantPhase, setIsInstantPhase] = React20.useState(false);
3410 useIsoLayoutEffect(() => {
3411 function unset() {
3412 setIsInstantPhase(false);
3413 currentContextRef.current?.setIsInstantPhase(false);
3414 currentIdRef.current = null;
3415 currentContextRef.current = null;
3416 delayRef.current = initialDelayRef.current;
3417 }
3418 if (!currentIdRef.current) {
3419 return void 0;
3420 }
3421 if (!open && currentIdRef.current === floatingId) {
3422 setIsInstantPhase(false);
3423 if (timeoutMs) {
3424 const closingId = floatingId;
3425 timeout.start(timeoutMs, () => {
3426 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3427 return;
3428 }
3429 unset();
3430 });
3431 return () => {
3432 timeout.clear();
3433 };
3434 }
3435 unset();
3436 }
3437 return void 0;
3438 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3439 useIsoLayoutEffect(() => {
3440 if (!open) {
3441 return;
3442 }
3443 const prevContext = currentContextRef.current;
3444 const prevId = currentIdRef.current;
3445 timeout.clear();
3446 currentContextRef.current = {
3447 onOpenChange: store.setOpen,
3448 setIsInstantPhase
3449 };
3450 currentIdRef.current = floatingId;
3451 delayRef.current = {
3452 open: 0,
3453 close: getDelay(initialDelayRef.current, "close")
3454 };
3455 if (prevId !== null && prevId !== floatingId) {
3456 setIsInstantPhase(true);
3457 prevContext?.setIsInstantPhase(true);
3458 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3459 } else {
3460 setIsInstantPhase(false);
3461 prevContext?.setIsInstantPhase(false);
3462 }
3463 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3464 useIsoLayoutEffect(() => {
3465 return () => {
3466 currentContextRef.current = null;
3467 };
3468 }, [currentContextRef]);
3469 return React20.useMemo(() => ({
3470 hasProvider,
3471 delayRef,
3472 isInstantPhase
3473 }), [hasProvider, delayRef, isInstantPhase]);
3474 }
3475
3476 // node_modules/@base-ui/utils/esm/mergeCleanups.js
3477 function mergeCleanups(...cleanups) {
3478 return () => {
3479 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3480 const cleanup = cleanups[i2];
3481 if (cleanup) {
3482 cleanup();
3483 }
3484 }
3485 };
3486 }
3487
3488 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3489 var React21 = __toESM(require_react(), 1);
3490
3491 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3492 var visuallyHiddenBase = {
3493 clipPath: "inset(50%)",
3494 overflow: "hidden",
3495 whiteSpace: "nowrap",
3496 border: 0,
3497 padding: 0,
3498 width: 1,
3499 height: 1,
3500 margin: -1
3501 };
3502 var visuallyHidden = {
3503 ...visuallyHiddenBase,
3504 position: "fixed",
3505 top: 0,
3506 left: 0
3507 };
3508 var visuallyHiddenInput = {
3509 ...visuallyHiddenBase,
3510 position: "absolute"
3511 };
3512
3513 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3514 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3515 var FocusGuard = /* @__PURE__ */ React21.forwardRef(function FocusGuard2(props, ref) {
3516 const [role, setRole] = React21.useState();
3517 useIsoLayoutEffect(() => {
3518 if (isSafari) {
3519 setRole("button");
3520 }
3521 }, []);
3522 const restProps = {
3523 tabIndex: 0,
3524 // Role is only for VoiceOver
3525 role
3526 };
3527 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3528 ...props,
3529 ref,
3530 style: visuallyHidden,
3531 "aria-hidden": role ? void 0 : true,
3532 ...restProps,
3533 "data-base-ui-focus-guard": ""
3534 });
3535 });
3536 if (true) FocusGuard.displayName = "FocusGuard";
3537
3538 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3539 function createAttribute(name) {
3540 return `data-base-ui-${name}`;
3541 }
3542
3543 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3544 var React22 = __toESM(require_react(), 1);
3545 var ReactDOM2 = __toESM(require_react_dom(), 1);
3546
3547 // node_modules/@base-ui/react/esm/internals/constants.js
3548 var DISABLED_TRANSITIONS_STYLE = {
3549 style: {
3550 transition: "none"
3551 }
3552 };
3553 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3554 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3555 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3556 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3557 var POPUP_COLLISION_AVOIDANCE = {
3558 fallbackAxisSide: "end"
3559 };
3560 var ownerVisuallyHidden = {
3561 clipPath: "inset(50%)",
3562 position: "fixed",
3563 top: 0,
3564 left: 0
3565 };
3566
3567 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3568 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3569 var PortalContext = /* @__PURE__ */ React22.createContext(null);
3570 if (true) PortalContext.displayName = "PortalContext";
3571 var usePortalContext = () => React22.useContext(PortalContext);
3572 var attr = createAttribute("portal");
3573 function useFloatingPortalNode(props = {}) {
3574 const {
3575 ref,
3576 container: containerProp,
3577 componentProps = EMPTY_OBJECT,
3578 elementProps
3579 } = props;
3580 const uniqueId = useId();
3581 const portalContext = usePortalContext();
3582 const parentPortalNode = portalContext?.portalNode;
3583 const [containerElement, setContainerElement] = React22.useState(null);
3584 const [portalNode, setPortalNode] = React22.useState(null);
3585 const setPortalNodeRef = useStableCallback((node) => {
3586 if (node !== null) {
3587 setPortalNode(node);
3588 }
3589 });
3590 const containerRef = React22.useRef(null);
3591 useIsoLayoutEffect(() => {
3592 if (containerProp === null) {
3593 if (containerRef.current) {
3594 containerRef.current = null;
3595 setPortalNode(null);
3596 setContainerElement(null);
3597 }
3598 return;
3599 }
3600 if (uniqueId == null) {
3601 return;
3602 }
3603 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3604 if (resolvedContainer == null) {
3605 if (containerRef.current) {
3606 containerRef.current = null;
3607 setPortalNode(null);
3608 setContainerElement(null);
3609 }
3610 return;
3611 }
3612 if (containerRef.current !== resolvedContainer) {
3613 containerRef.current = resolvedContainer;
3614 setPortalNode(null);
3615 setContainerElement(resolvedContainer);
3616 }
3617 }, [containerProp, parentPortalNode, uniqueId]);
3618 const portalElement = useRenderElement("div", componentProps, {
3619 ref: [ref, setPortalNodeRef],
3620 props: [{
3621 id: uniqueId,
3622 [attr]: ""
3623 }, elementProps]
3624 });
3625 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3626 return {
3627 portalNode,
3628 portalSubtree
3629 };
3630 }
3631 var FloatingPortal = /* @__PURE__ */ React22.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3632 const {
3633 render: render4,
3634 className,
3635 style,
3636 children,
3637 container,
3638 renderGuards,
3639 ...elementProps
3640 } = componentProps;
3641 const {
3642 portalNode,
3643 portalSubtree
3644 } = useFloatingPortalNode({
3645 container,
3646 ref: forwardedRef,
3647 componentProps,
3648 elementProps
3649 });
3650 const beforeOutsideRef = React22.useRef(null);
3651 const afterOutsideRef = React22.useRef(null);
3652 const beforeInsideRef = React22.useRef(null);
3653 const afterInsideRef = React22.useRef(null);
3654 const [focusManagerState, setFocusManagerState] = React22.useState(null);
3655 const focusInsideDisabledRef = React22.useRef(false);
3656 const modal = focusManagerState?.modal;
3657 const open = focusManagerState?.open;
3658 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3659 React22.useEffect(() => {
3660 if (!portalNode || modal) {
3661 return void 0;
3662 }
3663 function onFocus(event) {
3664 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3665 if (event.type === "focusin") {
3666 if (focusInsideDisabledRef.current) {
3667 enableFocusInside(portalNode);
3668 focusInsideDisabledRef.current = false;
3669 }
3670 } else {
3671 disableFocusInside(portalNode);
3672 focusInsideDisabledRef.current = true;
3673 }
3674 }
3675 }
3676 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3677 }, [portalNode, modal]);
3678 React22.useEffect(() => {
3679 if (!portalNode || open !== false) {
3680 return;
3681 }
3682 enableFocusInside(portalNode);
3683 focusInsideDisabledRef.current = false;
3684 }, [open, portalNode]);
3685 const portalContextValue = React22.useMemo(() => ({
3686 beforeOutsideRef,
3687 afterOutsideRef,
3688 beforeInsideRef,
3689 afterInsideRef,
3690 portalNode,
3691 setFocusManagerState
3692 }), [portalNode]);
3693 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React22.Fragment, {
3694 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3695 value: portalContextValue,
3696 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3697 "data-type": "outside",
3698 ref: beforeOutsideRef,
3699 onFocus: (event) => {
3700 if (isOutsideEvent(event, portalNode)) {
3701 beforeInsideRef.current?.focus();
3702 } else {
3703 const domReference = focusManagerState ? focusManagerState.domReference : null;
3704 const prevTabbable = getPreviousTabbable(domReference);
3705 prevTabbable?.focus();
3706 }
3707 }
3708 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3709 "aria-owns": portalNode.id,
3710 style: ownerVisuallyHidden
3711 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3712 "data-type": "outside",
3713 ref: afterOutsideRef,
3714 onFocus: (event) => {
3715 if (isOutsideEvent(event, portalNode)) {
3716 afterInsideRef.current?.focus();
3717 } else {
3718 const domReference = focusManagerState ? focusManagerState.domReference : null;
3719 const nextTabbable = getNextTabbable(domReference);
3720 nextTabbable?.focus();
3721 if (focusManagerState?.closeOnFocusOut) {
3722 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3723 }
3724 }
3725 }
3726 })]
3727 })]
3728 });
3729 });
3730 if (true) FloatingPortal.displayName = "FloatingPortal";
3731
3732 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3733 var React23 = __toESM(require_react(), 1);
3734
3735 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3736 function createEventEmitter() {
3737 const map = /* @__PURE__ */ new Map();
3738 return {
3739 emit(event, data) {
3740 map.get(event)?.forEach((listener) => listener(data));
3741 },
3742 on(event, listener) {
3743 if (!map.has(event)) {
3744 map.set(event, /* @__PURE__ */ new Set());
3745 }
3746 map.get(event).add(listener);
3747 },
3748 off(event, listener) {
3749 map.get(event)?.delete(listener);
3750 }
3751 };
3752 }
3753
3754 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3755 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3756 var FloatingNodeContext = /* @__PURE__ */ React23.createContext(null);
3757 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3758 var FloatingTreeContext = /* @__PURE__ */ React23.createContext(null);
3759 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3760 var useFloatingParentNodeId = () => React23.useContext(FloatingNodeContext)?.id || null;
3761 var useFloatingTree = (externalTree) => {
3762 const contextTree = React23.useContext(FloatingTreeContext);
3763 return externalTree ?? contextTree;
3764 };
3765
3766 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3767 var React24 = __toESM(require_react(), 1);
3768 function createVirtualElement(domElement, data) {
3769 let offsetX = null;
3770 let offsetY = null;
3771 let isAutoUpdateEvent = false;
3772 return {
3773 contextElement: domElement || void 0,
3774 getBoundingClientRect() {
3775 const domRect = domElement?.getBoundingClientRect() || {
3776 width: 0,
3777 height: 0,
3778 x: 0,
3779 y: 0
3780 };
3781 const isXAxis = data.axis === "x" || data.axis === "both";
3782 const isYAxis = data.axis === "y" || data.axis === "both";
3783 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3784 let width = domRect.width;
3785 let height = domRect.height;
3786 let x2 = domRect.x;
3787 let y2 = domRect.y;
3788 if (offsetX == null && data.x && isXAxis) {
3789 offsetX = domRect.x - data.x;
3790 }
3791 if (offsetY == null && data.y && isYAxis) {
3792 offsetY = domRect.y - data.y;
3793 }
3794 x2 -= offsetX || 0;
3795 y2 -= offsetY || 0;
3796 width = 0;
3797 height = 0;
3798 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3799 width = data.axis === "y" ? domRect.width : 0;
3800 height = data.axis === "x" ? domRect.height : 0;
3801 x2 = isXAxis && data.x != null ? data.x : x2;
3802 y2 = isYAxis && data.y != null ? data.y : y2;
3803 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3804 height = data.axis === "x" ? domRect.height : height;
3805 width = data.axis === "y" ? domRect.width : width;
3806 }
3807 isAutoUpdateEvent = true;
3808 return {
3809 width,
3810 height,
3811 x: x2,
3812 y: y2,
3813 top: y2,
3814 right: x2 + width,
3815 bottom: y2 + height,
3816 left: x2
3817 };
3818 }
3819 };
3820 }
3821 function isMouseBasedEvent(event) {
3822 return event != null && event.clientX != null;
3823 }
3824 function useClientPoint(context, props = {}) {
3825 const {
3826 enabled = true,
3827 axis = "both"
3828 } = props;
3829 const store = "rootStore" in context ? context.rootStore : context;
3830 const open = store.useState("open");
3831 const floating = store.useState("floatingElement");
3832 const domReference = store.useState("domReferenceElement");
3833 const dataRef = store.context.dataRef;
3834 const initialRef = React24.useRef(false);
3835 const cleanupListenerRef = React24.useRef(null);
3836 const [pointerType, setPointerType] = React24.useState();
3837 const [reactive, setReactive] = React24.useState([]);
3838 const resetReference = useStableCallback((reference2) => {
3839 store.set("positionReference", reference2);
3840 });
3841 const setReference = useStableCallback((newX, newY, referenceElement) => {
3842 if (initialRef.current) {
3843 return;
3844 }
3845 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3846 return;
3847 }
3848 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3849 x: newX,
3850 y: newY,
3851 axis,
3852 dataRef,
3853 pointerType
3854 }));
3855 });
3856 const handleReferenceEnterOrMove = useStableCallback((event) => {
3857 if (!open) {
3858 setReference(event.clientX, event.clientY, event.currentTarget);
3859 } else if (!cleanupListenerRef.current) {
3860 setReference(event.clientX, event.clientY, event.currentTarget);
3861 setReactive([]);
3862 }
3863 });
3864 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3865 React24.useEffect(() => {
3866 if (!enabled) {
3867 resetReference(domReference);
3868 return void 0;
3869 }
3870 if (!openCheck) {
3871 return void 0;
3872 }
3873 function cleanupListener() {
3874 cleanupListenerRef.current?.();
3875 cleanupListenerRef.current = null;
3876 }
3877 const win = getWindow(floating);
3878 function handleMouseMove(event) {
3879 const target = getTarget(event);
3880 if (!contains(floating, target)) {
3881 setReference(event.clientX, event.clientY);
3882 } else {
3883 cleanupListener();
3884 }
3885 }
3886 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3887 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3888 } else {
3889 resetReference(domReference);
3890 }
3891 return cleanupListener;
3892 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3893 React24.useEffect(() => () => {
3894 store.set("positionReference", null);
3895 }, [store]);
3896 React24.useEffect(() => {
3897 if (enabled && !floating) {
3898 initialRef.current = false;
3899 }
3900 }, [enabled, floating]);
3901 React24.useEffect(() => {
3902 if (!enabled && open) {
3903 initialRef.current = true;
3904 }
3905 }, [enabled, open]);
3906 const reference = React24.useMemo(() => {
3907 function setPointerTypeRef(event) {
3908 setPointerType(event.pointerType);
3909 }
3910 return {
3911 onPointerDown: setPointerTypeRef,
3912 onPointerEnter: setPointerTypeRef,
3913 onMouseMove: handleReferenceEnterOrMove,
3914 onMouseEnter: handleReferenceEnterOrMove
3915 };
3916 }, [handleReferenceEnterOrMove]);
3917 return React24.useMemo(() => enabled ? {
3918 reference,
3919 trigger: reference
3920 } : {}, [enabled, reference]);
3921 }
3922
3923 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3924 var React25 = __toESM(require_react(), 1);
3925 var bubbleHandlerKeys = {
3926 intentional: "onClick",
3927 sloppy: "onPointerDown"
3928 };
3929 function alwaysFalse() {
3930 return false;
3931 }
3932 function normalizeProp(normalizable) {
3933 return {
3934 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3935 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3936 };
3937 }
3938 function useDismiss(context, props = {}) {
3939 const {
3940 enabled = true,
3941 escapeKey: escapeKey2 = true,
3942 outsidePress: outsidePressProp = true,
3943 outsidePressEvent = "sloppy",
3944 referencePress = alwaysFalse,
3945 referencePressEvent = "sloppy",
3946 bubbles,
3947 externalTree
3948 } = props;
3949 const store = "rootStore" in context ? context.rootStore : context;
3950 const open = store.useState("open");
3951 const floatingElement = store.useState("floatingElement");
3952 const {
3953 dataRef
3954 } = store.context;
3955 const tree = useFloatingTree(externalTree);
3956 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3957 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3958 const outsidePressEnabled = outsidePress2 !== false;
3959 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3960 const {
3961 escapeKey: escapeKeyBubbles,
3962 outsidePress: outsidePressBubbles
3963 } = normalizeProp(bubbles);
3964 const pressStartedInsideRef = React25.useRef(false);
3965 const pressStartPreventedRef = React25.useRef(false);
3966 const suppressNextOutsideClickRef = React25.useRef(false);
3967 const isComposingRef = React25.useRef(false);
3968 const currentPointerTypeRef = React25.useRef("");
3969 const touchStateRef = React25.useRef(null);
3970 const cancelDismissOnEndTimeout = useTimeout();
3971 const clearInsideReactTreeTimeout = useTimeout();
3972 const clearInsideReactTree = useStableCallback(() => {
3973 clearInsideReactTreeTimeout.clear();
3974 dataRef.current.insideReactTree = false;
3975 });
3976 const hasBlockingChild = useStableCallback((bubbleKey) => {
3977 const nodeId = dataRef.current.floatingContext?.nodeId;
3978 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3979 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3980 });
3981 const isEventWithinOwnElements = useStableCallback((event) => {
3982 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3983 });
3984 const closeOnReferencePress = useStableCallback((event) => {
3985 if (!referencePress()) {
3986 return;
3987 }
3988 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3989 });
3990 const closeOnEscapeKeyDown = useStableCallback((event) => {
3991 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3992 return;
3993 }
3994 if (isComposingRef.current) {
3995 return;
3996 }
3997 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3998 return;
3999 }
4000 const native = isReactEvent(event) ? event.nativeEvent : event;
4001 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4002 store.setOpen(false, eventDetails);
4003 if (!eventDetails.isCanceled) {
4004 event.preventDefault();
4005 }
4006 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4007 event.stopPropagation();
4008 }
4009 });
4010 const markInsideReactTree = useStableCallback(() => {
4011 dataRef.current.insideReactTree = true;
4012 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4013 });
4014 const markPressStartedInsideReactTree = useStableCallback((event) => {
4015 if (!open || !enabled || event.button !== 0) {
4016 return;
4017 }
4018 const target = getTarget(event.nativeEvent);
4019 if (!contains(store.select("floatingElement"), target)) {
4020 return;
4021 }
4022 if (!pressStartedInsideRef.current) {
4023 pressStartedInsideRef.current = true;
4024 pressStartPreventedRef.current = false;
4025 }
4026 });
4027 const markInsidePressStartPrevented = useStableCallback((event) => {
4028 if (!open || !enabled) {
4029 return;
4030 }
4031 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4032 return;
4033 }
4034 if (pressStartedInsideRef.current) {
4035 pressStartPreventedRef.current = true;
4036 }
4037 });
4038 React25.useEffect(() => {
4039 if (!open || !enabled) {
4040 return void 0;
4041 }
4042 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4043 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4044 const compositionTimeout = new Timeout();
4045 const preventedPressSuppressionTimeout = new Timeout();
4046 function handleCompositionStart() {
4047 compositionTimeout.clear();
4048 isComposingRef.current = true;
4049 }
4050 function handleCompositionEnd() {
4051 compositionTimeout.start(
4052 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4053 // Only apply to WebKit for the test to remain 0ms.
4054 isWebKit() ? 5 : 0,
4055 () => {
4056 isComposingRef.current = false;
4057 }
4058 );
4059 }
4060 function suppressImmediateOutsideClickAfterPreventedStart() {
4061 suppressNextOutsideClickRef.current = true;
4062 preventedPressSuppressionTimeout.start(0, () => {
4063 suppressNextOutsideClickRef.current = false;
4064 });
4065 }
4066 function resetPressStartState() {
4067 pressStartedInsideRef.current = false;
4068 pressStartPreventedRef.current = false;
4069 }
4070 function getOutsidePressEvent() {
4071 const type = currentPointerTypeRef.current;
4072 const computedType = type === "pen" || !type ? "mouse" : type;
4073 const outsidePressEventValue = getOutsidePressEventProp();
4074 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4075 if (typeof resolved === "string") {
4076 return resolved;
4077 }
4078 return resolved[computedType];
4079 }
4080 function shouldIgnoreEvent(event) {
4081 const computedOutsidePressEvent = getOutsidePressEvent();
4082 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4083 }
4084 function isEventWithinFloatingTree(event) {
4085 const nodeId = dataRef.current.floatingContext?.nodeId;
4086 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4087 return isEventWithinOwnElements(event) || targetIsInsideChildren;
4088 }
4089 function closeOnPressOutside(event) {
4090 if (shouldIgnoreEvent(event)) {
4091 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
4092 preventedPressSuppressionTimeout.clear();
4093 suppressNextOutsideClickRef.current = false;
4094 }
4095 clearInsideReactTree();
4096 return;
4097 }
4098 if (dataRef.current.insideReactTree) {
4099 clearInsideReactTree();
4100 return;
4101 }
4102 const target = getTarget(event);
4103 const inertSelector = `[${createAttribute("inert")}]`;
4104 const targetRoot = isElement(target) ? target.getRootNode() : null;
4105 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4106 const triggers = store.context.triggerElements;
4107 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4108 return;
4109 }
4110 let targetRootAncestor = isElement(target) ? target : null;
4111 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4112 const nextParent = getParentNode(targetRootAncestor);
4113 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4114 break;
4115 }
4116 targetRootAncestor = nextParent;
4117 }
4118 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4119 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4120 // element was injected after the floating element rendered.
4121 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4122 return;
4123 }
4124 if (isHTMLElement(target) && !("touches" in event)) {
4125 const lastTraversableNode = isLastTraversableNode(target);
4126 const style = getComputedStyle2(target);
4127 const scrollRe = /auto|scroll/;
4128 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4129 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4130 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4131 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4132 const isRTL7 = style.direction === "rtl";
4133 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4134 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4135 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4136 return;
4137 }
4138 }
4139 if (isEventWithinFloatingTree(event)) {
4140 return;
4141 }
4142 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4143 preventedPressSuppressionTimeout.clear();
4144 suppressNextOutsideClickRef.current = false;
4145 return;
4146 }
4147 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4148 return;
4149 }
4150 if (hasBlockingChild("__outsidePressBubbles")) {
4151 return;
4152 }
4153 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4154 clearInsideReactTree();
4155 }
4156 function handlePointerDown(event) {
4157 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4158 return;
4159 }
4160 closeOnPressOutside(event);
4161 }
4162 function handleTouchStart(event) {
4163 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4164 return;
4165 }
4166 const touch = event.touches[0];
4167 if (touch) {
4168 touchStateRef.current = {
4169 startTime: Date.now(),
4170 startX: touch.clientX,
4171 startY: touch.clientY,
4172 dismissOnTouchEnd: false,
4173 dismissOnMouseDown: true
4174 };
4175 cancelDismissOnEndTimeout.start(1e3, () => {
4176 if (touchStateRef.current) {
4177 touchStateRef.current.dismissOnTouchEnd = false;
4178 touchStateRef.current.dismissOnMouseDown = false;
4179 }
4180 });
4181 }
4182 }
4183 function addTargetEventListenerOnce(event, listener) {
4184 const target = getTarget(event);
4185 if (!target) {
4186 return;
4187 }
4188 const unsubscribe2 = addEventListener(target, event.type, () => {
4189 listener(event);
4190 unsubscribe2();
4191 });
4192 }
4193 function handleTouchStartCapture(event) {
4194 currentPointerTypeRef.current = "touch";
4195 addTargetEventListenerOnce(event, handleTouchStart);
4196 }
4197 function closeOnPressOutsideCapture(event) {
4198 cancelDismissOnEndTimeout.clear();
4199 if (event.type === "pointerdown") {
4200 currentPointerTypeRef.current = event.pointerType;
4201 }
4202 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4203 return;
4204 }
4205 addTargetEventListenerOnce(event, (targetEvent) => {
4206 if (targetEvent.type === "pointerdown") {
4207 handlePointerDown(targetEvent);
4208 } else {
4209 closeOnPressOutside(targetEvent);
4210 }
4211 });
4212 }
4213 function handlePressEndCapture(event) {
4214 if (!pressStartedInsideRef.current) {
4215 return;
4216 }
4217 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4218 resetPressStartState();
4219 if (getOutsidePressEvent() !== "intentional") {
4220 return;
4221 }
4222 if (event.type === "pointercancel") {
4223 if (pressStartedInsideDefaultPrevented) {
4224 suppressImmediateOutsideClickAfterPreventedStart();
4225 }
4226 return;
4227 }
4228 if (isEventWithinFloatingTree(event)) {
4229 return;
4230 }
4231 if (pressStartedInsideDefaultPrevented) {
4232 suppressImmediateOutsideClickAfterPreventedStart();
4233 return;
4234 }
4235 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4236 return;
4237 }
4238 preventedPressSuppressionTimeout.clear();
4239 suppressNextOutsideClickRef.current = true;
4240 clearInsideReactTree();
4241 }
4242 function handleTouchMove(event) {
4243 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4244 return;
4245 }
4246 const touch = event.touches[0];
4247 if (!touch) {
4248 return;
4249 }
4250 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4251 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4252 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4253 if (distance > 5) {
4254 touchStateRef.current.dismissOnTouchEnd = true;
4255 }
4256 if (distance > 10) {
4257 closeOnPressOutside(event);
4258 cancelDismissOnEndTimeout.clear();
4259 touchStateRef.current = null;
4260 }
4261 }
4262 function handleTouchMoveCapture(event) {
4263 addTargetEventListenerOnce(event, handleTouchMove);
4264 }
4265 function handleTouchEnd(event) {
4266 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4267 return;
4268 }
4269 if (touchStateRef.current.dismissOnTouchEnd) {
4270 closeOnPressOutside(event);
4271 }
4272 cancelDismissOnEndTimeout.clear();
4273 touchStateRef.current = null;
4274 }
4275 function handleTouchEndCapture(event) {
4276 addTargetEventListenerOnce(event, handleTouchEnd);
4277 }
4278 const doc = ownerDocument(floatingElement);
4279 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)));
4280 return () => {
4281 unsubscribe();
4282 compositionTimeout.clear();
4283 preventedPressSuppressionTimeout.clear();
4284 resetPressStartState();
4285 suppressNextOutsideClickRef.current = false;
4286 };
4287 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
4288 React25.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4289 const reference = React25.useMemo(() => ({
4290 onKeyDown: closeOnEscapeKeyDown,
4291 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
4292 ...referencePressEvent !== "intentional" && {
4293 onClick: closeOnReferencePress
4294 }
4295 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
4296 const floating = React25.useMemo(() => ({
4297 onKeyDown: closeOnEscapeKeyDown,
4298 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4299 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4300 // See https://github.com/mui/base-ui/pull/3379
4301 onPointerDown: markInsidePressStartPrevented,
4302 onMouseDown: markInsidePressStartPrevented,
4303 onClickCapture: markInsideReactTree,
4304 onMouseDownCapture(event) {
4305 markInsideReactTree();
4306 markPressStartedInsideReactTree(event);
4307 },
4308 onPointerDownCapture(event) {
4309 markInsideReactTree();
4310 markPressStartedInsideReactTree(event);
4311 },
4312 onMouseUpCapture: markInsideReactTree,
4313 onTouchEndCapture: markInsideReactTree,
4314 onTouchMoveCapture: markInsideReactTree
4315 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4316 return React25.useMemo(() => enabled ? {
4317 reference,
4318 floating,
4319 trigger: reference
4320 } : {}, [enabled, reference, floating]);
4321 }
4322
4323 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
4324 var React32 = __toESM(require_react(), 1);
4325
4326 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4327 function computeCoordsFromPlacement(_ref, placement, rtl) {
4328 let {
4329 reference,
4330 floating
4331 } = _ref;
4332 const sideAxis = getSideAxis(placement);
4333 const alignmentAxis = getAlignmentAxis(placement);
4334 const alignLength = getAxisLength(alignmentAxis);
4335 const side = getSide(placement);
4336 const isVertical = sideAxis === "y";
4337 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4338 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4339 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4340 let coords;
4341 switch (side) {
4342 case "top":
4343 coords = {
4344 x: commonX,
4345 y: reference.y - floating.height
4346 };
4347 break;
4348 case "bottom":
4349 coords = {
4350 x: commonX,
4351 y: reference.y + reference.height
4352 };
4353 break;
4354 case "right":
4355 coords = {
4356 x: reference.x + reference.width,
4357 y: commonY
4358 };
4359 break;
4360 case "left":
4361 coords = {
4362 x: reference.x - floating.width,
4363 y: commonY
4364 };
4365 break;
4366 default:
4367 coords = {
4368 x: reference.x,
4369 y: reference.y
4370 };
4371 }
4372 switch (getAlignment(placement)) {
4373 case "start":
4374 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4375 break;
4376 case "end":
4377 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4378 break;
4379 }
4380 return coords;
4381 }
4382 async function detectOverflow(state, options) {
4383 var _await$platform$isEle;
4384 if (options === void 0) {
4385 options = {};
4386 }
4387 const {
4388 x: x2,
4389 y: y2,
4390 platform: platform3,
4391 rects,
4392 elements,
4393 strategy
4394 } = state;
4395 const {
4396 boundary = "clippingAncestors",
4397 rootBoundary = "viewport",
4398 elementContext = "floating",
4399 altBoundary = false,
4400 padding = 0
4401 } = evaluate(options, state);
4402 const paddingObject = getPaddingObject(padding);
4403 const altContext = elementContext === "floating" ? "reference" : "floating";
4404 const element = elements[altBoundary ? altContext : elementContext];
4405 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4406 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)),
4407 boundary,
4408 rootBoundary,
4409 strategy
4410 }));
4411 const rect = elementContext === "floating" ? {
4412 x: x2,
4413 y: y2,
4414 width: rects.floating.width,
4415 height: rects.floating.height
4416 } : rects.reference;
4417 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4418 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4419 x: 1,
4420 y: 1
4421 } : {
4422 x: 1,
4423 y: 1
4424 };
4425 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4426 elements,
4427 rect,
4428 offsetParent,
4429 strategy
4430 }) : rect);
4431 return {
4432 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4433 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4434 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4435 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4436 };
4437 }
4438 var MAX_RESET_COUNT = 50;
4439 var computePosition = async (reference, floating, config) => {
4440 const {
4441 placement = "bottom",
4442 strategy = "absolute",
4443 middleware = [],
4444 platform: platform3
4445 } = config;
4446 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4447 ...platform3,
4448 detectOverflow
4449 };
4450 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4451 let rects = await platform3.getElementRects({
4452 reference,
4453 floating,
4454 strategy
4455 });
4456 let {
4457 x: x2,
4458 y: y2
4459 } = computeCoordsFromPlacement(rects, placement, rtl);
4460 let statefulPlacement = placement;
4461 let resetCount = 0;
4462 const middlewareData = {};
4463 for (let i2 = 0; i2 < middleware.length; i2++) {
4464 const currentMiddleware = middleware[i2];
4465 if (!currentMiddleware) {
4466 continue;
4467 }
4468 const {
4469 name,
4470 fn
4471 } = currentMiddleware;
4472 const {
4473 x: nextX,
4474 y: nextY,
4475 data,
4476 reset
4477 } = await fn({
4478 x: x2,
4479 y: y2,
4480 initialPlacement: placement,
4481 placement: statefulPlacement,
4482 strategy,
4483 middlewareData,
4484 rects,
4485 platform: platformWithDetectOverflow,
4486 elements: {
4487 reference,
4488 floating
4489 }
4490 });
4491 x2 = nextX != null ? nextX : x2;
4492 y2 = nextY != null ? nextY : y2;
4493 middlewareData[name] = {
4494 ...middlewareData[name],
4495 ...data
4496 };
4497 if (reset && resetCount < MAX_RESET_COUNT) {
4498 resetCount++;
4499 if (typeof reset === "object") {
4500 if (reset.placement) {
4501 statefulPlacement = reset.placement;
4502 }
4503 if (reset.rects) {
4504 rects = reset.rects === true ? await platform3.getElementRects({
4505 reference,
4506 floating,
4507 strategy
4508 }) : reset.rects;
4509 }
4510 ({
4511 x: x2,
4512 y: y2
4513 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4514 }
4515 i2 = -1;
4516 }
4517 }
4518 return {
4519 x: x2,
4520 y: y2,
4521 placement: statefulPlacement,
4522 strategy,
4523 middlewareData
4524 };
4525 };
4526 var flip = function(options) {
4527 if (options === void 0) {
4528 options = {};
4529 }
4530 return {
4531 name: "flip",
4532 options,
4533 async fn(state) {
4534 var _middlewareData$arrow, _middlewareData$flip;
4535 const {
4536 placement,
4537 middlewareData,
4538 rects,
4539 initialPlacement,
4540 platform: platform3,
4541 elements
4542 } = state;
4543 const {
4544 mainAxis: checkMainAxis = true,
4545 crossAxis: checkCrossAxis = true,
4546 fallbackPlacements: specifiedFallbackPlacements,
4547 fallbackStrategy = "bestFit",
4548 fallbackAxisSideDirection = "none",
4549 flipAlignment = true,
4550 ...detectOverflowOptions
4551 } = evaluate(options, state);
4552 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4553 return {};
4554 }
4555 const side = getSide(placement);
4556 const initialSideAxis = getSideAxis(initialPlacement);
4557 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4558 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4559 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4560 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4561 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4562 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4563 }
4564 const placements2 = [initialPlacement, ...fallbackPlacements];
4565 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4566 const overflows = [];
4567 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4568 if (checkMainAxis) {
4569 overflows.push(overflow[side]);
4570 }
4571 if (checkCrossAxis) {
4572 const sides2 = getAlignmentSides(placement, rects, rtl);
4573 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4574 }
4575 overflowsData = [...overflowsData, {
4576 placement,
4577 overflows
4578 }];
4579 if (!overflows.every((side2) => side2 <= 0)) {
4580 var _middlewareData$flip2, _overflowsData$filter;
4581 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4582 const nextPlacement = placements2[nextIndex];
4583 if (nextPlacement) {
4584 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4585 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4586 // overflows the main axis.
4587 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4588 return {
4589 data: {
4590 index: nextIndex,
4591 overflows: overflowsData
4592 },
4593 reset: {
4594 placement: nextPlacement
4595 }
4596 };
4597 }
4598 }
4599 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;
4600 if (!resetPlacement) {
4601 switch (fallbackStrategy) {
4602 case "bestFit": {
4603 var _overflowsData$filter2;
4604 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4605 if (hasFallbackAxisSideDirection) {
4606 const currentSideAxis = getSideAxis(d2.placement);
4607 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4608 // reading directions favoring greater width.
4609 currentSideAxis === "y";
4610 }
4611 return true;
4612 }).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];
4613 if (placement2) {
4614 resetPlacement = placement2;
4615 }
4616 break;
4617 }
4618 case "initialPlacement":
4619 resetPlacement = initialPlacement;
4620 break;
4621 }
4622 }
4623 if (placement !== resetPlacement) {
4624 return {
4625 reset: {
4626 placement: resetPlacement
4627 }
4628 };
4629 }
4630 }
4631 return {};
4632 }
4633 };
4634 };
4635 function getSideOffsets(overflow, rect) {
4636 return {
4637 top: overflow.top - rect.height,
4638 right: overflow.right - rect.width,
4639 bottom: overflow.bottom - rect.height,
4640 left: overflow.left - rect.width
4641 };
4642 }
4643 function isAnySideFullyClipped(overflow) {
4644 return sides.some((side) => overflow[side] >= 0);
4645 }
4646 var hide = function(options) {
4647 if (options === void 0) {
4648 options = {};
4649 }
4650 return {
4651 name: "hide",
4652 options,
4653 async fn(state) {
4654 const {
4655 rects,
4656 platform: platform3
4657 } = state;
4658 const {
4659 strategy = "referenceHidden",
4660 ...detectOverflowOptions
4661 } = evaluate(options, state);
4662 switch (strategy) {
4663 case "referenceHidden": {
4664 const overflow = await platform3.detectOverflow(state, {
4665 ...detectOverflowOptions,
4666 elementContext: "reference"
4667 });
4668 const offsets = getSideOffsets(overflow, rects.reference);
4669 return {
4670 data: {
4671 referenceHiddenOffsets: offsets,
4672 referenceHidden: isAnySideFullyClipped(offsets)
4673 }
4674 };
4675 }
4676 case "escaped": {
4677 const overflow = await platform3.detectOverflow(state, {
4678 ...detectOverflowOptions,
4679 altBoundary: true
4680 });
4681 const offsets = getSideOffsets(overflow, rects.floating);
4682 return {
4683 data: {
4684 escapedOffsets: offsets,
4685 escaped: isAnySideFullyClipped(offsets)
4686 }
4687 };
4688 }
4689 default: {
4690 return {};
4691 }
4692 }
4693 }
4694 };
4695 };
4696 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4697 async function convertValueToCoords(state, options) {
4698 const {
4699 placement,
4700 platform: platform3,
4701 elements
4702 } = state;
4703 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4704 const side = getSide(placement);
4705 const alignment = getAlignment(placement);
4706 const isVertical = getSideAxis(placement) === "y";
4707 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4708 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4709 const rawValue = evaluate(options, state);
4710 let {
4711 mainAxis,
4712 crossAxis,
4713 alignmentAxis
4714 } = typeof rawValue === "number" ? {
4715 mainAxis: rawValue,
4716 crossAxis: 0,
4717 alignmentAxis: null
4718 } : {
4719 mainAxis: rawValue.mainAxis || 0,
4720 crossAxis: rawValue.crossAxis || 0,
4721 alignmentAxis: rawValue.alignmentAxis
4722 };
4723 if (alignment && typeof alignmentAxis === "number") {
4724 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4725 }
4726 return isVertical ? {
4727 x: crossAxis * crossAxisMulti,
4728 y: mainAxis * mainAxisMulti
4729 } : {
4730 x: mainAxis * mainAxisMulti,
4731 y: crossAxis * crossAxisMulti
4732 };
4733 }
4734 var offset = function(options) {
4735 if (options === void 0) {
4736 options = 0;
4737 }
4738 return {
4739 name: "offset",
4740 options,
4741 async fn(state) {
4742 var _middlewareData$offse, _middlewareData$arrow;
4743 const {
4744 x: x2,
4745 y: y2,
4746 placement,
4747 middlewareData
4748 } = state;
4749 const diffCoords = await convertValueToCoords(state, options);
4750 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4751 return {};
4752 }
4753 return {
4754 x: x2 + diffCoords.x,
4755 y: y2 + diffCoords.y,
4756 data: {
4757 ...diffCoords,
4758 placement
4759 }
4760 };
4761 }
4762 };
4763 };
4764 var shift = function(options) {
4765 if (options === void 0) {
4766 options = {};
4767 }
4768 return {
4769 name: "shift",
4770 options,
4771 async fn(state) {
4772 const {
4773 x: x2,
4774 y: y2,
4775 placement,
4776 platform: platform3
4777 } = state;
4778 const {
4779 mainAxis: checkMainAxis = true,
4780 crossAxis: checkCrossAxis = false,
4781 limiter = {
4782 fn: (_ref) => {
4783 let {
4784 x: x3,
4785 y: y3
4786 } = _ref;
4787 return {
4788 x: x3,
4789 y: y3
4790 };
4791 }
4792 },
4793 ...detectOverflowOptions
4794 } = evaluate(options, state);
4795 const coords = {
4796 x: x2,
4797 y: y2
4798 };
4799 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4800 const crossAxis = getSideAxis(getSide(placement));
4801 const mainAxis = getOppositeAxis(crossAxis);
4802 let mainAxisCoord = coords[mainAxis];
4803 let crossAxisCoord = coords[crossAxis];
4804 if (checkMainAxis) {
4805 const minSide = mainAxis === "y" ? "top" : "left";
4806 const maxSide = mainAxis === "y" ? "bottom" : "right";
4807 const min2 = mainAxisCoord + overflow[minSide];
4808 const max2 = mainAxisCoord - overflow[maxSide];
4809 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4810 }
4811 if (checkCrossAxis) {
4812 const minSide = crossAxis === "y" ? "top" : "left";
4813 const maxSide = crossAxis === "y" ? "bottom" : "right";
4814 const min2 = crossAxisCoord + overflow[minSide];
4815 const max2 = crossAxisCoord - overflow[maxSide];
4816 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4817 }
4818 const limitedCoords = limiter.fn({
4819 ...state,
4820 [mainAxis]: mainAxisCoord,
4821 [crossAxis]: crossAxisCoord
4822 });
4823 return {
4824 ...limitedCoords,
4825 data: {
4826 x: limitedCoords.x - x2,
4827 y: limitedCoords.y - y2,
4828 enabled: {
4829 [mainAxis]: checkMainAxis,
4830 [crossAxis]: checkCrossAxis
4831 }
4832 }
4833 };
4834 }
4835 };
4836 };
4837 var limitShift = function(options) {
4838 if (options === void 0) {
4839 options = {};
4840 }
4841 return {
4842 options,
4843 fn(state) {
4844 const {
4845 x: x2,
4846 y: y2,
4847 placement,
4848 rects,
4849 middlewareData
4850 } = state;
4851 const {
4852 offset: offset4 = 0,
4853 mainAxis: checkMainAxis = true,
4854 crossAxis: checkCrossAxis = true
4855 } = evaluate(options, state);
4856 const coords = {
4857 x: x2,
4858 y: y2
4859 };
4860 const crossAxis = getSideAxis(placement);
4861 const mainAxis = getOppositeAxis(crossAxis);
4862 let mainAxisCoord = coords[mainAxis];
4863 let crossAxisCoord = coords[crossAxis];
4864 const rawOffset = evaluate(offset4, state);
4865 const computedOffset = typeof rawOffset === "number" ? {
4866 mainAxis: rawOffset,
4867 crossAxis: 0
4868 } : {
4869 mainAxis: 0,
4870 crossAxis: 0,
4871 ...rawOffset
4872 };
4873 if (checkMainAxis) {
4874 const len = mainAxis === "y" ? "height" : "width";
4875 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4876 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4877 if (mainAxisCoord < limitMin) {
4878 mainAxisCoord = limitMin;
4879 } else if (mainAxisCoord > limitMax) {
4880 mainAxisCoord = limitMax;
4881 }
4882 }
4883 if (checkCrossAxis) {
4884 var _middlewareData$offse, _middlewareData$offse2;
4885 const len = mainAxis === "y" ? "width" : "height";
4886 const isOriginSide = originSides.has(getSide(placement));
4887 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);
4888 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);
4889 if (crossAxisCoord < limitMin) {
4890 crossAxisCoord = limitMin;
4891 } else if (crossAxisCoord > limitMax) {
4892 crossAxisCoord = limitMax;
4893 }
4894 }
4895 return {
4896 [mainAxis]: mainAxisCoord,
4897 [crossAxis]: crossAxisCoord
4898 };
4899 }
4900 };
4901 };
4902 var size = function(options) {
4903 if (options === void 0) {
4904 options = {};
4905 }
4906 return {
4907 name: "size",
4908 options,
4909 async fn(state) {
4910 var _state$middlewareData, _state$middlewareData2;
4911 const {
4912 placement,
4913 rects,
4914 platform: platform3,
4915 elements
4916 } = state;
4917 const {
4918 apply = () => {
4919 },
4920 ...detectOverflowOptions
4921 } = evaluate(options, state);
4922 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4923 const side = getSide(placement);
4924 const alignment = getAlignment(placement);
4925 const isYAxis = getSideAxis(placement) === "y";
4926 const {
4927 width,
4928 height
4929 } = rects.floating;
4930 let heightSide;
4931 let widthSide;
4932 if (side === "top" || side === "bottom") {
4933 heightSide = side;
4934 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4935 } else {
4936 widthSide = side;
4937 heightSide = alignment === "end" ? "top" : "bottom";
4938 }
4939 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4940 const maximumClippingWidth = width - overflow.left - overflow.right;
4941 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4942 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4943 const noShift = !state.middlewareData.shift;
4944 let availableHeight = overflowAvailableHeight;
4945 let availableWidth = overflowAvailableWidth;
4946 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4947 availableWidth = maximumClippingWidth;
4948 }
4949 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4950 availableHeight = maximumClippingHeight;
4951 }
4952 if (noShift && !alignment) {
4953 const xMin = max(overflow.left, 0);
4954 const xMax = max(overflow.right, 0);
4955 const yMin = max(overflow.top, 0);
4956 const yMax = max(overflow.bottom, 0);
4957 if (isYAxis) {
4958 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4959 } else {
4960 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4961 }
4962 }
4963 await apply({
4964 ...state,
4965 availableWidth,
4966 availableHeight
4967 });
4968 const nextDimensions = await platform3.getDimensions(elements.floating);
4969 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4970 return {
4971 reset: {
4972 rects: true
4973 }
4974 };
4975 }
4976 return {};
4977 }
4978 };
4979 };
4980
4981 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4982 function getCssDimensions(element) {
4983 const css = getComputedStyle2(element);
4984 let width = parseFloat(css.width) || 0;
4985 let height = parseFloat(css.height) || 0;
4986 const hasOffset = isHTMLElement(element);
4987 const offsetWidth = hasOffset ? element.offsetWidth : width;
4988 const offsetHeight = hasOffset ? element.offsetHeight : height;
4989 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4990 if (shouldFallback) {
4991 width = offsetWidth;
4992 height = offsetHeight;
4993 }
4994 return {
4995 width,
4996 height,
4997 $: shouldFallback
4998 };
4999 }
5000 function unwrapElement(element) {
5001 return !isElement(element) ? element.contextElement : element;
5002 }
5003 function getScale(element) {
5004 const domElement = unwrapElement(element);
5005 if (!isHTMLElement(domElement)) {
5006 return createCoords(1);
5007 }
5008 const rect = domElement.getBoundingClientRect();
5009 const {
5010 width,
5011 height,
5012 $: $2
5013 } = getCssDimensions(domElement);
5014 let x2 = ($2 ? round(rect.width) : rect.width) / width;
5015 let y2 = ($2 ? round(rect.height) : rect.height) / height;
5016 if (!x2 || !Number.isFinite(x2)) {
5017 x2 = 1;
5018 }
5019 if (!y2 || !Number.isFinite(y2)) {
5020 y2 = 1;
5021 }
5022 return {
5023 x: x2,
5024 y: y2
5025 };
5026 }
5027 var noOffsets = /* @__PURE__ */ createCoords(0);
5028 function getVisualOffsets(element) {
5029 const win = getWindow(element);
5030 if (!isWebKit() || !win.visualViewport) {
5031 return noOffsets;
5032 }
5033 return {
5034 x: win.visualViewport.offsetLeft,
5035 y: win.visualViewport.offsetTop
5036 };
5037 }
5038 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5039 if (isFixed === void 0) {
5040 isFixed = false;
5041 }
5042 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5043 return false;
5044 }
5045 return isFixed;
5046 }
5047 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5048 if (includeScale === void 0) {
5049 includeScale = false;
5050 }
5051 if (isFixedStrategy === void 0) {
5052 isFixedStrategy = false;
5053 }
5054 const clientRect = element.getBoundingClientRect();
5055 const domElement = unwrapElement(element);
5056 let scale = createCoords(1);
5057 if (includeScale) {
5058 if (offsetParent) {
5059 if (isElement(offsetParent)) {
5060 scale = getScale(offsetParent);
5061 }
5062 } else {
5063 scale = getScale(element);
5064 }
5065 }
5066 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5067 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5068 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5069 let width = clientRect.width / scale.x;
5070 let height = clientRect.height / scale.y;
5071 if (domElement) {
5072 const win = getWindow(domElement);
5073 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5074 let currentWin = win;
5075 let currentIFrame = getFrameElement(currentWin);
5076 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5077 const iframeScale = getScale(currentIFrame);
5078 const iframeRect = currentIFrame.getBoundingClientRect();
5079 const css = getComputedStyle2(currentIFrame);
5080 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5081 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5082 x2 *= iframeScale.x;
5083 y2 *= iframeScale.y;
5084 width *= iframeScale.x;
5085 height *= iframeScale.y;
5086 x2 += left;
5087 y2 += top;
5088 currentWin = getWindow(currentIFrame);
5089 currentIFrame = getFrameElement(currentWin);
5090 }
5091 }
5092 return rectToClientRect({
5093 width,
5094 height,
5095 x: x2,
5096 y: y2
5097 });
5098 }
5099 function getWindowScrollBarX(element, rect) {
5100 const leftScroll = getNodeScroll(element).scrollLeft;
5101 if (!rect) {
5102 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5103 }
5104 return rect.left + leftScroll;
5105 }
5106 function getHTMLOffset(documentElement, scroll) {
5107 const htmlRect = documentElement.getBoundingClientRect();
5108 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5109 const y2 = htmlRect.top + scroll.scrollTop;
5110 return {
5111 x: x2,
5112 y: y2
5113 };
5114 }
5115 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5116 let {
5117 elements,
5118 rect,
5119 offsetParent,
5120 strategy
5121 } = _ref;
5122 const isFixed = strategy === "fixed";
5123 const documentElement = getDocumentElement(offsetParent);
5124 const topLayer = elements ? isTopLayer(elements.floating) : false;
5125 if (offsetParent === documentElement || topLayer && isFixed) {
5126 return rect;
5127 }
5128 let scroll = {
5129 scrollLeft: 0,
5130 scrollTop: 0
5131 };
5132 let scale = createCoords(1);
5133 const offsets = createCoords(0);
5134 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5135 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5136 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5137 scroll = getNodeScroll(offsetParent);
5138 }
5139 if (isOffsetParentAnElement) {
5140 const offsetRect = getBoundingClientRect(offsetParent);
5141 scale = getScale(offsetParent);
5142 offsets.x = offsetRect.x + offsetParent.clientLeft;
5143 offsets.y = offsetRect.y + offsetParent.clientTop;
5144 }
5145 }
5146 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5147 return {
5148 width: rect.width * scale.x,
5149 height: rect.height * scale.y,
5150 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5151 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5152 };
5153 }
5154 function getClientRects(element) {
5155 return Array.from(element.getClientRects());
5156 }
5157 function getDocumentRect(element) {
5158 const html = getDocumentElement(element);
5159 const scroll = getNodeScroll(element);
5160 const body = element.ownerDocument.body;
5161 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5162 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5163 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5164 const y2 = -scroll.scrollTop;
5165 if (getComputedStyle2(body).direction === "rtl") {
5166 x2 += max(html.clientWidth, body.clientWidth) - width;
5167 }
5168 return {
5169 width,
5170 height,
5171 x: x2,
5172 y: y2
5173 };
5174 }
5175 var SCROLLBAR_MAX = 25;
5176 function getViewportRect(element, strategy) {
5177 const win = getWindow(element);
5178 const html = getDocumentElement(element);
5179 const visualViewport = win.visualViewport;
5180 let width = html.clientWidth;
5181 let height = html.clientHeight;
5182 let x2 = 0;
5183 let y2 = 0;
5184 if (visualViewport) {
5185 width = visualViewport.width;
5186 height = visualViewport.height;
5187 const visualViewportBased = isWebKit();
5188 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5189 x2 = visualViewport.offsetLeft;
5190 y2 = visualViewport.offsetTop;
5191 }
5192 }
5193 const windowScrollbarX = getWindowScrollBarX(html);
5194 if (windowScrollbarX <= 0) {
5195 const doc = html.ownerDocument;
5196 const body = doc.body;
5197 const bodyStyles = getComputedStyle(body);
5198 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5199 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5200 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5201 width -= clippingStableScrollbarWidth;
5202 }
5203 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5204 width += windowScrollbarX;
5205 }
5206 return {
5207 width,
5208 height,
5209 x: x2,
5210 y: y2
5211 };
5212 }
5213 function getInnerBoundingClientRect(element, strategy) {
5214 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5215 const top = clientRect.top + element.clientTop;
5216 const left = clientRect.left + element.clientLeft;
5217 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5218 const width = element.clientWidth * scale.x;
5219 const height = element.clientHeight * scale.y;
5220 const x2 = left * scale.x;
5221 const y2 = top * scale.y;
5222 return {
5223 width,
5224 height,
5225 x: x2,
5226 y: y2
5227 };
5228 }
5229 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5230 let rect;
5231 if (clippingAncestor === "viewport") {
5232 rect = getViewportRect(element, strategy);
5233 } else if (clippingAncestor === "document") {
5234 rect = getDocumentRect(getDocumentElement(element));
5235 } else if (isElement(clippingAncestor)) {
5236 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5237 } else {
5238 const visualOffsets = getVisualOffsets(element);
5239 rect = {
5240 x: clippingAncestor.x - visualOffsets.x,
5241 y: clippingAncestor.y - visualOffsets.y,
5242 width: clippingAncestor.width,
5243 height: clippingAncestor.height
5244 };
5245 }
5246 return rectToClientRect(rect);
5247 }
5248 function hasFixedPositionAncestor(element, stopNode) {
5249 const parentNode = getParentNode(element);
5250 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5251 return false;
5252 }
5253 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5254 }
5255 function getClippingElementAncestors(element, cache) {
5256 const cachedResult = cache.get(element);
5257 if (cachedResult) {
5258 return cachedResult;
5259 }
5260 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5261 let currentContainingBlockComputedStyle = null;
5262 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5263 let currentNode = elementIsFixed ? getParentNode(element) : element;
5264 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5265 const computedStyle = getComputedStyle2(currentNode);
5266 const currentNodeIsContaining = isContainingBlock(currentNode);
5267 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5268 currentContainingBlockComputedStyle = null;
5269 }
5270 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5271 if (shouldDropCurrentNode) {
5272 result = result.filter((ancestor) => ancestor !== currentNode);
5273 } else {
5274 currentContainingBlockComputedStyle = computedStyle;
5275 }
5276 currentNode = getParentNode(currentNode);
5277 }
5278 cache.set(element, result);
5279 return result;
5280 }
5281 function getClippingRect(_ref) {
5282 let {
5283 element,
5284 boundary,
5285 rootBoundary,
5286 strategy
5287 } = _ref;
5288 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5289 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5290 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5291 let top = firstRect.top;
5292 let right = firstRect.right;
5293 let bottom = firstRect.bottom;
5294 let left = firstRect.left;
5295 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5296 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5297 top = max(rect.top, top);
5298 right = min(rect.right, right);
5299 bottom = min(rect.bottom, bottom);
5300 left = max(rect.left, left);
5301 }
5302 return {
5303 width: right - left,
5304 height: bottom - top,
5305 x: left,
5306 y: top
5307 };
5308 }
5309 function getDimensions2(element) {
5310 const {
5311 width,
5312 height
5313 } = getCssDimensions(element);
5314 return {
5315 width,
5316 height
5317 };
5318 }
5319 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5320 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5321 const documentElement = getDocumentElement(offsetParent);
5322 const isFixed = strategy === "fixed";
5323 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5324 let scroll = {
5325 scrollLeft: 0,
5326 scrollTop: 0
5327 };
5328 const offsets = createCoords(0);
5329 function setLeftRTLScrollbarOffset() {
5330 offsets.x = getWindowScrollBarX(documentElement);
5331 }
5332 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5333 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5334 scroll = getNodeScroll(offsetParent);
5335 }
5336 if (isOffsetParentAnElement) {
5337 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5338 offsets.x = offsetRect.x + offsetParent.clientLeft;
5339 offsets.y = offsetRect.y + offsetParent.clientTop;
5340 } else if (documentElement) {
5341 setLeftRTLScrollbarOffset();
5342 }
5343 }
5344 if (isFixed && !isOffsetParentAnElement && documentElement) {
5345 setLeftRTLScrollbarOffset();
5346 }
5347 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5348 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5349 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5350 return {
5351 x: x2,
5352 y: y2,
5353 width: rect.width,
5354 height: rect.height
5355 };
5356 }
5357 function isStaticPositioned(element) {
5358 return getComputedStyle2(element).position === "static";
5359 }
5360 function getTrueOffsetParent(element, polyfill) {
5361 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5362 return null;
5363 }
5364 if (polyfill) {
5365 return polyfill(element);
5366 }
5367 let rawOffsetParent = element.offsetParent;
5368 if (getDocumentElement(element) === rawOffsetParent) {
5369 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5370 }
5371 return rawOffsetParent;
5372 }
5373 function getOffsetParent(element, polyfill) {
5374 const win = getWindow(element);
5375 if (isTopLayer(element)) {
5376 return win;
5377 }
5378 if (!isHTMLElement(element)) {
5379 let svgOffsetParent = getParentNode(element);
5380 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5381 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5382 return svgOffsetParent;
5383 }
5384 svgOffsetParent = getParentNode(svgOffsetParent);
5385 }
5386 return win;
5387 }
5388 let offsetParent = getTrueOffsetParent(element, polyfill);
5389 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5390 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5391 }
5392 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5393 return win;
5394 }
5395 return offsetParent || getContainingBlock(element) || win;
5396 }
5397 var getElementRects = async function(data) {
5398 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5399 const getDimensionsFn = this.getDimensions;
5400 const floatingDimensions = await getDimensionsFn(data.floating);
5401 return {
5402 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5403 floating: {
5404 x: 0,
5405 y: 0,
5406 width: floatingDimensions.width,
5407 height: floatingDimensions.height
5408 }
5409 };
5410 };
5411 function isRTL(element) {
5412 return getComputedStyle2(element).direction === "rtl";
5413 }
5414 var platform2 = {
5415 convertOffsetParentRelativeRectToViewportRelativeRect,
5416 getDocumentElement,
5417 getClippingRect,
5418 getOffsetParent,
5419 getElementRects,
5420 getClientRects,
5421 getDimensions: getDimensions2,
5422 getScale,
5423 isElement,
5424 isRTL
5425 };
5426 function rectsAreEqual(a2, b2) {
5427 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5428 }
5429 function observeMove(element, onMove) {
5430 let io = null;
5431 let timeoutId;
5432 const root = getDocumentElement(element);
5433 function cleanup() {
5434 var _io;
5435 clearTimeout(timeoutId);
5436 (_io = io) == null || _io.disconnect();
5437 io = null;
5438 }
5439 function refresh(skip, threshold) {
5440 if (skip === void 0) {
5441 skip = false;
5442 }
5443 if (threshold === void 0) {
5444 threshold = 1;
5445 }
5446 cleanup();
5447 const elementRectForRootMargin = element.getBoundingClientRect();
5448 const {
5449 left,
5450 top,
5451 width,
5452 height
5453 } = elementRectForRootMargin;
5454 if (!skip) {
5455 onMove();
5456 }
5457 if (!width || !height) {
5458 return;
5459 }
5460 const insetTop = floor(top);
5461 const insetRight = floor(root.clientWidth - (left + width));
5462 const insetBottom = floor(root.clientHeight - (top + height));
5463 const insetLeft = floor(left);
5464 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5465 const options = {
5466 rootMargin,
5467 threshold: max(0, min(1, threshold)) || 1
5468 };
5469 let isFirstUpdate = true;
5470 function handleObserve(entries) {
5471 const ratio = entries[0].intersectionRatio;
5472 if (ratio !== threshold) {
5473 if (!isFirstUpdate) {
5474 return refresh();
5475 }
5476 if (!ratio) {
5477 timeoutId = setTimeout(() => {
5478 refresh(false, 1e-7);
5479 }, 1e3);
5480 } else {
5481 refresh(false, ratio);
5482 }
5483 }
5484 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5485 refresh();
5486 }
5487 isFirstUpdate = false;
5488 }
5489 try {
5490 io = new IntersectionObserver(handleObserve, {
5491 ...options,
5492 // Handle <iframe>s
5493 root: root.ownerDocument
5494 });
5495 } catch (_e) {
5496 io = new IntersectionObserver(handleObserve, options);
5497 }
5498 io.observe(element);
5499 }
5500 refresh(true);
5501 return cleanup;
5502 }
5503 function autoUpdate(reference, floating, update2, options) {
5504 if (options === void 0) {
5505 options = {};
5506 }
5507 const {
5508 ancestorScroll = true,
5509 ancestorResize = true,
5510 elementResize = typeof ResizeObserver === "function",
5511 layoutShift = typeof IntersectionObserver === "function",
5512 animationFrame = false
5513 } = options;
5514 const referenceEl = unwrapElement(reference);
5515 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5516 ancestors.forEach((ancestor) => {
5517 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5518 passive: true
5519 });
5520 ancestorResize && ancestor.addEventListener("resize", update2);
5521 });
5522 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5523 let reobserveFrame = -1;
5524 let resizeObserver = null;
5525 if (elementResize) {
5526 resizeObserver = new ResizeObserver((_ref) => {
5527 let [firstEntry] = _ref;
5528 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5529 resizeObserver.unobserve(floating);
5530 cancelAnimationFrame(reobserveFrame);
5531 reobserveFrame = requestAnimationFrame(() => {
5532 var _resizeObserver;
5533 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5534 });
5535 }
5536 update2();
5537 });
5538 if (referenceEl && !animationFrame) {
5539 resizeObserver.observe(referenceEl);
5540 }
5541 if (floating) {
5542 resizeObserver.observe(floating);
5543 }
5544 }
5545 let frameId;
5546 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5547 if (animationFrame) {
5548 frameLoop();
5549 }
5550 function frameLoop() {
5551 const nextRefRect = getBoundingClientRect(reference);
5552 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5553 update2();
5554 }
5555 prevRefRect = nextRefRect;
5556 frameId = requestAnimationFrame(frameLoop);
5557 }
5558 update2();
5559 return () => {
5560 var _resizeObserver2;
5561 ancestors.forEach((ancestor) => {
5562 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5563 ancestorResize && ancestor.removeEventListener("resize", update2);
5564 });
5565 cleanupIo == null || cleanupIo();
5566 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5567 resizeObserver = null;
5568 if (animationFrame) {
5569 cancelAnimationFrame(frameId);
5570 }
5571 };
5572 }
5573 var offset2 = offset;
5574 var shift2 = shift;
5575 var flip2 = flip;
5576 var size2 = size;
5577 var hide2 = hide;
5578 var limitShift2 = limitShift;
5579 var computePosition2 = (reference, floating, options) => {
5580 const cache = /* @__PURE__ */ new Map();
5581 const mergedOptions = {
5582 platform: platform2,
5583 ...options
5584 };
5585 const platformWithCache = {
5586 ...mergedOptions.platform,
5587 _c: cache
5588 };
5589 return computePosition(reference, floating, {
5590 ...mergedOptions,
5591 platform: platformWithCache
5592 });
5593 };
5594
5595 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5596 var React26 = __toESM(require_react(), 1);
5597 var import_react2 = __toESM(require_react(), 1);
5598 var ReactDOM3 = __toESM(require_react_dom(), 1);
5599 var isClient = typeof document !== "undefined";
5600 var noop2 = function noop3() {
5601 };
5602 var index = isClient ? import_react2.useLayoutEffect : noop2;
5603 function deepEqual(a2, b2) {
5604 if (a2 === b2) {
5605 return true;
5606 }
5607 if (typeof a2 !== typeof b2) {
5608 return false;
5609 }
5610 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5611 return true;
5612 }
5613 let length;
5614 let i2;
5615 let keys;
5616 if (a2 && b2 && typeof a2 === "object") {
5617 if (Array.isArray(a2)) {
5618 length = a2.length;
5619 if (length !== b2.length) return false;
5620 for (i2 = length; i2-- !== 0; ) {
5621 if (!deepEqual(a2[i2], b2[i2])) {
5622 return false;
5623 }
5624 }
5625 return true;
5626 }
5627 keys = Object.keys(a2);
5628 length = keys.length;
5629 if (length !== Object.keys(b2).length) {
5630 return false;
5631 }
5632 for (i2 = length; i2-- !== 0; ) {
5633 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5634 return false;
5635 }
5636 }
5637 for (i2 = length; i2-- !== 0; ) {
5638 const key = keys[i2];
5639 if (key === "_owner" && a2.$$typeof) {
5640 continue;
5641 }
5642 if (!deepEqual(a2[key], b2[key])) {
5643 return false;
5644 }
5645 }
5646 return true;
5647 }
5648 return a2 !== a2 && b2 !== b2;
5649 }
5650 function getDPR(element) {
5651 if (typeof window === "undefined") {
5652 return 1;
5653 }
5654 const win = element.ownerDocument.defaultView || window;
5655 return win.devicePixelRatio || 1;
5656 }
5657 function roundByDPR(element, value) {
5658 const dpr = getDPR(element);
5659 return Math.round(value * dpr) / dpr;
5660 }
5661 function useLatestRef(value) {
5662 const ref = React26.useRef(value);
5663 index(() => {
5664 ref.current = value;
5665 });
5666 return ref;
5667 }
5668 function useFloating(options) {
5669 if (options === void 0) {
5670 options = {};
5671 }
5672 const {
5673 placement = "bottom",
5674 strategy = "absolute",
5675 middleware = [],
5676 platform: platform3,
5677 elements: {
5678 reference: externalReference,
5679 floating: externalFloating
5680 } = {},
5681 transform = true,
5682 whileElementsMounted,
5683 open
5684 } = options;
5685 const [data, setData] = React26.useState({
5686 x: 0,
5687 y: 0,
5688 strategy,
5689 placement,
5690 middlewareData: {},
5691 isPositioned: false
5692 });
5693 const [latestMiddleware, setLatestMiddleware] = React26.useState(middleware);
5694 if (!deepEqual(latestMiddleware, middleware)) {
5695 setLatestMiddleware(middleware);
5696 }
5697 const [_reference, _setReference] = React26.useState(null);
5698 const [_floating, _setFloating] = React26.useState(null);
5699 const setReference = React26.useCallback((node) => {
5700 if (node !== referenceRef.current) {
5701 referenceRef.current = node;
5702 _setReference(node);
5703 }
5704 }, []);
5705 const setFloating = React26.useCallback((node) => {
5706 if (node !== floatingRef.current) {
5707 floatingRef.current = node;
5708 _setFloating(node);
5709 }
5710 }, []);
5711 const referenceEl = externalReference || _reference;
5712 const floatingEl = externalFloating || _floating;
5713 const referenceRef = React26.useRef(null);
5714 const floatingRef = React26.useRef(null);
5715 const dataRef = React26.useRef(data);
5716 const hasWhileElementsMounted = whileElementsMounted != null;
5717 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5718 const platformRef = useLatestRef(platform3);
5719 const openRef = useLatestRef(open);
5720 const update2 = React26.useCallback(() => {
5721 if (!referenceRef.current || !floatingRef.current) {
5722 return;
5723 }
5724 const config = {
5725 placement,
5726 strategy,
5727 middleware: latestMiddleware
5728 };
5729 if (platformRef.current) {
5730 config.platform = platformRef.current;
5731 }
5732 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5733 const fullData = {
5734 ...data2,
5735 // The floating element's position may be recomputed while it's closed
5736 // but still mounted (such as when transitioning out). To ensure
5737 // `isPositioned` will be `false` initially on the next open, avoid
5738 // setting it to `true` when `open === false` (must be specified).
5739 isPositioned: openRef.current !== false
5740 };
5741 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5742 dataRef.current = fullData;
5743 ReactDOM3.flushSync(() => {
5744 setData(fullData);
5745 });
5746 }
5747 });
5748 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5749 index(() => {
5750 if (open === false && dataRef.current.isPositioned) {
5751 dataRef.current.isPositioned = false;
5752 setData((data2) => ({
5753 ...data2,
5754 isPositioned: false
5755 }));
5756 }
5757 }, [open]);
5758 const isMountedRef = React26.useRef(false);
5759 index(() => {
5760 isMountedRef.current = true;
5761 return () => {
5762 isMountedRef.current = false;
5763 };
5764 }, []);
5765 index(() => {
5766 if (referenceEl) referenceRef.current = referenceEl;
5767 if (floatingEl) floatingRef.current = floatingEl;
5768 if (referenceEl && floatingEl) {
5769 if (whileElementsMountedRef.current) {
5770 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5771 }
5772 update2();
5773 }
5774 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5775 const refs = React26.useMemo(() => ({
5776 reference: referenceRef,
5777 floating: floatingRef,
5778 setReference,
5779 setFloating
5780 }), [setReference, setFloating]);
5781 const elements = React26.useMemo(() => ({
5782 reference: referenceEl,
5783 floating: floatingEl
5784 }), [referenceEl, floatingEl]);
5785 const floatingStyles = React26.useMemo(() => {
5786 const initialStyles = {
5787 position: strategy,
5788 left: 0,
5789 top: 0
5790 };
5791 if (!elements.floating) {
5792 return initialStyles;
5793 }
5794 const x2 = roundByDPR(elements.floating, data.x);
5795 const y2 = roundByDPR(elements.floating, data.y);
5796 if (transform) {
5797 return {
5798 ...initialStyles,
5799 transform: "translate(" + x2 + "px, " + y2 + "px)",
5800 ...getDPR(elements.floating) >= 1.5 && {
5801 willChange: "transform"
5802 }
5803 };
5804 }
5805 return {
5806 position: strategy,
5807 left: x2,
5808 top: y2
5809 };
5810 }, [strategy, transform, elements.floating, data.x, data.y]);
5811 return React26.useMemo(() => ({
5812 ...data,
5813 update: update2,
5814 refs,
5815 elements,
5816 floatingStyles
5817 }), [data, update2, refs, elements, floatingStyles]);
5818 }
5819 var offset3 = (options, deps) => {
5820 const result = offset2(options);
5821 return {
5822 name: result.name,
5823 fn: result.fn,
5824 options: [options, deps]
5825 };
5826 };
5827 var shift3 = (options, deps) => {
5828 const result = shift2(options);
5829 return {
5830 name: result.name,
5831 fn: result.fn,
5832 options: [options, deps]
5833 };
5834 };
5835 var limitShift3 = (options, deps) => {
5836 const result = limitShift2(options);
5837 return {
5838 fn: result.fn,
5839 options: [options, deps]
5840 };
5841 };
5842 var flip3 = (options, deps) => {
5843 const result = flip2(options);
5844 return {
5845 name: result.name,
5846 fn: result.fn,
5847 options: [options, deps]
5848 };
5849 };
5850 var size3 = (options, deps) => {
5851 const result = size2(options);
5852 return {
5853 name: result.name,
5854 fn: result.fn,
5855 options: [options, deps]
5856 };
5857 };
5858 var hide3 = (options, deps) => {
5859 const result = hide2(options);
5860 return {
5861 name: result.name,
5862 fn: result.fn,
5863 options: [options, deps]
5864 };
5865 };
5866
5867 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5868 var React31 = __toESM(require_react(), 1);
5869
5870 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5871 var React30 = __toESM(require_react(), 1);
5872
5873 // node_modules/@base-ui/utils/esm/store/createSelector.js
5874 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5875 if (other.length > 0) {
5876 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5877 }
5878 let selector2;
5879 if (a2 && b2 && c2 && d2 && e2 && f2) {
5880 selector2 = (state, a1, a22, a3) => {
5881 const va = a2(state, a1, a22, a3);
5882 const vb = b2(state, a1, a22, a3);
5883 const vc = c2(state, a1, a22, a3);
5884 const vd = d2(state, a1, a22, a3);
5885 const ve = e2(state, a1, a22, a3);
5886 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5887 };
5888 } else if (a2 && b2 && c2 && d2 && e2) {
5889 selector2 = (state, a1, a22, a3) => {
5890 const va = a2(state, a1, a22, a3);
5891 const vb = b2(state, a1, a22, a3);
5892 const vc = c2(state, a1, a22, a3);
5893 const vd = d2(state, a1, a22, a3);
5894 return e2(va, vb, vc, vd, a1, a22, a3);
5895 };
5896 } else if (a2 && b2 && c2 && d2) {
5897 selector2 = (state, a1, a22, a3) => {
5898 const va = a2(state, a1, a22, a3);
5899 const vb = b2(state, a1, a22, a3);
5900 const vc = c2(state, a1, a22, a3);
5901 return d2(va, vb, vc, a1, a22, a3);
5902 };
5903 } else if (a2 && b2 && c2) {
5904 selector2 = (state, a1, a22, a3) => {
5905 const va = a2(state, a1, a22, a3);
5906 const vb = b2(state, a1, a22, a3);
5907 return c2(va, vb, a1, a22, a3);
5908 };
5909 } else if (a2 && b2) {
5910 selector2 = (state, a1, a22, a3) => {
5911 const va = a2(state, a1, a22, a3);
5912 return b2(va, a1, a22, a3);
5913 };
5914 } else if (a2) {
5915 selector2 = a2;
5916 } else {
5917 throw (
5918 /* minify-error-disabled */
5919 new Error("Missing arguments")
5920 );
5921 }
5922 return selector2;
5923 };
5924
5925 // node_modules/@base-ui/utils/esm/store/useStore.js
5926 var React28 = __toESM(require_react(), 1);
5927 var import_shim = __toESM(require_shim(), 1);
5928 var import_with_selector = __toESM(require_with_selector(), 1);
5929
5930 // node_modules/@base-ui/utils/esm/fastHooks.js
5931 var React27 = __toESM(require_react(), 1);
5932 var hooks = [];
5933 var currentInstance = void 0;
5934 function getInstance() {
5935 return currentInstance;
5936 }
5937 function register(hook) {
5938 hooks.push(hook);
5939 }
5940 function fastComponent(fn) {
5941 const FastComponent = (props, forwardedRef) => {
5942 const instance = useRefWithInit(createInstance).current;
5943 let result;
5944 try {
5945 currentInstance = instance;
5946 for (const hook of hooks) {
5947 hook.before(instance);
5948 }
5949 result = fn(props, forwardedRef);
5950 for (const hook of hooks) {
5951 hook.after(instance);
5952 }
5953 instance.didInitialize = true;
5954 } finally {
5955 currentInstance = void 0;
5956 }
5957 return result;
5958 };
5959 FastComponent.displayName = fn.displayName || fn.name;
5960 return FastComponent;
5961 }
5962 function fastComponentRef(fn) {
5963 return /* @__PURE__ */ React27.forwardRef(fastComponent(fn));
5964 }
5965 function createInstance() {
5966 return {
5967 didInitialize: false
5968 };
5969 }
5970
5971 // node_modules/@base-ui/utils/esm/store/useStore.js
5972 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5973 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5974 function useStore(store, selector2, a1, a2, a3) {
5975 return useStoreImplementation(store, selector2, a1, a2, a3);
5976 }
5977 function useStoreR19(store, selector2, a1, a2, a3) {
5978 const getSelection = React28.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5979 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5980 }
5981 register({
5982 before(instance) {
5983 instance.syncIndex = 0;
5984 if (!instance.didInitialize) {
5985 instance.syncTick = 1;
5986 instance.syncHooks = [];
5987 instance.didChangeStore = true;
5988 instance.getSnapshot = () => {
5989 let didChange2 = false;
5990 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5991 const hook = instance.syncHooks[i2];
5992 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5993 if (hook.didChange || !Object.is(hook.value, value)) {
5994 didChange2 = true;
5995 hook.value = value;
5996 hook.didChange = false;
5997 }
5998 }
5999 if (didChange2) {
6000 instance.syncTick += 1;
6001 }
6002 return instance.syncTick;
6003 };
6004 }
6005 },
6006 after(instance) {
6007 if (instance.syncHooks.length > 0) {
6008 if (instance.didChangeStore) {
6009 instance.didChangeStore = false;
6010 instance.subscribe = (onStoreChange) => {
6011 const stores = /* @__PURE__ */ new Set();
6012 for (const hook of instance.syncHooks) {
6013 stores.add(hook.store);
6014 }
6015 const unsubscribes = [];
6016 for (const store of stores) {
6017 unsubscribes.push(store.subscribe(onStoreChange));
6018 }
6019 return () => {
6020 for (const unsubscribe of unsubscribes) {
6021 unsubscribe();
6022 }
6023 };
6024 };
6025 }
6026 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6027 }
6028 }
6029 });
6030 function useStoreFast(store, selector2, a1, a2, a3) {
6031 const instance = getInstance();
6032 if (!instance) {
6033 return useStoreR19(store, selector2, a1, a2, a3);
6034 }
6035 const index2 = instance.syncIndex;
6036 instance.syncIndex += 1;
6037 let hook;
6038 if (!instance.didInitialize) {
6039 hook = {
6040 store,
6041 selector: selector2,
6042 a1,
6043 a2,
6044 a3,
6045 value: selector2(store.getSnapshot(), a1, a2, a3),
6046 didChange: false
6047 };
6048 instance.syncHooks.push(hook);
6049 } else {
6050 hook = instance.syncHooks[index2];
6051 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6052 if (hook.store !== store) {
6053 instance.didChangeStore = true;
6054 }
6055 hook.store = store;
6056 hook.selector = selector2;
6057 hook.a1 = a1;
6058 hook.a2 = a2;
6059 hook.a3 = a3;
6060 hook.didChange = true;
6061 }
6062 }
6063 return hook.value;
6064 }
6065 function useStoreLegacy(store, selector2, a1, a2, a3) {
6066 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6067 }
6068
6069 // node_modules/@base-ui/utils/esm/store/Store.js
6070 var Store = class {
6071 /**
6072 * The current state of the store.
6073 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6074 * 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).
6075 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6076 *
6077 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6078 */
6079 // Internal state to handle recursive `setState()` calls
6080 constructor(state) {
6081 this.state = state;
6082 this.listeners = /* @__PURE__ */ new Set();
6083 this.updateTick = 0;
6084 }
6085 /**
6086 * Registers a listener that will be called whenever the store's state changes.
6087 *
6088 * @param fn The listener function to be called on state changes.
6089 * @returns A function to unsubscribe the listener.
6090 */
6091 subscribe = (fn) => {
6092 this.listeners.add(fn);
6093 return () => {
6094 this.listeners.delete(fn);
6095 };
6096 };
6097 /**
6098 * Returns the current state of the store.
6099 */
6100 getSnapshot = () => {
6101 return this.state;
6102 };
6103 /**
6104 * Updates the entire store's state and notifies all registered listeners.
6105 *
6106 * @param newState The new state to set for the store.
6107 */
6108 setState(newState) {
6109 if (this.state === newState) {
6110 return;
6111 }
6112 this.state = newState;
6113 this.updateTick += 1;
6114 const currentTick = this.updateTick;
6115 for (const listener of this.listeners) {
6116 if (currentTick !== this.updateTick) {
6117 return;
6118 }
6119 listener(newState);
6120 }
6121 }
6122 /**
6123 * Merges the provided changes into the current state and notifies listeners if there are changes.
6124 *
6125 * @param changes An object containing the changes to apply to the current state.
6126 */
6127 update(changes) {
6128 for (const key in changes) {
6129 if (!Object.is(this.state[key], changes[key])) {
6130 this.setState({
6131 ...this.state,
6132 ...changes
6133 });
6134 return;
6135 }
6136 }
6137 }
6138 /**
6139 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6140 *
6141 * @param key The key in the store's state to update.
6142 * @param value The new value to set for the specified key.
6143 */
6144 set(key, value) {
6145 if (!Object.is(this.state[key], value)) {
6146 this.setState({
6147 ...this.state,
6148 [key]: value
6149 });
6150 }
6151 }
6152 /**
6153 * Gives the state a new reference and updates all registered listeners.
6154 */
6155 notifyAll() {
6156 const newState = {
6157 ...this.state
6158 };
6159 this.setState(newState);
6160 }
6161 use(selector2, a1, a2, a3) {
6162 return useStore(this, selector2, a1, a2, a3);
6163 }
6164 };
6165
6166 // node_modules/@base-ui/utils/esm/store/ReactStore.js
6167 var React29 = __toESM(require_react(), 1);
6168 var ReactStore = class extends Store {
6169 /**
6170 * Creates a new ReactStore instance.
6171 *
6172 * @param state Initial state of the store.
6173 * @param context Non-reactive context values.
6174 * @param selectors Optional selectors for use with `useState`.
6175 */
6176 constructor(state, context = {}, selectors3) {
6177 super(state);
6178 this.context = context;
6179 this.selectors = selectors3;
6180 }
6181 /**
6182 * Non-reactive values such as refs, callbacks, etc.
6183 */
6184 /**
6185 * Synchronizes a single external value into the store.
6186 *
6187 * Note that the while the value in `state` is updated immediately, the value returned
6188 * by `useState` is updated before the next render (similarly to React's `useState`).
6189 */
6190 useSyncedValue(key, value) {
6191 React29.useDebugValue(key);
6192 const store = this;
6193 useIsoLayoutEffect(() => {
6194 if (store.state[key] !== value) {
6195 store.set(key, value);
6196 }
6197 }, [store, key, value]);
6198 }
6199 /**
6200 * Synchronizes a single external value into the store and
6201 * cleans it up (sets to `undefined`) on unmount.
6202 *
6203 * Note that the while the value in `state` is updated immediately, the value returned
6204 * by `useState` is updated before the next render (similarly to React's `useState`).
6205 */
6206 useSyncedValueWithCleanup(key, value) {
6207 const store = this;
6208 useIsoLayoutEffect(() => {
6209 if (store.state[key] !== value) {
6210 store.set(key, value);
6211 }
6212 return () => {
6213 store.set(key, void 0);
6214 };
6215 }, [store, key, value]);
6216 }
6217 /**
6218 * Synchronizes multiple external values into the store.
6219 *
6220 * Note that the while the values in `state` are updated immediately, the values returned
6221 * by `useState` are updated before the next render (similarly to React's `useState`).
6222 */
6223 useSyncedValues(statePart) {
6224 const store = this;
6225 if (true) {
6226 React29.useDebugValue(statePart, (p2) => Object.keys(p2));
6227 const keys = React29.useRef(Object.keys(statePart)).current;
6228 const nextKeys = Object.keys(statePart);
6229 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
6230 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6231 }
6232 }
6233 const dependencies = Object.values(statePart);
6234 useIsoLayoutEffect(() => {
6235 store.update(statePart);
6236 }, [store, ...dependencies]);
6237 }
6238 /**
6239 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6240 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6241 */
6242 useControlledProp(key, controlled) {
6243 React29.useDebugValue(key);
6244 const store = this;
6245 const isControlled = controlled !== void 0;
6246 useIsoLayoutEffect(() => {
6247 if (isControlled && !Object.is(store.state[key], controlled)) {
6248 store.setState({
6249 ...store.state,
6250 [key]: controlled
6251 });
6252 }
6253 }, [store, key, controlled, isControlled]);
6254 if (true) {
6255 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6256 if (!cache.has(key)) {
6257 cache.set(key, isControlled);
6258 }
6259 const previouslyControlled = cache.get(key);
6260 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6261 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).`);
6262 }
6263 }
6264 }
6265 /** Gets the current value from the store using a selector with the provided key.
6266 *
6267 * @param key Key of the selector to use.
6268 */
6269 select(key, a1, a2, a3) {
6270 const selector2 = this.selectors[key];
6271 return selector2(this.state, a1, a2, a3);
6272 }
6273 /**
6274 * Returns a value from the store's state using a selector function.
6275 * Used to subscribe to specific parts of the state.
6276 * This methods causes a rerender whenever the selected state changes.
6277 *
6278 * @param key Key of the selector to use.
6279 */
6280 useState(key, a1, a2, a3) {
6281 React29.useDebugValue(key);
6282 return useStore(this, this.selectors[key], a1, a2, a3);
6283 }
6284 /**
6285 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6286 * and assigns it to the context.
6287 *
6288 * @param key Key of the event callback. Must be a function in the context.
6289 * @param fn Function to assign.
6290 */
6291 useContextCallback(key, fn) {
6292 React29.useDebugValue(key);
6293 const stableFunction = useStableCallback(fn ?? NOOP);
6294 this.context[key] = stableFunction;
6295 }
6296 /**
6297 * Returns a stable setter function for a specific key in the store's state.
6298 * It's commonly used to pass as a ref callback to React elements.
6299 *
6300 * @param key Key of the state to set.
6301 */
6302 useStateSetter(key) {
6303 const ref = React29.useRef(void 0);
6304 if (ref.current === void 0) {
6305 ref.current = (value) => {
6306 this.set(key, value);
6307 };
6308 }
6309 return ref.current;
6310 }
6311 /**
6312 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6313 *
6314 * @param key Key of the selector to observe.
6315 * @param listener Listener function called when the selector result changes.
6316 */
6317 observe(selector2, listener) {
6318 let selectFn;
6319 if (typeof selector2 === "function") {
6320 selectFn = selector2;
6321 } else {
6322 selectFn = this.selectors[selector2];
6323 }
6324 let prevValue = selectFn(this.state);
6325 listener(prevValue, prevValue, this);
6326 return this.subscribe((nextState) => {
6327 const nextValue = selectFn(nextState);
6328 if (!Object.is(prevValue, nextValue)) {
6329 const oldValue = prevValue;
6330 prevValue = nextValue;
6331 listener(nextValue, oldValue, this);
6332 }
6333 });
6334 }
6335 };
6336
6337 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
6338 var selectors = {
6339 open: createSelector((state) => state.open),
6340 transitionStatus: createSelector((state) => state.transitionStatus),
6341 domReferenceElement: createSelector((state) => state.domReferenceElement),
6342 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6343 floatingElement: createSelector((state) => state.floatingElement),
6344 floatingId: createSelector((state) => state.floatingId)
6345 };
6346 var FloatingRootStore = class extends ReactStore {
6347 constructor(options) {
6348 const {
6349 syncOnly,
6350 nested,
6351 onOpenChange,
6352 triggerElements,
6353 ...initialState
6354 } = options;
6355 super({
6356 ...initialState,
6357 positionReference: initialState.referenceElement,
6358 domReferenceElement: initialState.referenceElement
6359 }, {
6360 onOpenChange,
6361 dataRef: {
6362 current: {}
6363 },
6364 events: createEventEmitter(),
6365 nested,
6366 triggerElements
6367 }, selectors);
6368 this.syncOnly = syncOnly;
6369 }
6370 /**
6371 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6372 */
6373 syncOpenEvent = (newOpen, event) => {
6374 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6375 // click events to upgrade a hover-open.
6376 event != null && isClickLikeEvent(event)) {
6377 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6378 }
6379 };
6380 /**
6381 * Runs the root-owned side effects for an open state change.
6382 */
6383 dispatchOpenChange = (newOpen, eventDetails) => {
6384 this.syncOpenEvent(newOpen, eventDetails.event);
6385 const details = {
6386 open: newOpen,
6387 reason: eventDetails.reason,
6388 nativeEvent: eventDetails.event,
6389 nested: this.context.nested,
6390 triggerElement: eventDetails.trigger
6391 };
6392 this.context.events.emit("openchange", details);
6393 };
6394 /**
6395 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6396 *
6397 * @param newOpen The new open state.
6398 * @param eventDetails Details about the event that triggered the open state change.
6399 */
6400 setOpen = (newOpen, eventDetails) => {
6401 if (this.syncOnly) {
6402 this.context.onOpenChange?.(newOpen, eventDetails);
6403 return;
6404 }
6405 this.dispatchOpenChange(newOpen, eventDetails);
6406 this.context.onOpenChange?.(newOpen, eventDetails);
6407 };
6408 };
6409
6410 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
6411 function useSyncedFloatingRootContext(options) {
6412 const {
6413 popupStore,
6414 treatPopupAsFloatingElement = false,
6415 floatingRootContext: floatingRootContextProp,
6416 floatingId,
6417 nested,
6418 onOpenChange
6419 } = options;
6420 const open = popupStore.useState("open");
6421 const referenceElement = popupStore.useState("activeTriggerElement");
6422 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6423 const triggerElements = popupStore.context.triggerElements;
6424 const handleOpenChange = onOpenChange;
6425 const internalStoreRef = React30.useRef(null);
6426 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6427 internalStoreRef.current = new FloatingRootStore({
6428 open,
6429 transitionStatus: void 0,
6430 referenceElement,
6431 floatingElement,
6432 triggerElements,
6433 onOpenChange: handleOpenChange,
6434 floatingId,
6435 syncOnly: true,
6436 nested
6437 });
6438 }
6439 const store = floatingRootContextProp ?? internalStoreRef.current;
6440 popupStore.useSyncedValue("floatingId", floatingId);
6441 useIsoLayoutEffect(() => {
6442 const valuesToSync = {
6443 open,
6444 floatingId,
6445 referenceElement,
6446 floatingElement
6447 };
6448 if (isElement(referenceElement)) {
6449 valuesToSync.domReferenceElement = referenceElement;
6450 }
6451 if (store.state.positionReference === store.state.referenceElement) {
6452 valuesToSync.positionReference = referenceElement;
6453 }
6454 store.update(valuesToSync);
6455 }, [open, floatingId, referenceElement, floatingElement, store]);
6456 store.context.onOpenChange = handleOpenChange;
6457 store.context.nested = nested;
6458 return store;
6459 }
6460
6461 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
6462 var FOCUSABLE_POPUP_PROPS = {
6463 tabIndex: -1,
6464 [FOCUSABLE_ATTRIBUTE]: ""
6465 };
6466 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6467 const floatingId = useId();
6468 const nested = useFloatingParentNodeId() != null;
6469 const internalStoreRef = React31.useRef(null);
6470 if (externalStore === void 0 && internalStoreRef.current === null) {
6471 internalStoreRef.current = createStore2(floatingId, nested);
6472 }
6473 const store = externalStore ?? internalStoreRef.current;
6474 useSyncedFloatingRootContext({
6475 popupStore: store,
6476 treatPopupAsFloatingElement,
6477 floatingRootContext: store.state.floatingRootContext,
6478 floatingId,
6479 nested,
6480 onOpenChange: store.setOpen
6481 });
6482 return {
6483 store,
6484 internalStore: internalStoreRef.current
6485 };
6486 }
6487 function useTriggerRegistration(id, store) {
6488 const registeredElementIdRef = React31.useRef(null);
6489 const registeredElementRef = React31.useRef(null);
6490 return React31.useCallback((element) => {
6491 if (id === void 0) {
6492 return;
6493 }
6494 let shouldSyncTriggerCount = false;
6495 if (registeredElementIdRef.current !== null) {
6496 const registeredId = registeredElementIdRef.current;
6497 const registeredElement = registeredElementRef.current;
6498 const currentElement = store.context.triggerElements.getById(registeredId);
6499 if (registeredElement && currentElement === registeredElement) {
6500 store.context.triggerElements.delete(registeredId);
6501 shouldSyncTriggerCount = true;
6502 }
6503 registeredElementIdRef.current = null;
6504 registeredElementRef.current = null;
6505 }
6506 if (element !== null) {
6507 registeredElementIdRef.current = id;
6508 registeredElementRef.current = element;
6509 store.context.triggerElements.add(id, element);
6510 shouldSyncTriggerCount = true;
6511 }
6512 if (shouldSyncTriggerCount) {
6513 const triggerCount = store.context.triggerElements.size;
6514 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6515 store.set("triggerCount", triggerCount);
6516 }
6517 }
6518 }, [store, id]);
6519 }
6520 function setOpenTriggerState(state, open, trigger) {
6521 const triggerId = trigger?.id ?? null;
6522 if (triggerId || open) {
6523 state.activeTriggerId = triggerId;
6524 state.activeTriggerElement = trigger ?? null;
6525 }
6526 }
6527 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6528 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6529 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6530 const registerTrigger = useStableCallback((element) => {
6531 baseRegisterTrigger(element);
6532 if (!element) {
6533 return;
6534 }
6535 const open = store.select("open");
6536 const activeTriggerId = store.select("activeTriggerId");
6537 if (activeTriggerId === triggerId) {
6538 store.update({
6539 activeTriggerElement: element,
6540 ...open ? stateUpdates : null
6541 });
6542 return;
6543 }
6544 if (activeTriggerId == null && open) {
6545 store.update({
6546 activeTriggerId: triggerId,
6547 activeTriggerElement: element,
6548 ...stateUpdates
6549 });
6550 }
6551 });
6552 useIsoLayoutEffect(() => {
6553 if (isMountedByThisTrigger) {
6554 store.update({
6555 activeTriggerElement: triggerElementRef.current,
6556 ...stateUpdates
6557 });
6558 }
6559 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6560 return {
6561 registerTrigger,
6562 isMountedByThisTrigger
6563 };
6564 }
6565 function useImplicitActiveTrigger(store) {
6566 const open = store.useState("open");
6567 const reactiveTriggerCount = store.useState("triggerCount");
6568 useIsoLayoutEffect(() => {
6569 if (!open) {
6570 if (store.state.triggerCount !== 0) {
6571 store.set("triggerCount", 0);
6572 }
6573 return;
6574 }
6575 const triggerCount = store.context.triggerElements.size;
6576 const stateUpdates = {};
6577 if (store.state.triggerCount !== triggerCount) {
6578 stateUpdates.triggerCount = triggerCount;
6579 }
6580 if (!store.select("activeTriggerId") && triggerCount === 1) {
6581 const iteratorResult = store.context.triggerElements.entries().next();
6582 if (!iteratorResult.done) {
6583 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6584 stateUpdates.activeTriggerId = implicitTriggerId;
6585 stateUpdates.activeTriggerElement = implicitTriggerElement;
6586 }
6587 }
6588 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
6589 store.update(stateUpdates);
6590 }
6591 }, [open, store, reactiveTriggerCount]);
6592 }
6593 function useOpenStateTransitions(open, store, onUnmount) {
6594 const {
6595 mounted,
6596 setMounted,
6597 transitionStatus
6598 } = useTransitionStatus(open);
6599 store.useSyncedValues({
6600 mounted,
6601 transitionStatus
6602 });
6603 const forceUnmount = useStableCallback(() => {
6604 setMounted(false);
6605 store.update({
6606 activeTriggerId: null,
6607 activeTriggerElement: null,
6608 mounted: false,
6609 preventUnmountingOnClose: false
6610 });
6611 onUnmount?.();
6612 store.context.onOpenChangeComplete?.(false);
6613 });
6614 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6615 useOpenChangeComplete({
6616 enabled: mounted && !open && !preventUnmountingOnClose,
6617 open,
6618 ref: store.context.popupRef,
6619 onComplete() {
6620 if (!open) {
6621 forceUnmount();
6622 }
6623 }
6624 });
6625 return {
6626 forceUnmount,
6627 transitionStatus
6628 };
6629 }
6630 function usePopupInteractionProps(store, statePart) {
6631 store.useSyncedValues(statePart);
6632 useIsoLayoutEffect(() => () => {
6633 store.update({
6634 activeTriggerProps: EMPTY_OBJECT,
6635 inactiveTriggerProps: EMPTY_OBJECT,
6636 popupProps: EMPTY_OBJECT
6637 });
6638 }, [store]);
6639 }
6640
6641 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
6642 var PopupTriggerMap = class {
6643 constructor() {
6644 this.elementsSet = /* @__PURE__ */ new Set();
6645 this.idMap = /* @__PURE__ */ new Map();
6646 }
6647 /**
6648 * Adds a trigger element with the given ID.
6649 *
6650 * Note: The provided element is assumed to not be registered under multiple IDs.
6651 */
6652 add(id, element) {
6653 const existingElement = this.idMap.get(id);
6654 if (existingElement === element) {
6655 return;
6656 }
6657 if (existingElement !== void 0) {
6658 this.elementsSet.delete(existingElement);
6659 }
6660 this.elementsSet.add(element);
6661 this.idMap.set(id, element);
6662 if (true) {
6663 if (this.elementsSet.size !== this.idMap.size) {
6664 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6665 }
6666 }
6667 }
6668 /**
6669 * Removes the trigger element with the given ID.
6670 */
6671 delete(id) {
6672 const element = this.idMap.get(id);
6673 if (element) {
6674 this.elementsSet.delete(element);
6675 this.idMap.delete(id);
6676 }
6677 }
6678 /**
6679 * Whether the given element is registered as a trigger.
6680 */
6681 hasElement(element) {
6682 return this.elementsSet.has(element);
6683 }
6684 /**
6685 * Whether there is a registered trigger element matching the given predicate.
6686 */
6687 hasMatchingElement(predicate) {
6688 for (const element of this.elementsSet) {
6689 if (predicate(element)) {
6690 return true;
6691 }
6692 }
6693 return false;
6694 }
6695 /**
6696 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6697 */
6698 getById(id) {
6699 return this.idMap.get(id);
6700 }
6701 /**
6702 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6703 */
6704 entries() {
6705 return this.idMap.entries();
6706 }
6707 /**
6708 * Returns an iterable of all registered trigger elements.
6709 */
6710 elements() {
6711 return this.elementsSet.values();
6712 }
6713 /**
6714 * Returns the number of registered trigger elements.
6715 */
6716 get size() {
6717 return this.idMap.size;
6718 }
6719 };
6720
6721 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6722 function getEmptyRootContext() {
6723 return new FloatingRootStore({
6724 open: false,
6725 transitionStatus: void 0,
6726 floatingElement: null,
6727 referenceElement: null,
6728 triggerElements: new PopupTriggerMap(),
6729 floatingId: void 0,
6730 syncOnly: false,
6731 nested: false,
6732 onOpenChange: void 0
6733 });
6734 }
6735
6736 // node_modules/@base-ui/react/esm/utils/popups/store.js
6737 function createInitialPopupStoreState() {
6738 return {
6739 open: false,
6740 openProp: void 0,
6741 mounted: false,
6742 transitionStatus: void 0,
6743 floatingRootContext: getEmptyRootContext(),
6744 floatingId: void 0,
6745 triggerCount: 0,
6746 preventUnmountingOnClose: false,
6747 payload: void 0,
6748 activeTriggerId: null,
6749 activeTriggerElement: null,
6750 triggerIdProp: void 0,
6751 popupElement: null,
6752 positionerElement: null,
6753 activeTriggerProps: EMPTY_OBJECT,
6754 inactiveTriggerProps: EMPTY_OBJECT,
6755 popupProps: EMPTY_OBJECT
6756 };
6757 }
6758 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6759 return new FloatingRootStore({
6760 open: false,
6761 transitionStatus: void 0,
6762 floatingElement: null,
6763 referenceElement: null,
6764 triggerElements,
6765 floatingId,
6766 syncOnly: true,
6767 nested,
6768 onOpenChange: void 0
6769 });
6770 }
6771 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6772 var openSelector = createSelector((state) => state.openProp ?? state.open);
6773 var popupIdSelector = createSelector((state) => {
6774 const popupId = state.popupElement?.id ?? state.floatingId;
6775 return popupId || void 0;
6776 });
6777 function triggerOwnsOpenPopup(state, triggerId) {
6778 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6779 }
6780 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6781 if (triggerOwnsOpenPopup(state, triggerId)) {
6782 return true;
6783 }
6784 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6785 }
6786 var popupStoreSelectors = {
6787 open: openSelector,
6788 mounted: createSelector((state) => state.mounted),
6789 transitionStatus: createSelector((state) => state.transitionStatus),
6790 floatingRootContext: createSelector((state) => state.floatingRootContext),
6791 triggerCount: createSelector((state) => state.triggerCount),
6792 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6793 payload: createSelector((state) => state.payload),
6794 activeTriggerId: activeTriggerIdSelector,
6795 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6796 popupId: popupIdSelector,
6797 /**
6798 * Whether the trigger with the given ID was used to open the popup.
6799 */
6800 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6801 /**
6802 * Whether the popup is open and was activated by a trigger with the given ID.
6803 */
6804 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6805 /**
6806 * Whether the popup is mounted and was activated by a trigger with the given ID.
6807 */
6808 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6809 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6810 /**
6811 * Popup id for the trigger that currently owns the open popup.
6812 */
6813 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6814 popupProps: createSelector((state) => state.popupProps),
6815 popupElement: createSelector((state) => state.popupElement),
6816 positionerElement: createSelector((state) => state.positionerElement)
6817 };
6818
6819 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6820 function useFloatingRootContext(options) {
6821 const {
6822 open = false,
6823 onOpenChange,
6824 elements = {}
6825 } = options;
6826 const floatingId = useId();
6827 const nested = useFloatingParentNodeId() != null;
6828 if (true) {
6829 const optionDomReference = elements.reference;
6830 if (optionDomReference && !isElement(optionDomReference)) {
6831 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6832 }
6833 }
6834 const store = useRefWithInit(() => new FloatingRootStore({
6835 open,
6836 transitionStatus: void 0,
6837 onOpenChange,
6838 referenceElement: elements.reference ?? null,
6839 floatingElement: elements.floating ?? null,
6840 triggerElements: new PopupTriggerMap(),
6841 floatingId,
6842 syncOnly: false,
6843 nested
6844 })).current;
6845 useIsoLayoutEffect(() => {
6846 const valuesToSync = {
6847 open,
6848 floatingId
6849 };
6850 if (elements.reference !== void 0) {
6851 valuesToSync.referenceElement = elements.reference;
6852 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6853 }
6854 if (elements.floating !== void 0) {
6855 valuesToSync.floatingElement = elements.floating;
6856 }
6857 store.update(valuesToSync);
6858 }, [open, floatingId, elements.reference, elements.floating, store]);
6859 store.context.onOpenChange = onOpenChange;
6860 store.context.nested = nested;
6861 return store;
6862 }
6863
6864 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6865 function useFloating2(options = {}) {
6866 const {
6867 nodeId,
6868 externalTree
6869 } = options;
6870 const internalStore = useFloatingRootContext(options);
6871 const store = options.rootContext || internalStore;
6872 const referenceElement = store.useState("referenceElement");
6873 const floatingElement = store.useState("floatingElement");
6874 const domReferenceElement = store.useState("domReferenceElement");
6875 const open = store.useState("open");
6876 const floatingId = store.useState("floatingId");
6877 const [positionReference, setPositionReferenceRaw] = React32.useState(null);
6878 const [localDomReference, setLocalDomReference] = React32.useState(void 0);
6879 const [localFloatingElement, setLocalFloatingElement] = React32.useState(void 0);
6880 const domReferenceRef = React32.useRef(null);
6881 const tree = useFloatingTree(externalTree);
6882 const storeElements = React32.useMemo(() => ({
6883 reference: referenceElement,
6884 floating: floatingElement,
6885 domReference: domReferenceElement
6886 }), [referenceElement, floatingElement, domReferenceElement]);
6887 const position = useFloating({
6888 ...options,
6889 elements: {
6890 ...storeElements,
6891 ...positionReference && {
6892 reference: positionReference
6893 }
6894 }
6895 });
6896 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6897 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6898 store.useSyncedValue("referenceElement", localDomReference ?? null);
6899 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6900 store.useSyncedValue("floatingElement", syncedFloatingElement);
6901 const setPositionReference = React32.useCallback((node) => {
6902 const computedPositionReference = isElement(node) ? {
6903 getBoundingClientRect: () => node.getBoundingClientRect(),
6904 getClientRects: () => node.getClientRects(),
6905 contextElement: node
6906 } : node;
6907 setPositionReferenceRaw(computedPositionReference);
6908 position.refs.setReference(computedPositionReference);
6909 }, [position.refs]);
6910 const setReference = React32.useCallback((node) => {
6911 if (isElement(node) || node === null) {
6912 domReferenceRef.current = node;
6913 setLocalDomReference(node);
6914 }
6915 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6916 // `null` to support `positionReference` + an unstable `reference`
6917 // callback ref.
6918 node !== null && !isElement(node)) {
6919 position.refs.setReference(node);
6920 }
6921 }, [position.refs, setLocalDomReference]);
6922 const setFloating = React32.useCallback((node) => {
6923 setLocalFloatingElement(node);
6924 position.refs.setFloating(node);
6925 }, [position.refs]);
6926 const refs = React32.useMemo(() => ({
6927 ...position.refs,
6928 setReference,
6929 setFloating,
6930 setPositionReference,
6931 domReference: domReferenceRef
6932 }), [position.refs, setReference, setFloating, setPositionReference]);
6933 const elements = React32.useMemo(() => ({
6934 ...position.elements,
6935 domReference: domReferenceElement
6936 }), [position.elements, domReferenceElement]);
6937 const context = React32.useMemo(() => ({
6938 ...position,
6939 dataRef: store.context.dataRef,
6940 open,
6941 onOpenChange: store.setOpen,
6942 events: store.context.events,
6943 floatingId,
6944 refs,
6945 elements,
6946 nodeId,
6947 rootStore: store
6948 }), [position, refs, elements, nodeId, store, open, floatingId]);
6949 useIsoLayoutEffect(() => {
6950 if (domReferenceElement) {
6951 domReferenceRef.current = domReferenceElement;
6952 }
6953 }, [domReferenceElement]);
6954 useIsoLayoutEffect(() => {
6955 store.context.dataRef.current.floatingContext = context;
6956 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6957 if (node) {
6958 node.context = context;
6959 }
6960 });
6961 return React32.useMemo(() => ({
6962 ...position,
6963 context,
6964 refs,
6965 elements,
6966 rootStore: store
6967 }), [position, refs, elements, context, store]);
6968 }
6969
6970 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6971 var React33 = __toESM(require_react(), 1);
6972 var isMacSafari = isMac && isSafari;
6973 function useFocus(context, props = {}) {
6974 const {
6975 enabled = true,
6976 delay
6977 } = props;
6978 const store = "rootStore" in context ? context.rootStore : context;
6979 const {
6980 events,
6981 dataRef
6982 } = store.context;
6983 const blockFocusRef = React33.useRef(false);
6984 const blockedReferenceRef = React33.useRef(null);
6985 const keyboardModalityRef = React33.useRef(true);
6986 const timeout = useTimeout();
6987 React33.useEffect(() => {
6988 const domReference = store.select("domReferenceElement");
6989 if (!enabled) {
6990 return void 0;
6991 }
6992 const win = getWindow(domReference);
6993 function onBlur() {
6994 const currentDomReference = store.select("domReferenceElement");
6995 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6996 blockFocusRef.current = true;
6997 }
6998 }
6999 function onKeyDown() {
7000 keyboardModalityRef.current = true;
7001 }
7002 function onPointerDown() {
7003 keyboardModalityRef.current = false;
7004 }
7005 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7006 }, [store, enabled]);
7007 React33.useEffect(() => {
7008 if (!enabled) {
7009 return void 0;
7010 }
7011 function onOpenChangeLocal(details) {
7012 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7013 const referenceElement = store.select("domReferenceElement");
7014 if (isElement(referenceElement)) {
7015 blockedReferenceRef.current = referenceElement;
7016 blockFocusRef.current = true;
7017 }
7018 }
7019 }
7020 events.on("openchange", onOpenChangeLocal);
7021 return () => {
7022 events.off("openchange", onOpenChangeLocal);
7023 };
7024 }, [events, enabled, store]);
7025 const reference = React33.useMemo(() => {
7026 function resetBlockedFocus() {
7027 blockFocusRef.current = false;
7028 blockedReferenceRef.current = null;
7029 }
7030 return {
7031 onMouseLeave() {
7032 resetBlockedFocus();
7033 },
7034 onFocus(event) {
7035 const focusTarget = event.currentTarget;
7036 if (blockFocusRef.current) {
7037 if (blockedReferenceRef.current === focusTarget) {
7038 return;
7039 }
7040 resetBlockedFocus();
7041 }
7042 const target = getTarget(event.nativeEvent);
7043 if (isElement(target)) {
7044 if (isMacSafari && !event.relatedTarget) {
7045 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7046 return;
7047 }
7048 } else if (!matchesFocusVisible(target)) {
7049 return;
7050 }
7051 }
7052 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7053 const {
7054 nativeEvent,
7055 currentTarget
7056 } = event;
7057 const delayValue = typeof delay === "function" ? delay() : delay;
7058 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7059 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7060 return;
7061 }
7062 timeout.start(delayValue, () => {
7063 if (blockFocusRef.current) {
7064 return;
7065 }
7066 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7067 });
7068 },
7069 onBlur(event) {
7070 resetBlockedFocus();
7071 const relatedTarget = event.relatedTarget;
7072 const nativeEvent = event.nativeEvent;
7073 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7074 timeout.start(0, () => {
7075 const domReference = store.select("domReferenceElement");
7076 const activeEl = activeElement(ownerDocument(domReference));
7077 if (!relatedTarget && activeEl === domReference) {
7078 return;
7079 }
7080 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7081 return;
7082 }
7083 const nextFocusedElement = relatedTarget ?? activeEl;
7084 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7085 return;
7086 }
7087 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7088 });
7089 }
7090 };
7091 }, [dataRef, delay, store, timeout]);
7092 return React33.useMemo(() => enabled ? {
7093 reference,
7094 trigger: reference
7095 } : {}, [enabled, reference]);
7096 }
7097
7098 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
7099 var React34 = __toESM(require_react(), 1);
7100
7101 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
7102 var HoverInteraction = class _HoverInteraction {
7103 constructor() {
7104 this.pointerType = void 0;
7105 this.interactedInside = false;
7106 this.handler = void 0;
7107 this.blockMouseMove = true;
7108 this.performedPointerEventsMutation = false;
7109 this.pointerEventsScopeElement = null;
7110 this.pointerEventsReferenceElement = null;
7111 this.pointerEventsFloatingElement = null;
7112 this.restTimeoutPending = false;
7113 this.openChangeTimeout = new Timeout();
7114 this.restTimeout = new Timeout();
7115 this.handleCloseOptions = void 0;
7116 }
7117 static create() {
7118 return new _HoverInteraction();
7119 }
7120 dispose = () => {
7121 this.openChangeTimeout.clear();
7122 this.restTimeout.clear();
7123 };
7124 disposeEffect = () => {
7125 return this.dispose;
7126 };
7127 };
7128 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7129 function clearSafePolygonPointerEventsMutation(instance) {
7130 if (!instance.performedPointerEventsMutation) {
7131 return;
7132 }
7133 const scopeElement = instance.pointerEventsScopeElement;
7134 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7135 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7136 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7137 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7138 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7139 }
7140 instance.performedPointerEventsMutation = false;
7141 instance.pointerEventsScopeElement = null;
7142 instance.pointerEventsReferenceElement = null;
7143 instance.pointerEventsFloatingElement = null;
7144 }
7145 function applySafePolygonPointerEventsMutation(instance, options) {
7146 const {
7147 scopeElement,
7148 referenceElement,
7149 floatingElement
7150 } = options;
7151 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7152 if (existingOwner && existingOwner !== instance) {
7153 clearSafePolygonPointerEventsMutation(existingOwner);
7154 }
7155 clearSafePolygonPointerEventsMutation(instance);
7156 instance.performedPointerEventsMutation = true;
7157 instance.pointerEventsScopeElement = scopeElement;
7158 instance.pointerEventsReferenceElement = referenceElement;
7159 instance.pointerEventsFloatingElement = floatingElement;
7160 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7161 scopeElement.style.pointerEvents = "none";
7162 referenceElement.style.pointerEvents = "auto";
7163 floatingElement.style.pointerEvents = "auto";
7164 }
7165 function useHoverInteractionSharedState(store) {
7166 const data = store.context.dataRef.current;
7167 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
7168 if (!data.hoverInteractionState) {
7169 data.hoverInteractionState = instance;
7170 }
7171 useOnMount(data.hoverInteractionState.disposeEffect);
7172 return data.hoverInteractionState;
7173 }
7174
7175 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
7176 function useHoverFloatingInteraction(context, parameters = {}) {
7177 const {
7178 enabled = true,
7179 closeDelay: closeDelayProp = 0,
7180 nodeId: nodeIdProp
7181 } = parameters;
7182 const store = "rootStore" in context ? context.rootStore : context;
7183 const open = store.useState("open");
7184 const floatingElement = store.useState("floatingElement");
7185 const domReferenceElement = store.useState("domReferenceElement");
7186 const {
7187 dataRef
7188 } = store.context;
7189 const tree = useFloatingTree();
7190 const parentId = useFloatingParentNodeId();
7191 const instance = useHoverInteractionSharedState(store);
7192 const childClosedTimeout = useTimeout();
7193 const isClickLikeOpenEvent2 = useStableCallback(() => {
7194 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7195 });
7196 const isHoverOpen = useStableCallback(() => {
7197 return isHoverOpenEvent(dataRef.current.openEvent?.type);
7198 });
7199 const clearPointerEvents = useStableCallback(() => {
7200 clearSafePolygonPointerEventsMutation(instance);
7201 });
7202 useIsoLayoutEffect(() => {
7203 if (!open) {
7204 instance.pointerType = void 0;
7205 instance.restTimeoutPending = false;
7206 instance.interactedInside = false;
7207 clearPointerEvents();
7208 }
7209 }, [open, instance, clearPointerEvents]);
7210 React34.useEffect(() => {
7211 return clearPointerEvents;
7212 }, [clearPointerEvents]);
7213 useIsoLayoutEffect(() => {
7214 if (!enabled) {
7215 return void 0;
7216 }
7217 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7218 const ref = domReferenceElement;
7219 const floatingEl = floatingElement;
7220 const doc = ownerDocument(floatingElement);
7221 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7222 if (parentFloating) {
7223 parentFloating.style.pointerEvents = "";
7224 }
7225 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
7226 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
7227 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
7228 applySafePolygonPointerEventsMutation(instance, {
7229 scopeElement,
7230 referenceElement: ref,
7231 floatingElement: floatingEl
7232 });
7233 return () => {
7234 clearPointerEvents();
7235 };
7236 }
7237 return void 0;
7238 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7239 React34.useEffect(() => {
7240 if (!enabled) {
7241 return void 0;
7242 }
7243 function hasParentChildren() {
7244 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
7245 }
7246 function closeWithDelay(event) {
7247 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7248 const close = () => {
7249 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7250 tree?.events.emit("floating.closed", event);
7251 };
7252 if (closeDelay) {
7253 instance.openChangeTimeout.start(closeDelay, close);
7254 } else {
7255 instance.openChangeTimeout.clear();
7256 close();
7257 }
7258 }
7259 function handleInteractInside(event) {
7260 const target = getTarget(event);
7261 if (!isInteractiveElement(target)) {
7262 instance.interactedInside = false;
7263 return;
7264 }
7265 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7266 }
7267 function onFloatingMouseEnter() {
7268 instance.openChangeTimeout.clear();
7269 childClosedTimeout.clear();
7270 tree?.events.off("floating.closed", onNodeClosed);
7271 clearPointerEvents();
7272 }
7273 function onFloatingMouseLeave(event) {
7274 if (hasParentChildren() && tree) {
7275 tree.events.on("floating.closed", onNodeClosed);
7276 return;
7277 }
7278 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7279 return;
7280 }
7281 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7282 const relatedTarget = event.relatedTarget;
7283 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7284 if (isMovingIntoDescendantFloating) {
7285 return;
7286 }
7287 if (instance.handler) {
7288 instance.handler(event);
7289 return;
7290 }
7291 clearPointerEvents();
7292 if (!isClickLikeOpenEvent2()) {
7293 closeWithDelay(event);
7294 }
7295 }
7296 function onNodeClosed(event) {
7297 if (!tree || !parentId || hasParentChildren()) {
7298 return;
7299 }
7300 childClosedTimeout.start(0, () => {
7301 tree.events.off("floating.closed", onNodeClosed);
7302 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7303 tree.events.emit("floating.closed", event);
7304 });
7305 }
7306 const floating = floatingElement;
7307 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7308 tree?.events.off("floating.closed", onNodeClosed);
7309 });
7310 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
7311 }
7312
7313 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
7314 var React35 = __toESM(require_react(), 1);
7315 var ReactDOM4 = __toESM(require_react_dom(), 1);
7316 var EMPTY_REF = {
7317 current: null
7318 };
7319 function useHoverReferenceInteraction(context, props = {}) {
7320 const {
7321 enabled = true,
7322 delay = 0,
7323 handleClose = null,
7324 mouseOnly = false,
7325 restMs = 0,
7326 move = true,
7327 triggerElementRef = EMPTY_REF,
7328 externalTree,
7329 isActiveTrigger = true,
7330 getHandleCloseContext,
7331 isClosing,
7332 shouldOpen: shouldOpenProp
7333 } = props;
7334 const store = "rootStore" in context ? context.rootStore : context;
7335 const {
7336 dataRef,
7337 events
7338 } = store.context;
7339 const tree = useFloatingTree(externalTree);
7340 const instance = useHoverInteractionSharedState(store);
7341 const isHoverCloseActiveRef = React35.useRef(false);
7342 const handleCloseRef = useValueAsRef(handleClose);
7343 const delayRef = useValueAsRef(delay);
7344 const restMsRef = useValueAsRef(restMs);
7345 const enabledRef = useValueAsRef(enabled);
7346 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7347 const isClosingRef = useValueAsRef(isClosing);
7348 const isClickLikeOpenEvent2 = useStableCallback(() => {
7349 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7350 });
7351 const checkShouldOpen = useStableCallback(() => {
7352 return shouldOpenRef.current?.() !== false;
7353 });
7354 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7355 const allTriggers = store.context.triggerElements;
7356 if (allTriggers.hasElement(currentTarget)) {
7357 return !currentDomReference || !contains(currentDomReference, currentTarget);
7358 }
7359 if (!isElement(target)) {
7360 return false;
7361 }
7362 const targetElement = target;
7363 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7364 });
7365 const cleanupMouseMoveHandler = useStableCallback(() => {
7366 if (!instance.handler) {
7367 return;
7368 }
7369 const doc = ownerDocument(store.select("domReferenceElement"));
7370 doc.removeEventListener("mousemove", instance.handler);
7371 instance.handler = void 0;
7372 });
7373 const clearPointerEvents = useStableCallback(() => {
7374 clearSafePolygonPointerEventsMutation(instance);
7375 });
7376 if (isActiveTrigger) {
7377 instance.handleCloseOptions = handleCloseRef.current?.__options;
7378 }
7379 React35.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7380 React35.useEffect(() => {
7381 if (!enabled) {
7382 return void 0;
7383 }
7384 function onOpenChangeLocal(details) {
7385 if (!details.open) {
7386 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7387 cleanupMouseMoveHandler();
7388 instance.openChangeTimeout.clear();
7389 instance.restTimeout.clear();
7390 instance.blockMouseMove = true;
7391 instance.restTimeoutPending = false;
7392 } else {
7393 isHoverCloseActiveRef.current = false;
7394 }
7395 }
7396 events.on("openchange", onOpenChangeLocal);
7397 return () => {
7398 events.off("openchange", onOpenChangeLocal);
7399 };
7400 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7401 React35.useEffect(() => {
7402 if (!enabled) {
7403 return void 0;
7404 }
7405 function closeWithDelay(event, runElseBranch = true) {
7406 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7407 if (closeDelay) {
7408 instance.openChangeTimeout.start(closeDelay, () => {
7409 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7410 tree?.events.emit("floating.closed", event);
7411 });
7412 } else if (runElseBranch) {
7413 instance.openChangeTimeout.clear();
7414 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7415 tree?.events.emit("floating.closed", event);
7416 }
7417 }
7418 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7419 if (!isElement(trigger)) {
7420 return void 0;
7421 }
7422 function onMouseEnter(event) {
7423 instance.openChangeTimeout.clear();
7424 instance.blockMouseMove = false;
7425 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7426 return;
7427 }
7428 const restMsValue = getRestMs(restMsRef.current);
7429 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7430 const eventTarget = getTarget(event);
7431 const currentTarget = event.currentTarget ?? null;
7432 const currentDomReference = store.select("domReferenceElement");
7433 let triggerNode = currentTarget;
7434 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7435 for (const triggerElement of store.context.triggerElements.elements()) {
7436 if (contains(triggerElement, eventTarget)) {
7437 triggerNode = triggerElement;
7438 break;
7439 }
7440 }
7441 }
7442 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7443 triggerNode = currentDomReference;
7444 }
7445 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7446 const isOpen = store.select("open");
7447 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7448 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7449 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7450 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7451 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7452 const shouldOpen = !isOpen || isOverInactive;
7453 if (shouldOpenImmediately) {
7454 if (checkShouldOpen()) {
7455 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7456 }
7457 return;
7458 }
7459 if (isRestOnlyDelay) {
7460 return;
7461 }
7462 if (openDelay) {
7463 instance.openChangeTimeout.start(openDelay, () => {
7464 if (shouldOpen && checkShouldOpen()) {
7465 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7466 }
7467 });
7468 } else if (shouldOpen) {
7469 if (checkShouldOpen()) {
7470 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7471 }
7472 }
7473 }
7474 function onMouseLeave(event) {
7475 if (isClickLikeOpenEvent2()) {
7476 clearPointerEvents();
7477 return;
7478 }
7479 cleanupMouseMoveHandler();
7480 const domReferenceElement = store.select("domReferenceElement");
7481 const doc = ownerDocument(domReferenceElement);
7482 instance.restTimeout.clear();
7483 instance.restTimeoutPending = false;
7484 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7485 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7486 return;
7487 }
7488 if (handleCloseRef.current && handleCloseContextBase) {
7489 if (!store.select("open")) {
7490 instance.openChangeTimeout.clear();
7491 }
7492 const currentTrigger = triggerElementRef.current;
7493 instance.handler = handleCloseRef.current({
7494 ...handleCloseContextBase,
7495 tree,
7496 x: event.clientX,
7497 y: event.clientY,
7498 onClose() {
7499 clearPointerEvents();
7500 cleanupMouseMoveHandler();
7501 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7502 closeWithDelay(event, true);
7503 }
7504 }
7505 });
7506 doc.addEventListener("mousemove", instance.handler);
7507 instance.handler(event);
7508 return;
7509 }
7510 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7511 if (shouldClose) {
7512 closeWithDelay(event);
7513 }
7514 }
7515 if (move) {
7516 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7517 once: true
7518 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7519 }
7520 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7521 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7522 return React35.useMemo(() => {
7523 if (!enabled) {
7524 return void 0;
7525 }
7526 function setPointerRef(event) {
7527 instance.pointerType = event.pointerType;
7528 }
7529 return {
7530 onPointerDown: setPointerRef,
7531 onPointerEnter: setPointerRef,
7532 onMouseMove(event) {
7533 const {
7534 nativeEvent
7535 } = event;
7536 const trigger = event.currentTarget;
7537 const currentDomReference = store.select("domReferenceElement");
7538 const currentOpen = store.select("open");
7539 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7540 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7541 return;
7542 }
7543 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7544 const floatingElement = store.select("floatingElement");
7545 if (floatingElement) {
7546 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7547 applySafePolygonPointerEventsMutation(instance, {
7548 scopeElement,
7549 referenceElement: trigger,
7550 floatingElement
7551 });
7552 }
7553 }
7554 const restMsValue = getRestMs(restMsRef.current);
7555 if (currentOpen && !isOverInactive || restMsValue === 0) {
7556 return;
7557 }
7558 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7559 return;
7560 }
7561 instance.restTimeout.clear();
7562 function handleMouseMove() {
7563 instance.restTimeoutPending = false;
7564 if (isClickLikeOpenEvent2()) {
7565 return;
7566 }
7567 const latestOpen = store.select("open");
7568 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7569 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7570 }
7571 }
7572 if (instance.pointerType === "touch") {
7573 ReactDOM4.flushSync(() => {
7574 handleMouseMove();
7575 });
7576 } else if (isOverInactive && currentOpen) {
7577 handleMouseMove();
7578 } else {
7579 instance.restTimeoutPending = true;
7580 instance.restTimeout.start(restMsValue, handleMouseMove);
7581 }
7582 }
7583 };
7584 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7585 }
7586
7587 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
7588 var CURSOR_SPEED_THRESHOLD = 0.1;
7589 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7590 var POLYGON_BUFFER = 0.5;
7591 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7592 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7593 }
7594 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7595 let isInsideValue = false;
7596 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7597 isInsideValue = !isInsideValue;
7598 }
7599 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7600 isInsideValue = !isInsideValue;
7601 }
7602 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7603 isInsideValue = !isInsideValue;
7604 }
7605 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7606 isInsideValue = !isInsideValue;
7607 }
7608 return isInsideValue;
7609 }
7610 function isInsideRect(pointX, pointY, rect) {
7611 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7612 }
7613 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7614 const minX = Math.min(x1, x2);
7615 const maxX = Math.max(x1, x2);
7616 const minY = Math.min(y1, y2);
7617 const maxY = Math.max(y1, y2);
7618 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7619 }
7620 function safePolygon(options = {}) {
7621 const {
7622 blockPointerEvents = false
7623 } = options;
7624 const timeout = new Timeout();
7625 const fn = ({
7626 x: x2,
7627 y: y2,
7628 placement,
7629 elements,
7630 onClose,
7631 nodeId,
7632 tree
7633 }) => {
7634 const side = placement?.split("-")[0];
7635 let hasLanded = false;
7636 let lastX = null;
7637 let lastY = null;
7638 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7639 function isCursorMovingSlowly(nextX, nextY) {
7640 const currentTime = performance.now();
7641 const elapsedTime = currentTime - lastCursorTime;
7642 if (lastX === null || lastY === null || elapsedTime === 0) {
7643 lastX = nextX;
7644 lastY = nextY;
7645 lastCursorTime = currentTime;
7646 return false;
7647 }
7648 const deltaX = nextX - lastX;
7649 const deltaY = nextY - lastY;
7650 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7651 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7652 lastX = nextX;
7653 lastY = nextY;
7654 lastCursorTime = currentTime;
7655 return distanceSquared < thresholdSquared;
7656 }
7657 function close() {
7658 timeout.clear();
7659 onClose();
7660 }
7661 return function onMouseMove(event) {
7662 timeout.clear();
7663 const domReference = elements.domReference;
7664 const floating = elements.floating;
7665 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7666 return void 0;
7667 }
7668 const {
7669 clientX,
7670 clientY
7671 } = event;
7672 const target = getTarget(event);
7673 const isLeave = event.type === "mouseleave";
7674 const isOverFloatingEl = contains(floating, target);
7675 const isOverReferenceEl = contains(domReference, target);
7676 if (isOverFloatingEl) {
7677 hasLanded = true;
7678 if (!isLeave) {
7679 return void 0;
7680 }
7681 }
7682 if (isOverReferenceEl) {
7683 hasLanded = false;
7684 if (!isLeave) {
7685 hasLanded = true;
7686 return void 0;
7687 }
7688 }
7689 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7690 return void 0;
7691 }
7692 function hasOpenChildNode() {
7693 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7694 }
7695 function closeIfNoOpenChild() {
7696 if (!hasOpenChildNode()) {
7697 close();
7698 }
7699 }
7700 if (hasOpenChildNode()) {
7701 return void 0;
7702 }
7703 const refRect = domReference.getBoundingClientRect();
7704 const rect = floating.getBoundingClientRect();
7705 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7706 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7707 const isFloatingWider = rect.width > refRect.width;
7708 const isFloatingTaller = rect.height > refRect.height;
7709 const left = (isFloatingWider ? refRect : rect).left;
7710 const right = (isFloatingWider ? refRect : rect).right;
7711 const top = (isFloatingTaller ? refRect : rect).top;
7712 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7713 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) {
7714 closeIfNoOpenChild();
7715 return void 0;
7716 }
7717 let isInsideTroughRect = false;
7718 switch (side) {
7719 case "top":
7720 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7721 break;
7722 case "bottom":
7723 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7724 break;
7725 case "left":
7726 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7727 break;
7728 case "right":
7729 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7730 break;
7731 default:
7732 }
7733 if (isInsideTroughRect) {
7734 return void 0;
7735 }
7736 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7737 closeIfNoOpenChild();
7738 return void 0;
7739 }
7740 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7741 closeIfNoOpenChild();
7742 return void 0;
7743 }
7744 let isInsidePolygon = false;
7745 switch (side) {
7746 case "top": {
7747 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7748 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7749 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7750 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7751 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7752 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7753 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7754 break;
7755 }
7756 case "bottom": {
7757 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7758 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7759 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7760 const cursorPointY = y2 - POLYGON_BUFFER;
7761 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7762 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7763 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7764 break;
7765 }
7766 case "left": {
7767 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7768 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7769 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7770 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7771 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7772 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7773 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7774 break;
7775 }
7776 case "right": {
7777 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7778 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7779 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7780 const cursorPointX = x2 - POLYGON_BUFFER;
7781 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7782 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7783 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7784 break;
7785 }
7786 default:
7787 }
7788 if (!isInsidePolygon) {
7789 closeIfNoOpenChild();
7790 } else if (!hasLanded) {
7791 timeout.start(40, closeIfNoOpenChild);
7792 }
7793 return void 0;
7794 };
7795 };
7796 fn.__options = {
7797 ...options,
7798 blockPointerEvents
7799 };
7800 return fn;
7801 }
7802
7803 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7804 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7805 CommonPopupDataAttributes2["open"] = "data-open";
7806 CommonPopupDataAttributes2["closed"] = "data-closed";
7807 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7808 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7809 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7810 CommonPopupDataAttributes2["side"] = "data-side";
7811 CommonPopupDataAttributes2["align"] = "data-align";
7812 return CommonPopupDataAttributes2;
7813 })({});
7814 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7815 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7816 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7817 return CommonTriggerDataAttributes2;
7818 })({});
7819 var TRIGGER_HOOK = {
7820 [CommonTriggerDataAttributes.popupOpen]: ""
7821 };
7822 var PRESSABLE_TRIGGER_HOOK = {
7823 [CommonTriggerDataAttributes.popupOpen]: "",
7824 [CommonTriggerDataAttributes.pressed]: ""
7825 };
7826 var POPUP_OPEN_HOOK = {
7827 [CommonPopupDataAttributes.open]: ""
7828 };
7829 var POPUP_CLOSED_HOOK = {
7830 [CommonPopupDataAttributes.closed]: ""
7831 };
7832 var ANCHOR_HIDDEN_HOOK = {
7833 [CommonPopupDataAttributes.anchorHidden]: ""
7834 };
7835 var triggerOpenStateMapping2 = {
7836 open(value) {
7837 if (value) {
7838 return TRIGGER_HOOK;
7839 }
7840 return null;
7841 }
7842 };
7843 var popupStateMapping = {
7844 open(value) {
7845 if (value) {
7846 return POPUP_OPEN_HOOK;
7847 }
7848 return POPUP_CLOSED_HOOK;
7849 },
7850 anchorHidden(value) {
7851 if (value) {
7852 return ANCHOR_HIDDEN_HOOK;
7853 }
7854 return null;
7855 }
7856 };
7857
7858 // node_modules/@base-ui/utils/esm/inertValue.js
7859 function inertValue(value) {
7860 if (isReactVersionAtLeast(19)) {
7861 return value;
7862 }
7863 return value ? "true" : void 0;
7864 }
7865
7866 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7867 var React36 = __toESM(require_react(), 1);
7868
7869 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7870 var baseArrow = (options) => ({
7871 name: "arrow",
7872 options,
7873 async fn(state) {
7874 const {
7875 x: x2,
7876 y: y2,
7877 placement,
7878 rects,
7879 platform: platform3,
7880 elements,
7881 middlewareData
7882 } = state;
7883 const {
7884 element,
7885 padding = 0,
7886 offsetParent = "real"
7887 } = evaluate(options, state) || {};
7888 if (element == null) {
7889 return {};
7890 }
7891 const paddingObject = getPaddingObject(padding);
7892 const coords = {
7893 x: x2,
7894 y: y2
7895 };
7896 const axis = getAlignmentAxis(placement);
7897 const length = getAxisLength(axis);
7898 const arrowDimensions = await platform3.getDimensions(element);
7899 const isYAxis = axis === "y";
7900 const minProp = isYAxis ? "top" : "left";
7901 const maxProp = isYAxis ? "bottom" : "right";
7902 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7903 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7904 const startDiff = coords[axis] - rects.reference[axis];
7905 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7906 let clientSize = elements.floating[clientProp] || rects.floating[length];
7907 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7908 clientSize = elements.floating[clientProp] || rects.floating[length];
7909 }
7910 const centerToReference = endDiff / 2 - startDiff / 2;
7911 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7912 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7913 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7914 const min2 = minPadding;
7915 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7916 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7917 const offset4 = clamp(min2, center, max2);
7918 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7919 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7920 return {
7921 [axis]: coords[axis] + alignmentOffset,
7922 data: {
7923 [axis]: offset4,
7924 centerOffset: center - offset4 - alignmentOffset,
7925 ...shouldAddOffset && {
7926 alignmentOffset
7927 }
7928 },
7929 reset: shouldAddOffset
7930 };
7931 }
7932 });
7933 var arrow4 = (options, deps) => ({
7934 ...baseArrow(options),
7935 options: [options, deps]
7936 });
7937
7938 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7939 var hide4 = {
7940 name: "hide",
7941 async fn(state) {
7942 const {
7943 width,
7944 height,
7945 x: x2,
7946 y: y2
7947 } = state.rects.reference;
7948 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7949 const nativeHideResult = await hide3().fn(state);
7950 return {
7951 data: {
7952 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7953 }
7954 };
7955 }
7956 };
7957
7958 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7959 var DEFAULT_SIDES = {
7960 sideX: "left",
7961 sideY: "top"
7962 };
7963 var adaptiveOrigin = {
7964 name: "adaptiveOrigin",
7965 async fn(state) {
7966 const {
7967 x: rawX,
7968 y: rawY,
7969 rects: {
7970 floating: floatRect
7971 },
7972 elements: {
7973 floating
7974 },
7975 platform: platform3,
7976 strategy,
7977 placement
7978 } = state;
7979 const win = getWindow(floating);
7980 const styles = win.getComputedStyle(floating);
7981 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7982 if (!hasTransition) {
7983 return {
7984 x: rawX,
7985 y: rawY,
7986 data: DEFAULT_SIDES
7987 };
7988 }
7989 const offsetParent = await platform3.getOffsetParent?.(floating);
7990 let offsetDimensions = {
7991 width: 0,
7992 height: 0
7993 };
7994 if (strategy === "fixed" && win?.visualViewport) {
7995 offsetDimensions = {
7996 width: win.visualViewport.width,
7997 height: win.visualViewport.height
7998 };
7999 } else if (offsetParent === win) {
8000 const doc = ownerDocument(floating);
8001 offsetDimensions = {
8002 width: doc.documentElement.clientWidth,
8003 height: doc.documentElement.clientHeight
8004 };
8005 } else if (await platform3.isElement?.(offsetParent)) {
8006 offsetDimensions = await platform3.getDimensions(offsetParent);
8007 }
8008 const currentSide = getSide(placement);
8009 let x2 = rawX;
8010 let y2 = rawY;
8011 if (currentSide === "left") {
8012 x2 = offsetDimensions.width - (rawX + floatRect.width);
8013 }
8014 if (currentSide === "top") {
8015 y2 = offsetDimensions.height - (rawY + floatRect.height);
8016 }
8017 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
8018 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
8019 return {
8020 x: x2,
8021 y: y2,
8022 data: {
8023 sideX,
8024 sideY
8025 }
8026 };
8027 }
8028 };
8029
8030 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
8031 function getLogicalSide(sideParam, renderedSide, isRtl) {
8032 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8033 const logicalRight = isRtl ? "inline-start" : "inline-end";
8034 const logicalLeft = isRtl ? "inline-end" : "inline-start";
8035 return {
8036 top: "top",
8037 right: isLogicalSideParam ? logicalRight : "right",
8038 bottom: "bottom",
8039 left: isLogicalSideParam ? logicalLeft : "left"
8040 }[renderedSide];
8041 }
8042 function getOffsetData(state, sideParam, isRtl) {
8043 const {
8044 rects,
8045 placement
8046 } = state;
8047 const data = {
8048 side: getLogicalSide(sideParam, getSide(placement), isRtl),
8049 align: getAlignment(placement) || "center",
8050 anchor: {
8051 width: rects.reference.width,
8052 height: rects.reference.height
8053 },
8054 positioner: {
8055 width: rects.floating.width,
8056 height: rects.floating.height
8057 }
8058 };
8059 return data;
8060 }
8061 function useAnchorPositioning(params) {
8062 const {
8063 // Public parameters
8064 anchor,
8065 positionMethod = "absolute",
8066 side: sideParam = "bottom",
8067 sideOffset = 0,
8068 align = "center",
8069 alignOffset = 0,
8070 collisionBoundary,
8071 collisionPadding: collisionPaddingParam = 5,
8072 sticky = false,
8073 arrowPadding = 5,
8074 disableAnchorTracking = false,
8075 inline: inlineMiddleware,
8076 // Private parameters
8077 keepMounted = false,
8078 floatingRootContext,
8079 mounted,
8080 collisionAvoidance,
8081 shiftCrossAxis = false,
8082 nodeId,
8083 adaptiveOrigin: adaptiveOrigin2,
8084 lazyFlip = false,
8085 externalTree
8086 } = params;
8087 const [mountSide, setMountSide] = React36.useState(null);
8088 if (!mounted && mountSide !== null) {
8089 setMountSide(null);
8090 }
8091 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8092 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8093 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8094 const anchorFn = typeof anchor === "function" ? anchor : void 0;
8095 const anchorFnCallback = useStableCallback(anchorFn);
8096 const anchorDep = anchorFn ? anchorFnCallback : anchor;
8097 const anchorValueRef = useValueAsRef(anchor);
8098 const mountedRef = useValueAsRef(mounted);
8099 const direction = useDirection();
8100 const isRtl = direction === "rtl";
8101 const side = mountSide || {
8102 top: "top",
8103 right: "right",
8104 bottom: "bottom",
8105 left: "left",
8106 "inline-end": isRtl ? "left" : "right",
8107 "inline-start": isRtl ? "right" : "left"
8108 }[sideParam];
8109 const placement = align === "center" ? side : `${side}-${align}`;
8110 let collisionPadding = collisionPaddingParam;
8111 const bias = 1;
8112 const biasTop = sideParam === "bottom" ? bias : 0;
8113 const biasBottom = sideParam === "top" ? bias : 0;
8114 const biasLeft = sideParam === "right" ? bias : 0;
8115 const biasRight = sideParam === "left" ? bias : 0;
8116 if (typeof collisionPadding === "number") {
8117 collisionPadding = {
8118 top: collisionPadding + biasTop,
8119 right: collisionPadding + biasRight,
8120 bottom: collisionPadding + biasBottom,
8121 left: collisionPadding + biasLeft
8122 };
8123 } else if (collisionPadding) {
8124 collisionPadding = {
8125 top: (collisionPadding.top || 0) + biasTop,
8126 right: (collisionPadding.right || 0) + biasRight,
8127 bottom: (collisionPadding.bottom || 0) + biasBottom,
8128 left: (collisionPadding.left || 0) + biasLeft
8129 };
8130 }
8131 const commonCollisionProps = {
8132 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8133 padding: collisionPadding
8134 };
8135 const arrowRef = React36.useRef(null);
8136 const sideOffsetRef = useValueAsRef(sideOffset);
8137 const alignOffsetRef = useValueAsRef(alignOffset);
8138 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8139 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8140 const middleware = [];
8141 if (inlineMiddleware) {
8142 middleware.push(inlineMiddleware);
8143 }
8144 middleware.push(offset3((state) => {
8145 const data = getOffsetData(state, sideParam, isRtl);
8146 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8147 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8148 return {
8149 mainAxis: sideAxis,
8150 crossAxis: alignAxis,
8151 alignmentAxis: alignAxis
8152 };
8153 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
8154 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8155 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8156 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8157 ...commonCollisionProps,
8158 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8159 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8160 padding: {
8161 top: collisionPadding.top + bias,
8162 right: collisionPadding.right + bias,
8163 bottom: collisionPadding.bottom + bias,
8164 left: collisionPadding.left + bias
8165 },
8166 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8167 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8168 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8169 });
8170 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
8171 const html = ownerDocument(data.elements.floating).documentElement;
8172 return {
8173 ...commonCollisionProps,
8174 // Use the Layout Viewport to avoid shifting around when pinch-zooming
8175 // for context menus.
8176 rootBoundary: shiftCrossAxis ? {
8177 x: 0,
8178 y: 0,
8179 width: html.clientWidth,
8180 height: html.clientHeight
8181 } : void 0,
8182 mainAxis: collisionAvoidanceAlign !== "none",
8183 crossAxis: crossAxisShiftEnabled,
8184 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8185 if (!arrowRef.current) {
8186 return {};
8187 }
8188 const {
8189 width,
8190 height
8191 } = arrowRef.current.getBoundingClientRect();
8192 const sideAxis = getSideAxis(getSide(limitData.placement));
8193 const arrowSize = sideAxis === "y" ? width : height;
8194 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8195 return {
8196 offset: arrowSize / 2 + offsetAmount / 2
8197 };
8198 })
8199 };
8200 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
8201 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8202 middleware.push(shiftMiddleware, flipMiddleware);
8203 } else {
8204 middleware.push(flipMiddleware, shiftMiddleware);
8205 }
8206 middleware.push(size3({
8207 ...commonCollisionProps,
8208 apply({
8209 elements: {
8210 floating
8211 },
8212 availableWidth,
8213 availableHeight,
8214 rects
8215 }) {
8216 if (!mountedRef.current) {
8217 return;
8218 }
8219 const floatingStyle = floating.style;
8220 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
8221 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
8222 const dpr = getWindow(floating).devicePixelRatio || 1;
8223 const {
8224 x: x3,
8225 y: y3,
8226 width,
8227 height
8228 } = rects.reference;
8229 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8230 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8231 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
8232 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
8233 }
8234 }), arrow4((state) => ({
8235 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8236 // we'll create a fake element.
8237 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
8238 padding: arrowPadding,
8239 offsetParent: "floating"
8240 }), [arrowPadding]), {
8241 name: "transformOrigin",
8242 fn(state) {
8243 const {
8244 elements: elements2,
8245 middlewareData: middlewareData2,
8246 placement: renderedPlacement2,
8247 rects,
8248 y: y3
8249 } = state;
8250 const currentRenderedSide = getSide(renderedPlacement2);
8251 const currentRenderedAxis = getSideAxis(currentRenderedSide);
8252 const arrowEl = arrowRef.current;
8253 const arrowX = middlewareData2.arrow?.x || 0;
8254 const arrowY = middlewareData2.arrow?.y || 0;
8255 const arrowWidth = arrowEl?.clientWidth || 0;
8256 const arrowHeight = arrowEl?.clientHeight || 0;
8257 const transformX = arrowX + arrowWidth / 2;
8258 const transformY = arrowY + arrowHeight / 2;
8259 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
8260 const halfAnchorHeight = rects.reference.height / 2;
8261 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8262 const isOverlappingAnchor = shiftY > sideOffsetValue;
8263 const adjacentTransformOrigin = {
8264 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
8265 bottom: `${transformX}px ${-sideOffsetValue}px`,
8266 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
8267 right: `${-sideOffsetValue}px ${transformY}px`
8268 }[currentRenderedSide];
8269 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
8270 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
8271 return {};
8272 }
8273 }, hide4, adaptiveOrigin2);
8274 useIsoLayoutEffect(() => {
8275 if (!mounted && floatingRootContext) {
8276 floatingRootContext.update({
8277 referenceElement: null,
8278 floatingElement: null,
8279 domReferenceElement: null,
8280 positionReference: null
8281 });
8282 }
8283 }, [mounted, floatingRootContext]);
8284 const autoUpdateOptions = React36.useMemo(() => ({
8285 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8286 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8287 }), [disableAnchorTracking]);
8288 const {
8289 refs,
8290 elements,
8291 x: x2,
8292 y: y2,
8293 middlewareData,
8294 update: update2,
8295 placement: renderedPlacement,
8296 context,
8297 isPositioned,
8298 floatingStyles: originalFloatingStyles
8299 } = useFloating2({
8300 rootContext: floatingRootContext,
8301 open: keepMounted ? mounted : void 0,
8302 placement,
8303 middleware,
8304 strategy: positionMethod,
8305 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8306 nodeId,
8307 externalTree
8308 });
8309 const {
8310 sideX,
8311 sideY
8312 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8313 const resolvedPosition = isPositioned ? positionMethod : "fixed";
8314 const floatingStyles = React36.useMemo(() => {
8315 const base = adaptiveOrigin2 ? {
8316 position: resolvedPosition,
8317 [sideX]: x2,
8318 [sideY]: y2
8319 } : {
8320 position: resolvedPosition,
8321 ...originalFloatingStyles
8322 };
8323 if (!isPositioned) {
8324 base.opacity = 0;
8325 }
8326 return base;
8327 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8328 const registeredPositionReferenceRef = React36.useRef(null);
8329 useIsoLayoutEffect(() => {
8330 if (!mounted) {
8331 return;
8332 }
8333 const anchorValue = anchorValueRef.current;
8334 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8335 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8336 const finalAnchor = unwrappedElement || null;
8337 if (finalAnchor !== registeredPositionReferenceRef.current) {
8338 refs.setPositionReference(finalAnchor);
8339 registeredPositionReferenceRef.current = finalAnchor;
8340 }
8341 }, [mounted, refs, anchorDep, anchorValueRef]);
8342 React36.useEffect(() => {
8343 if (!mounted) {
8344 return;
8345 }
8346 const anchorValue = anchorValueRef.current;
8347 if (typeof anchorValue === "function") {
8348 return;
8349 }
8350 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8351 refs.setPositionReference(anchorValue.current);
8352 registeredPositionReferenceRef.current = anchorValue.current;
8353 }
8354 }, [mounted, refs, anchorDep, anchorValueRef]);
8355 React36.useEffect(() => {
8356 if (keepMounted && mounted && elements.domReference && elements.floating) {
8357 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
8358 }
8359 return void 0;
8360 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8361 const renderedSide = getSide(renderedPlacement);
8362 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8363 const renderedAlign = getAlignment(renderedPlacement) || "center";
8364 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8365 useIsoLayoutEffect(() => {
8366 if (lazyFlip && mounted && isPositioned) {
8367 setMountSide(renderedSide);
8368 }
8369 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8370 const arrowStyles = React36.useMemo(() => ({
8371 position: "absolute",
8372 top: middlewareData.arrow?.y,
8373 left: middlewareData.arrow?.x
8374 }), [middlewareData.arrow]);
8375 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8376 return React36.useMemo(() => ({
8377 positionerStyles: floatingStyles,
8378 arrowStyles,
8379 arrowRef,
8380 arrowUncentered,
8381 side: logicalRenderedSide,
8382 align: renderedAlign,
8383 physicalSide: renderedSide,
8384 anchorHidden,
8385 refs,
8386 context,
8387 isPositioned,
8388 update: update2
8389 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8390 }
8391 function isRef(param) {
8392 return param != null && "current" in param;
8393 }
8394
8395 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
8396 function getDisabledMountTransitionStyles(transitionStatus) {
8397 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8398 }
8399
8400 // node_modules/@base-ui/react/esm/utils/usePositioner.js
8401 function usePositioner(componentProps, state, {
8402 styles,
8403 transitionStatus,
8404 props,
8405 refs,
8406 hidden,
8407 inert = false
8408 }) {
8409 const style = {
8410 ...styles
8411 };
8412 if (inert) {
8413 style.pointerEvents = "none";
8414 }
8415 return useRenderElement("div", componentProps, {
8416 state,
8417 ref: refs,
8418 props: [{
8419 role: "presentation",
8420 hidden,
8421 style
8422 }, getDisabledMountTransitionStyles(transitionStatus), props],
8423 stateAttributesMapping: popupStateMapping
8424 });
8425 }
8426
8427 // node_modules/@base-ui/react/esm/button/Button.js
8428 var React37 = __toESM(require_react(), 1);
8429 var Button = /* @__PURE__ */ React37.forwardRef(function Button2(componentProps, forwardedRef) {
8430 const {
8431 render: render4,
8432 className,
8433 disabled: disabled2 = false,
8434 focusableWhenDisabled = false,
8435 nativeButton = true,
8436 style,
8437 ...elementProps
8438 } = componentProps;
8439 const {
8440 getButtonProps,
8441 buttonRef
8442 } = useButton({
8443 disabled: disabled2,
8444 focusableWhenDisabled,
8445 native: nativeButton
8446 });
8447 const state = {
8448 disabled: disabled2
8449 };
8450 return useRenderElement("button", componentProps, {
8451 state,
8452 ref: [forwardedRef, buttonRef],
8453 props: [elementProps, getButtonProps]
8454 });
8455 });
8456 if (true) Button.displayName = "Button";
8457
8458 // node_modules/@base-ui/react/esm/collapsible/index.parts.js
8459 var index_parts_exports = {};
8460 __export(index_parts_exports, {
8461 Panel: () => CollapsiblePanel,
8462 Root: () => CollapsibleRoot,
8463 Trigger: () => CollapsibleTrigger
8464 });
8465
8466 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
8467 var React38 = __toESM(require_react(), 1);
8468
8469 // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js
8470 var collapsibleStateAttributesMapping = {
8471 ...collapsibleOpenStateMapping,
8472 ...transitionStatusMapping
8473 };
8474
8475 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
8476 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8477 var CollapsibleRoot = /* @__PURE__ */ React38.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
8478 const {
8479 render: render4,
8480 className,
8481 defaultOpen = false,
8482 disabled: disabled2 = false,
8483 onOpenChange: onOpenChangeProp,
8484 open,
8485 style,
8486 ...elementProps
8487 } = componentProps;
8488 const onOpenChange = useStableCallback(onOpenChangeProp);
8489 const collapsible = useCollapsibleRoot({
8490 open,
8491 defaultOpen,
8492 onOpenChange,
8493 disabled: disabled2
8494 });
8495 const state = React38.useMemo(() => ({
8496 open: collapsible.open,
8497 disabled: collapsible.disabled,
8498 transitionStatus: collapsible.transitionStatus
8499 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
8500 const contextValue = React38.useMemo(() => ({
8501 ...collapsible,
8502 onOpenChange,
8503 state
8504 }), [collapsible, onOpenChange, state]);
8505 const element = useRenderElement("div", componentProps, {
8506 state,
8507 ref: forwardedRef,
8508 props: elementProps,
8509 stateAttributesMapping: collapsibleStateAttributesMapping
8510 });
8511 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapsibleRootContext.Provider, {
8512 value: contextValue,
8513 children: element
8514 });
8515 });
8516 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
8517
8518 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js
8519 var React39 = __toESM(require_react(), 1);
8520 var stateAttributesMapping = {
8521 ...triggerOpenStateMapping,
8522 ...transitionStatusMapping
8523 };
8524 var CollapsibleTrigger = /* @__PURE__ */ React39.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
8525 const {
8526 panelId,
8527 open,
8528 handleTrigger,
8529 state,
8530 disabled: contextDisabled
8531 } = useCollapsibleRootContext();
8532 const {
8533 className,
8534 disabled: disabled2 = contextDisabled,
8535 id,
8536 render: render4,
8537 nativeButton = true,
8538 style,
8539 ...elementProps
8540 } = componentProps;
8541 const {
8542 getButtonProps,
8543 buttonRef
8544 } = useButton({
8545 disabled: disabled2,
8546 focusableWhenDisabled: true,
8547 native: nativeButton
8548 });
8549 const element = useRenderElement("button", componentProps, {
8550 state,
8551 ref: [forwardedRef, buttonRef],
8552 props: [{
8553 "aria-controls": open ? panelId : void 0,
8554 "aria-expanded": open,
8555 onClick: handleTrigger
8556 }, elementProps, getButtonProps],
8557 stateAttributesMapping
8558 });
8559 return element;
8560 });
8561 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
8562
8563 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
8564 var React40 = __toESM(require_react(), 1);
8565
8566 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js
8567 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
8568 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
8569 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
8570 return CollapsiblePanelCssVars2;
8571 })({});
8572
8573 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
8574 var CollapsiblePanel = /* @__PURE__ */ React40.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
8575 const {
8576 className,
8577 hiddenUntilFound: hiddenUntilFoundProp,
8578 keepMounted: keepMountedProp,
8579 render: render4,
8580 id: idProp,
8581 style,
8582 ...elementProps
8583 } = componentProps;
8584 if (true) {
8585 useIsoLayoutEffect(() => {
8586 if (hiddenUntilFoundProp && keepMountedProp === false) {
8587 warn("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.");
8588 }
8589 }, [hiddenUntilFoundProp, keepMountedProp]);
8590 }
8591 const {
8592 mounted,
8593 onOpenChange,
8594 open,
8595 panelId,
8596 setMounted,
8597 setPanelIdState,
8598 setOpen,
8599 state,
8600 transitionStatus
8601 } = useCollapsibleRootContext();
8602 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
8603 const keepMounted = keepMountedProp ?? false;
8604 useIsoLayoutEffect(() => {
8605 if (idProp) {
8606 setPanelIdState(idProp);
8607 return () => {
8608 setPanelIdState(void 0);
8609 };
8610 }
8611 return void 0;
8612 }, [idProp, setPanelIdState]);
8613 const {
8614 height,
8615 props,
8616 ref,
8617 shouldPreventOpenAnimation,
8618 shouldRender,
8619 transitionStatus: panelTransitionStatus,
8620 width
8621 } = useCollapsiblePanel({
8622 externalRef: forwardedRef,
8623 hiddenUntilFound,
8624 id: panelId,
8625 keepMounted,
8626 mounted,
8627 onOpenChange,
8628 open,
8629 setMounted,
8630 setOpen,
8631 transitionStatus
8632 });
8633 const panelState = {
8634 ...state,
8635 transitionStatus: panelTransitionStatus
8636 };
8637 const resolvedStyle = resolveStyle(style, panelState);
8638 const element = useRenderElement("div", {
8639 ...componentProps,
8640 style: void 0
8641 }, {
8642 state: panelState,
8643 ref,
8644 props: [
8645 props,
8646 {
8647 style: {
8648 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
8649 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
8650 }
8651 },
8652 elementProps,
8653 resolvedStyle ? {
8654 style: resolvedStyle
8655 } : void 0,
8656 // Resolve the public `style` prop so temporary `animationName: 'none'`
8657 // can still win after user's inline styles have been merged.
8658 shouldPreventOpenAnimation ? {
8659 style: {
8660 animationName: "none"
8661 }
8662 } : void 0
8663 ],
8664 stateAttributesMapping: collapsibleStateAttributesMapping
8665 });
8666 if (!shouldRender) {
8667 return null;
8668 }
8669 return element;
8670 });
8671 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
8672
8673 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8674 var React43 = __toESM(require_react(), 1);
8675 var ReactDOM5 = __toESM(require_react_dom(), 1);
8676
8677 // node_modules/@base-ui/utils/esm/usePreviousValue.js
8678 var React41 = __toESM(require_react(), 1);
8679 function usePreviousValue(value) {
8680 const [state, setState] = React41.useState({
8681 current: value,
8682 previous: null
8683 });
8684 if (value !== state.current) {
8685 setState({
8686 current: value,
8687 previous: state.current
8688 });
8689 }
8690 return state.previous;
8691 }
8692
8693 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
8694 var React42 = __toESM(require_react(), 1);
8695
8696 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
8697 function getCssDimensions2(element) {
8698 const css = getComputedStyle2(element);
8699 let width = parseFloat(css.width) || 0;
8700 let height = parseFloat(css.height) || 0;
8701 const hasOffset = isHTMLElement(element);
8702 const offsetWidth = hasOffset ? element.offsetWidth : width;
8703 const offsetHeight = hasOffset ? element.offsetHeight : height;
8704 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8705 if (shouldFallback) {
8706 width = offsetWidth;
8707 height = offsetHeight;
8708 }
8709 return {
8710 width,
8711 height
8712 };
8713 }
8714
8715 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
8716 var DEFAULT_ENABLED = () => true;
8717 function usePopupAutoResize(parameters) {
8718 const {
8719 popupElement,
8720 positionerElement,
8721 content,
8722 mounted,
8723 enabled = DEFAULT_ENABLED,
8724 onMeasureLayout: onMeasureLayoutParam,
8725 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8726 side,
8727 direction
8728 } = parameters;
8729 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8730 const animationFrame = useAnimationFrame();
8731 const committedDimensionsRef = React42.useRef(null);
8732 const liveDimensionsRef = React42.useRef(null);
8733 const isInitialRenderRef = React42.useRef(true);
8734 const restoreAnchoringStylesRef = React42.useRef(NOOP);
8735 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8736 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8737 const anchoringStyles = React42.useMemo(() => {
8738 let isOriginSide = side === "top";
8739 let isPhysicalLeft = side === "left";
8740 if (direction === "rtl") {
8741 isOriginSide = isOriginSide || side === "inline-end";
8742 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8743 } else {
8744 isOriginSide = isOriginSide || side === "inline-start";
8745 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8746 }
8747 return isOriginSide ? {
8748 position: "absolute",
8749 [side === "top" ? "bottom" : "top"]: "0",
8750 [isPhysicalLeft ? "right" : "left"]: "0"
8751 } : EMPTY_OBJECT;
8752 }, [side, direction]);
8753 useIsoLayoutEffect(() => {
8754 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
8755 restoreAnchoringStylesRef.current = NOOP;
8756 isInitialRenderRef.current = true;
8757 committedDimensionsRef.current = null;
8758 liveDimensionsRef.current = null;
8759 return void 0;
8760 }
8761 if (!popupElement || !positionerElement) {
8762 return void 0;
8763 }
8764 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8765 const observer = new ResizeObserver((entries) => {
8766 const entry = entries[0];
8767 if (entry) {
8768 liveDimensionsRef.current = {
8769 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
8770 height: Math.ceil(entry.borderBoxSize[0].blockSize)
8771 };
8772 }
8773 });
8774 observer.observe(popupElement);
8775 setPopupCssSize(popupElement, "auto");
8776 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8777 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8778 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8779 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8780 "--available-width": "max-content",
8781 "--available-height": "max-content"
8782 });
8783 function restoreMeasurementOverrides() {
8784 restorePopupPosition();
8785 restorePopupTransform();
8786 restorePositionerAvailableSize();
8787 }
8788 function restoreMeasurementOverridesIncludingScale() {
8789 restoreMeasurementOverrides();
8790 restorePopupScale();
8791 }
8792 onMeasureLayout?.();
8793 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8794 setPositionerCssSize(positionerElement, "max-content");
8795 const dimensions = getCssDimensions2(popupElement);
8796 committedDimensionsRef.current = dimensions;
8797 setPositionerCssSize(positionerElement, dimensions);
8798 restoreMeasurementOverridesIncludingScale();
8799 onMeasureLayoutComplete?.(null, dimensions);
8800 isInitialRenderRef.current = false;
8801 return () => {
8802 observer.disconnect();
8803 restoreAnchoringStylesRef.current();
8804 restoreAnchoringStylesRef.current = NOOP;
8805 };
8806 }
8807 setPopupCssSize(popupElement, "auto");
8808 setPositionerCssSize(positionerElement, "max-content");
8809 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
8810 const newDimensions = getCssDimensions2(popupElement);
8811 committedDimensionsRef.current = newDimensions;
8812 if (!previousDimensions) {
8813 setPositionerCssSize(positionerElement, newDimensions);
8814 restoreMeasurementOverridesIncludingScale();
8815 onMeasureLayoutComplete?.(null, newDimensions);
8816 return () => {
8817 observer.disconnect();
8818 animationFrame.cancel();
8819 restoreAnchoringStylesRef.current();
8820 restoreAnchoringStylesRef.current = NOOP;
8821 };
8822 }
8823 setPopupCssSize(popupElement, previousDimensions);
8824 restoreMeasurementOverridesIncludingScale();
8825 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8826 setPositionerCssSize(positionerElement, newDimensions);
8827 const abortController = new AbortController();
8828 animationFrame.request(() => {
8829 setPopupCssSize(popupElement, newDimensions);
8830 runOnceAnimationsFinish(() => {
8831 popupElement.style.setProperty("--popup-width", "auto");
8832 popupElement.style.setProperty("--popup-height", "auto");
8833 }, abortController.signal);
8834 });
8835 return () => {
8836 observer.disconnect();
8837 abortController.abort();
8838 animationFrame.cancel();
8839 restoreAnchoringStylesRef.current();
8840 restoreAnchoringStylesRef.current = NOOP;
8841 };
8842 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8843 }
8844 function overrideElementStyle(element, property, value) {
8845 const originalValue = element.style.getPropertyValue(property);
8846 element.style.setProperty(property, value);
8847 return () => {
8848 element.style.setProperty(property, originalValue);
8849 };
8850 }
8851 function applyElementStyles(element, styles) {
8852 const restorers = [];
8853 for (const [key, value] of Object.entries(styles)) {
8854 restorers.push(overrideElementStyle(element, key, value));
8855 }
8856 return restorers.length ? () => {
8857 restorers.forEach((restore) => restore());
8858 } : NOOP;
8859 }
8860 function setPopupCssSize(popupElement, size4) {
8861 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8862 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8863 popupElement.style.setProperty("--popup-width", width);
8864 popupElement.style.setProperty("--popup-height", height);
8865 }
8866 function setPositionerCssSize(positionerElement, size4) {
8867 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8868 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8869 positionerElement.style.setProperty("--positioner-width", width);
8870 positionerElement.style.setProperty("--positioner-height", height);
8871 }
8872
8873 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8874 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8875 function usePopupViewport(parameters) {
8876 const {
8877 store,
8878 side,
8879 cssVars,
8880 children
8881 } = parameters;
8882 const direction = useDirection();
8883 const activeTrigger = store.useState("activeTriggerElement");
8884 const activeTriggerId = store.useState("activeTriggerId");
8885 const open = store.useState("open");
8886 const payload = store.useState("payload");
8887 const mounted = store.useState("mounted");
8888 const popupElement = store.useState("popupElement");
8889 const positionerElement = store.useState("positionerElement");
8890 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8891 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8892 const capturedNodeRef = React43.useRef(null);
8893 const [previousContentNode, setPreviousContentNode] = React43.useState(null);
8894 const [newTriggerOffset, setNewTriggerOffset] = React43.useState(null);
8895 const currentContainerRef = React43.useRef(null);
8896 const previousContainerRef = React43.useRef(null);
8897 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8898 const cleanupFrame = useAnimationFrame();
8899 const [previousContentDimensions, setPreviousContentDimensions] = React43.useState(null);
8900 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React43.useState(false);
8901 useIsoLayoutEffect(() => {
8902 store.set("hasViewport", true);
8903 return () => {
8904 store.set("hasViewport", false);
8905 };
8906 }, [store]);
8907 const handleMeasureLayout = useStableCallback(() => {
8908 currentContainerRef.current?.style.setProperty("animation", "none");
8909 currentContainerRef.current?.style.setProperty("transition", "none");
8910 previousContainerRef.current?.style.setProperty("display", "none");
8911 });
8912 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8913 currentContainerRef.current?.style.removeProperty("animation");
8914 currentContainerRef.current?.style.removeProperty("transition");
8915 previousContainerRef.current?.style.removeProperty("display");
8916 if (previousDimensions) {
8917 setPreviousContentDimensions(previousDimensions);
8918 }
8919 });
8920 const lastHandledTriggerRef = React43.useRef(null);
8921 useIsoLayoutEffect(() => {
8922 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8923 setPreviousContentNode(capturedNodeRef.current);
8924 setShowStartingStyleAttribute(true);
8925 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8926 setNewTriggerOffset(offset4);
8927 cleanupFrame.request(() => {
8928 ReactDOM5.flushSync(() => {
8929 setShowStartingStyleAttribute(false);
8930 });
8931 onAnimationsFinished(() => {
8932 setPreviousContentNode(null);
8933 setPreviousContentDimensions(null);
8934 capturedNodeRef.current = null;
8935 });
8936 });
8937 lastHandledTriggerRef.current = activeTrigger;
8938 }
8939 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8940 useIsoLayoutEffect(() => {
8941 const source = currentContainerRef.current;
8942 if (!source) {
8943 return;
8944 }
8945 const wrapper = ownerDocument(source).createElement("div");
8946 for (const child of Array.from(source.childNodes)) {
8947 wrapper.appendChild(child.cloneNode(true));
8948 }
8949 capturedNodeRef.current = wrapper;
8950 });
8951 const isTransitioning = previousContentNode != null;
8952 let childrenToRender;
8953 if (!isTransitioning) {
8954 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
8955 "data-current": true,
8956 ref: currentContainerRef,
8957 children
8958 }, currentContentKey);
8959 } else {
8960 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React43.Fragment, {
8961 children: [/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
8962 "data-previous": true,
8963 inert: inertValue(true),
8964 ref: previousContainerRef,
8965 style: {
8966 ...previousContentDimensions ? {
8967 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8968 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8969 } : null,
8970 position: "absolute"
8971 },
8972 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8973 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
8974 "data-current": true,
8975 ref: currentContainerRef,
8976 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8977 children
8978 }, currentContentKey)]
8979 });
8980 }
8981 useIsoLayoutEffect(() => {
8982 const container = previousContainerRef.current;
8983 if (!container || !previousContentNode) {
8984 return;
8985 }
8986 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8987 }, [previousContentNode]);
8988 usePopupAutoResize({
8989 popupElement,
8990 positionerElement,
8991 mounted,
8992 content: payload,
8993 onMeasureLayout: handleMeasureLayout,
8994 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8995 side,
8996 direction
8997 });
8998 const state = {
8999 activationDirection: getActivationDirection(newTriggerOffset),
9000 transitioning: isTransitioning
9001 };
9002 return {
9003 children: childrenToRender,
9004 state
9005 };
9006 }
9007 function getActivationDirection(offset4) {
9008 if (!offset4) {
9009 return void 0;
9010 }
9011 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
9012 }
9013 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
9014 if (value > tolerance) {
9015 return positiveLabel;
9016 }
9017 if (value < -tolerance) {
9018 return negativeLabel;
9019 }
9020 return "";
9021 }
9022 function calculateRelativePosition(from, to) {
9023 const fromRect = from.getBoundingClientRect();
9024 const toRect = to.getBoundingClientRect();
9025 const fromCenter = {
9026 x: fromRect.left + fromRect.width / 2,
9027 y: fromRect.top + fromRect.height / 2
9028 };
9029 const toCenter = {
9030 x: toRect.left + toRect.width / 2,
9031 y: toRect.top + toRect.height / 2
9032 };
9033 return {
9034 horizontal: toCenter.x - fromCenter.x,
9035 vertical: toCenter.y - fromCenter.y
9036 };
9037 }
9038 function usePopupContentKey(activeTriggerId, payload) {
9039 const [contentKey, setContentKey] = React43.useState(0);
9040 const previousActiveTriggerIdRef = React43.useRef(activeTriggerId);
9041 const previousPayloadRef = React43.useRef(payload);
9042 const pendingPayloadUpdateRef = React43.useRef(false);
9043 useIsoLayoutEffect(() => {
9044 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
9045 const previousPayload = previousPayloadRef.current;
9046 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
9047 const payloadChanged = payload !== previousPayload;
9048 if (triggerIdChanged) {
9049 setContentKey((value) => value + 1);
9050 pendingPayloadUpdateRef.current = !payloadChanged;
9051 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
9052 setContentKey((value) => value + 1);
9053 pendingPayloadUpdateRef.current = false;
9054 }
9055 previousActiveTriggerIdRef.current = activeTriggerId;
9056 previousPayloadRef.current = payload;
9057 }, [activeTriggerId, payload]);
9058 return `${activeTriggerId ?? "current"}-${contentKey}`;
9059 }
9060
9061 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
9062 var React44 = __toESM(require_react(), 1);
9063 var ReactDOM6 = __toESM(require_react_dom(), 1);
9064 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
9065 var FloatingPortalLite = /* @__PURE__ */ React44.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
9066 const {
9067 children,
9068 container,
9069 className,
9070 render: render4,
9071 style,
9072 ...elementProps
9073 } = componentProps;
9074 const {
9075 portalNode,
9076 portalSubtree
9077 } = useFloatingPortalNode({
9078 container,
9079 ref: forwardedRef,
9080 componentProps,
9081 elementProps
9082 });
9083 if (!portalSubtree && !portalNode) {
9084 return null;
9085 }
9086 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(React44.Fragment, {
9087 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
9088 });
9089 });
9090 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
9091
9092 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
9093 var index_parts_exports2 = {};
9094 __export(index_parts_exports2, {
9095 Arrow: () => TooltipArrow,
9096 Handle: () => TooltipHandle,
9097 Popup: () => TooltipPopup,
9098 Portal: () => TooltipPortal,
9099 Positioner: () => TooltipPositioner,
9100 Provider: () => TooltipProvider,
9101 Root: () => TooltipRoot,
9102 Trigger: () => TooltipTrigger,
9103 Viewport: () => TooltipViewport,
9104 createHandle: () => createTooltipHandle
9105 });
9106
9107 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
9108 var React47 = __toESM(require_react(), 1);
9109
9110 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
9111 var React45 = __toESM(require_react(), 1);
9112 var TooltipRootContext = /* @__PURE__ */ React45.createContext(void 0);
9113 if (true) TooltipRootContext.displayName = "TooltipRootContext";
9114 function useTooltipRootContext(optional) {
9115 const context = React45.useContext(TooltipRootContext);
9116 if (context === void 0 && !optional) {
9117 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
9118 }
9119 return context;
9120 }
9121
9122 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
9123 var React46 = __toESM(require_react(), 1);
9124 var ReactDOM7 = __toESM(require_react_dom(), 1);
9125 var selectors2 = {
9126 ...popupStoreSelectors,
9127 disabled: createSelector((state) => state.disabled),
9128 instantType: createSelector((state) => state.instantType),
9129 isInstantPhase: createSelector((state) => state.isInstantPhase),
9130 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
9131 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
9132 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
9133 closeOnClick: createSelector((state) => state.closeOnClick),
9134 closeDelay: createSelector((state) => state.closeDelay),
9135 hasViewport: createSelector((state) => state.hasViewport)
9136 };
9137 var TooltipStore = class _TooltipStore extends ReactStore {
9138 constructor(initialState, floatingId, nested = false) {
9139 const triggerElements = new PopupTriggerMap();
9140 const state = {
9141 ...createInitialState(),
9142 ...initialState
9143 };
9144 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
9145 super(state, {
9146 popupRef: /* @__PURE__ */ React46.createRef(),
9147 onOpenChange: void 0,
9148 onOpenChangeComplete: void 0,
9149 triggerElements
9150 }, selectors2);
9151 }
9152 setOpen = (nextOpen, eventDetails) => {
9153 const reason = eventDetails.reason;
9154 const isHover = reason === reason_parts_exports.triggerHover;
9155 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
9156 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
9157 eventDetails.preventUnmountOnClose = () => {
9158 this.set("preventUnmountingOnClose", true);
9159 };
9160 this.context.onOpenChange?.(nextOpen, eventDetails);
9161 if (eventDetails.isCanceled) {
9162 return;
9163 }
9164 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
9165 const changeState = () => {
9166 const updatedState = {
9167 open: nextOpen,
9168 openChangeReason: reason
9169 };
9170 if (isFocusOpen) {
9171 updatedState.instantType = "focus";
9172 } else if (isDismissClose) {
9173 updatedState.instantType = "dismiss";
9174 } else if (reason === reason_parts_exports.triggerHover) {
9175 updatedState.instantType = void 0;
9176 }
9177 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
9178 this.update(updatedState);
9179 };
9180 if (isHover) {
9181 ReactDOM7.flushSync(changeState);
9182 } else {
9183 changeState();
9184 }
9185 };
9186 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
9187 cancelPendingOpen(event) {
9188 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
9189 }
9190 static useStore(externalStore, initialState) {
9191 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
9192 return store;
9193 }
9194 };
9195 function createInitialState() {
9196 return {
9197 ...createInitialPopupStoreState(),
9198 disabled: false,
9199 instantType: void 0,
9200 isInstantPhase: false,
9201 trackCursorAxis: "none",
9202 disableHoverablePopup: false,
9203 openChangeReason: null,
9204 closeOnClick: true,
9205 closeDelay: 0,
9206 hasViewport: false
9207 };
9208 }
9209
9210 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
9211 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
9212 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
9213 const {
9214 disabled: disabled2 = false,
9215 defaultOpen = false,
9216 open: openProp,
9217 disableHoverablePopup = false,
9218 trackCursorAxis = "none",
9219 actionsRef,
9220 onOpenChange,
9221 onOpenChangeComplete,
9222 handle,
9223 triggerId: triggerIdProp,
9224 defaultTriggerId: defaultTriggerIdProp = null,
9225 children
9226 } = props;
9227 const store = TooltipStore.useStore(handle?.store, {
9228 open: defaultOpen,
9229 openProp,
9230 activeTriggerId: defaultTriggerIdProp,
9231 triggerIdProp
9232 });
9233 useOnFirstRender(() => {
9234 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
9235 store.update({
9236 open: true,
9237 activeTriggerId: defaultTriggerIdProp
9238 });
9239 }
9240 });
9241 store.useControlledProp("openProp", openProp);
9242 store.useControlledProp("triggerIdProp", triggerIdProp);
9243 store.useContextCallback("onOpenChange", onOpenChange);
9244 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
9245 const openState = store.useState("open");
9246 const open = !disabled2 && openState;
9247 const activeTriggerId = store.useState("activeTriggerId");
9248 const mounted = store.useState("mounted");
9249 const payload = store.useState("payload");
9250 store.useSyncedValues({
9251 trackCursorAxis,
9252 disableHoverablePopup
9253 });
9254 store.useSyncedValue("disabled", disabled2);
9255 useImplicitActiveTrigger(store);
9256 const {
9257 forceUnmount,
9258 transitionStatus
9259 } = useOpenStateTransitions(open, store);
9260 const isInstantPhase = store.useState("isInstantPhase");
9261 const instantType = store.useState("instantType");
9262 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
9263 const previousInstantTypeRef = React47.useRef(null);
9264 useIsoLayoutEffect(() => {
9265 if (openState && disabled2) {
9266 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
9267 }
9268 }, [openState, disabled2, store]);
9269 useIsoLayoutEffect(() => {
9270 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
9271 if (instantType !== "delay") {
9272 previousInstantTypeRef.current = instantType;
9273 }
9274 store.set("instantType", "delay");
9275 } else if (previousInstantTypeRef.current !== null) {
9276 store.set("instantType", previousInstantTypeRef.current);
9277 previousInstantTypeRef.current = null;
9278 }
9279 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
9280 useIsoLayoutEffect(() => {
9281 if (open) {
9282 if (activeTriggerId == null) {
9283 store.set("payload", void 0);
9284 }
9285 }
9286 }, [store, activeTriggerId, open]);
9287 const handleImperativeClose = React47.useCallback(() => {
9288 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
9289 }, [store]);
9290 React47.useImperativeHandle(actionsRef, () => ({
9291 unmount: forceUnmount,
9292 close: handleImperativeClose
9293 }), [forceUnmount, handleImperativeClose]);
9294 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
9295 return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(TooltipRootContext.Provider, {
9296 value: store,
9297 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipInteractions, {
9298 store,
9299 disabled: disabled2,
9300 trackCursorAxis
9301 }), typeof children === "function" ? children({
9302 payload
9303 }) : children]
9304 });
9305 });
9306 if (true) TooltipRoot.displayName = "TooltipRoot";
9307 function TooltipInteractions({
9308 store,
9309 disabled: disabled2,
9310 trackCursorAxis
9311 }) {
9312 const floatingRootContext = store.useState("floatingRootContext");
9313 const dismiss = useDismiss(floatingRootContext, {
9314 enabled: !disabled2,
9315 referencePress: () => store.select("closeOnClick")
9316 });
9317 const clientPoint = useClientPoint(floatingRootContext, {
9318 enabled: !disabled2 && trackCursorAxis !== "none",
9319 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
9320 });
9321 const activeTriggerProps = React47.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
9322 const inactiveTriggerProps = React47.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
9323 const popupProps = React47.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
9324 usePopupInteractionProps(store, {
9325 activeTriggerProps,
9326 inactiveTriggerProps,
9327 popupProps
9328 });
9329 return null;
9330 }
9331
9332 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
9333 var React49 = __toESM(require_react(), 1);
9334
9335 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
9336 var React48 = __toESM(require_react(), 1);
9337 var TooltipProviderContext = /* @__PURE__ */ React48.createContext(void 0);
9338 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
9339 function useTooltipProviderContext() {
9340 return React48.useContext(TooltipProviderContext);
9341 }
9342
9343 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
9344 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
9345 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
9346 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
9347 return TooltipTriggerDataAttributes2;
9348 })({});
9349
9350 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
9351 var OPEN_DELAY = 600;
9352
9353 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
9354 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
9355 function getTargetElement(event) {
9356 if ("composedPath" in event) {
9357 const path = event.composedPath();
9358 for (let i2 = 0; i2 < path.length; i2 += 1) {
9359 const element = path[i2];
9360 if (isElement(element)) {
9361 return element;
9362 }
9363 }
9364 }
9365 const target = event.target;
9366 if (isElement(target)) {
9367 return target;
9368 }
9369 return null;
9370 }
9371 function closestEnabledTooltipTrigger(element) {
9372 let current = element;
9373 while (current) {
9374 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
9375 return current;
9376 }
9377 const parentElement = current.parentElement;
9378 if (parentElement) {
9379 current = parentElement;
9380 continue;
9381 }
9382 const root = current.getRootNode();
9383 current = "host" in root && isElement(root.host) ? root.host : null;
9384 }
9385 return null;
9386 }
9387 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
9388 const {
9389 render: render4,
9390 className,
9391 style,
9392 handle,
9393 payload,
9394 disabled: disabledProp,
9395 delay,
9396 closeOnClick = true,
9397 closeDelay,
9398 id: idProp,
9399 ...elementProps
9400 } = componentProps;
9401 const rootContext = useTooltipRootContext(true);
9402 const store = handle?.store ?? rootContext;
9403 if (!store) {
9404 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));
9405 }
9406 const thisTriggerId = useBaseUiId(idProp);
9407 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
9408 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9409 const floatingRootContext = store.useState("floatingRootContext");
9410 const triggerElementRef = React49.useRef(null);
9411 const delayWithDefault = delay ?? OPEN_DELAY;
9412 const closeDelayWithDefault = closeDelay ?? 0;
9413 const {
9414 registerTrigger,
9415 isMountedByThisTrigger
9416 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9417 payload,
9418 closeOnClick,
9419 closeDelay: closeDelayWithDefault
9420 });
9421 const providerContext = useTooltipProviderContext();
9422 const {
9423 delayRef,
9424 isInstantPhase,
9425 hasProvider
9426 } = useDelayGroup(floatingRootContext, {
9427 open: isOpenedByThisTrigger
9428 });
9429 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
9430 store.useSyncedValue("isInstantPhase", isInstantPhase);
9431 const rootDisabled = store.useState("disabled");
9432 const disabled2 = disabledProp ?? rootDisabled;
9433 const disabledRef = useValueAsRef(disabled2);
9434 const trackCursorAxis = store.useState("trackCursorAxis");
9435 const disableHoverablePopup = store.useState("disableHoverablePopup");
9436 const isNestedTriggerHoveredRef = React49.useRef(false);
9437 const nestedTriggerOpenTimeout = useTimeout();
9438 const pointerTypeRef = React49.useRef(void 0);
9439 function getOpenDelay() {
9440 const providerDelay = providerContext?.delay;
9441 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
9442 let computedOpenDelay = delayWithDefault;
9443 if (hasProvider) {
9444 if (groupOpenValue !== 0) {
9445 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
9446 } else {
9447 computedOpenDelay = 0;
9448 }
9449 }
9450 return computedOpenDelay;
9451 }
9452 function isEnabledNestedTriggerTarget(target) {
9453 const triggerEl = triggerElementRef.current;
9454 if (!triggerEl || !target) {
9455 return false;
9456 }
9457 const nearestTrigger = closestEnabledTooltipTrigger(target);
9458 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
9459 }
9460 function detectNestedTriggerHover(target) {
9461 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
9462 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
9463 if (nestedTriggerHovered) {
9464 hoverInteraction.openChangeTimeout.clear();
9465 hoverInteraction.restTimeout.clear();
9466 hoverInteraction.restTimeoutPending = false;
9467 nestedTriggerOpenTimeout.clear();
9468 }
9469 return nestedTriggerHovered;
9470 }
9471 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
9472 enabled: !disabled2,
9473 mouseOnly: true,
9474 move: false,
9475 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
9476 restMs: getOpenDelay,
9477 delay() {
9478 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
9479 let computedCloseDelay = closeDelayWithDefault;
9480 if (closeDelay == null && hasProvider) {
9481 computedCloseDelay = closeValue;
9482 }
9483 return {
9484 close: computedCloseDelay
9485 };
9486 },
9487 triggerElementRef,
9488 isActiveTrigger: isTriggerActive,
9489 isClosing: () => store.select("transitionStatus") === "ending",
9490 shouldOpen() {
9491 return !isNestedTriggerHoveredRef.current;
9492 }
9493 });
9494 const focusProps = useFocus(floatingRootContext, {
9495 enabled: !disabled2
9496 }).reference;
9497 const handleNestedTriggerHover = (event) => {
9498 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
9499 const target = getTargetElement(event);
9500 const nestedTriggerHovered = detectNestedTriggerHover(target);
9501 const triggerEl = triggerElementRef.current;
9502 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
9503 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
9504 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
9505 return;
9506 }
9507 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
9508 isMouseLikePointerType(pointerTypeRef.current)) {
9509 const open = () => {
9510 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
9511 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
9512 }
9513 };
9514 const openDelay = getOpenDelay();
9515 if (openDelay === 0) {
9516 nestedTriggerOpenTimeout.clear();
9517 open();
9518 } else {
9519 nestedTriggerOpenTimeout.start(openDelay, open);
9520 }
9521 }
9522 };
9523 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9524 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
9525 const state = {
9526 open: isOpenedByThisTrigger
9527 };
9528 const element = useRenderElement("button", componentProps, {
9529 state,
9530 ref: [forwardedRef, registerTrigger, triggerElementRef],
9531 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
9532 onMouseOver(event) {
9533 handleNestedTriggerHover(event.nativeEvent);
9534 },
9535 onFocus(event) {
9536 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
9537 event.preventBaseUIHandler();
9538 }
9539 },
9540 onMouseLeave() {
9541 isNestedTriggerHoveredRef.current = false;
9542 nestedTriggerOpenTimeout.clear();
9543 pointerTypeRef.current = void 0;
9544 },
9545 onPointerEnter(event) {
9546 pointerTypeRef.current = event.pointerType;
9547 },
9548 onPointerDown(event) {
9549 pointerTypeRef.current = event.pointerType;
9550 store.set("closeOnClick", closeOnClick);
9551 if (closeOnClick && !store.select("open")) {
9552 store.cancelPendingOpen(event.nativeEvent);
9553 }
9554 },
9555 onClick(event) {
9556 if (closeOnClick && !store.select("open")) {
9557 store.cancelPendingOpen(event.nativeEvent);
9558 }
9559 },
9560 id: thisTriggerId,
9561 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
9562 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
9563 }, elementProps],
9564 stateAttributesMapping: triggerOpenStateMapping2
9565 });
9566 return element;
9567 });
9568 if (true) TooltipTrigger.displayName = "TooltipTrigger";
9569
9570 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
9571 var React51 = __toESM(require_react(), 1);
9572
9573 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
9574 var React50 = __toESM(require_react(), 1);
9575 var TooltipPortalContext = /* @__PURE__ */ React50.createContext(void 0);
9576 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
9577 function useTooltipPortalContext() {
9578 const value = React50.useContext(TooltipPortalContext);
9579 if (value === void 0) {
9580 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
9581 }
9582 return value;
9583 }
9584
9585 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
9586 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
9587 var TooltipPortal = /* @__PURE__ */ React51.forwardRef(function TooltipPortal2(props, forwardedRef) {
9588 const {
9589 keepMounted = false,
9590 ...portalProps
9591 } = props;
9592 const store = useTooltipRootContext();
9593 const mounted = store.useState("mounted");
9594 const shouldRender = mounted || keepMounted;
9595 if (!shouldRender) {
9596 return null;
9597 }
9598 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPortalContext.Provider, {
9599 value: keepMounted,
9600 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingPortalLite, {
9601 ref: forwardedRef,
9602 ...portalProps
9603 })
9604 });
9605 });
9606 if (true) TooltipPortal.displayName = "TooltipPortal";
9607
9608 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
9609 var React53 = __toESM(require_react(), 1);
9610
9611 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
9612 var React52 = __toESM(require_react(), 1);
9613 var TooltipPositionerContext = /* @__PURE__ */ React52.createContext(void 0);
9614 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
9615 function useTooltipPositionerContext() {
9616 const context = React52.useContext(TooltipPositionerContext);
9617 if (context === void 0) {
9618 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
9619 }
9620 return context;
9621 }
9622
9623 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
9624 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9625 var TooltipPositioner = /* @__PURE__ */ React53.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9626 const {
9627 render: render4,
9628 className,
9629 anchor,
9630 positionMethod = "absolute",
9631 side = "top",
9632 align = "center",
9633 sideOffset = 0,
9634 alignOffset = 0,
9635 collisionBoundary = "clipping-ancestors",
9636 collisionPadding = 5,
9637 arrowPadding = 5,
9638 sticky = false,
9639 disableAnchorTracking = false,
9640 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9641 style,
9642 ...elementProps
9643 } = componentProps;
9644 const store = useTooltipRootContext();
9645 const keepMounted = useTooltipPortalContext();
9646 const open = store.useState("open");
9647 const mounted = store.useState("mounted");
9648 const trackCursorAxis = store.useState("trackCursorAxis");
9649 const disableHoverablePopup = store.useState("disableHoverablePopup");
9650 const floatingRootContext = store.useState("floatingRootContext");
9651 const instantType = store.useState("instantType");
9652 const transitionStatus = store.useState("transitionStatus");
9653 const hasViewport = store.useState("hasViewport");
9654 const positioning = useAnchorPositioning({
9655 anchor,
9656 positionMethod,
9657 floatingRootContext,
9658 mounted,
9659 side,
9660 sideOffset,
9661 align,
9662 alignOffset,
9663 collisionBoundary,
9664 collisionPadding,
9665 sticky,
9666 arrowPadding,
9667 disableAnchorTracking,
9668 keepMounted,
9669 collisionAvoidance,
9670 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9671 });
9672 const state = React53.useMemo(() => ({
9673 open,
9674 side: positioning.side,
9675 align: positioning.align,
9676 anchorHidden: positioning.anchorHidden,
9677 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9678 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9679 const element = usePositioner(componentProps, state, {
9680 styles: positioning.positionerStyles,
9681 transitionStatus,
9682 props: elementProps,
9683 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9684 hidden: !mounted,
9685 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9686 });
9687 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipPositionerContext.Provider, {
9688 value: positioning,
9689 children: element
9690 });
9691 });
9692 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9693
9694 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
9695 var React54 = __toESM(require_react(), 1);
9696 var stateAttributesMapping2 = {
9697 ...popupStateMapping,
9698 ...transitionStatusMapping
9699 };
9700 var TooltipPopup = /* @__PURE__ */ React54.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9701 const {
9702 render: render4,
9703 className,
9704 style,
9705 ...elementProps
9706 } = componentProps;
9707 const store = useTooltipRootContext();
9708 const {
9709 side,
9710 align
9711 } = useTooltipPositionerContext();
9712 const open = store.useState("open");
9713 const instantType = store.useState("instantType");
9714 const transitionStatus = store.useState("transitionStatus");
9715 const popupProps = store.useState("popupProps");
9716 const floatingContext = store.useState("floatingRootContext");
9717 const disabled2 = store.useState("disabled");
9718 const closeDelay = store.useState("closeDelay");
9719 useOpenChangeComplete({
9720 open,
9721 ref: store.context.popupRef,
9722 onComplete() {
9723 if (open) {
9724 store.context.onOpenChangeComplete?.(true);
9725 }
9726 }
9727 });
9728 useHoverFloatingInteraction(floatingContext, {
9729 enabled: !disabled2,
9730 closeDelay
9731 });
9732 const setPopupElement = store.useStateSetter("popupElement");
9733 const state = {
9734 open,
9735 side,
9736 align,
9737 instant: instantType,
9738 transitionStatus
9739 };
9740 const element = useRenderElement("div", componentProps, {
9741 state,
9742 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9743 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9744 stateAttributesMapping: stateAttributesMapping2
9745 });
9746 return element;
9747 });
9748 if (true) TooltipPopup.displayName = "TooltipPopup";
9749
9750 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
9751 var React55 = __toESM(require_react(), 1);
9752 var TooltipArrow = /* @__PURE__ */ React55.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9753 const {
9754 render: render4,
9755 className,
9756 style,
9757 ...elementProps
9758 } = componentProps;
9759 const store = useTooltipRootContext();
9760 const {
9761 arrowRef,
9762 side,
9763 align,
9764 arrowUncentered,
9765 arrowStyles
9766 } = useTooltipPositionerContext();
9767 const open = store.useState("open");
9768 const instantType = store.useState("instantType");
9769 const state = {
9770 open,
9771 side,
9772 align,
9773 uncentered: arrowUncentered,
9774 instant: instantType
9775 };
9776 const element = useRenderElement("div", componentProps, {
9777 state,
9778 ref: [forwardedRef, arrowRef],
9779 props: [{
9780 style: arrowStyles,
9781 "aria-hidden": true
9782 }, elementProps],
9783 stateAttributesMapping: popupStateMapping
9784 });
9785 return element;
9786 });
9787 if (true) TooltipArrow.displayName = "TooltipArrow";
9788
9789 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
9790 var React56 = __toESM(require_react(), 1);
9791 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9792 var TooltipProvider = function TooltipProvider2(props) {
9793 const {
9794 delay,
9795 closeDelay,
9796 timeout = 400
9797 } = props;
9798 const contextValue = React56.useMemo(() => ({
9799 delay,
9800 closeDelay
9801 }), [delay, closeDelay]);
9802 const delayValue = React56.useMemo(() => ({
9803 open: delay,
9804 close: closeDelay
9805 }), [delay, closeDelay]);
9806 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipProviderContext.Provider, {
9807 value: contextValue,
9808 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingDelayGroup, {
9809 delay: delayValue,
9810 timeoutMs: timeout,
9811 children: props.children
9812 })
9813 });
9814 };
9815 if (true) TooltipProvider.displayName = "TooltipProvider";
9816
9817 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9818 var React57 = __toESM(require_react(), 1);
9819
9820 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
9821 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9822 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9823 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9824 return TooltipViewportCssVars2;
9825 })({});
9826
9827 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9828 var stateAttributesMapping3 = {
9829 activationDirection: (value) => value ? {
9830 "data-activation-direction": value
9831 } : null
9832 };
9833 var TooltipViewport = /* @__PURE__ */ React57.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9834 const {
9835 render: render4,
9836 className,
9837 style,
9838 children,
9839 ...elementProps
9840 } = componentProps;
9841 const store = useTooltipRootContext();
9842 const positioner = useTooltipPositionerContext();
9843 const instantType = store.useState("instantType");
9844 const {
9845 children: childrenToRender,
9846 state: viewportState
9847 } = usePopupViewport({
9848 store,
9849 side: positioner.side,
9850 cssVars: TooltipViewportCssVars,
9851 children
9852 });
9853 const state = {
9854 activationDirection: viewportState.activationDirection,
9855 transitioning: viewportState.transitioning,
9856 instant: instantType
9857 };
9858 return useRenderElement("div", componentProps, {
9859 state,
9860 ref: forwardedRef,
9861 props: [elementProps, {
9862 children: childrenToRender
9863 }],
9864 stateAttributesMapping: stateAttributesMapping3
9865 });
9866 });
9867 if (true) TooltipViewport.displayName = "TooltipViewport";
9868
9869 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
9870 var TooltipHandle = class {
9871 /**
9872 * Internal store holding the tooltip state.
9873 * @internal
9874 */
9875 constructor() {
9876 this.store = new TooltipStore();
9877 }
9878 /**
9879 * Opens the tooltip and associates it with the trigger with the given ID.
9880 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9881 *
9882 * This method should only be called in an event handler or an effect (not during rendering).
9883 *
9884 * @param triggerId ID of the trigger to associate with the tooltip.
9885 */
9886 open(triggerId) {
9887 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9888 if (triggerId && !triggerElement) {
9889 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9890 }
9891 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9892 }
9893 /**
9894 * Closes the tooltip.
9895 */
9896 close() {
9897 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9898 }
9899 /**
9900 * Indicates whether the tooltip is currently open.
9901 */
9902 get isOpen() {
9903 return this.store.select("open");
9904 }
9905 };
9906 function createTooltipHandle() {
9907 return new TooltipHandle();
9908 }
9909
9910 // node_modules/@base-ui/react/esm/use-render/useRender.js
9911 function useRender(params) {
9912 return useRenderElement(params.defaultTagName ?? "div", params, params);
9913 }
9914
9915 // packages/ui/build-module/text/text.mjs
9916 var import_element10 = __toESM(require_element(), 1);
9917 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9918 function getRuntime() {
9919 const globalScope = globalThis;
9920 if (globalScope.__wpStyleRuntime) {
9921 return globalScope.__wpStyleRuntime;
9922 }
9923 globalScope.__wpStyleRuntime = {
9924 documents: /* @__PURE__ */ new Map(),
9925 styles: /* @__PURE__ */ new Map(),
9926 injectedStyles: /* @__PURE__ */ new WeakMap()
9927 };
9928 if (typeof document !== "undefined") {
9929 registerDocument(document);
9930 }
9931 return globalScope.__wpStyleRuntime;
9932 }
9933 function documentContainsStyleHash(targetDocument, hash) {
9934 if (!targetDocument.head) {
9935 return false;
9936 }
9937 for (const style of targetDocument.head.querySelectorAll(
9938 `style[${STYLE_HASH_ATTRIBUTE}]`
9939 )) {
9940 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9941 return true;
9942 }
9943 }
9944 return false;
9945 }
9946 function injectStyle(targetDocument, hash, css) {
9947 if (!targetDocument.head) {
9948 return;
9949 }
9950 const runtime = getRuntime();
9951 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9952 if (!injectedStyles) {
9953 injectedStyles = /* @__PURE__ */ new Set();
9954 runtime.injectedStyles.set(targetDocument, injectedStyles);
9955 }
9956 if (injectedStyles.has(hash)) {
9957 return;
9958 }
9959 if (documentContainsStyleHash(targetDocument, hash)) {
9960 injectedStyles.add(hash);
9961 return;
9962 }
9963 const style = targetDocument.createElement("style");
9964 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9965 style.appendChild(targetDocument.createTextNode(css));
9966 targetDocument.head.appendChild(style);
9967 injectedStyles.add(hash);
9968 }
9969 function registerDocument(targetDocument) {
9970 const runtime = getRuntime();
9971 runtime.documents.set(
9972 targetDocument,
9973 (runtime.documents.get(targetDocument) ?? 0) + 1
9974 );
9975 for (const [hash, css] of runtime.styles) {
9976 injectStyle(targetDocument, hash, css);
9977 }
9978 return () => {
9979 const count = runtime.documents.get(targetDocument);
9980 if (count === void 0) {
9981 return;
9982 }
9983 if (count <= 1) {
9984 runtime.documents.delete(targetDocument);
9985 return;
9986 }
9987 runtime.documents.set(targetDocument, count - 1);
9988 };
9989 }
9990 function registerStyle(hash, css) {
9991 const runtime = getRuntime();
9992 runtime.styles.set(hash, css);
9993 for (const targetDocument of runtime.documents.keys()) {
9994 injectStyle(targetDocument, hash, css);
9995 }
9996 }
9997 if (typeof process === "undefined" || true) {
9998 registerStyle("0c5702ddca", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
9999 }
10000 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
10001 if (typeof process === "undefined" || true) {
10002 registerStyle("d5c1b736fd", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10003 }
10004 var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
10005 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
10006 const element = useRender({
10007 render: render4,
10008 defaultTagName: "span",
10009 ref,
10010 props: mergeProps(props, {
10011 className: clsx_default(
10012 style_default.text,
10013 global_css_defense_default.heading,
10014 global_css_defense_default.p,
10015 style_default[variant],
10016 className
10017 )
10018 })
10019 });
10020 return element;
10021 });
10022
10023 // packages/ui/build-module/badge/badge.mjs
10024 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
10025 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
10026 function getRuntime2() {
10027 const globalScope = globalThis;
10028 if (globalScope.__wpStyleRuntime) {
10029 return globalScope.__wpStyleRuntime;
10030 }
10031 globalScope.__wpStyleRuntime = {
10032 documents: /* @__PURE__ */ new Map(),
10033 styles: /* @__PURE__ */ new Map(),
10034 injectedStyles: /* @__PURE__ */ new WeakMap()
10035 };
10036 if (typeof document !== "undefined") {
10037 registerDocument2(document);
10038 }
10039 return globalScope.__wpStyleRuntime;
10040 }
10041 function documentContainsStyleHash2(targetDocument, hash) {
10042 if (!targetDocument.head) {
10043 return false;
10044 }
10045 for (const style of targetDocument.head.querySelectorAll(
10046 `style[${STYLE_HASH_ATTRIBUTE2}]`
10047 )) {
10048 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
10049 return true;
10050 }
10051 }
10052 return false;
10053 }
10054 function injectStyle2(targetDocument, hash, css) {
10055 if (!targetDocument.head) {
10056 return;
10057 }
10058 const runtime = getRuntime2();
10059 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10060 if (!injectedStyles) {
10061 injectedStyles = /* @__PURE__ */ new Set();
10062 runtime.injectedStyles.set(targetDocument, injectedStyles);
10063 }
10064 if (injectedStyles.has(hash)) {
10065 return;
10066 }
10067 if (documentContainsStyleHash2(targetDocument, hash)) {
10068 injectedStyles.add(hash);
10069 return;
10070 }
10071 const style = targetDocument.createElement("style");
10072 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
10073 style.appendChild(targetDocument.createTextNode(css));
10074 targetDocument.head.appendChild(style);
10075 injectedStyles.add(hash);
10076 }
10077 function registerDocument2(targetDocument) {
10078 const runtime = getRuntime2();
10079 runtime.documents.set(
10080 targetDocument,
10081 (runtime.documents.get(targetDocument) ?? 0) + 1
10082 );
10083 for (const [hash, css] of runtime.styles) {
10084 injectStyle2(targetDocument, hash, css);
10085 }
10086 return () => {
10087 const count = runtime.documents.get(targetDocument);
10088 if (count === void 0) {
10089 return;
10090 }
10091 if (count <= 1) {
10092 runtime.documents.delete(targetDocument);
10093 return;
10094 }
10095 runtime.documents.set(targetDocument, count - 1);
10096 };
10097 }
10098 function registerStyle2(hash, css) {
10099 const runtime = getRuntime2();
10100 runtime.styles.set(hash, css);
10101 for (const targetDocument of runtime.documents.keys()) {
10102 injectStyle2(targetDocument, hash, css);
10103 }
10104 }
10105 if (typeof process === "undefined" || true) {
10106 registerStyle2("9d817a6077", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-bg-surface-error,#f6e6e3);color:var(--wpds-color-fg-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-bg-surface-warning,#fde6be);color:var(--wpds-color-fg-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-bg-surface-caution,#fee995);color:var(--wpds-color-fg-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-bg-surface-success,#c6f7cd);color:var(--wpds-color-fg-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-bg-surface-info,#deebfa);color:var(--wpds-color-fg-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-fg-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}}");
10107 }
10108 var style_default2 = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" };
10109 var Badge = (0, import_element11.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
10110 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10111 Text,
10112 {
10113 ref,
10114 className: clsx_default(
10115 style_default2.badge,
10116 style_default2[`is-${intent}-intent`],
10117 className
10118 ),
10119 ...props,
10120 variant: "body-sm"
10121 }
10122 );
10123 });
10124
10125 // packages/ui/build-module/button/button.mjs
10126 var import_element12 = __toESM(require_element(), 1);
10127 var import_i18n = __toESM(require_i18n(), 1);
10128 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
10129 import { speak } from "@wordpress/a11y";
10130 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
10131 function getRuntime3() {
10132 const globalScope = globalThis;
10133 if (globalScope.__wpStyleRuntime) {
10134 return globalScope.__wpStyleRuntime;
10135 }
10136 globalScope.__wpStyleRuntime = {
10137 documents: /* @__PURE__ */ new Map(),
10138 styles: /* @__PURE__ */ new Map(),
10139 injectedStyles: /* @__PURE__ */ new WeakMap()
10140 };
10141 if (typeof document !== "undefined") {
10142 registerDocument3(document);
10143 }
10144 return globalScope.__wpStyleRuntime;
10145 }
10146 function documentContainsStyleHash3(targetDocument, hash) {
10147 if (!targetDocument.head) {
10148 return false;
10149 }
10150 for (const style of targetDocument.head.querySelectorAll(
10151 `style[${STYLE_HASH_ATTRIBUTE3}]`
10152 )) {
10153 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
10154 return true;
10155 }
10156 }
10157 return false;
10158 }
10159 function injectStyle3(targetDocument, hash, css) {
10160 if (!targetDocument.head) {
10161 return;
10162 }
10163 const runtime = getRuntime3();
10164 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10165 if (!injectedStyles) {
10166 injectedStyles = /* @__PURE__ */ new Set();
10167 runtime.injectedStyles.set(targetDocument, injectedStyles);
10168 }
10169 if (injectedStyles.has(hash)) {
10170 return;
10171 }
10172 if (documentContainsStyleHash3(targetDocument, hash)) {
10173 injectedStyles.add(hash);
10174 return;
10175 }
10176 const style = targetDocument.createElement("style");
10177 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
10178 style.appendChild(targetDocument.createTextNode(css));
10179 targetDocument.head.appendChild(style);
10180 injectedStyles.add(hash);
10181 }
10182 function registerDocument3(targetDocument) {
10183 const runtime = getRuntime3();
10184 runtime.documents.set(
10185 targetDocument,
10186 (runtime.documents.get(targetDocument) ?? 0) + 1
10187 );
10188 for (const [hash, css] of runtime.styles) {
10189 injectStyle3(targetDocument, hash, css);
10190 }
10191 return () => {
10192 const count = runtime.documents.get(targetDocument);
10193 if (count === void 0) {
10194 return;
10195 }
10196 if (count <= 1) {
10197 runtime.documents.delete(targetDocument);
10198 return;
10199 }
10200 runtime.documents.set(targetDocument, count - 1);
10201 };
10202 }
10203 function registerStyle3(hash, css) {
10204 const runtime = getRuntime3();
10205 runtime.styles.set(hash, css);
10206 for (const targetDocument of runtime.documents.keys()) {
10207 injectStyle3(targetDocument, hash, css);
10208 }
10209 }
10210 if (typeof process === "undefined" || true) {
10211 registerStyle3("459f56a7b7", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:499;--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-strong-disabled,#8d8d8d);--wp-ui-button-padding-block:var(--wpds-dimension-padding-xs,4px);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:40px;--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-icon-margin:-4px;--wp-ui-button-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:padding-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;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(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:transparent;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);inset-inline-start:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:24px}._9f6fc6553aeb36fe__icon{margin:var(--wp-ui-button-icon-margin)}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:32px}._914b42f315c0e580__is-loading{color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}}');
10212 }
10213 var style_default3 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "icon": "_9f6fc6553aeb36fe__icon", "is-brand": "dd460c965226cc77__is-brand", "is-outline": "_62d5a778b7b258ee__is-outline", "is-minimal": "ad0619a3217c6a5b__is-minimal", "is-neutral": "e722a8f96726aa99__is-neutral", "is-solid": "b50b3358c5fb4d0b__is-solid", "is-compact": "cf59cf1b69629838__is-compact", "loading-animation": "_5a1d53da6f830c8d__loading-animation" };
10214 if (typeof process === "undefined" || true) {
10215 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10216 }
10217 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10218 if (typeof process === "undefined" || true) {
10219 registerStyle3("693cd16544", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid transparent;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}}");
10220 }
10221 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
10222 if (typeof process === "undefined" || true) {
10223 registerStyle3("d5c1b736fd", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10224 }
10225 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
10226 var Button3 = (0, import_element12.forwardRef)(
10227 function Button22({
10228 tone = "brand",
10229 variant = "solid",
10230 size: size4 = "default",
10231 className,
10232 focusableWhenDisabled = true,
10233 disabled: disabled2,
10234 loading,
10235 loadingAnnouncement = (0, import_i18n.__)("Loading"),
10236 children,
10237 ...props
10238 }, ref) {
10239 const mergedClassName = clsx_default(
10240 global_css_defense_default2.button,
10241 resets_default["box-sizing"],
10242 focus_default["outset-ring--focus-except-active"],
10243 variant !== "unstyled" && style_default3.button,
10244 style_default3[`is-${tone}`],
10245 style_default3[`is-${variant}`],
10246 style_default3[`is-${size4}`],
10247 loading && style_default3["is-loading"],
10248 className
10249 );
10250 (0, import_element12.useEffect)(() => {
10251 if (loading && loadingAnnouncement) {
10252 speak(loadingAnnouncement);
10253 }
10254 }, [loading, loadingAnnouncement]);
10255 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
10256 Button,
10257 {
10258 ref,
10259 className: mergedClassName,
10260 focusableWhenDisabled,
10261 disabled: disabled2 ?? loading,
10262 ...props,
10263 children
10264 }
10265 );
10266 }
10267 );
10268
10269 // packages/ui/build-module/button/icon.mjs
10270 var import_element14 = __toESM(require_element(), 1);
10271
10272 // packages/ui/build-module/icon/icon.mjs
10273 var import_element13 = __toESM(require_element(), 1);
10274 var import_primitives = __toESM(require_primitives(), 1);
10275 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
10276 var Icon = (0, import_element13.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
10277 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
10278 import_primitives.SVG,
10279 {
10280 ref,
10281 fill: "currentColor",
10282 ...icon.props,
10283 ...restProps,
10284 width: size4,
10285 height: size4
10286 }
10287 );
10288 });
10289
10290 // packages/ui/build-module/button/icon.mjs
10291 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
10292 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
10293 function getRuntime4() {
10294 const globalScope = globalThis;
10295 if (globalScope.__wpStyleRuntime) {
10296 return globalScope.__wpStyleRuntime;
10297 }
10298 globalScope.__wpStyleRuntime = {
10299 documents: /* @__PURE__ */ new Map(),
10300 styles: /* @__PURE__ */ new Map(),
10301 injectedStyles: /* @__PURE__ */ new WeakMap()
10302 };
10303 if (typeof document !== "undefined") {
10304 registerDocument4(document);
10305 }
10306 return globalScope.__wpStyleRuntime;
10307 }
10308 function documentContainsStyleHash4(targetDocument, hash) {
10309 if (!targetDocument.head) {
10310 return false;
10311 }
10312 for (const style of targetDocument.head.querySelectorAll(
10313 `style[${STYLE_HASH_ATTRIBUTE4}]`
10314 )) {
10315 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
10316 return true;
10317 }
10318 }
10319 return false;
10320 }
10321 function injectStyle4(targetDocument, hash, css) {
10322 if (!targetDocument.head) {
10323 return;
10324 }
10325 const runtime = getRuntime4();
10326 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10327 if (!injectedStyles) {
10328 injectedStyles = /* @__PURE__ */ new Set();
10329 runtime.injectedStyles.set(targetDocument, injectedStyles);
10330 }
10331 if (injectedStyles.has(hash)) {
10332 return;
10333 }
10334 if (documentContainsStyleHash4(targetDocument, hash)) {
10335 injectedStyles.add(hash);
10336 return;
10337 }
10338 const style = targetDocument.createElement("style");
10339 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
10340 style.appendChild(targetDocument.createTextNode(css));
10341 targetDocument.head.appendChild(style);
10342 injectedStyles.add(hash);
10343 }
10344 function registerDocument4(targetDocument) {
10345 const runtime = getRuntime4();
10346 runtime.documents.set(
10347 targetDocument,
10348 (runtime.documents.get(targetDocument) ?? 0) + 1
10349 );
10350 for (const [hash, css] of runtime.styles) {
10351 injectStyle4(targetDocument, hash, css);
10352 }
10353 return () => {
10354 const count = runtime.documents.get(targetDocument);
10355 if (count === void 0) {
10356 return;
10357 }
10358 if (count <= 1) {
10359 runtime.documents.delete(targetDocument);
10360 return;
10361 }
10362 runtime.documents.set(targetDocument, count - 1);
10363 };
10364 }
10365 function registerStyle4(hash, css) {
10366 const runtime = getRuntime4();
10367 runtime.styles.set(hash, css);
10368 for (const targetDocument of runtime.documents.keys()) {
10369 injectStyle4(targetDocument, hash, css);
10370 }
10371 }
10372 if (typeof process === "undefined" || true) {
10373 registerStyle4("459f56a7b7", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:499;--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-strong-disabled,#8d8d8d);--wp-ui-button-padding-block:var(--wpds-dimension-padding-xs,4px);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:40px;--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-icon-margin:-4px;--wp-ui-button-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:padding-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;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(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:transparent;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);inset-inline-start:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:24px}._9f6fc6553aeb36fe__icon{margin:var(--wp-ui-button-icon-margin)}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:32px}._914b42f315c0e580__is-loading{color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}}');
10374 }
10375 var style_default4 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "icon": "_9f6fc6553aeb36fe__icon", "is-brand": "dd460c965226cc77__is-brand", "is-outline": "_62d5a778b7b258ee__is-outline", "is-minimal": "ad0619a3217c6a5b__is-minimal", "is-neutral": "e722a8f96726aa99__is-neutral", "is-solid": "b50b3358c5fb4d0b__is-solid", "is-compact": "cf59cf1b69629838__is-compact", "loading-animation": "_5a1d53da6f830c8d__loading-animation" };
10376 var ButtonIcon = (0, import_element14.forwardRef)(
10377 function ButtonIcon2({ className, icon, ...props }, ref) {
10378 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
10379 Icon,
10380 {
10381 ref,
10382 icon,
10383 className: clsx_default(style_default4.icon, className),
10384 size: 24,
10385 ...props
10386 }
10387 );
10388 }
10389 );
10390
10391 // packages/ui/build-module/button/index.mjs
10392 ButtonIcon.displayName = "Button.Icon";
10393 var Button4 = Object.assign(Button3, {
10394 /**
10395 * An icon component specifically designed to work well when rendered inside
10396 * a `Button` component.
10397 */
10398 Icon: ButtonIcon
10399 });
10400
10401 // packages/ui/build-module/card/index.mjs
10402 var card_exports = {};
10403 __export(card_exports, {
10404 Content: () => Content,
10405 FullBleed: () => FullBleed,
10406 Header: () => Header,
10407 Root: () => Root,
10408 Title: () => Title
10409 });
10410
10411 // packages/ui/build-module/card/root.mjs
10412 var import_element15 = __toESM(require_element(), 1);
10413 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
10414 function getRuntime5() {
10415 const globalScope = globalThis;
10416 if (globalScope.__wpStyleRuntime) {
10417 return globalScope.__wpStyleRuntime;
10418 }
10419 globalScope.__wpStyleRuntime = {
10420 documents: /* @__PURE__ */ new Map(),
10421 styles: /* @__PURE__ */ new Map(),
10422 injectedStyles: /* @__PURE__ */ new WeakMap()
10423 };
10424 if (typeof document !== "undefined") {
10425 registerDocument5(document);
10426 }
10427 return globalScope.__wpStyleRuntime;
10428 }
10429 function documentContainsStyleHash5(targetDocument, hash) {
10430 if (!targetDocument.head) {
10431 return false;
10432 }
10433 for (const style of targetDocument.head.querySelectorAll(
10434 `style[${STYLE_HASH_ATTRIBUTE5}]`
10435 )) {
10436 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
10437 return true;
10438 }
10439 }
10440 return false;
10441 }
10442 function injectStyle5(targetDocument, hash, css) {
10443 if (!targetDocument.head) {
10444 return;
10445 }
10446 const runtime = getRuntime5();
10447 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10448 if (!injectedStyles) {
10449 injectedStyles = /* @__PURE__ */ new Set();
10450 runtime.injectedStyles.set(targetDocument, injectedStyles);
10451 }
10452 if (injectedStyles.has(hash)) {
10453 return;
10454 }
10455 if (documentContainsStyleHash5(targetDocument, hash)) {
10456 injectedStyles.add(hash);
10457 return;
10458 }
10459 const style = targetDocument.createElement("style");
10460 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
10461 style.appendChild(targetDocument.createTextNode(css));
10462 targetDocument.head.appendChild(style);
10463 injectedStyles.add(hash);
10464 }
10465 function registerDocument5(targetDocument) {
10466 const runtime = getRuntime5();
10467 runtime.documents.set(
10468 targetDocument,
10469 (runtime.documents.get(targetDocument) ?? 0) + 1
10470 );
10471 for (const [hash, css] of runtime.styles) {
10472 injectStyle5(targetDocument, hash, css);
10473 }
10474 return () => {
10475 const count = runtime.documents.get(targetDocument);
10476 if (count === void 0) {
10477 return;
10478 }
10479 if (count <= 1) {
10480 runtime.documents.delete(targetDocument);
10481 return;
10482 }
10483 runtime.documents.set(targetDocument, count - 1);
10484 };
10485 }
10486 function registerStyle5(hash, css) {
10487 const runtime = getRuntime5();
10488 runtime.styles.set(hash, css);
10489 for (const targetDocument of runtime.documents.keys()) {
10490 injectStyle5(targetDocument, hash, css);
10491 }
10492 }
10493 if (typeof process === "undefined" || true) {
10494 registerStyle5("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10495 }
10496 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10497 if (typeof process === "undefined" || true) {
10498 registerStyle5("66ab1fd35b", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
10499 }
10500 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10501 var Root = (0, import_element15.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
10502 const mergedClassName = clsx_default(style_default5.root, resets_default2["box-sizing"]);
10503 const element = useRender({
10504 defaultTagName: "div",
10505 render: render4,
10506 ref,
10507 props: mergeProps({ className: mergedClassName }, restProps)
10508 });
10509 return element;
10510 });
10511
10512 // packages/ui/build-module/card/header.mjs
10513 var import_element16 = __toESM(require_element(), 1);
10514 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10515 function getRuntime6() {
10516 const globalScope = globalThis;
10517 if (globalScope.__wpStyleRuntime) {
10518 return globalScope.__wpStyleRuntime;
10519 }
10520 globalScope.__wpStyleRuntime = {
10521 documents: /* @__PURE__ */ new Map(),
10522 styles: /* @__PURE__ */ new Map(),
10523 injectedStyles: /* @__PURE__ */ new WeakMap()
10524 };
10525 if (typeof document !== "undefined") {
10526 registerDocument6(document);
10527 }
10528 return globalScope.__wpStyleRuntime;
10529 }
10530 function documentContainsStyleHash6(targetDocument, hash) {
10531 if (!targetDocument.head) {
10532 return false;
10533 }
10534 for (const style of targetDocument.head.querySelectorAll(
10535 `style[${STYLE_HASH_ATTRIBUTE6}]`
10536 )) {
10537 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10538 return true;
10539 }
10540 }
10541 return false;
10542 }
10543 function injectStyle6(targetDocument, hash, css) {
10544 if (!targetDocument.head) {
10545 return;
10546 }
10547 const runtime = getRuntime6();
10548 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10549 if (!injectedStyles) {
10550 injectedStyles = /* @__PURE__ */ new Set();
10551 runtime.injectedStyles.set(targetDocument, injectedStyles);
10552 }
10553 if (injectedStyles.has(hash)) {
10554 return;
10555 }
10556 if (documentContainsStyleHash6(targetDocument, hash)) {
10557 injectedStyles.add(hash);
10558 return;
10559 }
10560 const style = targetDocument.createElement("style");
10561 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10562 style.appendChild(targetDocument.createTextNode(css));
10563 targetDocument.head.appendChild(style);
10564 injectedStyles.add(hash);
10565 }
10566 function registerDocument6(targetDocument) {
10567 const runtime = getRuntime6();
10568 runtime.documents.set(
10569 targetDocument,
10570 (runtime.documents.get(targetDocument) ?? 0) + 1
10571 );
10572 for (const [hash, css] of runtime.styles) {
10573 injectStyle6(targetDocument, hash, css);
10574 }
10575 return () => {
10576 const count = runtime.documents.get(targetDocument);
10577 if (count === void 0) {
10578 return;
10579 }
10580 if (count <= 1) {
10581 runtime.documents.delete(targetDocument);
10582 return;
10583 }
10584 runtime.documents.set(targetDocument, count - 1);
10585 };
10586 }
10587 function registerStyle6(hash, css) {
10588 const runtime = getRuntime6();
10589 runtime.styles.set(hash, css);
10590 for (const targetDocument of runtime.documents.keys()) {
10591 injectStyle6(targetDocument, hash, css);
10592 }
10593 }
10594 if (typeof process === "undefined" || true) {
10595 registerStyle6("66ab1fd35b", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
10596 }
10597 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10598 var Header = (0, import_element16.forwardRef)(
10599 function CardHeader({ render: render4, ...props }, ref) {
10600 const element = useRender({
10601 defaultTagName: "div",
10602 render: render4,
10603 ref,
10604 props: mergeProps({ className: style_default6.header }, props)
10605 });
10606 return element;
10607 }
10608 );
10609
10610 // packages/ui/build-module/card/content.mjs
10611 var import_element17 = __toESM(require_element(), 1);
10612 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
10613 function getRuntime7() {
10614 const globalScope = globalThis;
10615 if (globalScope.__wpStyleRuntime) {
10616 return globalScope.__wpStyleRuntime;
10617 }
10618 globalScope.__wpStyleRuntime = {
10619 documents: /* @__PURE__ */ new Map(),
10620 styles: /* @__PURE__ */ new Map(),
10621 injectedStyles: /* @__PURE__ */ new WeakMap()
10622 };
10623 if (typeof document !== "undefined") {
10624 registerDocument7(document);
10625 }
10626 return globalScope.__wpStyleRuntime;
10627 }
10628 function documentContainsStyleHash7(targetDocument, hash) {
10629 if (!targetDocument.head) {
10630 return false;
10631 }
10632 for (const style of targetDocument.head.querySelectorAll(
10633 `style[${STYLE_HASH_ATTRIBUTE7}]`
10634 )) {
10635 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
10636 return true;
10637 }
10638 }
10639 return false;
10640 }
10641 function injectStyle7(targetDocument, hash, css) {
10642 if (!targetDocument.head) {
10643 return;
10644 }
10645 const runtime = getRuntime7();
10646 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10647 if (!injectedStyles) {
10648 injectedStyles = /* @__PURE__ */ new Set();
10649 runtime.injectedStyles.set(targetDocument, injectedStyles);
10650 }
10651 if (injectedStyles.has(hash)) {
10652 return;
10653 }
10654 if (documentContainsStyleHash7(targetDocument, hash)) {
10655 injectedStyles.add(hash);
10656 return;
10657 }
10658 const style = targetDocument.createElement("style");
10659 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
10660 style.appendChild(targetDocument.createTextNode(css));
10661 targetDocument.head.appendChild(style);
10662 injectedStyles.add(hash);
10663 }
10664 function registerDocument7(targetDocument) {
10665 const runtime = getRuntime7();
10666 runtime.documents.set(
10667 targetDocument,
10668 (runtime.documents.get(targetDocument) ?? 0) + 1
10669 );
10670 for (const [hash, css] of runtime.styles) {
10671 injectStyle7(targetDocument, hash, css);
10672 }
10673 return () => {
10674 const count = runtime.documents.get(targetDocument);
10675 if (count === void 0) {
10676 return;
10677 }
10678 if (count <= 1) {
10679 runtime.documents.delete(targetDocument);
10680 return;
10681 }
10682 runtime.documents.set(targetDocument, count - 1);
10683 };
10684 }
10685 function registerStyle7(hash, css) {
10686 const runtime = getRuntime7();
10687 runtime.styles.set(hash, css);
10688 for (const targetDocument of runtime.documents.keys()) {
10689 injectStyle7(targetDocument, hash, css);
10690 }
10691 }
10692 if (typeof process === "undefined" || true) {
10693 registerStyle7("66ab1fd35b", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
10694 }
10695 var style_default7 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10696 var Content = (0, import_element17.forwardRef)(
10697 function CardContent({ render: render4, ...props }, ref) {
10698 const element = useRender({
10699 defaultTagName: "div",
10700 render: render4,
10701 ref,
10702 props: mergeProps({ className: style_default7.content }, props)
10703 });
10704 return element;
10705 }
10706 );
10707
10708 // packages/ui/build-module/card/full-bleed.mjs
10709 var import_element18 = __toESM(require_element(), 1);
10710 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
10711 function getRuntime8() {
10712 const globalScope = globalThis;
10713 if (globalScope.__wpStyleRuntime) {
10714 return globalScope.__wpStyleRuntime;
10715 }
10716 globalScope.__wpStyleRuntime = {
10717 documents: /* @__PURE__ */ new Map(),
10718 styles: /* @__PURE__ */ new Map(),
10719 injectedStyles: /* @__PURE__ */ new WeakMap()
10720 };
10721 if (typeof document !== "undefined") {
10722 registerDocument8(document);
10723 }
10724 return globalScope.__wpStyleRuntime;
10725 }
10726 function documentContainsStyleHash8(targetDocument, hash) {
10727 if (!targetDocument.head) {
10728 return false;
10729 }
10730 for (const style of targetDocument.head.querySelectorAll(
10731 `style[${STYLE_HASH_ATTRIBUTE8}]`
10732 )) {
10733 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
10734 return true;
10735 }
10736 }
10737 return false;
10738 }
10739 function injectStyle8(targetDocument, hash, css) {
10740 if (!targetDocument.head) {
10741 return;
10742 }
10743 const runtime = getRuntime8();
10744 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10745 if (!injectedStyles) {
10746 injectedStyles = /* @__PURE__ */ new Set();
10747 runtime.injectedStyles.set(targetDocument, injectedStyles);
10748 }
10749 if (injectedStyles.has(hash)) {
10750 return;
10751 }
10752 if (documentContainsStyleHash8(targetDocument, hash)) {
10753 injectedStyles.add(hash);
10754 return;
10755 }
10756 const style = targetDocument.createElement("style");
10757 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
10758 style.appendChild(targetDocument.createTextNode(css));
10759 targetDocument.head.appendChild(style);
10760 injectedStyles.add(hash);
10761 }
10762 function registerDocument8(targetDocument) {
10763 const runtime = getRuntime8();
10764 runtime.documents.set(
10765 targetDocument,
10766 (runtime.documents.get(targetDocument) ?? 0) + 1
10767 );
10768 for (const [hash, css] of runtime.styles) {
10769 injectStyle8(targetDocument, hash, css);
10770 }
10771 return () => {
10772 const count = runtime.documents.get(targetDocument);
10773 if (count === void 0) {
10774 return;
10775 }
10776 if (count <= 1) {
10777 runtime.documents.delete(targetDocument);
10778 return;
10779 }
10780 runtime.documents.set(targetDocument, count - 1);
10781 };
10782 }
10783 function registerStyle8(hash, css) {
10784 const runtime = getRuntime8();
10785 runtime.styles.set(hash, css);
10786 for (const targetDocument of runtime.documents.keys()) {
10787 injectStyle8(targetDocument, hash, css);
10788 }
10789 }
10790 if (typeof process === "undefined" || true) {
10791 registerStyle8("66ab1fd35b", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
10792 }
10793 var style_default8 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10794 var FullBleed = (0, import_element18.forwardRef)(
10795 function CardFullBleed({ render: render4, ...props }, ref) {
10796 const element = useRender({
10797 defaultTagName: "div",
10798 render: render4,
10799 ref,
10800 props: mergeProps(
10801 { className: style_default8.fullbleed },
10802 props
10803 )
10804 });
10805 return element;
10806 }
10807 );
10808
10809 // packages/ui/build-module/card/title.mjs
10810 var import_element19 = __toESM(require_element(), 1);
10811 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
10812 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", {});
10813 var Title = (0, import_element19.forwardRef)(
10814 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
10815 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
10816 Text,
10817 {
10818 ref,
10819 variant: "heading-lg",
10820 render: render4,
10821 ...props,
10822 children
10823 }
10824 );
10825 }
10826 );
10827
10828 // packages/ui/build-module/collapsible/panel.mjs
10829 var import_element20 = __toESM(require_element(), 1);
10830 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
10831 var Panel = (0, import_element20.forwardRef)(
10832 function CollapsiblePanel3(props, forwardedRef) {
10833 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
10834 }
10835 );
10836
10837 // packages/ui/build-module/collapsible/root.mjs
10838 var import_element21 = __toESM(require_element(), 1);
10839 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
10840 var Root2 = (0, import_element21.forwardRef)(
10841 function CollapsibleRoot3(props, forwardedRef) {
10842 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
10843 }
10844 );
10845
10846 // packages/ui/build-module/collapsible/trigger.mjs
10847 var import_element22 = __toESM(require_element(), 1);
10848 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
10849 var Trigger = (0, import_element22.forwardRef)(
10850 function CollapsibleTrigger3(props, forwardedRef) {
10851 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
10852 }
10853 );
10854
10855 // packages/ui/build-module/collapsible-card/index.mjs
10856 var collapsible_card_exports = {};
10857 __export(collapsible_card_exports, {
10858 Content: () => Content2,
10859 Header: () => Header2,
10860 HeaderDescription: () => HeaderDescription,
10861 Root: () => Root3
10862 });
10863
10864 // packages/ui/build-module/collapsible-card/root.mjs
10865 var import_element23 = __toESM(require_element(), 1);
10866 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
10867 var Root3 = (0, import_element23.forwardRef)(
10868 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
10869 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
10870 Root2,
10871 {
10872 ref,
10873 render: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Root, { render: render4 }),
10874 ...restProps
10875 }
10876 );
10877 }
10878 );
10879
10880 // packages/ui/build-module/collapsible-card/header.mjs
10881 var import_element25 = __toESM(require_element(), 1);
10882
10883 // packages/icons/build-module/library/arrow-down.mjs
10884 var import_primitives2 = __toESM(require_primitives(), 1);
10885 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
10886 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives2.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
10887
10888 // packages/icons/build-module/library/arrow-left.mjs
10889 var import_primitives3 = __toESM(require_primitives(), 1);
10890 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
10891 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
10892
10893 // packages/icons/build-module/library/arrow-right.mjs
10894 var import_primitives4 = __toESM(require_primitives(), 1);
10895 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
10896 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
10897
10898 // packages/icons/build-module/library/arrow-up.mjs
10899 var import_primitives5 = __toESM(require_primitives(), 1);
10900 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
10901 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
10902
10903 // packages/icons/build-module/library/block-table.mjs
10904 var import_primitives6 = __toESM(require_primitives(), 1);
10905 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
10906 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.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" }) });
10907
10908 // packages/icons/build-module/library/category.mjs
10909 var import_primitives7 = __toESM(require_primitives(), 1);
10910 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
10911 var category_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.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" }) });
10912
10913 // packages/icons/build-module/library/check.mjs
10914 var import_primitives8 = __toESM(require_primitives(), 1);
10915 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
10916 var check_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.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" }) });
10917
10918 // packages/icons/build-module/library/chevron-down.mjs
10919 var import_primitives9 = __toESM(require_primitives(), 1);
10920 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
10921 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives9.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
10922
10923 // packages/icons/build-module/library/chevron-left.mjs
10924 var import_primitives10 = __toESM(require_primitives(), 1);
10925 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
10926 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives10.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
10927
10928 // packages/icons/build-module/library/chevron-right.mjs
10929 var import_primitives11 = __toESM(require_primitives(), 1);
10930 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
10931 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives11.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
10932
10933 // packages/icons/build-module/library/close-small.mjs
10934 var import_primitives12 = __toESM(require_primitives(), 1);
10935 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
10936 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives12.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" }) });
10937
10938 // packages/icons/build-module/library/cog.mjs
10939 var import_primitives13 = __toESM(require_primitives(), 1);
10940 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
10941 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives13.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" }) });
10942
10943 // packages/icons/build-module/library/drafts.mjs
10944 var import_primitives14 = __toESM(require_primitives(), 1);
10945 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
10946 var drafts_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives14.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 0Zm8 4a4 4 0 0 0 4-4H8a4 4 0 0 0 4 4Z" }) });
10947
10948 // packages/icons/build-module/library/envelope.mjs
10949 var import_primitives15 = __toESM(require_primitives(), 1);
10950 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
10951 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives15.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" }) });
10952
10953 // packages/icons/build-module/library/error.mjs
10954 var import_primitives16 = __toESM(require_primitives(), 1);
10955 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
10956 var error_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives16.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" }) });
10957
10958 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
10959 var import_primitives17 = __toESM(require_primitives(), 1);
10960 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
10961 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives17.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" }) });
10962
10963 // packages/icons/build-module/library/format-list-bullets.mjs
10964 var import_primitives18 = __toESM(require_primitives(), 1);
10965 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
10966 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives18.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" }) });
10967
10968 // packages/icons/build-module/library/funnel.mjs
10969 var import_primitives19 = __toESM(require_primitives(), 1);
10970 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
10971 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives19.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
10972
10973 // packages/icons/build-module/library/link.mjs
10974 var import_primitives20 = __toESM(require_primitives(), 1);
10975 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
10976 var link_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.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" }) });
10977
10978 // packages/icons/build-module/library/mobile.mjs
10979 var import_primitives21 = __toESM(require_primitives(), 1);
10980 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10981 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.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" }) });
10982
10983 // packages/icons/build-module/library/more-vertical.mjs
10984 var import_primitives22 = __toESM(require_primitives(), 1);
10985 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10986 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
10987
10988 // packages/icons/build-module/library/next.mjs
10989 var import_primitives23 = __toESM(require_primitives(), 1);
10990 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10991 var next_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.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" }) });
10992
10993 // packages/icons/build-module/library/pencil.mjs
10994 var import_primitives24 = __toESM(require_primitives(), 1);
10995 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10996 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives24.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
10997
10998 // packages/icons/build-module/library/post-featured-image.mjs
10999 var import_primitives25 = __toESM(require_primitives(), 1);
11000 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11001 var post_featured_image_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives25.Path, { d: "M19 3H5c-.6 0-1 .4-1 1v7c0 .5.4 1 1 1h14c.5 0 1-.4 1-1V4c0-.6-.4-1-1-1zM5.5 10.5v-.4l1.8-1.3 1.3.8c.3.2.7.2.9-.1L11 8.1l2.4 2.4H5.5zm13 0h-2.9l-4-4c-.3-.3-.8-.3-1.1 0L8.9 8l-1.2-.8c-.3-.2-.6-.2-.9 0l-1.3 1V4.5h13v6zM4 20h9v-1.5H4V20zm0-4h16v-1.5H4V16z" }) });
11002
11003 // packages/icons/build-module/library/previous.mjs
11004 var import_primitives26 = __toESM(require_primitives(), 1);
11005 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
11006 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives26.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" }) });
11007
11008 // packages/icons/build-module/library/scheduled.mjs
11009 var import_primitives27 = __toESM(require_primitives(), 1);
11010 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11011 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives27.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" }) });
11012
11013 // packages/icons/build-module/library/search.mjs
11014 var import_primitives28 = __toESM(require_primitives(), 1);
11015 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11016 var search_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives28.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" }) });
11017
11018 // packages/icons/build-module/library/seen.mjs
11019 var import_primitives29 = __toESM(require_primitives(), 1);
11020 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11021 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives29.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" }) });
11022
11023 // packages/icons/build-module/library/trash.mjs
11024 var import_primitives30 = __toESM(require_primitives(), 1);
11025 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11026 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives30.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" }) });
11027
11028 // packages/icons/build-module/library/unseen.mjs
11029 var import_primitives31 = __toESM(require_primitives(), 1);
11030 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11031 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives31.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" }) });
11032
11033 // packages/ui/build-module/collapsible-card/context.mjs
11034 var import_element24 = __toESM(require_element(), 1);
11035 var HeaderDescriptionIdContext = (0, import_element24.createContext)({
11036 setDescriptionId: () => {
11037 }
11038 });
11039
11040 // packages/ui/build-module/collapsible-card/header.mjs
11041 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11042 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
11043 function getRuntime9() {
11044 const globalScope = globalThis;
11045 if (globalScope.__wpStyleRuntime) {
11046 return globalScope.__wpStyleRuntime;
11047 }
11048 globalScope.__wpStyleRuntime = {
11049 documents: /* @__PURE__ */ new Map(),
11050 styles: /* @__PURE__ */ new Map(),
11051 injectedStyles: /* @__PURE__ */ new WeakMap()
11052 };
11053 if (typeof document !== "undefined") {
11054 registerDocument9(document);
11055 }
11056 return globalScope.__wpStyleRuntime;
11057 }
11058 function documentContainsStyleHash9(targetDocument, hash) {
11059 if (!targetDocument.head) {
11060 return false;
11061 }
11062 for (const style of targetDocument.head.querySelectorAll(
11063 `style[${STYLE_HASH_ATTRIBUTE9}]`
11064 )) {
11065 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
11066 return true;
11067 }
11068 }
11069 return false;
11070 }
11071 function injectStyle9(targetDocument, hash, css) {
11072 if (!targetDocument.head) {
11073 return;
11074 }
11075 const runtime = getRuntime9();
11076 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11077 if (!injectedStyles) {
11078 injectedStyles = /* @__PURE__ */ new Set();
11079 runtime.injectedStyles.set(targetDocument, injectedStyles);
11080 }
11081 if (injectedStyles.has(hash)) {
11082 return;
11083 }
11084 if (documentContainsStyleHash9(targetDocument, hash)) {
11085 injectedStyles.add(hash);
11086 return;
11087 }
11088 const style = targetDocument.createElement("style");
11089 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
11090 style.appendChild(targetDocument.createTextNode(css));
11091 targetDocument.head.appendChild(style);
11092 injectedStyles.add(hash);
11093 }
11094 function registerDocument9(targetDocument) {
11095 const runtime = getRuntime9();
11096 runtime.documents.set(
11097 targetDocument,
11098 (runtime.documents.get(targetDocument) ?? 0) + 1
11099 );
11100 for (const [hash, css] of runtime.styles) {
11101 injectStyle9(targetDocument, hash, css);
11102 }
11103 return () => {
11104 const count = runtime.documents.get(targetDocument);
11105 if (count === void 0) {
11106 return;
11107 }
11108 if (count <= 1) {
11109 runtime.documents.delete(targetDocument);
11110 return;
11111 }
11112 runtime.documents.set(targetDocument, count - 1);
11113 };
11114 }
11115 function registerStyle9(hash, css) {
11116 const runtime = getRuntime9();
11117 runtime.styles.set(hash, css);
11118 for (const targetDocument of runtime.documents.keys()) {
11119 injectStyle9(targetDocument, hash, css);
11120 }
11121 }
11122 if (typeof process === "undefined" || true) {
11123 registerStyle9("2072cdf420", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
11124 }
11125 var style_default9 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
11126 if (typeof process === "undefined" || true) {
11127 registerStyle9("d5c1b736fd", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
11128 }
11129 var global_css_defense_default3 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
11130 if (typeof process === "undefined" || true) {
11131 registerStyle9("693cd16544", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid transparent;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}}");
11132 }
11133 var focus_default2 = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
11134 var Header2 = (0, import_element25.forwardRef)(
11135 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
11136 const [descriptionId, setDescriptionId] = (0, import_element25.useState)();
11137 const contextValue = (0, import_element25.useMemo)(
11138 () => ({ setDescriptionId }),
11139 [setDescriptionId]
11140 );
11141 return useRender({
11142 defaultTagName: "div",
11143 render: render4,
11144 ref,
11145 props: mergeProps(restProps, {
11146 className: clsx_default(
11147 global_css_defense_default3.heading,
11148 style_default9["heading-wrapper"],
11149 className
11150 ),
11151 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11152 Trigger,
11153 {
11154 className: style_default9.header,
11155 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Header, {}),
11156 nativeButton: false,
11157 "aria-describedby": descriptionId,
11158 children: [
11159 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: style_default9["header-content"], children }),
11160 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11161 "div",
11162 {
11163 className: clsx_default(
11164 style_default9["header-trigger-positioner"]
11165 ),
11166 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11167 "div",
11168 {
11169 className: clsx_default(
11170 style_default9["header-trigger-wrapper"],
11171 global_css_defense_default3.div,
11172 // While the interactive trigger element is the whole header,
11173 // the focus ring will be displayed only on the icon to visually
11174 // emulate it being the button.
11175 focus_default2["outset-ring--focus-parent-visible"]
11176 ),
11177 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11178 Icon,
11179 {
11180 icon: chevron_down_default,
11181 className: style_default9["header-trigger"]
11182 }
11183 )
11184 }
11185 )
11186 }
11187 )
11188 ]
11189 }
11190 ) })
11191 })
11192 });
11193 }
11194 );
11195
11196 // packages/ui/build-module/collapsible-card/header-description.mjs
11197 var import_element26 = __toESM(require_element(), 1);
11198 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11199 var HeaderDescription = (0, import_element26.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
11200 const descriptionId = (0, import_element26.useId)();
11201 const { setDescriptionId } = (0, import_element26.useContext)(HeaderDescriptionIdContext);
11202 (0, import_element26.useEffect)(() => {
11203 setDescriptionId(descriptionId);
11204 return () => setDescriptionId(void 0);
11205 }, [descriptionId, setDescriptionId]);
11206 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11207 "div",
11208 {
11209 ref,
11210 id: descriptionId,
11211 "aria-hidden": "true",
11212 className,
11213 ...restProps,
11214 children
11215 }
11216 );
11217 });
11218
11219 // packages/ui/build-module/collapsible-card/content.mjs
11220 var import_element27 = __toESM(require_element(), 1);
11221 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11222 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
11223 function getRuntime10() {
11224 const globalScope = globalThis;
11225 if (globalScope.__wpStyleRuntime) {
11226 return globalScope.__wpStyleRuntime;
11227 }
11228 globalScope.__wpStyleRuntime = {
11229 documents: /* @__PURE__ */ new Map(),
11230 styles: /* @__PURE__ */ new Map(),
11231 injectedStyles: /* @__PURE__ */ new WeakMap()
11232 };
11233 if (typeof document !== "undefined") {
11234 registerDocument10(document);
11235 }
11236 return globalScope.__wpStyleRuntime;
11237 }
11238 function documentContainsStyleHash10(targetDocument, hash) {
11239 if (!targetDocument.head) {
11240 return false;
11241 }
11242 for (const style of targetDocument.head.querySelectorAll(
11243 `style[${STYLE_HASH_ATTRIBUTE10}]`
11244 )) {
11245 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
11246 return true;
11247 }
11248 }
11249 return false;
11250 }
11251 function injectStyle10(targetDocument, hash, css) {
11252 if (!targetDocument.head) {
11253 return;
11254 }
11255 const runtime = getRuntime10();
11256 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11257 if (!injectedStyles) {
11258 injectedStyles = /* @__PURE__ */ new Set();
11259 runtime.injectedStyles.set(targetDocument, injectedStyles);
11260 }
11261 if (injectedStyles.has(hash)) {
11262 return;
11263 }
11264 if (documentContainsStyleHash10(targetDocument, hash)) {
11265 injectedStyles.add(hash);
11266 return;
11267 }
11268 const style = targetDocument.createElement("style");
11269 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
11270 style.appendChild(targetDocument.createTextNode(css));
11271 targetDocument.head.appendChild(style);
11272 injectedStyles.add(hash);
11273 }
11274 function registerDocument10(targetDocument) {
11275 const runtime = getRuntime10();
11276 runtime.documents.set(
11277 targetDocument,
11278 (runtime.documents.get(targetDocument) ?? 0) + 1
11279 );
11280 for (const [hash, css] of runtime.styles) {
11281 injectStyle10(targetDocument, hash, css);
11282 }
11283 return () => {
11284 const count = runtime.documents.get(targetDocument);
11285 if (count === void 0) {
11286 return;
11287 }
11288 if (count <= 1) {
11289 runtime.documents.delete(targetDocument);
11290 return;
11291 }
11292 runtime.documents.set(targetDocument, count - 1);
11293 };
11294 }
11295 function registerStyle10(hash, css) {
11296 const runtime = getRuntime10();
11297 runtime.styles.set(hash, css);
11298 for (const targetDocument of runtime.documents.keys()) {
11299 injectStyle10(targetDocument, hash, css);
11300 }
11301 }
11302 if (typeof process === "undefined" || true) {
11303 registerStyle10("2072cdf420", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
11304 }
11305 var style_default10 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
11306 var Content2 = (0, import_element27.forwardRef)(
11307 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
11308 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11309 Panel,
11310 {
11311 ref,
11312 className: (state) => clsx_default(
11313 style_default10.content,
11314 state.open && state.transitionStatus === "idle" && style_default10.overflowVisible,
11315 className
11316 ),
11317 hiddenUntilFound,
11318 ...restProps,
11319 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11320 Content,
11321 {
11322 className: style_default10["content-inner"],
11323 render: render4,
11324 children
11325 }
11326 )
11327 }
11328 );
11329 }
11330 );
11331
11332 // packages/ui/build-module/utils/render-slot-with-children.mjs
11333 var import_element28 = __toESM(require_element(), 1);
11334 function renderSlotWithChildren(slot, defaultSlot, children) {
11335 return (0, import_element28.cloneElement)(slot ?? defaultSlot, { children });
11336 }
11337
11338 // packages/ui/build-module/lock-unlock.mjs
11339 var import_private_apis = __toESM(require_private_apis(), 1);
11340 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
11341 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
11342 "@wordpress/ui"
11343 );
11344
11345 // packages/ui/build-module/stack/stack.mjs
11346 var import_element29 = __toESM(require_element(), 1);
11347 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
11348 function getRuntime11() {
11349 const globalScope = globalThis;
11350 if (globalScope.__wpStyleRuntime) {
11351 return globalScope.__wpStyleRuntime;
11352 }
11353 globalScope.__wpStyleRuntime = {
11354 documents: /* @__PURE__ */ new Map(),
11355 styles: /* @__PURE__ */ new Map(),
11356 injectedStyles: /* @__PURE__ */ new WeakMap()
11357 };
11358 if (typeof document !== "undefined") {
11359 registerDocument11(document);
11360 }
11361 return globalScope.__wpStyleRuntime;
11362 }
11363 function documentContainsStyleHash11(targetDocument, hash) {
11364 if (!targetDocument.head) {
11365 return false;
11366 }
11367 for (const style of targetDocument.head.querySelectorAll(
11368 `style[${STYLE_HASH_ATTRIBUTE11}]`
11369 )) {
11370 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
11371 return true;
11372 }
11373 }
11374 return false;
11375 }
11376 function injectStyle11(targetDocument, hash, css) {
11377 if (!targetDocument.head) {
11378 return;
11379 }
11380 const runtime = getRuntime11();
11381 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11382 if (!injectedStyles) {
11383 injectedStyles = /* @__PURE__ */ new Set();
11384 runtime.injectedStyles.set(targetDocument, injectedStyles);
11385 }
11386 if (injectedStyles.has(hash)) {
11387 return;
11388 }
11389 if (documentContainsStyleHash11(targetDocument, hash)) {
11390 injectedStyles.add(hash);
11391 return;
11392 }
11393 const style = targetDocument.createElement("style");
11394 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
11395 style.appendChild(targetDocument.createTextNode(css));
11396 targetDocument.head.appendChild(style);
11397 injectedStyles.add(hash);
11398 }
11399 function registerDocument11(targetDocument) {
11400 const runtime = getRuntime11();
11401 runtime.documents.set(
11402 targetDocument,
11403 (runtime.documents.get(targetDocument) ?? 0) + 1
11404 );
11405 for (const [hash, css] of runtime.styles) {
11406 injectStyle11(targetDocument, hash, css);
11407 }
11408 return () => {
11409 const count = runtime.documents.get(targetDocument);
11410 if (count === void 0) {
11411 return;
11412 }
11413 if (count <= 1) {
11414 runtime.documents.delete(targetDocument);
11415 return;
11416 }
11417 runtime.documents.set(targetDocument, count - 1);
11418 };
11419 }
11420 function registerStyle11(hash, css) {
11421 const runtime = getRuntime11();
11422 runtime.styles.set(hash, css);
11423 for (const targetDocument of runtime.documents.keys()) {
11424 injectStyle11(targetDocument, hash, css);
11425 }
11426 }
11427 if (typeof process === "undefined" || true) {
11428 registerStyle11("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
11429 }
11430 var style_default11 = { "stack": "_19ce0419607e1896__stack" };
11431 var gapTokens = {
11432 xs: "var(--wpds-dimension-gap-xs, 4px)",
11433 sm: "var(--wpds-dimension-gap-sm, 8px)",
11434 md: "var(--wpds-dimension-gap-md, 12px)",
11435 lg: "var(--wpds-dimension-gap-lg, 16px)",
11436 xl: "var(--wpds-dimension-gap-xl, 24px)",
11437 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
11438 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
11439 };
11440 var Stack = (0, import_element29.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
11441 const style = {
11442 gap: gap && gapTokens[gap],
11443 alignItems: align,
11444 justifyContent: justify,
11445 flexDirection: direction,
11446 flexWrap: wrap
11447 };
11448 const element = useRender({
11449 render: render4,
11450 ref,
11451 props: mergeProps(props, { style, className: style_default11.stack })
11452 });
11453 return element;
11454 });
11455
11456 // packages/ui/build-module/icon-button/icon-button.mjs
11457 var import_element34 = __toESM(require_element(), 1);
11458
11459 // packages/ui/build-module/tooltip/index.mjs
11460 var tooltip_exports = {};
11461 __export(tooltip_exports, {
11462 Popup: () => Popup,
11463 Portal: () => Portal,
11464 Positioner: () => Positioner,
11465 Provider: () => Provider,
11466 Root: () => Root4,
11467 Trigger: () => Trigger2
11468 });
11469
11470 // packages/ui/build-module/tooltip/popup.mjs
11471 var import_element32 = __toESM(require_element(), 1);
11472 var import_theme = __toESM(require_theme(), 1);
11473
11474 // packages/ui/build-module/tooltip/portal.mjs
11475 var import_element30 = __toESM(require_element(), 1);
11476
11477 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
11478 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
11479 function getRuntime12() {
11480 const globalScope = globalThis;
11481 if (globalScope.__wpStyleRuntime) {
11482 return globalScope.__wpStyleRuntime;
11483 }
11484 globalScope.__wpStyleRuntime = {
11485 documents: /* @__PURE__ */ new Map(),
11486 styles: /* @__PURE__ */ new Map(),
11487 injectedStyles: /* @__PURE__ */ new WeakMap()
11488 };
11489 if (typeof document !== "undefined") {
11490 registerDocument12(document);
11491 }
11492 return globalScope.__wpStyleRuntime;
11493 }
11494 function documentContainsStyleHash12(targetDocument, hash) {
11495 if (!targetDocument.head) {
11496 return false;
11497 }
11498 for (const style of targetDocument.head.querySelectorAll(
11499 `style[${STYLE_HASH_ATTRIBUTE12}]`
11500 )) {
11501 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
11502 return true;
11503 }
11504 }
11505 return false;
11506 }
11507 function injectStyle12(targetDocument, hash, css) {
11508 if (!targetDocument.head) {
11509 return;
11510 }
11511 const runtime = getRuntime12();
11512 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11513 if (!injectedStyles) {
11514 injectedStyles = /* @__PURE__ */ new Set();
11515 runtime.injectedStyles.set(targetDocument, injectedStyles);
11516 }
11517 if (injectedStyles.has(hash)) {
11518 return;
11519 }
11520 if (documentContainsStyleHash12(targetDocument, hash)) {
11521 injectedStyles.add(hash);
11522 return;
11523 }
11524 const style = targetDocument.createElement("style");
11525 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
11526 style.appendChild(targetDocument.createTextNode(css));
11527 targetDocument.head.appendChild(style);
11528 injectedStyles.add(hash);
11529 }
11530 function registerDocument12(targetDocument) {
11531 const runtime = getRuntime12();
11532 runtime.documents.set(
11533 targetDocument,
11534 (runtime.documents.get(targetDocument) ?? 0) + 1
11535 );
11536 for (const [hash, css] of runtime.styles) {
11537 injectStyle12(targetDocument, hash, css);
11538 }
11539 return () => {
11540 const count = runtime.documents.get(targetDocument);
11541 if (count === void 0) {
11542 return;
11543 }
11544 if (count <= 1) {
11545 runtime.documents.delete(targetDocument);
11546 return;
11547 }
11548 runtime.documents.set(targetDocument, count - 1);
11549 };
11550 }
11551 function registerStyle12(hash, css) {
11552 const runtime = getRuntime12();
11553 runtime.styles.set(hash, css);
11554 for (const targetDocument of runtime.documents.keys()) {
11555 injectStyle12(targetDocument, hash, css);
11556 }
11557 }
11558 if (typeof process === "undefined" || true) {
11559 registerStyle12("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
11560 }
11561 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
11562 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
11563 function resolveOwnerDocument() {
11564 return typeof document === "undefined" ? null : document;
11565 }
11566 function isInWordPressEnvironment() {
11567 let topWp;
11568 try {
11569 topWp = window.top?.wp;
11570 } catch {
11571 }
11572 const wp = topWp ?? window.wp;
11573 return typeof wp?.components === "object" && wp.components !== null;
11574 }
11575 var cachedSlot = null;
11576 function createSlot(ownerDocument2) {
11577 const element = ownerDocument2.createElement("div");
11578 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
11579 if (wp_compat_overlay_slot_default.slot) {
11580 element.classList.add(wp_compat_overlay_slot_default.slot);
11581 }
11582 ownerDocument2.body.appendChild(element);
11583 return element;
11584 }
11585 function getWpCompatOverlaySlot() {
11586 if (typeof window === "undefined") {
11587 return void 0;
11588 }
11589 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
11590 return void 0;
11591 }
11592 const ownerDocument2 = resolveOwnerDocument();
11593 if (!ownerDocument2 || !ownerDocument2.body) {
11594 return void 0;
11595 }
11596 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
11597 return cachedSlot;
11598 }
11599 const existing = ownerDocument2.querySelector(
11600 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
11601 );
11602 if (existing instanceof HTMLDivElement) {
11603 cachedSlot = existing;
11604 return existing;
11605 }
11606 if (cachedSlot?.isConnected) {
11607 cachedSlot.remove();
11608 }
11609 cachedSlot = createSlot(ownerDocument2);
11610 return cachedSlot;
11611 }
11612
11613 // packages/ui/build-module/tooltip/portal.mjs
11614 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11615 var Portal = (0, import_element30.forwardRef)(
11616 function TooltipPortal3({ container, ...restProps }, ref) {
11617 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11618 index_parts_exports2.Portal,
11619 {
11620 container: container ?? getWpCompatOverlaySlot(),
11621 ...restProps,
11622 ref
11623 }
11624 );
11625 }
11626 );
11627
11628 // packages/ui/build-module/tooltip/positioner.mjs
11629 var import_element31 = __toESM(require_element(), 1);
11630 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11631 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
11632 function getRuntime13() {
11633 const globalScope = globalThis;
11634 if (globalScope.__wpStyleRuntime) {
11635 return globalScope.__wpStyleRuntime;
11636 }
11637 globalScope.__wpStyleRuntime = {
11638 documents: /* @__PURE__ */ new Map(),
11639 styles: /* @__PURE__ */ new Map(),
11640 injectedStyles: /* @__PURE__ */ new WeakMap()
11641 };
11642 if (typeof document !== "undefined") {
11643 registerDocument13(document);
11644 }
11645 return globalScope.__wpStyleRuntime;
11646 }
11647 function documentContainsStyleHash13(targetDocument, hash) {
11648 if (!targetDocument.head) {
11649 return false;
11650 }
11651 for (const style of targetDocument.head.querySelectorAll(
11652 `style[${STYLE_HASH_ATTRIBUTE13}]`
11653 )) {
11654 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
11655 return true;
11656 }
11657 }
11658 return false;
11659 }
11660 function injectStyle13(targetDocument, hash, css) {
11661 if (!targetDocument.head) {
11662 return;
11663 }
11664 const runtime = getRuntime13();
11665 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11666 if (!injectedStyles) {
11667 injectedStyles = /* @__PURE__ */ new Set();
11668 runtime.injectedStyles.set(targetDocument, injectedStyles);
11669 }
11670 if (injectedStyles.has(hash)) {
11671 return;
11672 }
11673 if (documentContainsStyleHash13(targetDocument, hash)) {
11674 injectedStyles.add(hash);
11675 return;
11676 }
11677 const style = targetDocument.createElement("style");
11678 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
11679 style.appendChild(targetDocument.createTextNode(css));
11680 targetDocument.head.appendChild(style);
11681 injectedStyles.add(hash);
11682 }
11683 function registerDocument13(targetDocument) {
11684 const runtime = getRuntime13();
11685 runtime.documents.set(
11686 targetDocument,
11687 (runtime.documents.get(targetDocument) ?? 0) + 1
11688 );
11689 for (const [hash, css] of runtime.styles) {
11690 injectStyle13(targetDocument, hash, css);
11691 }
11692 return () => {
11693 const count = runtime.documents.get(targetDocument);
11694 if (count === void 0) {
11695 return;
11696 }
11697 if (count <= 1) {
11698 runtime.documents.delete(targetDocument);
11699 return;
11700 }
11701 runtime.documents.set(targetDocument, count - 1);
11702 };
11703 }
11704 function registerStyle13(hash, css) {
11705 const runtime = getRuntime13();
11706 runtime.styles.set(hash, css);
11707 for (const targetDocument of runtime.documents.keys()) {
11708 injectStyle13(targetDocument, hash, css);
11709 }
11710 }
11711 if (typeof process === "undefined" || true) {
11712 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
11713 }
11714 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
11715 if (typeof process === "undefined" || true) {
11716 registerStyle13("4811d023d1", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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-md,4px);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}}}}');
11717 }
11718 var style_default12 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
11719 var Positioner = (0, import_element31.forwardRef)(
11720 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
11721 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11722 index_parts_exports2.Positioner,
11723 {
11724 ref,
11725 align,
11726 side,
11727 sideOffset,
11728 ...props,
11729 className: clsx_default(
11730 resets_default3["box-sizing"],
11731 style_default12.positioner,
11732 className
11733 )
11734 }
11735 );
11736 }
11737 );
11738
11739 // packages/ui/build-module/tooltip/popup.mjs
11740 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
11741 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
11742 function getRuntime14() {
11743 const globalScope = globalThis;
11744 if (globalScope.__wpStyleRuntime) {
11745 return globalScope.__wpStyleRuntime;
11746 }
11747 globalScope.__wpStyleRuntime = {
11748 documents: /* @__PURE__ */ new Map(),
11749 styles: /* @__PURE__ */ new Map(),
11750 injectedStyles: /* @__PURE__ */ new WeakMap()
11751 };
11752 if (typeof document !== "undefined") {
11753 registerDocument14(document);
11754 }
11755 return globalScope.__wpStyleRuntime;
11756 }
11757 function documentContainsStyleHash14(targetDocument, hash) {
11758 if (!targetDocument.head) {
11759 return false;
11760 }
11761 for (const style of targetDocument.head.querySelectorAll(
11762 `style[${STYLE_HASH_ATTRIBUTE14}]`
11763 )) {
11764 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
11765 return true;
11766 }
11767 }
11768 return false;
11769 }
11770 function injectStyle14(targetDocument, hash, css) {
11771 if (!targetDocument.head) {
11772 return;
11773 }
11774 const runtime = getRuntime14();
11775 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11776 if (!injectedStyles) {
11777 injectedStyles = /* @__PURE__ */ new Set();
11778 runtime.injectedStyles.set(targetDocument, injectedStyles);
11779 }
11780 if (injectedStyles.has(hash)) {
11781 return;
11782 }
11783 if (documentContainsStyleHash14(targetDocument, hash)) {
11784 injectedStyles.add(hash);
11785 return;
11786 }
11787 const style = targetDocument.createElement("style");
11788 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
11789 style.appendChild(targetDocument.createTextNode(css));
11790 targetDocument.head.appendChild(style);
11791 injectedStyles.add(hash);
11792 }
11793 function registerDocument14(targetDocument) {
11794 const runtime = getRuntime14();
11795 runtime.documents.set(
11796 targetDocument,
11797 (runtime.documents.get(targetDocument) ?? 0) + 1
11798 );
11799 for (const [hash, css] of runtime.styles) {
11800 injectStyle14(targetDocument, hash, css);
11801 }
11802 return () => {
11803 const count = runtime.documents.get(targetDocument);
11804 if (count === void 0) {
11805 return;
11806 }
11807 if (count <= 1) {
11808 runtime.documents.delete(targetDocument);
11809 return;
11810 }
11811 runtime.documents.set(targetDocument, count - 1);
11812 };
11813 }
11814 function registerStyle14(hash, css) {
11815 const runtime = getRuntime14();
11816 runtime.styles.set(hash, css);
11817 for (const targetDocument of runtime.documents.keys()) {
11818 injectStyle14(targetDocument, hash, css);
11819 }
11820 }
11821 if (typeof process === "undefined" || true) {
11822 registerStyle14("4811d023d1", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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-md,4px);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}}}}');
11823 }
11824 var style_default13 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
11825 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
11826 var POPUP_COLOR = { background: "#1e1e1e" };
11827 var Popup = (0, import_element32.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
11828 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
11829 index_parts_exports2.Popup,
11830 {
11831 ref,
11832 className: clsx_default(style_default13.popup, className),
11833 ...props,
11834 children
11835 }
11836 ) });
11837 const positionedPopup = renderSlotWithChildren(
11838 positioner,
11839 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Positioner, {}),
11840 popupContent
11841 );
11842 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Portal, {}), positionedPopup);
11843 });
11844
11845 // packages/ui/build-module/tooltip/trigger.mjs
11846 var import_element33 = __toESM(require_element(), 1);
11847 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
11848 var Trigger2 = (0, import_element33.forwardRef)(
11849 function TooltipTrigger3(props, ref) {
11850 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(index_parts_exports2.Trigger, { ref, ...props });
11851 }
11852 );
11853
11854 // packages/ui/build-module/tooltip/root.mjs
11855 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
11856 function Root4(props) {
11857 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(index_parts_exports2.Root, { ...props });
11858 }
11859
11860 // packages/ui/build-module/tooltip/provider.mjs
11861 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
11862 function Provider({ ...props }) {
11863 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(index_parts_exports2.Provider, { ...props });
11864 }
11865
11866 // packages/ui/build-module/icon-button/icon-button.mjs
11867 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
11868 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash";
11869 function getRuntime15() {
11870 const globalScope = globalThis;
11871 if (globalScope.__wpStyleRuntime) {
11872 return globalScope.__wpStyleRuntime;
11873 }
11874 globalScope.__wpStyleRuntime = {
11875 documents: /* @__PURE__ */ new Map(),
11876 styles: /* @__PURE__ */ new Map(),
11877 injectedStyles: /* @__PURE__ */ new WeakMap()
11878 };
11879 if (typeof document !== "undefined") {
11880 registerDocument15(document);
11881 }
11882 return globalScope.__wpStyleRuntime;
11883 }
11884 function documentContainsStyleHash15(targetDocument, hash) {
11885 if (!targetDocument.head) {
11886 return false;
11887 }
11888 for (const style of targetDocument.head.querySelectorAll(
11889 `style[${STYLE_HASH_ATTRIBUTE15}]`
11890 )) {
11891 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) {
11892 return true;
11893 }
11894 }
11895 return false;
11896 }
11897 function injectStyle15(targetDocument, hash, css) {
11898 if (!targetDocument.head) {
11899 return;
11900 }
11901 const runtime = getRuntime15();
11902 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11903 if (!injectedStyles) {
11904 injectedStyles = /* @__PURE__ */ new Set();
11905 runtime.injectedStyles.set(targetDocument, injectedStyles);
11906 }
11907 if (injectedStyles.has(hash)) {
11908 return;
11909 }
11910 if (documentContainsStyleHash15(targetDocument, hash)) {
11911 injectedStyles.add(hash);
11912 return;
11913 }
11914 const style = targetDocument.createElement("style");
11915 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash);
11916 style.appendChild(targetDocument.createTextNode(css));
11917 targetDocument.head.appendChild(style);
11918 injectedStyles.add(hash);
11919 }
11920 function registerDocument15(targetDocument) {
11921 const runtime = getRuntime15();
11922 runtime.documents.set(
11923 targetDocument,
11924 (runtime.documents.get(targetDocument) ?? 0) + 1
11925 );
11926 for (const [hash, css] of runtime.styles) {
11927 injectStyle15(targetDocument, hash, css);
11928 }
11929 return () => {
11930 const count = runtime.documents.get(targetDocument);
11931 if (count === void 0) {
11932 return;
11933 }
11934 if (count <= 1) {
11935 runtime.documents.delete(targetDocument);
11936 return;
11937 }
11938 runtime.documents.set(targetDocument, count - 1);
11939 };
11940 }
11941 function registerStyle15(hash, css) {
11942 const runtime = getRuntime15();
11943 runtime.styles.set(hash, css);
11944 for (const targetDocument of runtime.documents.keys()) {
11945 injectStyle15(targetDocument, hash, css);
11946 }
11947 }
11948 if (typeof process === "undefined" || true) {
11949 registerStyle15("65cec4cf71", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer compositions{._28cfdc260e755391__icon-button{--wp-ui-button-aspect-ratio:1;--wp-ui-button-padding-inline:0;--wp-ui-button-min-width:unset}.f1c70d719989a85a__icon{margin:-1px}}}");
11950 }
11951 var style_default14 = { "icon-button": "_28cfdc260e755391__icon-button", "icon": "f1c70d719989a85a__icon" };
11952 var IconButton = (0, import_element34.forwardRef)(
11953 function IconButton2({
11954 label,
11955 className,
11956 // Prevent accidental forwarding of `children`
11957 children: _children,
11958 disabled: disabled2,
11959 focusableWhenDisabled = true,
11960 icon,
11961 size: size4,
11962 shortcut,
11963 positioner,
11964 ...restProps
11965 }, ref) {
11966 const classes = clsx_default(style_default14["icon-button"], className);
11967 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Root4, { children: [
11968 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
11969 Trigger2,
11970 {
11971 ref,
11972 disabled: disabled2 && !focusableWhenDisabled,
11973 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
11974 Button4,
11975 {
11976 ...restProps,
11977 size: size4,
11978 "aria-label": label,
11979 "aria-keyshortcuts": shortcut?.ariaKeyShortcut,
11980 disabled: disabled2,
11981 focusableWhenDisabled
11982 }
11983 ),
11984 className: classes,
11985 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
11986 Icon,
11987 {
11988 icon,
11989 size: 24,
11990 className: style_default14.icon
11991 }
11992 )
11993 }
11994 ),
11995 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Popup, { positioner, children: [
11996 label,
11997 shortcut && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
11998 " ",
11999 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { "aria-hidden": "true", children: shortcut.displayShortcut })
12000 ] })
12001 ] })
12002 ] }) });
12003 }
12004 );
12005
12006 // packages/ui/build-module/empty-state/index.mjs
12007 var empty_state_exports = {};
12008 __export(empty_state_exports, {
12009 Actions: () => Actions,
12010 Description: () => Description,
12011 Icon: () => Icon3,
12012 Root: () => Root5,
12013 Title: () => Title2,
12014 Visual: () => Visual
12015 });
12016
12017 // packages/ui/build-module/empty-state/root.mjs
12018 var import_element35 = __toESM(require_element(), 1);
12019 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash";
12020 function getRuntime16() {
12021 const globalScope = globalThis;
12022 if (globalScope.__wpStyleRuntime) {
12023 return globalScope.__wpStyleRuntime;
12024 }
12025 globalScope.__wpStyleRuntime = {
12026 documents: /* @__PURE__ */ new Map(),
12027 styles: /* @__PURE__ */ new Map(),
12028 injectedStyles: /* @__PURE__ */ new WeakMap()
12029 };
12030 if (typeof document !== "undefined") {
12031 registerDocument16(document);
12032 }
12033 return globalScope.__wpStyleRuntime;
12034 }
12035 function documentContainsStyleHash16(targetDocument, hash) {
12036 if (!targetDocument.head) {
12037 return false;
12038 }
12039 for (const style of targetDocument.head.querySelectorAll(
12040 `style[${STYLE_HASH_ATTRIBUTE16}]`
12041 )) {
12042 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) {
12043 return true;
12044 }
12045 }
12046 return false;
12047 }
12048 function injectStyle16(targetDocument, hash, css) {
12049 if (!targetDocument.head) {
12050 return;
12051 }
12052 const runtime = getRuntime16();
12053 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12054 if (!injectedStyles) {
12055 injectedStyles = /* @__PURE__ */ new Set();
12056 runtime.injectedStyles.set(targetDocument, injectedStyles);
12057 }
12058 if (injectedStyles.has(hash)) {
12059 return;
12060 }
12061 if (documentContainsStyleHash16(targetDocument, hash)) {
12062 injectedStyles.add(hash);
12063 return;
12064 }
12065 const style = targetDocument.createElement("style");
12066 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash);
12067 style.appendChild(targetDocument.createTextNode(css));
12068 targetDocument.head.appendChild(style);
12069 injectedStyles.add(hash);
12070 }
12071 function registerDocument16(targetDocument) {
12072 const runtime = getRuntime16();
12073 runtime.documents.set(
12074 targetDocument,
12075 (runtime.documents.get(targetDocument) ?? 0) + 1
12076 );
12077 for (const [hash, css] of runtime.styles) {
12078 injectStyle16(targetDocument, hash, css);
12079 }
12080 return () => {
12081 const count = runtime.documents.get(targetDocument);
12082 if (count === void 0) {
12083 return;
12084 }
12085 if (count <= 1) {
12086 runtime.documents.delete(targetDocument);
12087 return;
12088 }
12089 runtime.documents.set(targetDocument, count - 1);
12090 };
12091 }
12092 function registerStyle16(hash, css) {
12093 const runtime = getRuntime16();
12094 runtime.styles.set(hash, css);
12095 for (const targetDocument of runtime.documents.keys()) {
12096 injectStyle16(targetDocument, hash, css);
12097 }
12098 }
12099 if (typeof process === "undefined" || true) {
12100 registerStyle16("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12101 }
12102 var style_default15 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12103 var Root5 = (0, import_element35.forwardRef)(
12104 function EmptyStateRoot({ render: render4, ...props }, ref) {
12105 const className = clsx_default(style_default15.root);
12106 const element = useRender({
12107 defaultTagName: "div",
12108 render: render4,
12109 ref,
12110 props: mergeProps({ className }, props)
12111 });
12112 return element;
12113 }
12114 );
12115
12116 // packages/ui/build-module/empty-state/visual.mjs
12117 var import_element36 = __toESM(require_element(), 1);
12118 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash";
12119 function getRuntime17() {
12120 const globalScope = globalThis;
12121 if (globalScope.__wpStyleRuntime) {
12122 return globalScope.__wpStyleRuntime;
12123 }
12124 globalScope.__wpStyleRuntime = {
12125 documents: /* @__PURE__ */ new Map(),
12126 styles: /* @__PURE__ */ new Map(),
12127 injectedStyles: /* @__PURE__ */ new WeakMap()
12128 };
12129 if (typeof document !== "undefined") {
12130 registerDocument17(document);
12131 }
12132 return globalScope.__wpStyleRuntime;
12133 }
12134 function documentContainsStyleHash17(targetDocument, hash) {
12135 if (!targetDocument.head) {
12136 return false;
12137 }
12138 for (const style of targetDocument.head.querySelectorAll(
12139 `style[${STYLE_HASH_ATTRIBUTE17}]`
12140 )) {
12141 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) {
12142 return true;
12143 }
12144 }
12145 return false;
12146 }
12147 function injectStyle17(targetDocument, hash, css) {
12148 if (!targetDocument.head) {
12149 return;
12150 }
12151 const runtime = getRuntime17();
12152 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12153 if (!injectedStyles) {
12154 injectedStyles = /* @__PURE__ */ new Set();
12155 runtime.injectedStyles.set(targetDocument, injectedStyles);
12156 }
12157 if (injectedStyles.has(hash)) {
12158 return;
12159 }
12160 if (documentContainsStyleHash17(targetDocument, hash)) {
12161 injectedStyles.add(hash);
12162 return;
12163 }
12164 const style = targetDocument.createElement("style");
12165 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash);
12166 style.appendChild(targetDocument.createTextNode(css));
12167 targetDocument.head.appendChild(style);
12168 injectedStyles.add(hash);
12169 }
12170 function registerDocument17(targetDocument) {
12171 const runtime = getRuntime17();
12172 runtime.documents.set(
12173 targetDocument,
12174 (runtime.documents.get(targetDocument) ?? 0) + 1
12175 );
12176 for (const [hash, css] of runtime.styles) {
12177 injectStyle17(targetDocument, hash, css);
12178 }
12179 return () => {
12180 const count = runtime.documents.get(targetDocument);
12181 if (count === void 0) {
12182 return;
12183 }
12184 if (count <= 1) {
12185 runtime.documents.delete(targetDocument);
12186 return;
12187 }
12188 runtime.documents.set(targetDocument, count - 1);
12189 };
12190 }
12191 function registerStyle17(hash, css) {
12192 const runtime = getRuntime17();
12193 runtime.styles.set(hash, css);
12194 for (const targetDocument of runtime.documents.keys()) {
12195 injectStyle17(targetDocument, hash, css);
12196 }
12197 }
12198 if (typeof process === "undefined" || true) {
12199 registerStyle17("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12200 }
12201 var style_default16 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12202 var Visual = (0, import_element36.forwardRef)(
12203 function EmptyStateVisual({ render: render4, ...props }, ref) {
12204 const className = clsx_default(style_default16.visual);
12205 const element = useRender({
12206 defaultTagName: "div",
12207 render: render4,
12208 ref,
12209 props: mergeProps({ className }, props)
12210 });
12211 return element;
12212 }
12213 );
12214
12215 // packages/ui/build-module/empty-state/icon.mjs
12216 var import_element37 = __toESM(require_element(), 1);
12217 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
12218 var STYLE_HASH_ATTRIBUTE18 = "data-wp-hash";
12219 function getRuntime18() {
12220 const globalScope = globalThis;
12221 if (globalScope.__wpStyleRuntime) {
12222 return globalScope.__wpStyleRuntime;
12223 }
12224 globalScope.__wpStyleRuntime = {
12225 documents: /* @__PURE__ */ new Map(),
12226 styles: /* @__PURE__ */ new Map(),
12227 injectedStyles: /* @__PURE__ */ new WeakMap()
12228 };
12229 if (typeof document !== "undefined") {
12230 registerDocument18(document);
12231 }
12232 return globalScope.__wpStyleRuntime;
12233 }
12234 function documentContainsStyleHash18(targetDocument, hash) {
12235 if (!targetDocument.head) {
12236 return false;
12237 }
12238 for (const style of targetDocument.head.querySelectorAll(
12239 `style[${STYLE_HASH_ATTRIBUTE18}]`
12240 )) {
12241 if (style.getAttribute(STYLE_HASH_ATTRIBUTE18) === hash) {
12242 return true;
12243 }
12244 }
12245 return false;
12246 }
12247 function injectStyle18(targetDocument, hash, css) {
12248 if (!targetDocument.head) {
12249 return;
12250 }
12251 const runtime = getRuntime18();
12252 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12253 if (!injectedStyles) {
12254 injectedStyles = /* @__PURE__ */ new Set();
12255 runtime.injectedStyles.set(targetDocument, injectedStyles);
12256 }
12257 if (injectedStyles.has(hash)) {
12258 return;
12259 }
12260 if (documentContainsStyleHash18(targetDocument, hash)) {
12261 injectedStyles.add(hash);
12262 return;
12263 }
12264 const style = targetDocument.createElement("style");
12265 style.setAttribute(STYLE_HASH_ATTRIBUTE18, hash);
12266 style.appendChild(targetDocument.createTextNode(css));
12267 targetDocument.head.appendChild(style);
12268 injectedStyles.add(hash);
12269 }
12270 function registerDocument18(targetDocument) {
12271 const runtime = getRuntime18();
12272 runtime.documents.set(
12273 targetDocument,
12274 (runtime.documents.get(targetDocument) ?? 0) + 1
12275 );
12276 for (const [hash, css] of runtime.styles) {
12277 injectStyle18(targetDocument, hash, css);
12278 }
12279 return () => {
12280 const count = runtime.documents.get(targetDocument);
12281 if (count === void 0) {
12282 return;
12283 }
12284 if (count <= 1) {
12285 runtime.documents.delete(targetDocument);
12286 return;
12287 }
12288 runtime.documents.set(targetDocument, count - 1);
12289 };
12290 }
12291 function registerStyle18(hash, css) {
12292 const runtime = getRuntime18();
12293 runtime.styles.set(hash, css);
12294 for (const targetDocument of runtime.documents.keys()) {
12295 injectStyle18(targetDocument, hash, css);
12296 }
12297 }
12298 if (typeof process === "undefined" || true) {
12299 registerStyle18("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12300 }
12301 var style_default17 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12302 var Icon3 = (0, import_element37.forwardRef)(
12303 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
12304 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
12305 Visual,
12306 {
12307 ref,
12308 className: clsx_default(style_default17.icon, className),
12309 ...restProps,
12310 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Icon, { icon })
12311 }
12312 );
12313 }
12314 );
12315
12316 // packages/ui/build-module/empty-state/title.mjs
12317 var import_element38 = __toESM(require_element(), 1);
12318 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
12319 var STYLE_HASH_ATTRIBUTE19 = "data-wp-hash";
12320 function getRuntime19() {
12321 const globalScope = globalThis;
12322 if (globalScope.__wpStyleRuntime) {
12323 return globalScope.__wpStyleRuntime;
12324 }
12325 globalScope.__wpStyleRuntime = {
12326 documents: /* @__PURE__ */ new Map(),
12327 styles: /* @__PURE__ */ new Map(),
12328 injectedStyles: /* @__PURE__ */ new WeakMap()
12329 };
12330 if (typeof document !== "undefined") {
12331 registerDocument19(document);
12332 }
12333 return globalScope.__wpStyleRuntime;
12334 }
12335 function documentContainsStyleHash19(targetDocument, hash) {
12336 if (!targetDocument.head) {
12337 return false;
12338 }
12339 for (const style of targetDocument.head.querySelectorAll(
12340 `style[${STYLE_HASH_ATTRIBUTE19}]`
12341 )) {
12342 if (style.getAttribute(STYLE_HASH_ATTRIBUTE19) === hash) {
12343 return true;
12344 }
12345 }
12346 return false;
12347 }
12348 function injectStyle19(targetDocument, hash, css) {
12349 if (!targetDocument.head) {
12350 return;
12351 }
12352 const runtime = getRuntime19();
12353 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12354 if (!injectedStyles) {
12355 injectedStyles = /* @__PURE__ */ new Set();
12356 runtime.injectedStyles.set(targetDocument, injectedStyles);
12357 }
12358 if (injectedStyles.has(hash)) {
12359 return;
12360 }
12361 if (documentContainsStyleHash19(targetDocument, hash)) {
12362 injectedStyles.add(hash);
12363 return;
12364 }
12365 const style = targetDocument.createElement("style");
12366 style.setAttribute(STYLE_HASH_ATTRIBUTE19, hash);
12367 style.appendChild(targetDocument.createTextNode(css));
12368 targetDocument.head.appendChild(style);
12369 injectedStyles.add(hash);
12370 }
12371 function registerDocument19(targetDocument) {
12372 const runtime = getRuntime19();
12373 runtime.documents.set(
12374 targetDocument,
12375 (runtime.documents.get(targetDocument) ?? 0) + 1
12376 );
12377 for (const [hash, css] of runtime.styles) {
12378 injectStyle19(targetDocument, hash, css);
12379 }
12380 return () => {
12381 const count = runtime.documents.get(targetDocument);
12382 if (count === void 0) {
12383 return;
12384 }
12385 if (count <= 1) {
12386 runtime.documents.delete(targetDocument);
12387 return;
12388 }
12389 runtime.documents.set(targetDocument, count - 1);
12390 };
12391 }
12392 function registerStyle19(hash, css) {
12393 const runtime = getRuntime19();
12394 runtime.styles.set(hash, css);
12395 for (const targetDocument of runtime.documents.keys()) {
12396 injectStyle19(targetDocument, hash, css);
12397 }
12398 }
12399 if (typeof process === "undefined" || true) {
12400 registerStyle19("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12401 }
12402 var style_default18 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12403 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("h2", {});
12404 var Title2 = (0, import_element38.forwardRef)(
12405 function EmptyStateTitle({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
12406 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
12407 Text,
12408 {
12409 ref,
12410 variant: "heading-lg",
12411 render: render4,
12412 className: clsx_default(style_default18.title, className),
12413 ...props,
12414 children
12415 }
12416 );
12417 }
12418 );
12419
12420 // packages/ui/build-module/empty-state/description.mjs
12421 var import_element39 = __toESM(require_element(), 1);
12422 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
12423 var STYLE_HASH_ATTRIBUTE20 = "data-wp-hash";
12424 function getRuntime20() {
12425 const globalScope = globalThis;
12426 if (globalScope.__wpStyleRuntime) {
12427 return globalScope.__wpStyleRuntime;
12428 }
12429 globalScope.__wpStyleRuntime = {
12430 documents: /* @__PURE__ */ new Map(),
12431 styles: /* @__PURE__ */ new Map(),
12432 injectedStyles: /* @__PURE__ */ new WeakMap()
12433 };
12434 if (typeof document !== "undefined") {
12435 registerDocument20(document);
12436 }
12437 return globalScope.__wpStyleRuntime;
12438 }
12439 function documentContainsStyleHash20(targetDocument, hash) {
12440 if (!targetDocument.head) {
12441 return false;
12442 }
12443 for (const style of targetDocument.head.querySelectorAll(
12444 `style[${STYLE_HASH_ATTRIBUTE20}]`
12445 )) {
12446 if (style.getAttribute(STYLE_HASH_ATTRIBUTE20) === hash) {
12447 return true;
12448 }
12449 }
12450 return false;
12451 }
12452 function injectStyle20(targetDocument, hash, css) {
12453 if (!targetDocument.head) {
12454 return;
12455 }
12456 const runtime = getRuntime20();
12457 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12458 if (!injectedStyles) {
12459 injectedStyles = /* @__PURE__ */ new Set();
12460 runtime.injectedStyles.set(targetDocument, injectedStyles);
12461 }
12462 if (injectedStyles.has(hash)) {
12463 return;
12464 }
12465 if (documentContainsStyleHash20(targetDocument, hash)) {
12466 injectedStyles.add(hash);
12467 return;
12468 }
12469 const style = targetDocument.createElement("style");
12470 style.setAttribute(STYLE_HASH_ATTRIBUTE20, hash);
12471 style.appendChild(targetDocument.createTextNode(css));
12472 targetDocument.head.appendChild(style);
12473 injectedStyles.add(hash);
12474 }
12475 function registerDocument20(targetDocument) {
12476 const runtime = getRuntime20();
12477 runtime.documents.set(
12478 targetDocument,
12479 (runtime.documents.get(targetDocument) ?? 0) + 1
12480 );
12481 for (const [hash, css] of runtime.styles) {
12482 injectStyle20(targetDocument, hash, css);
12483 }
12484 return () => {
12485 const count = runtime.documents.get(targetDocument);
12486 if (count === void 0) {
12487 return;
12488 }
12489 if (count <= 1) {
12490 runtime.documents.delete(targetDocument);
12491 return;
12492 }
12493 runtime.documents.set(targetDocument, count - 1);
12494 };
12495 }
12496 function registerStyle20(hash, css) {
12497 const runtime = getRuntime20();
12498 runtime.styles.set(hash, css);
12499 for (const targetDocument of runtime.documents.keys()) {
12500 injectStyle20(targetDocument, hash, css);
12501 }
12502 }
12503 if (typeof process === "undefined" || true) {
12504 registerStyle20("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12505 }
12506 var style_default19 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12507 var DEFAULT_TAG3 = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", {});
12508 var Description = (0, import_element39.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG3, className, children, ...props }, ref) {
12509 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12510 Text,
12511 {
12512 ref,
12513 variant: "body-md",
12514 render: render4,
12515 className: clsx_default(style_default19.description, className),
12516 ...props,
12517 children
12518 }
12519 );
12520 });
12521
12522 // packages/ui/build-module/empty-state/actions.mjs
12523 var import_element40 = __toESM(require_element(), 1);
12524 var STYLE_HASH_ATTRIBUTE21 = "data-wp-hash";
12525 function getRuntime21() {
12526 const globalScope = globalThis;
12527 if (globalScope.__wpStyleRuntime) {
12528 return globalScope.__wpStyleRuntime;
12529 }
12530 globalScope.__wpStyleRuntime = {
12531 documents: /* @__PURE__ */ new Map(),
12532 styles: /* @__PURE__ */ new Map(),
12533 injectedStyles: /* @__PURE__ */ new WeakMap()
12534 };
12535 if (typeof document !== "undefined") {
12536 registerDocument21(document);
12537 }
12538 return globalScope.__wpStyleRuntime;
12539 }
12540 function documentContainsStyleHash21(targetDocument, hash) {
12541 if (!targetDocument.head) {
12542 return false;
12543 }
12544 for (const style of targetDocument.head.querySelectorAll(
12545 `style[${STYLE_HASH_ATTRIBUTE21}]`
12546 )) {
12547 if (style.getAttribute(STYLE_HASH_ATTRIBUTE21) === hash) {
12548 return true;
12549 }
12550 }
12551 return false;
12552 }
12553 function injectStyle21(targetDocument, hash, css) {
12554 if (!targetDocument.head) {
12555 return;
12556 }
12557 const runtime = getRuntime21();
12558 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12559 if (!injectedStyles) {
12560 injectedStyles = /* @__PURE__ */ new Set();
12561 runtime.injectedStyles.set(targetDocument, injectedStyles);
12562 }
12563 if (injectedStyles.has(hash)) {
12564 return;
12565 }
12566 if (documentContainsStyleHash21(targetDocument, hash)) {
12567 injectedStyles.add(hash);
12568 return;
12569 }
12570 const style = targetDocument.createElement("style");
12571 style.setAttribute(STYLE_HASH_ATTRIBUTE21, hash);
12572 style.appendChild(targetDocument.createTextNode(css));
12573 targetDocument.head.appendChild(style);
12574 injectedStyles.add(hash);
12575 }
12576 function registerDocument21(targetDocument) {
12577 const runtime = getRuntime21();
12578 runtime.documents.set(
12579 targetDocument,
12580 (runtime.documents.get(targetDocument) ?? 0) + 1
12581 );
12582 for (const [hash, css] of runtime.styles) {
12583 injectStyle21(targetDocument, hash, css);
12584 }
12585 return () => {
12586 const count = runtime.documents.get(targetDocument);
12587 if (count === void 0) {
12588 return;
12589 }
12590 if (count <= 1) {
12591 runtime.documents.delete(targetDocument);
12592 return;
12593 }
12594 runtime.documents.set(targetDocument, count - 1);
12595 };
12596 }
12597 function registerStyle21(hash, css) {
12598 const runtime = getRuntime21();
12599 runtime.styles.set(hash, css);
12600 for (const targetDocument of runtime.documents.keys()) {
12601 injectStyle21(targetDocument, hash, css);
12602 }
12603 }
12604 if (typeof process === "undefined" || true) {
12605 registerStyle21("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12606 }
12607 var style_default20 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12608 var Actions = (0, import_element40.forwardRef)(
12609 function EmptyStateActions({ render: render4, ...props }, ref) {
12610 const className = clsx_default(style_default20.actions);
12611 const element = useRender({
12612 defaultTagName: "div",
12613 render: render4,
12614 ref,
12615 props: mergeProps({ className }, props)
12616 });
12617 return element;
12618 }
12619 );
12620
12621 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
12622 var import_element41 = __toESM(require_element(), 1);
12623 var STYLE_HASH_ATTRIBUTE22 = "data-wp-hash";
12624 function getRuntime22() {
12625 const globalScope = globalThis;
12626 if (globalScope.__wpStyleRuntime) {
12627 return globalScope.__wpStyleRuntime;
12628 }
12629 globalScope.__wpStyleRuntime = {
12630 documents: /* @__PURE__ */ new Map(),
12631 styles: /* @__PURE__ */ new Map(),
12632 injectedStyles: /* @__PURE__ */ new WeakMap()
12633 };
12634 if (typeof document !== "undefined") {
12635 registerDocument22(document);
12636 }
12637 return globalScope.__wpStyleRuntime;
12638 }
12639 function documentContainsStyleHash22(targetDocument, hash) {
12640 if (!targetDocument.head) {
12641 return false;
12642 }
12643 for (const style of targetDocument.head.querySelectorAll(
12644 `style[${STYLE_HASH_ATTRIBUTE22}]`
12645 )) {
12646 if (style.getAttribute(STYLE_HASH_ATTRIBUTE22) === hash) {
12647 return true;
12648 }
12649 }
12650 return false;
12651 }
12652 function injectStyle22(targetDocument, hash, css) {
12653 if (!targetDocument.head) {
12654 return;
12655 }
12656 const runtime = getRuntime22();
12657 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12658 if (!injectedStyles) {
12659 injectedStyles = /* @__PURE__ */ new Set();
12660 runtime.injectedStyles.set(targetDocument, injectedStyles);
12661 }
12662 if (injectedStyles.has(hash)) {
12663 return;
12664 }
12665 if (documentContainsStyleHash22(targetDocument, hash)) {
12666 injectedStyles.add(hash);
12667 return;
12668 }
12669 const style = targetDocument.createElement("style");
12670 style.setAttribute(STYLE_HASH_ATTRIBUTE22, hash);
12671 style.appendChild(targetDocument.createTextNode(css));
12672 targetDocument.head.appendChild(style);
12673 injectedStyles.add(hash);
12674 }
12675 function registerDocument22(targetDocument) {
12676 const runtime = getRuntime22();
12677 runtime.documents.set(
12678 targetDocument,
12679 (runtime.documents.get(targetDocument) ?? 0) + 1
12680 );
12681 for (const [hash, css] of runtime.styles) {
12682 injectStyle22(targetDocument, hash, css);
12683 }
12684 return () => {
12685 const count = runtime.documents.get(targetDocument);
12686 if (count === void 0) {
12687 return;
12688 }
12689 if (count <= 1) {
12690 runtime.documents.delete(targetDocument);
12691 return;
12692 }
12693 runtime.documents.set(targetDocument, count - 1);
12694 };
12695 }
12696 function registerStyle22(hash, css) {
12697 const runtime = getRuntime22();
12698 runtime.styles.set(hash, css);
12699 for (const targetDocument of runtime.documents.keys()) {
12700 injectStyle22(targetDocument, hash, css);
12701 }
12702 }
12703 if (typeof process === "undefined" || true) {
12704 registerStyle22("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}");
12705 }
12706 var style_default21 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
12707 var VisuallyHidden = (0, import_element41.forwardRef)(
12708 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
12709 const element = useRender({
12710 render: render4,
12711 ref,
12712 props: mergeProps(
12713 { className: style_default21["visually-hidden"] },
12714 restProps,
12715 {
12716 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
12717 "data-visually-hidden": ""
12718 }
12719 )
12720 });
12721 return element;
12722 }
12723 );
12724
12725 // packages/ui/build-module/link/link.mjs
12726 var import_element42 = __toESM(require_element(), 1);
12727 var import_i18n2 = __toESM(require_i18n(), 1);
12728 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
12729 var STYLE_HASH_ATTRIBUTE23 = "data-wp-hash";
12730 function getRuntime23() {
12731 const globalScope = globalThis;
12732 if (globalScope.__wpStyleRuntime) {
12733 return globalScope.__wpStyleRuntime;
12734 }
12735 globalScope.__wpStyleRuntime = {
12736 documents: /* @__PURE__ */ new Map(),
12737 styles: /* @__PURE__ */ new Map(),
12738 injectedStyles: /* @__PURE__ */ new WeakMap()
12739 };
12740 if (typeof document !== "undefined") {
12741 registerDocument23(document);
12742 }
12743 return globalScope.__wpStyleRuntime;
12744 }
12745 function documentContainsStyleHash23(targetDocument, hash) {
12746 if (!targetDocument.head) {
12747 return false;
12748 }
12749 for (const style of targetDocument.head.querySelectorAll(
12750 `style[${STYLE_HASH_ATTRIBUTE23}]`
12751 )) {
12752 if (style.getAttribute(STYLE_HASH_ATTRIBUTE23) === hash) {
12753 return true;
12754 }
12755 }
12756 return false;
12757 }
12758 function injectStyle23(targetDocument, hash, css) {
12759 if (!targetDocument.head) {
12760 return;
12761 }
12762 const runtime = getRuntime23();
12763 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12764 if (!injectedStyles) {
12765 injectedStyles = /* @__PURE__ */ new Set();
12766 runtime.injectedStyles.set(targetDocument, injectedStyles);
12767 }
12768 if (injectedStyles.has(hash)) {
12769 return;
12770 }
12771 if (documentContainsStyleHash23(targetDocument, hash)) {
12772 injectedStyles.add(hash);
12773 return;
12774 }
12775 const style = targetDocument.createElement("style");
12776 style.setAttribute(STYLE_HASH_ATTRIBUTE23, hash);
12777 style.appendChild(targetDocument.createTextNode(css));
12778 targetDocument.head.appendChild(style);
12779 injectedStyles.add(hash);
12780 }
12781 function registerDocument23(targetDocument) {
12782 const runtime = getRuntime23();
12783 runtime.documents.set(
12784 targetDocument,
12785 (runtime.documents.get(targetDocument) ?? 0) + 1
12786 );
12787 for (const [hash, css] of runtime.styles) {
12788 injectStyle23(targetDocument, hash, css);
12789 }
12790 return () => {
12791 const count = runtime.documents.get(targetDocument);
12792 if (count === void 0) {
12793 return;
12794 }
12795 if (count <= 1) {
12796 runtime.documents.delete(targetDocument);
12797 return;
12798 }
12799 runtime.documents.set(targetDocument, count - 1);
12800 };
12801 }
12802 function registerStyle23(hash, css) {
12803 const runtime = getRuntime23();
12804 runtime.styles.set(hash, css);
12805 for (const targetDocument of runtime.documents.keys()) {
12806 injectStyle23(targetDocument, hash, css);
12807 }
12808 }
12809 if (typeof process === "undefined" || true) {
12810 registerStyle23("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
12811 }
12812 var resets_default4 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
12813 if (typeof process === "undefined" || true) {
12814 registerStyle23("693cd16544", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid transparent;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}}");
12815 }
12816 var focus_default3 = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
12817 if (typeof process === "undefined" || true) {
12818 registerStyle23("9f01019e30", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-regular,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}}');
12819 }
12820 var style_default22 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
12821 if (typeof process === "undefined" || true) {
12822 registerStyle23("d5c1b736fd", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
12823 }
12824 var global_css_defense_default4 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
12825 var Link = (0, import_element42.forwardRef)(function Link2({
12826 children,
12827 variant = "default",
12828 tone = "brand",
12829 openInNewTab = false,
12830 render: render4,
12831 className,
12832 ...props
12833 }, ref) {
12834 const element = useRender({
12835 render: render4,
12836 defaultTagName: "a",
12837 ref,
12838 props: mergeProps(props, {
12839 className: clsx_default(
12840 global_css_defense_default4.a,
12841 resets_default4["box-sizing"],
12842 focus_default3["outset-ring--focus"],
12843 variant !== "unstyled" && style_default22.link,
12844 variant !== "unstyled" && style_default22[`is-${tone}`],
12845 variant === "unstyled" && style_default22["is-unstyled"],
12846 className
12847 ),
12848 target: openInNewTab ? "_blank" : void 0,
12849 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
12850 children,
12851 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
12852 "span",
12853 {
12854 className: style_default22["link-icon"],
12855 role: "img",
12856 "aria-label": (
12857 /* translators: accessibility text appended to link text */
12858 (0, import_i18n2.__)("(opens in a new tab)")
12859 )
12860 }
12861 )
12862 ] })
12863 })
12864 });
12865 return element;
12866 });
12867
12868 // packages/dataviews/build-module/components/dataviews-context/index.mjs
12869 var import_element43 = __toESM(require_element(), 1);
12870
12871 // packages/dataviews/build-module/constants.mjs
12872 var import_i18n3 = __toESM(require_i18n(), 1);
12873 var OPERATOR_IS_ANY = "isAny";
12874 var OPERATOR_IS_NONE = "isNone";
12875 var OPERATOR_IS_ALL = "isAll";
12876 var OPERATOR_IS_NOT_ALL = "isNotAll";
12877 var OPERATOR_BETWEEN = "between";
12878 var OPERATOR_IN_THE_PAST = "inThePast";
12879 var OPERATOR_OVER = "over";
12880 var OPERATOR_IS = "is";
12881 var OPERATOR_IS_NOT = "isNot";
12882 var OPERATOR_LESS_THAN = "lessThan";
12883 var OPERATOR_GREATER_THAN = "greaterThan";
12884 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
12885 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
12886 var OPERATOR_BEFORE = "before";
12887 var OPERATOR_AFTER = "after";
12888 var OPERATOR_BEFORE_INC = "beforeInc";
12889 var OPERATOR_AFTER_INC = "afterInc";
12890 var OPERATOR_CONTAINS = "contains";
12891 var OPERATOR_NOT_CONTAINS = "notContains";
12892 var OPERATOR_STARTS_WITH = "startsWith";
12893 var OPERATOR_ON = "on";
12894 var OPERATOR_NOT_ON = "notOn";
12895 var SORTING_DIRECTIONS = ["asc", "desc"];
12896 var sortArrows = { asc: "\u2191", desc: "\u2193" };
12897 var sortValues = { asc: "ascending", desc: "descending" };
12898 var sortLabels = {
12899 asc: (0, import_i18n3.__)("Sort ascending"),
12900 desc: (0, import_i18n3.__)("Sort descending")
12901 };
12902 var sortIcons = {
12903 asc: arrow_up_default,
12904 desc: arrow_down_default
12905 };
12906 var LAYOUT_TABLE = "table";
12907 var LAYOUT_GRID = "grid";
12908 var LAYOUT_LIST = "list";
12909 var LAYOUT_ACTIVITY = "activity";
12910 var LAYOUT_PICKER_GRID = "pickerGrid";
12911 var LAYOUT_PICKER_TABLE = "pickerTable";
12912 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
12913
12914 // packages/dataviews/build-module/components/dataviews-context/index.mjs
12915 var DataViewsContext = (0, import_element43.createContext)({
12916 view: { type: LAYOUT_TABLE },
12917 onChangeView: () => {
12918 },
12919 fields: [],
12920 data: [],
12921 paginationInfo: {
12922 totalItems: 0,
12923 totalPages: 0
12924 },
12925 selection: [],
12926 onChangeSelection: () => {
12927 },
12928 setOpenedFilter: () => {
12929 },
12930 openedFilter: null,
12931 getItemId: (item) => item.id,
12932 isItemClickable: () => true,
12933 renderItemLink: void 0,
12934 containerWidth: 0,
12935 containerRef: (0, import_element43.createRef)(),
12936 resizeObserverRef: () => {
12937 },
12938 defaultLayouts: { list: {}, grid: {}, table: {} },
12939 filters: [],
12940 isShowingFilter: false,
12941 setIsShowingFilter: () => {
12942 },
12943 hasInitiallyLoaded: false,
12944 config: {
12945 perPageSizes: []
12946 },
12947 intersectionObserver: null
12948 });
12949 DataViewsContext.displayName = "DataViewsContext";
12950 var dataviews_context_default = DataViewsContext;
12951
12952 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
12953 var import_i18n24 = __toESM(require_i18n(), 1);
12954
12955 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
12956 var import_i18n11 = __toESM(require_i18n(), 1);
12957 var import_components6 = __toESM(require_components(), 1);
12958 var import_element51 = __toESM(require_element(), 1);
12959 var import_keycodes = __toESM(require_keycodes(), 1);
12960
12961 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
12962 var import_components = __toESM(require_components(), 1);
12963 var import_i18n4 = __toESM(require_i18n(), 1);
12964 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
12965 function DataViewsSelectionCheckbox({
12966 selection,
12967 onChangeSelection,
12968 item,
12969 getItemId,
12970 titleField,
12971 disabled: disabled2,
12972 ...extraProps
12973 }) {
12974 const id = getItemId(item);
12975 const isInSelectionArray = selection.includes(id);
12976 const checked = !disabled2 && isInSelectionArray;
12977 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n4.__)("(no title)");
12978 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
12979 import_components.CheckboxControl,
12980 {
12981 className: "dataviews-selection-checkbox",
12982 "aria-label": selectionLabel,
12983 "aria-disabled": disabled2,
12984 checked,
12985 onChange: () => {
12986 if (disabled2) {
12987 return;
12988 }
12989 onChangeSelection(
12990 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
12991 );
12992 },
12993 ...extraProps
12994 }
12995 );
12996 }
12997
12998 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
12999 var import_components2 = __toESM(require_components(), 1);
13000 var import_i18n5 = __toESM(require_i18n(), 1);
13001 var import_element44 = __toESM(require_element(), 1);
13002 var import_data = __toESM(require_data(), 1);
13003 var import_compose = __toESM(require_compose(), 1);
13004
13005 // packages/dataviews/build-module/lock-unlock.mjs
13006 var import_private_apis2 = __toESM(require_private_apis(), 1);
13007 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
13008 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
13009 "@wordpress/dataviews"
13010 );
13011
13012 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
13013 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13014 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
13015 function ButtonTrigger({
13016 action,
13017 onClick,
13018 items,
13019 variant
13020 }) {
13021 const label = typeof action.label === "string" ? action.label : action.label(items);
13022 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13023 import_components2.Button,
13024 {
13025 disabled: !!action.disabled,
13026 accessibleWhenDisabled: true,
13027 size: "compact",
13028 variant,
13029 onClick,
13030 children: label
13031 }
13032 );
13033 }
13034 function MenuItemTrigger({
13035 action,
13036 onClick,
13037 items
13038 }) {
13039 const label = typeof action.label === "string" ? action.label : action.label(items);
13040 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.ItemLabel, { children: label }) });
13041 }
13042 function ActionModal({
13043 action,
13044 items,
13045 closeModal
13046 }) {
13047 const label = typeof action.label === "string" ? action.label : action.label(items);
13048 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
13049 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13050 import_components2.Modal,
13051 {
13052 title: modalHeader || label,
13053 __experimentalHideHeader: !!action.hideModalHeader,
13054 onRequestClose: closeModal,
13055 focusOnMount: action.modalFocusOnMount ?? true,
13056 size: action.modalSize || "medium",
13057 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
13058 action.id
13059 )}`,
13060 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(action.RenderModal, { items, closeModal })
13061 }
13062 );
13063 }
13064 function ActionsMenuGroup({
13065 actions,
13066 item,
13067 registry,
13068 setActiveModalAction
13069 }) {
13070 const { primaryActions, regularActions } = (0, import_element44.useMemo)(() => {
13071 return actions.reduce(
13072 (acc, action) => {
13073 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
13074 return acc;
13075 },
13076 {
13077 primaryActions: [],
13078 regularActions: []
13079 }
13080 );
13081 }, [actions]);
13082 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13083 MenuItemTrigger,
13084 {
13085 action,
13086 onClick: () => {
13087 if ("RenderModal" in action) {
13088 setActiveModalAction(action);
13089 return;
13090 }
13091 action.callback([item], { registry });
13092 },
13093 items: [item]
13094 },
13095 action.id
13096 ));
13097 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Menu.Group, { children: [
13098 renderActionGroup(primaryActions),
13099 renderActionGroup(regularActions)
13100 ] });
13101 }
13102 function ItemActions({
13103 item,
13104 actions,
13105 isCompact
13106 }) {
13107 const registry = (0, import_data.useRegistry)();
13108 const { primaryActions, eligibleActions } = (0, import_element44.useMemo)(() => {
13109 const _eligibleActions = actions.filter(
13110 (action) => !action.isEligible || action.isEligible(item)
13111 );
13112 const _primaryActions = _eligibleActions.filter(
13113 (action) => action.isPrimary
13114 );
13115 return {
13116 primaryActions: _primaryActions,
13117 eligibleActions: _eligibleActions
13118 };
13119 }, [actions, item]);
13120 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
13121 if (isCompact) {
13122 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13123 CompactItemActions,
13124 {
13125 item,
13126 actions: eligibleActions,
13127 isSmall: true,
13128 registry
13129 }
13130 );
13131 }
13132 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13133 Stack,
13134 {
13135 direction: "row",
13136 justify: "flex-end",
13137 className: "dataviews-item-actions",
13138 style: {
13139 flexShrink: 0,
13140 width: "auto"
13141 },
13142 children: [
13143 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13144 PrimaryActions,
13145 {
13146 item,
13147 actions: primaryActions,
13148 registry
13149 }
13150 ),
13151 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13152 // there if there are any actions at all.
13153 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13154 CompactItemActions,
13155 {
13156 item,
13157 actions: eligibleActions,
13158 registry
13159 }
13160 )
13161 ]
13162 }
13163 );
13164 }
13165 function CompactItemActions({
13166 item,
13167 actions,
13168 isSmall,
13169 registry
13170 }) {
13171 const [activeModalAction, setActiveModalAction] = (0, import_element44.useState)(
13172 null
13173 );
13174 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13175 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Menu, { placement: "bottom-end", children: [
13176 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13177 Menu.TriggerButton,
13178 {
13179 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13180 import_components2.Button,
13181 {
13182 size: isSmall ? "small" : "compact",
13183 icon: more_vertical_default,
13184 label: (0, import_i18n5.__)("Actions"),
13185 accessibleWhenDisabled: true,
13186 disabled: !actions.length,
13187 className: "dataviews-all-actions-button"
13188 }
13189 )
13190 }
13191 ),
13192 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13193 ActionsMenuGroup,
13194 {
13195 actions,
13196 item,
13197 registry,
13198 setActiveModalAction
13199 }
13200 ) })
13201 ] }),
13202 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13203 ActionModal,
13204 {
13205 action: activeModalAction,
13206 items: [item],
13207 closeModal: () => setActiveModalAction(null)
13208 }
13209 )
13210 ] });
13211 }
13212 function PrimaryActions({
13213 item,
13214 actions,
13215 registry,
13216 buttonVariant
13217 }) {
13218 const [activeModalAction, setActiveModalAction] = (0, import_element44.useState)(null);
13219 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
13220 if (isMobileViewport) {
13221 return null;
13222 }
13223 if (!Array.isArray(actions) || actions.length === 0) {
13224 return null;
13225 }
13226 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13227 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13228 ButtonTrigger,
13229 {
13230 action,
13231 onClick: () => {
13232 if ("RenderModal" in action) {
13233 setActiveModalAction(action);
13234 return;
13235 }
13236 action.callback([item], { registry });
13237 },
13238 items: [item],
13239 variant: buttonVariant
13240 },
13241 action.id
13242 )),
13243 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13244 ActionModal,
13245 {
13246 action: activeModalAction,
13247 items: [item],
13248 closeModal: () => setActiveModalAction(null)
13249 }
13250 )
13251 ] });
13252 }
13253
13254 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
13255 var import_components3 = __toESM(require_components(), 1);
13256 var import_i18n7 = __toESM(require_i18n(), 1);
13257 var import_element45 = __toESM(require_element(), 1);
13258 var import_data2 = __toESM(require_data(), 1);
13259 var import_compose2 = __toESM(require_compose(), 1);
13260
13261 // packages/dataviews/build-module/utils/get-footer-message.mjs
13262 var import_i18n6 = __toESM(require_i18n(), 1);
13263 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
13264 if (selectionCount > 0) {
13265 return (0, import_i18n6.sprintf)(
13266 /* translators: %d: number of items. */
13267 (0, import_i18n6._n)("%d Item selected", "%d Items selected", selectionCount),
13268 selectionCount
13269 );
13270 }
13271 if (onlyTotalCount || totalItems <= itemsCount) {
13272 return (0, import_i18n6.sprintf)(
13273 /* translators: %d: number of items. */
13274 (0, import_i18n6._n)("%d Item", "%d Items", totalItems),
13275 totalItems
13276 );
13277 }
13278 return (0, import_i18n6.sprintf)(
13279 /* translators: %1$d: number of items. %2$d: total number of items. */
13280 (0, import_i18n6._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
13281 itemsCount,
13282 totalItems
13283 );
13284 }
13285
13286 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
13287 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
13288 function ActionWithModal({
13289 action,
13290 items,
13291 ActionTriggerComponent
13292 }) {
13293 const [isModalOpen, setIsModalOpen] = (0, import_element45.useState)(false);
13294 const actionTriggerProps = {
13295 action,
13296 onClick: () => {
13297 setIsModalOpen(true);
13298 },
13299 items
13300 };
13301 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
13302 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
13303 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13304 ActionModal,
13305 {
13306 action,
13307 items,
13308 closeModal: () => setIsModalOpen(false)
13309 }
13310 )
13311 ] });
13312 }
13313 function useHasAPossibleBulkAction(actions, item) {
13314 return (0, import_element45.useMemo)(() => {
13315 return actions.some((action) => {
13316 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
13317 });
13318 }, [actions, item]);
13319 }
13320 function useSomeItemHasAPossibleBulkAction(actions, data) {
13321 return (0, import_element45.useMemo)(() => {
13322 return data.some((item) => {
13323 return actions.some((action) => {
13324 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
13325 });
13326 });
13327 }, [actions, data]);
13328 }
13329 function BulkSelectionCheckbox({
13330 selection,
13331 onChangeSelection,
13332 data,
13333 actions,
13334 getItemId,
13335 disableSelectAll = false
13336 }) {
13337 const selectableItems = (0, import_element45.useMemo)(() => {
13338 return data.filter((item) => {
13339 return actions.some(
13340 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
13341 );
13342 });
13343 }, [data, actions]);
13344 const selectedItems = data.filter(
13345 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
13346 );
13347 const hasSelection = selection.length > 0;
13348 const areAllSelected = selectedItems.length === selectableItems.length;
13349 if (disableSelectAll) {
13350 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13351 import_components3.CheckboxControl,
13352 {
13353 className: "dataviews-view-table-selection-checkbox",
13354 checked: hasSelection,
13355 disabled: !hasSelection,
13356 onChange: () => {
13357 onChangeSelection([]);
13358 },
13359 "aria-label": (0, import_i18n7.__)("Deselect all")
13360 }
13361 );
13362 }
13363 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13364 import_components3.CheckboxControl,
13365 {
13366 className: "dataviews-view-table-selection-checkbox",
13367 checked: areAllSelected,
13368 indeterminate: !areAllSelected && !!selectedItems.length,
13369 onChange: () => {
13370 if (areAllSelected) {
13371 onChangeSelection([]);
13372 } else {
13373 onChangeSelection(
13374 selectableItems.map((item) => getItemId(item))
13375 );
13376 }
13377 },
13378 "aria-label": areAllSelected ? (0, import_i18n7.__)("Deselect all") : (0, import_i18n7.__)("Select all")
13379 }
13380 );
13381 }
13382 function ActionTrigger({
13383 action,
13384 onClick,
13385 isBusy,
13386 items
13387 }) {
13388 const label = typeof action.label === "string" ? action.label : action.label(items);
13389 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
13390 if (isMobile) {
13391 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13392 import_components3.Button,
13393 {
13394 disabled: isBusy,
13395 accessibleWhenDisabled: true,
13396 label,
13397 icon: action.icon,
13398 size: "compact",
13399 onClick,
13400 isBusy
13401 }
13402 );
13403 }
13404 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13405 import_components3.Button,
13406 {
13407 disabled: isBusy,
13408 accessibleWhenDisabled: true,
13409 size: "compact",
13410 onClick,
13411 isBusy,
13412 children: label
13413 }
13414 );
13415 }
13416 var EMPTY_ARRAY2 = [];
13417 function ActionButton({
13418 action,
13419 selectedItems,
13420 actionInProgress,
13421 setActionInProgress
13422 }) {
13423 const registry = (0, import_data2.useRegistry)();
13424 const selectedEligibleItems = (0, import_element45.useMemo)(() => {
13425 return selectedItems.filter((item) => {
13426 return !action.isEligible || action.isEligible(item);
13427 });
13428 }, [action, selectedItems]);
13429 if ("RenderModal" in action) {
13430 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13431 ActionWithModal,
13432 {
13433 action,
13434 items: selectedEligibleItems,
13435 ActionTriggerComponent: ActionTrigger
13436 },
13437 action.id
13438 );
13439 }
13440 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13441 ActionTrigger,
13442 {
13443 action,
13444 onClick: async () => {
13445 setActionInProgress(action.id);
13446 await action.callback(selectedItems, {
13447 registry
13448 });
13449 setActionInProgress(null);
13450 },
13451 items: selectedEligibleItems,
13452 isBusy: actionInProgress === action.id
13453 },
13454 action.id
13455 );
13456 }
13457 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
13458 const message2 = getFooterMessage(
13459 selection.length,
13460 data.length,
13461 paginationInfo.totalItems,
13462 isInfiniteScroll
13463 );
13464 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13465 Stack,
13466 {
13467 direction: "row",
13468 className: "dataviews-bulk-actions-footer__container",
13469 gap: "md",
13470 align: "center",
13471 children: [
13472 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13473 BulkSelectionCheckbox,
13474 {
13475 selection,
13476 onChangeSelection,
13477 data,
13478 actions,
13479 getItemId,
13480 disableSelectAll: isInfiniteScroll
13481 }
13482 ),
13483 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
13484 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13485 Stack,
13486 {
13487 direction: "row",
13488 className: "dataviews-bulk-actions-footer__action-buttons",
13489 gap: "xs",
13490 children: [
13491 actionsToShow.map((action) => {
13492 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13493 ActionButton,
13494 {
13495 action,
13496 selectedItems,
13497 actionInProgress,
13498 setActionInProgress
13499 },
13500 action.id
13501 );
13502 }),
13503 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13504 import_components3.Button,
13505 {
13506 icon: close_small_default,
13507 showTooltip: true,
13508 tooltipPosition: "top",
13509 size: "compact",
13510 label: (0, import_i18n7.__)("Cancel"),
13511 disabled: !!actionInProgress,
13512 accessibleWhenDisabled: false,
13513 onClick: () => {
13514 onChangeSelection(EMPTY_ARRAY2);
13515 }
13516 }
13517 )
13518 ]
13519 }
13520 )
13521 ]
13522 }
13523 );
13524 }
13525 function FooterContent({
13526 selection,
13527 actions,
13528 onChangeSelection,
13529 data,
13530 getItemId,
13531 isInfiniteScroll,
13532 paginationInfo
13533 }) {
13534 const [actionInProgress, setActionInProgress] = (0, import_element45.useState)(
13535 null
13536 );
13537 const footerContentRef = (0, import_element45.useRef)(void 0);
13538 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
13539 const bulkActions = (0, import_element45.useMemo)(
13540 () => actions.filter((action) => action.supportsBulk),
13541 [actions]
13542 );
13543 const selectableItems = (0, import_element45.useMemo)(() => {
13544 return data.filter((item) => {
13545 return bulkActions.some(
13546 (action) => !action.isEligible || action.isEligible(item)
13547 );
13548 });
13549 }, [data, bulkActions]);
13550 const selectedItems = (0, import_element45.useMemo)(() => {
13551 return data.filter(
13552 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
13553 );
13554 }, [selection, data, getItemId, selectableItems]);
13555 const actionsToShow = (0, import_element45.useMemo)(
13556 () => actions.filter((action) => {
13557 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
13558 (item) => !action.isEligible || action.isEligible(item)
13559 );
13560 }),
13561 [actions, selectedItems, isMobile]
13562 );
13563 if (!actionInProgress) {
13564 if (footerContentRef.current) {
13565 footerContentRef.current = void 0;
13566 }
13567 return renderFooterContent(
13568 data,
13569 actions,
13570 getItemId,
13571 isInfiniteScroll,
13572 selection,
13573 actionsToShow,
13574 selectedItems,
13575 actionInProgress,
13576 setActionInProgress,
13577 onChangeSelection,
13578 paginationInfo
13579 );
13580 } else if (!footerContentRef.current) {
13581 footerContentRef.current = renderFooterContent(
13582 data,
13583 actions,
13584 getItemId,
13585 isInfiniteScroll,
13586 selection,
13587 actionsToShow,
13588 selectedItems,
13589 actionInProgress,
13590 setActionInProgress,
13591 onChangeSelection,
13592 paginationInfo
13593 );
13594 }
13595 return footerContentRef.current;
13596 }
13597 function BulkActionsFooter() {
13598 const {
13599 data,
13600 selection,
13601 actions = EMPTY_ARRAY2,
13602 onChangeSelection,
13603 getItemId,
13604 paginationInfo,
13605 view
13606 } = (0, import_element45.useContext)(dataviews_context_default);
13607 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13608 FooterContent,
13609 {
13610 selection,
13611 onChangeSelection,
13612 data,
13613 actions,
13614 getItemId,
13615 isInfiniteScroll: !!view.infiniteScrollEnabled,
13616 paginationInfo
13617 }
13618 );
13619 }
13620
13621 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
13622 var import_i18n8 = __toESM(require_i18n(), 1);
13623 var import_components4 = __toESM(require_components(), 1);
13624 var import_element46 = __toESM(require_element(), 1);
13625
13626 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
13627 function getHideableFields(view, fields) {
13628 const togglableFields = [
13629 view?.titleField,
13630 view?.mediaField,
13631 view?.descriptionField
13632 ].filter(Boolean);
13633 return fields.filter(
13634 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
13635 );
13636 }
13637
13638 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
13639 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
13640 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
13641 function WithMenuSeparators({ children }) {
13642 return import_element46.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_element46.Fragment, { children: [
13643 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Separator, {}),
13644 child
13645 ] }, i2));
13646 }
13647 var _HeaderMenu = (0, import_element46.forwardRef)(function HeaderMenu({
13648 fieldId,
13649 view,
13650 fields,
13651 onChangeView,
13652 onHide,
13653 setOpenedFilter,
13654 canMove = true,
13655 canInsertLeft = true,
13656 canInsertRight = true
13657 }, ref) {
13658 const visibleFieldIds = view.fields ?? [];
13659 const index2 = visibleFieldIds?.indexOf(fieldId);
13660 const isSorted = view.sort?.field === fieldId;
13661 let isHidable = false;
13662 let isSortable = false;
13663 let canAddFilter = false;
13664 let operators = [];
13665 const field = fields.find((f2) => f2.id === fieldId);
13666 const { setIsShowingFilter } = (0, import_element46.useContext)(dataviews_context_default);
13667 if (!field) {
13668 return null;
13669 }
13670 isHidable = field.enableHiding !== false;
13671 isSortable = field.enableSorting !== false;
13672 const header = field.header;
13673 operators = !!field.filterBy && field.filterBy?.operators || [];
13674 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
13675 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
13676 return header;
13677 }
13678 const hiddenFields = getHideableFields(view, fields).filter(
13679 (f2) => !visibleFieldIds.includes(f2.id)
13680 );
13681 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
13682 const isRtl = (0, import_i18n8.isRTL)();
13683 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13684 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
13685 Menu2.TriggerButton,
13686 {
13687 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13688 import_components4.Button,
13689 {
13690 size: "compact",
13691 className: "dataviews-view-table-header-button",
13692 ref,
13693 variant: "tertiary"
13694 }
13695 ),
13696 children: [
13697 header,
13698 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
13699 ]
13700 }
13701 ),
13702 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(WithMenuSeparators, { children: [
13703 isSortable && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
13704 (direction) => {
13705 const isChecked = view.sort && isSorted && view.sort.direction === direction;
13706 const value = `${fieldId}-${direction}`;
13707 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13708 Menu2.RadioItem,
13709 {
13710 name: "view-table-sorting",
13711 value,
13712 checked: isChecked,
13713 onChange: () => {
13714 onChangeView({
13715 ...view,
13716 sort: {
13717 field: fieldId,
13718 direction
13719 },
13720 showLevels: false
13721 });
13722 },
13723 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
13724 },
13725 value
13726 );
13727 }
13728 ) }),
13729 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13730 Menu2.Item,
13731 {
13732 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: funnel_default }),
13733 onClick: () => {
13734 setOpenedFilter(fieldId);
13735 setIsShowingFilter(true);
13736 onChangeView({
13737 ...view,
13738 page: 1,
13739 filters: [
13740 ...view.filters || [],
13741 {
13742 field: fieldId,
13743 value: void 0,
13744 operator: operators[0]
13745 }
13746 ]
13747 });
13748 },
13749 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Add filter") })
13750 }
13751 ) }),
13752 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2.Group, { children: [
13753 canMove && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13754 Menu2.Item,
13755 {
13756 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: arrow_left_default }),
13757 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
13758 onClick: () => {
13759 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
13760 const newFields = [
13761 ...visibleFieldIds
13762 ];
13763 newFields.splice(index2, 1);
13764 newFields.splice(
13765 targetIndex,
13766 0,
13767 fieldId
13768 );
13769 onChangeView({
13770 ...view,
13771 fields: newFields
13772 });
13773 },
13774 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Move left") })
13775 }
13776 ),
13777 canMove && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13778 Menu2.Item,
13779 {
13780 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: arrow_right_default }),
13781 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
13782 onClick: () => {
13783 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
13784 const newFields = [
13785 ...visibleFieldIds
13786 ];
13787 newFields.splice(index2, 1);
13788 newFields.splice(
13789 targetIndex,
13790 0,
13791 fieldId
13792 );
13793 onChangeView({
13794 ...view,
13795 fields: newFields
13796 });
13797 },
13798 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Move right") })
13799 }
13800 ),
13801 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13802 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Insert left") }) }),
13803 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
13804 const insertIndex = isRtl ? index2 + 1 : index2;
13805 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13806 Menu2.Item,
13807 {
13808 onClick: () => {
13809 onChangeView({
13810 ...view,
13811 fields: [
13812 ...visibleFieldIds.slice(
13813 0,
13814 insertIndex
13815 ),
13816 hiddenField.id,
13817 ...visibleFieldIds.slice(
13818 insertIndex
13819 )
13820 ]
13821 });
13822 },
13823 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
13824 },
13825 hiddenField.id
13826 );
13827 }) })
13828 ] }),
13829 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13830 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Insert right") }) }),
13831 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
13832 const insertIndex = isRtl ? index2 : index2 + 1;
13833 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13834 Menu2.Item,
13835 {
13836 onClick: () => {
13837 onChangeView({
13838 ...view,
13839 fields: [
13840 ...visibleFieldIds.slice(
13841 0,
13842 insertIndex
13843 ),
13844 hiddenField.id,
13845 ...visibleFieldIds.slice(
13846 insertIndex
13847 )
13848 ]
13849 });
13850 },
13851 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
13852 },
13853 hiddenField.id
13854 );
13855 }) })
13856 ] }),
13857 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13858 Menu2.Item,
13859 {
13860 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: unseen_default }),
13861 onClick: () => {
13862 onHide(field);
13863 onChangeView({
13864 ...view,
13865 fields: visibleFieldIds.filter(
13866 (id) => id !== fieldId
13867 )
13868 });
13869 },
13870 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Hide column") })
13871 }
13872 )
13873 ] })
13874 ] }) })
13875 ] });
13876 });
13877 var ColumnHeaderMenu = _HeaderMenu;
13878 var column_header_menu_default = ColumnHeaderMenu;
13879
13880 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
13881 var import_element47 = __toESM(require_element(), 1);
13882 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
13883 function getClickableItemProps({
13884 item,
13885 isItemClickable,
13886 onClickItem,
13887 className
13888 }) {
13889 if (!isItemClickable(item) || !onClickItem) {
13890 return { className };
13891 }
13892 return {
13893 className: className ? `${className} ${className}--clickable` : void 0,
13894 role: "button",
13895 tabIndex: 0,
13896 onClick: (event) => {
13897 event.stopPropagation();
13898 onClickItem(item);
13899 },
13900 onKeyDown: (event) => {
13901 if (event.key === "Enter" || event.key === "" || event.key === " ") {
13902 event.stopPropagation();
13903 onClickItem(item);
13904 }
13905 }
13906 };
13907 }
13908 function ItemClickWrapper({
13909 item,
13910 isItemClickable,
13911 onClickItem,
13912 renderItemLink,
13913 className,
13914 children,
13915 ...extraProps
13916 }) {
13917 if (!isItemClickable(item)) {
13918 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className, ...extraProps, children });
13919 }
13920 if (renderItemLink) {
13921 const renderedElement = renderItemLink({
13922 item,
13923 className: `${className} ${className}--clickable`,
13924 ...extraProps,
13925 children
13926 });
13927 return (0, import_element47.cloneElement)(renderedElement, {
13928 onClick: (event) => {
13929 event.stopPropagation();
13930 if (renderedElement.props.onClick) {
13931 renderedElement.props.onClick(event);
13932 }
13933 },
13934 onKeyDown: (event) => {
13935 if (event.key === "Enter" || event.key === "" || event.key === " ") {
13936 event.stopPropagation();
13937 if (renderedElement.props.onKeyDown) {
13938 renderedElement.props.onKeyDown(event);
13939 }
13940 }
13941 }
13942 });
13943 }
13944 const clickProps = getClickableItemProps({
13945 item,
13946 isItemClickable,
13947 onClickItem,
13948 className
13949 });
13950 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { ...clickProps, ...extraProps, children });
13951 }
13952
13953 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
13954 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
13955 function ColumnPrimary({
13956 item,
13957 level,
13958 titleField,
13959 mediaField,
13960 descriptionField,
13961 onClickItem,
13962 renderItemLink,
13963 isItemClickable
13964 }) {
13965 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
13966 mediaField && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
13967 ItemClickWrapper,
13968 {
13969 item,
13970 isItemClickable,
13971 onClickItem,
13972 renderItemLink,
13973 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
13974 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
13975 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
13976 mediaField.render,
13977 {
13978 item,
13979 field: mediaField,
13980 config: { sizes: "32px" }
13981 }
13982 )
13983 }
13984 ),
13985 /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
13986 Stack,
13987 {
13988 direction: "column",
13989 align: "flex-start",
13990 className: "dataviews-view-table__primary-column-content",
13991 children: [
13992 titleField && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
13993 ItemClickWrapper,
13994 {
13995 item,
13996 isItemClickable,
13997 onClickItem,
13998 renderItemLink,
13999 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
14000 children: [
14001 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "dataviews-view-table__level", children: [
14002 Array(level).fill("\u2014").join(" "),
14003 "\xA0"
14004 ] }),
14005 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(titleField.render, { item, field: titleField })
14006 ]
14007 }
14008 ),
14009 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14010 descriptionField.render,
14011 {
14012 item,
14013 field: descriptionField
14014 }
14015 )
14016 ]
14017 }
14018 )
14019 ] });
14020 }
14021 var column_primary_default = ColumnPrimary;
14022
14023 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
14024 var import_element48 = __toESM(require_element(), 1);
14025 var import_i18n9 = __toESM(require_i18n(), 1);
14026 var isScrolledToEnd = (element) => {
14027 if ((0, import_i18n9.isRTL)()) {
14028 const scrollLeft = Math.abs(element.scrollLeft);
14029 return scrollLeft <= 1;
14030 }
14031 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
14032 };
14033 function useScrollState({
14034 scrollContainerRef,
14035 enabledHorizontal = false
14036 }) {
14037 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element48.useState)(false);
14038 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element48.useState)(false);
14039 const handleScroll = (0, import_element48.useCallback)(() => {
14040 const scrollContainer = scrollContainerRef.current;
14041 if (!scrollContainer) {
14042 return;
14043 }
14044 if (enabledHorizontal) {
14045 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
14046 }
14047 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
14048 }, [scrollContainerRef, enabledHorizontal]);
14049 (0, import_element48.useEffect)(() => {
14050 if (typeof window === "undefined" || !scrollContainerRef.current) {
14051 return () => {
14052 };
14053 }
14054 const scrollContainer = scrollContainerRef.current;
14055 handleScroll();
14056 scrollContainer.addEventListener("scroll", handleScroll);
14057 window.addEventListener("resize", handleScroll);
14058 return () => {
14059 scrollContainer.removeEventListener("scroll", handleScroll);
14060 window.removeEventListener("resize", handleScroll);
14061 };
14062 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
14063 return { isHorizontalScrollEnd, isVerticallyScrolled };
14064 }
14065
14066 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
14067 function getDataByGroup(data, groupByField) {
14068 return data.reduce((groups, item) => {
14069 const groupName = groupByField.getValue({ item });
14070 if (!groups.has(groupName)) {
14071 groups.set(groupName, []);
14072 }
14073 groups.get(groupName)?.push(item);
14074 return groups;
14075 }, /* @__PURE__ */ new Map());
14076 }
14077
14078 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
14079 var import_components5 = __toESM(require_components(), 1);
14080 var import_i18n10 = __toESM(require_i18n(), 1);
14081 var import_element49 = __toESM(require_element(), 1);
14082 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
14083 function FieldItem({
14084 field,
14085 isVisible: isVisible2,
14086 onToggleVisibility
14087 }) {
14088 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
14089 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components5.Icon, { icon: check_default }) }),
14090 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
14091 ] }) });
14092 }
14093 function isDefined(item) {
14094 return !!item;
14095 }
14096 function PropertiesSection({
14097 showLabel = true
14098 }) {
14099 const { view, fields, onChangeView } = (0, import_element49.useContext)(dataviews_context_default);
14100 const regularFields = getHideableFields(view, fields);
14101 if (!regularFields?.length) {
14102 return null;
14103 }
14104 const titleField = fields.find((f2) => f2.id === view.titleField);
14105 const previewField = fields.find((f2) => f2.id === view.mediaField);
14106 const descriptionField = fields.find(
14107 (f2) => f2.id === view.descriptionField
14108 );
14109 const lockedFields = [
14110 {
14111 field: titleField,
14112 isVisibleFlag: "showTitle"
14113 },
14114 {
14115 field: previewField,
14116 isVisibleFlag: "showMedia"
14117 },
14118 {
14119 field: descriptionField,
14120 isVisibleFlag: "showDescription"
14121 }
14122 ].filter(({ field }) => isDefined(field));
14123 const visibleFieldIds = view.fields ?? [];
14124 const visibleRegularFieldsCount = regularFields.filter(
14125 (f2) => visibleFieldIds.includes(f2.id)
14126 ).length;
14127 const visibleLockedFields = lockedFields.filter(
14128 ({ isVisibleFlag }) => (
14129 // @ts-expect-error
14130 view[isVisibleFlag] ?? true
14131 )
14132 );
14133 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
14134 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
14135 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
14136 showLabel && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n10.__)("Properties") }),
14137 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14138 Stack,
14139 {
14140 direction: "column",
14141 className: "dataviews-view-config__properties",
14142 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
14143 lockedFields.map(({ field, isVisibleFlag }) => {
14144 const isVisible2 = view[isVisibleFlag] ?? true;
14145 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
14146 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14147 FieldItem,
14148 {
14149 field: fieldToRender,
14150 isVisible: isVisible2,
14151 onToggleVisibility: () => {
14152 onChangeView({
14153 ...view,
14154 [isVisibleFlag]: !isVisible2
14155 });
14156 }
14157 },
14158 field.id
14159 );
14160 }),
14161 regularFields.map((field) => {
14162 const isVisible2 = visibleFieldIds.includes(field.id);
14163 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
14164 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14165 FieldItem,
14166 {
14167 field: fieldToRender,
14168 isVisible: isVisible2,
14169 onToggleVisibility: () => {
14170 onChangeView({
14171 ...view,
14172 fields: isVisible2 ? visibleFieldIds.filter(
14173 (fieldId) => fieldId !== field.id
14174 ) : [...visibleFieldIds, field.id]
14175 });
14176 }
14177 },
14178 field.id
14179 );
14180 })
14181 ] })
14182 }
14183 )
14184 ] });
14185 }
14186
14187 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
14188 var import_element50 = __toESM(require_element(), 1);
14189 function useDelayedLoading(isLoading, options = { delay: 400 }) {
14190 const [showLoader, setShowLoader] = (0, import_element50.useState)(false);
14191 (0, import_element50.useEffect)(() => {
14192 if (!isLoading) {
14193 return;
14194 }
14195 const timeout = setTimeout(() => {
14196 setShowLoader(true);
14197 }, options.delay);
14198 return () => {
14199 clearTimeout(timeout);
14200 setShowLoader(false);
14201 };
14202 }, [isLoading, options.delay]);
14203 return showLoader;
14204 }
14205
14206 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
14207 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
14208 function getEffectiveAlign(explicitAlign, fieldType) {
14209 if (explicitAlign) {
14210 return explicitAlign;
14211 }
14212 if (fieldType === "integer" || fieldType === "number") {
14213 return "end";
14214 }
14215 return void 0;
14216 }
14217 function TableColumnField({
14218 item,
14219 fields,
14220 column,
14221 align
14222 }) {
14223 const field = fields.find((f2) => f2.id === column);
14224 if (!field) {
14225 return null;
14226 }
14227 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14228 "dataviews-view-table__cell-align-end": align === "end",
14229 "dataviews-view-table__cell-align-center": align === "center"
14230 });
14231 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(field.render, { item, field }) });
14232 }
14233 function TableRow({
14234 hasBulkActions,
14235 item,
14236 level,
14237 actions,
14238 fields,
14239 id,
14240 view,
14241 titleField,
14242 mediaField,
14243 descriptionField,
14244 selection,
14245 getItemId,
14246 isItemClickable,
14247 onClickItem,
14248 renderItemLink,
14249 onChangeSelection,
14250 isActionsColumnSticky,
14251 posinset
14252 }) {
14253 const { paginationInfo } = (0, import_element51.useContext)(dataviews_context_default);
14254 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
14255 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
14256 const {
14257 showTitle = true,
14258 showMedia = true,
14259 showDescription = true,
14260 infiniteScrollEnabled
14261 } = view;
14262 const isTouchDeviceRef = (0, import_element51.useRef)(false);
14263 const columns = view.fields ?? [];
14264 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14265 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14266 "tr",
14267 {
14268 className: clsx_default("dataviews-view-table__row", {
14269 "is-selected": hasPossibleBulkAction && isSelected2,
14270 "has-bulk-actions": hasPossibleBulkAction
14271 }),
14272 onTouchStart: () => {
14273 isTouchDeviceRef.current = true;
14274 },
14275 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
14276 "aria-posinset": posinset,
14277 role: infiniteScrollEnabled ? "article" : void 0,
14278 onMouseDown: (event) => {
14279 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
14280 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
14281 event?.preventDefault();
14282 }
14283 },
14284 onClick: (event) => {
14285 if (!hasPossibleBulkAction) {
14286 return;
14287 }
14288 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
14289 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
14290 onChangeSelection(
14291 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
14292 );
14293 }
14294 },
14295 children: [
14296 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14297 DataViewsSelectionCheckbox,
14298 {
14299 item,
14300 selection,
14301 onChangeSelection,
14302 getItemId,
14303 titleField,
14304 disabled: !hasPossibleBulkAction
14305 }
14306 ) }) }),
14307 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14308 column_primary_default,
14309 {
14310 item,
14311 level,
14312 titleField: showTitle ? titleField : void 0,
14313 mediaField: showMedia ? mediaField : void 0,
14314 descriptionField: showDescription ? descriptionField : void 0,
14315 isItemClickable,
14316 onClickItem,
14317 renderItemLink
14318 }
14319 ) }),
14320 columns.map((column) => {
14321 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14322 const field = fields.find((f2) => f2.id === column);
14323 const effectiveAlign = getEffectiveAlign(align, field?.type);
14324 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14325 "td",
14326 {
14327 style: {
14328 width,
14329 maxWidth,
14330 minWidth
14331 },
14332 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14333 TableColumnField,
14334 {
14335 fields,
14336 item,
14337 column,
14338 align: effectiveAlign
14339 }
14340 )
14341 },
14342 column
14343 );
14344 }),
14345 !!actions?.length && // Disable reason: we are not making the element interactive,
14346 // but preventing any click events from bubbling up to the
14347 // table row. This allows us to add a click handler to the row
14348 // itself (to toggle row selection) without erroneously
14349 // intercepting click events from ItemActions.
14350 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14351 "td",
14352 {
14353 className: clsx_default("dataviews-view-table__actions-column", {
14354 "dataviews-view-table__actions-column--sticky": true,
14355 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
14356 }),
14357 onClick: (e2) => e2.stopPropagation(),
14358 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ItemActions, { item, actions })
14359 }
14360 )
14361 ]
14362 }
14363 );
14364 }
14365 function ViewTable({
14366 actions,
14367 data,
14368 fields,
14369 getItemId,
14370 getItemLevel,
14371 isLoading = false,
14372 onChangeView,
14373 onChangeSelection,
14374 selection,
14375 setOpenedFilter,
14376 onClickItem,
14377 isItemClickable,
14378 renderItemLink,
14379 view,
14380 className,
14381 empty
14382 }) {
14383 const { containerRef } = (0, import_element51.useContext)(dataviews_context_default);
14384 const isDelayedLoading = useDelayedLoading(isLoading);
14385 const headerMenuRefs = (0, import_element51.useRef)(/* @__PURE__ */ new Map());
14386 const headerMenuToFocusRef = (0, import_element51.useRef)(void 0);
14387 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element51.useState)();
14388 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element51.useState)(null);
14389 (0, import_element51.useEffect)(() => {
14390 if (headerMenuToFocusRef.current) {
14391 headerMenuToFocusRef.current.focus();
14392 headerMenuToFocusRef.current = void 0;
14393 }
14394 });
14395 const tableNoticeId = (0, import_element51.useId)();
14396 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
14397 scrollContainerRef: containerRef,
14398 enabledHorizontal: !!actions?.length
14399 });
14400 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
14401 if (nextHeaderMenuToFocus) {
14402 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14403 setNextHeaderMenuToFocus(void 0);
14404 return;
14405 }
14406 const onHide = (field) => {
14407 const hidden = headerMenuRefs.current.get(field.id);
14408 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14409 setNextHeaderMenuToFocus(fallback?.node);
14410 };
14411 const handleHeaderContextMenu = (event) => {
14412 event.preventDefault();
14413 event.stopPropagation();
14414 const virtualAnchor = {
14415 getBoundingClientRect: () => ({
14416 x: event.clientX,
14417 y: event.clientY,
14418 top: event.clientY,
14419 left: event.clientX,
14420 right: event.clientX,
14421 bottom: event.clientY,
14422 width: 0,
14423 height: 0,
14424 toJSON: () => ({})
14425 })
14426 };
14427 window.requestAnimationFrame(() => {
14428 setContextMenuAnchor(virtualAnchor);
14429 });
14430 };
14431 const hasData = !!data?.length;
14432 const titleField = fields.find((field) => field.id === view.titleField);
14433 const mediaField = fields.find((field) => field.id === view.mediaField);
14434 const descriptionField = fields.find(
14435 (field) => field.id === view.descriptionField
14436 );
14437 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14438 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14439 const { showTitle = true, showMedia = true, showDescription = true } = view;
14440 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14441 const columns = view.fields ?? [];
14442 const headerMenuRef = (column, index2) => (node) => {
14443 if (node) {
14444 headerMenuRefs.current.set(column, {
14445 node,
14446 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14447 });
14448 } else {
14449 headerMenuRefs.current.delete(column);
14450 }
14451 };
14452 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14453 const isRtl = (0, import_i18n11.isRTL)();
14454 if (!hasData) {
14455 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14456 "div",
14457 {
14458 className: clsx_default("dataviews-no-results", {
14459 "is-refreshing": isDelayedLoading
14460 }),
14461 id: tableNoticeId,
14462 children: empty
14463 }
14464 );
14465 }
14466 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
14467 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14468 "table",
14469 {
14470 className: clsx_default("dataviews-view-table", className, {
14471 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14472 view.layout.density
14473 ),
14474 "has-bulk-actions": hasBulkActions,
14475 "is-refreshing": !isInfiniteScroll && isDelayedLoading
14476 }),
14477 "aria-busy": isLoading,
14478 "aria-describedby": tableNoticeId,
14479 role: isInfiniteScroll ? "feed" : void 0,
14480 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
14481 children: [
14482 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("colgroup", { children: [
14483 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
14484 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
14485 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14486 "col",
14487 {
14488 className: clsx_default(
14489 `dataviews-view-table__col-${column}`,
14490 {
14491 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
14492 }
14493 )
14494 },
14495 `col-${column}`
14496 )),
14497 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-actions" })
14498 ] }),
14499 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14500 import_components6.Popover,
14501 {
14502 anchor: contextMenuAnchor,
14503 onClose: () => setContextMenuAnchor(null),
14504 placement: "bottom-start",
14505 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(PropertiesSection, { showLabel: false })
14506 }
14507 ),
14508 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14509 "thead",
14510 {
14511 className: clsx_default({
14512 "dataviews-view-table__thead--stuck": isVerticallyScrolled
14513 }),
14514 onContextMenu: handleHeaderContextMenu,
14515 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("tr", { className: "dataviews-view-table__row", children: [
14516 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14517 "th",
14518 {
14519 className: "dataviews-view-table__checkbox-column",
14520 scope: "col",
14521 onContextMenu: handleHeaderContextMenu,
14522 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14523 BulkSelectionCheckbox,
14524 {
14525 selection,
14526 onChangeSelection,
14527 data,
14528 actions,
14529 getItemId
14530 }
14531 )
14532 }
14533 ),
14534 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14535 column_header_menu_default,
14536 {
14537 ref: headerMenuRef(
14538 titleField.id,
14539 0
14540 ),
14541 fieldId: titleField.id,
14542 view,
14543 fields,
14544 onChangeView,
14545 onHide,
14546 setOpenedFilter,
14547 canMove: false,
14548 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
14549 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
14550 }
14551 ) }),
14552 columns.map((column, index2) => {
14553 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14554 const field = fields.find(
14555 (f2) => f2.id === column
14556 );
14557 const effectiveAlign = getEffectiveAlign(
14558 align,
14559 field?.type
14560 );
14561 const canInsertOrMove = view.layout?.enableMoving ?? true;
14562 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14563 "th",
14564 {
14565 style: {
14566 width,
14567 maxWidth,
14568 minWidth,
14569 textAlign: effectiveAlign
14570 },
14571 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14572 scope: "col",
14573 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14574 column_header_menu_default,
14575 {
14576 ref: headerMenuRef(column, index2),
14577 fieldId: column,
14578 view,
14579 fields,
14580 onChangeView,
14581 onHide,
14582 setOpenedFilter,
14583 canMove: canInsertOrMove,
14584 canInsertLeft: canInsertOrMove,
14585 canInsertRight: canInsertOrMove
14586 }
14587 )
14588 },
14589 column
14590 );
14591 }),
14592 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14593 "th",
14594 {
14595 className: clsx_default(
14596 "dataviews-view-table__actions-column",
14597 {
14598 "dataviews-view-table__actions-column--sticky": true,
14599 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
14600 }
14601 ),
14602 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n11.__)("Actions") })
14603 }
14604 )
14605 ] })
14606 }
14607 ),
14608 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14609 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("tbody", { children: [
14610 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14611 "td",
14612 {
14613 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
14614 className: "dataviews-view-table__group-header-cell",
14615 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n11.sprintf)(
14616 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14617 (0, import_i18n11.__)("%1$s: %2$s"),
14618 groupField.label,
14619 groupName
14620 )
14621 }
14622 ) }),
14623 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14624 TableRow,
14625 {
14626 item,
14627 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
14628 hasBulkActions,
14629 actions,
14630 fields,
14631 id: getItemId(item) || index2.toString(),
14632 view,
14633 titleField,
14634 mediaField,
14635 descriptionField,
14636 selection,
14637 getItemId,
14638 onChangeSelection,
14639 onClickItem,
14640 renderItemLink,
14641 isItemClickable,
14642 isActionsColumnSticky: !isHorizontalScrollEnd
14643 },
14644 getItemId(item)
14645 ))
14646 ] }, `group-${groupName}`)
14647 ) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14648 TableRow,
14649 {
14650 item,
14651 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
14652 hasBulkActions,
14653 actions,
14654 fields,
14655 id: getItemId(item) || index2.toString(),
14656 view,
14657 titleField,
14658 mediaField,
14659 descriptionField,
14660 selection,
14661 getItemId,
14662 onChangeSelection,
14663 onClickItem,
14664 renderItemLink,
14665 isItemClickable,
14666 isActionsColumnSticky: !isHorizontalScrollEnd,
14667 posinset: isInfiniteScroll ? index2 + 1 : void 0
14668 },
14669 getItemId(item)
14670 )) })
14671 ]
14672 }
14673 ),
14674 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components6.Spinner, {}) }) })
14675 ] });
14676 }
14677 var table_default = ViewTable;
14678
14679 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
14680 var import_components9 = __toESM(require_components(), 1);
14681 var import_i18n14 = __toESM(require_i18n(), 1);
14682
14683 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
14684 var import_components8 = __toESM(require_components(), 1);
14685 var import_i18n13 = __toESM(require_i18n(), 1);
14686 var import_compose3 = __toESM(require_compose(), 1);
14687 var import_keycodes2 = __toESM(require_keycodes(), 1);
14688 var import_element55 = __toESM(require_element(), 1);
14689
14690 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
14691 var import_components7 = __toESM(require_components(), 1);
14692 var import_i18n12 = __toESM(require_i18n(), 1);
14693 var import_element52 = __toESM(require_element(), 1);
14694 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
14695 var imageSizes = [
14696 {
14697 value: 120,
14698 breakpoint: 1
14699 },
14700 {
14701 value: 170,
14702 breakpoint: 1
14703 },
14704 {
14705 value: 230,
14706 breakpoint: 1
14707 },
14708 {
14709 value: 290,
14710 breakpoint: 1112
14711 // at minimum image width, 4 images display at this container size
14712 },
14713 {
14714 value: 350,
14715 breakpoint: 1636
14716 // at minimum image width, 6 images display at this container size
14717 },
14718 {
14719 value: 430,
14720 breakpoint: 588
14721 // at minimum image width, 2 images display at this container size
14722 }
14723 ];
14724 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
14725 function useGridColumns() {
14726 const context = (0, import_element52.useContext)(dataviews_context_default);
14727 const view = context.view;
14728 return (0, import_element52.useMemo)(() => {
14729 const containerWidth = context.containerWidth;
14730 const gap = 32;
14731 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
14732 const columns = Math.floor(
14733 (containerWidth + gap) / (previewSize + gap)
14734 );
14735 return Math.max(1, columns);
14736 }, [context.containerWidth, view.layout?.previewSize]);
14737 }
14738
14739 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
14740 var import_element53 = __toESM(require_element(), 1);
14741 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
14742 var GridItems = (0, import_element53.forwardRef)(({ className, previewSize, ...props }, ref) => {
14743 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
14744 "div",
14745 {
14746 ref,
14747 className: clsx_default("dataviews-view-grid-items", className),
14748 style: {
14749 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
14750 },
14751 ...props
14752 }
14753 );
14754 });
14755
14756 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
14757 var import_element54 = __toESM(require_element(), 1);
14758 function useIntersectionObserver(elementRef, posinset) {
14759 const { intersectionObserver } = (0, import_element54.useContext)(dataviews_context_default);
14760 (0, import_element54.useEffect)(() => {
14761 const element = elementRef.current;
14762 if (!element || posinset === void 0 || !intersectionObserver) {
14763 return;
14764 }
14765 intersectionObserver.observe(element);
14766 return () => {
14767 intersectionObserver.unobserve(element);
14768 };
14769 }, [elementRef, intersectionObserver, posinset]);
14770 }
14771 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
14772 const hasData = !!data?.length;
14773 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
14774 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
14775 }
14776
14777 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
14778 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
14779 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
14780 function chunk(array, size4) {
14781 const chunks = [];
14782 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
14783 chunks.push(array.slice(i2, i2 + size4));
14784 }
14785 return chunks;
14786 }
14787 var GridItem = (0, import_element55.forwardRef)(
14788 function GridItem2({
14789 view,
14790 selection,
14791 onChangeSelection,
14792 onClickItem,
14793 isItemClickable,
14794 renderItemLink,
14795 getItemId,
14796 item,
14797 actions,
14798 mediaField,
14799 titleField,
14800 descriptionField,
14801 regularFields,
14802 badgeFields,
14803 hasBulkActions,
14804 config,
14805 posinset,
14806 setsize,
14807 ...props
14808 }, forwardedRef) {
14809 const {
14810 showTitle = true,
14811 showMedia = true,
14812 showDescription = true
14813 } = view;
14814 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
14815 const id = getItemId(item);
14816 const elementRef = (0, import_element55.useRef)(null);
14817 const setRefs = (0, import_element55.useCallback)(
14818 (node) => {
14819 elementRef.current = node;
14820 if (typeof forwardedRef === "function") {
14821 forwardedRef(node);
14822 } else if (forwardedRef) {
14823 forwardedRef.current = node;
14824 }
14825 },
14826 [forwardedRef]
14827 );
14828 useIntersectionObserver(elementRef, posinset);
14829 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
14830 const isSelected2 = selection.includes(id);
14831 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
14832 const rendersMediaField = showMedia && mediaField?.render;
14833 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14834 mediaField.render,
14835 {
14836 item,
14837 field: mediaField,
14838 config
14839 }
14840 ) : mediaPlaceholder;
14841 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(titleField.render, { item, field: titleField }) : null;
14842 let mediaA11yProps;
14843 let titleA11yProps;
14844 if (isItemClickable(item) && onClickItem) {
14845 if (renderedTitleField) {
14846 mediaA11yProps = {
14847 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
14848 };
14849 titleA11yProps = {
14850 id: `dataviews-view-grid__title-field-${instanceId}`
14851 };
14852 } else {
14853 mediaA11yProps = {
14854 "aria-label": (0, import_i18n13.__)("Navigate to item")
14855 };
14856 }
14857 }
14858 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
14859 Stack,
14860 {
14861 direction: "column",
14862 ...props,
14863 ref: setRefs,
14864 "aria-setsize": setsize,
14865 "aria-posinset": posinset,
14866 className: clsx_default(
14867 props.className,
14868 "dataviews-view-grid__row__gridcell",
14869 "dataviews-view-grid__card",
14870 {
14871 "is-selected": hasBulkAction && isSelected2
14872 }
14873 ),
14874 onClickCapture: (event) => {
14875 props.onClickCapture?.(event);
14876 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
14877 event.stopPropagation();
14878 event.preventDefault();
14879 if (!hasBulkAction) {
14880 return;
14881 }
14882 onChangeSelection(
14883 isSelected2 ? selection.filter(
14884 (itemId) => id !== itemId
14885 ) : [...selection, id]
14886 );
14887 }
14888 },
14889 children: [
14890 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14891 ItemClickWrapper,
14892 {
14893 item,
14894 isItemClickable,
14895 onClickItem,
14896 renderItemLink,
14897 className: clsx_default("dataviews-view-grid__media", {
14898 "dataviews-view-grid__media--placeholder": !rendersMediaField
14899 }),
14900 ...mediaA11yProps,
14901 children: renderedMediaField
14902 }
14903 ),
14904 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14905 DataViewsSelectionCheckbox,
14906 {
14907 item,
14908 selection,
14909 onChangeSelection,
14910 getItemId,
14911 titleField,
14912 disabled: !hasBulkAction
14913 }
14914 ),
14915 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14916 ItemActions,
14917 {
14918 item,
14919 actions,
14920 isCompact: true
14921 }
14922 ) }),
14923 showTitle && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14924 ItemClickWrapper,
14925 {
14926 item,
14927 isItemClickable,
14928 onClickItem,
14929 renderItemLink,
14930 className: "dataviews-view-grid__title-field dataviews-title-field",
14931 ...titleA11yProps,
14932 title: titleField?.getValueFormatted({
14933 item,
14934 field: titleField
14935 }) || void 0,
14936 children: renderedTitleField
14937 }
14938 ) }),
14939 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14940 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14941 descriptionField.render,
14942 {
14943 item,
14944 field: descriptionField
14945 }
14946 ),
14947 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14948 Stack,
14949 {
14950 direction: "row",
14951 className: "dataviews-view-grid__badge-fields",
14952 gap: "sm",
14953 wrap: "wrap",
14954 align: "top",
14955 justify: "flex-start",
14956 children: badgeFields.map((field) => {
14957 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14958 WCBadge,
14959 {
14960 className: "dataviews-view-grid__field-value",
14961 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14962 field.render,
14963 {
14964 item,
14965 field
14966 }
14967 )
14968 },
14969 field.id
14970 );
14971 })
14972 }
14973 ),
14974 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14975 Stack,
14976 {
14977 direction: "column",
14978 className: "dataviews-view-grid__fields",
14979 gap: "xs",
14980 children: regularFields.map((field) => {
14981 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14982 import_components8.Flex,
14983 {
14984 className: "dataviews-view-grid__field",
14985 gap: 1,
14986 justify: "flex-start",
14987 expanded: true,
14988 style: { height: "auto" },
14989 direction: "row",
14990 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
14991 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
14992 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14993 tooltip_exports.Trigger,
14994 {
14995 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
14996 }
14997 ),
14998 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: field.label })
14999 ] }),
15000 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15001 import_components8.FlexItem,
15002 {
15003 className: "dataviews-view-grid__field-value",
15004 style: { maxHeight: "none" },
15005 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15006 field.render,
15007 {
15008 item,
15009 field
15010 }
15011 )
15012 }
15013 )
15014 ] })
15015 },
15016 field.id
15017 );
15018 })
15019 }
15020 )
15021 ] })
15022 ]
15023 }
15024 );
15025 }
15026 );
15027 function CompositeGrid({
15028 data,
15029 isInfiniteScroll,
15030 className,
15031 inert,
15032 isLoading,
15033 view,
15034 fields,
15035 selection,
15036 onChangeSelection,
15037 onClickItem,
15038 isItemClickable,
15039 renderItemLink,
15040 getItemId,
15041 actions
15042 }) {
15043 const { paginationInfo, resizeObserverRef } = (0, import_element55.useContext)(dataviews_context_default);
15044 const gridColumns = useGridColumns();
15045 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
15046 const titleField = fields.find(
15047 (field) => field.id === view?.titleField
15048 );
15049 const mediaField = fields.find(
15050 (field) => field.id === view?.mediaField
15051 );
15052 const descriptionField = fields.find(
15053 (field) => field.id === view?.descriptionField
15054 );
15055 const otherFields = view.fields ?? [];
15056 const { regularFields, badgeFields } = otherFields.reduce(
15057 (accumulator, fieldId) => {
15058 const field = fields.find((f2) => f2.id === fieldId);
15059 if (!field) {
15060 return accumulator;
15061 }
15062 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
15063 accumulator[key].push(field);
15064 return accumulator;
15065 },
15066 { regularFields: [], badgeFields: [] }
15067 );
15068 const size4 = "900px";
15069 const totalRows = Math.ceil(data.length / gridColumns);
15070 const placeholdersNeeded = usePlaceholdersNeeded(
15071 data,
15072 isInfiniteScroll,
15073 gridColumns
15074 );
15075 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, {
15076 // Render infinite scroll layout (no rows, feed semantics)
15077 children: [
15078 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
15079 import_components8.Composite,
15080 {
15081 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15082 GridItems,
15083 {
15084 className: clsx_default(
15085 "dataviews-view-grid-infinite-scroll",
15086 className,
15087 {
15088 [`has-${view.layout?.density}-density`]: view.layout?.density && [
15089 "compact",
15090 "comfortable"
15091 ].includes(view.layout.density)
15092 }
15093 ),
15094 previewSize: view.layout?.previewSize,
15095 "aria-busy": isLoading,
15096 ref: resizeObserverRef
15097 }
15098 ),
15099 role: "feed",
15100 focusWrap: true,
15101 inert,
15102 children: [
15103 Array.from({ length: placeholdersNeeded }).map(
15104 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15105 import_components8.Composite.Item,
15106 {
15107 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15108 Stack,
15109 {
15110 ...props,
15111 direction: "column",
15112 role: "article",
15113 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
15114 }
15115 ),
15116 "aria-hidden": true,
15117 tabIndex: -1
15118 },
15119 `placeholder-${index2}`
15120 )
15121 ),
15122 data.map((item) => {
15123 const itemId = getItemId(item);
15124 const stablePosition = item.position;
15125 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15126 import_components8.Composite.Item,
15127 {
15128 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15129 GridItem,
15130 {
15131 ...props,
15132 id: itemId,
15133 role: "article",
15134 view,
15135 selection,
15136 onChangeSelection,
15137 onClickItem,
15138 isItemClickable,
15139 renderItemLink,
15140 getItemId,
15141 item,
15142 actions,
15143 mediaField,
15144 titleField,
15145 descriptionField,
15146 regularFields,
15147 badgeFields,
15148 hasBulkActions,
15149 posinset: stablePosition,
15150 setsize: paginationInfo.totalItems,
15151 config: {
15152 sizes: size4
15153 }
15154 }
15155 )
15156 },
15157 itemId
15158 );
15159 })
15160 ]
15161 }
15162 ),
15163 // Render standard grid layout (with rows, grid semantics)
15164 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15165 import_components8.Composite,
15166 {
15167 role: "grid",
15168 className: clsx_default("dataviews-view-grid", className, {
15169 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
15170 view.layout.density
15171 )
15172 }),
15173 focusWrap: true,
15174 "aria-busy": isLoading,
15175 "aria-rowcount": totalRows,
15176 ref: resizeObserverRef,
15177 inert,
15178 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15179 import_components8.Composite.Row,
15180 {
15181 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15182 "div",
15183 {
15184 role: "row",
15185 "aria-rowindex": i2 + 1,
15186 "aria-label": (0, import_i18n13.sprintf)(
15187 /* translators: %d: The row number in the grid */
15188 (0, import_i18n13.__)("Row %d"),
15189 i2 + 1
15190 ),
15191 className: "dataviews-view-grid__row",
15192 style: {
15193 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
15194 }
15195 }
15196 ),
15197 children: row.map((item) => {
15198 const itemId = getItemId(item);
15199 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15200 import_components8.Composite.Item,
15201 {
15202 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15203 GridItem,
15204 {
15205 ...props,
15206 id: itemId,
15207 role: "gridcell",
15208 view,
15209 selection,
15210 onChangeSelection,
15211 onClickItem,
15212 isItemClickable,
15213 renderItemLink,
15214 getItemId,
15215 item,
15216 actions,
15217 mediaField,
15218 titleField,
15219 descriptionField,
15220 regularFields,
15221 badgeFields,
15222 hasBulkActions,
15223 config: {
15224 sizes: size4
15225 }
15226 }
15227 )
15228 },
15229 itemId
15230 );
15231 })
15232 },
15233 i2
15234 ))
15235 }
15236 )
15237 ]
15238 });
15239 }
15240
15241 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
15242 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15243 function ViewGrid({
15244 actions,
15245 data,
15246 fields,
15247 getItemId,
15248 isLoading,
15249 onChangeSelection,
15250 onClickItem,
15251 isItemClickable,
15252 renderItemLink,
15253 selection,
15254 view,
15255 className,
15256 empty
15257 }) {
15258 const isDelayedLoading = useDelayedLoading(!!isLoading);
15259 const hasData = !!data?.length;
15260 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
15261 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15262 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
15263 if (!hasData) {
15264 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15265 "div",
15266 {
15267 className: clsx_default("dataviews-no-results", {
15268 "is-refreshing": isDelayedLoading
15269 }),
15270 children: empty
15271 }
15272 );
15273 }
15274 const gridProps = {
15275 className: clsx_default(className, {
15276 "is-refreshing": !isInfiniteScroll && isDelayedLoading
15277 }),
15278 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
15279 isLoading,
15280 view,
15281 fields,
15282 selection,
15283 onChangeSelection,
15284 onClickItem,
15285 isItemClickable,
15286 renderItemLink,
15287 getItemId,
15288 actions
15289 };
15290 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, {
15291 // Render multiple groups.
15292 children: [
15293 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
15294 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
15295 Stack,
15296 {
15297 direction: "column",
15298 gap: "sm",
15299 children: [
15300 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
15301 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15302 (0, import_i18n14.__)("%1$s: %2$s"),
15303 groupField.label,
15304 groupName
15305 ) }),
15306 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15307 CompositeGrid,
15308 {
15309 ...gridProps,
15310 data: groupItems,
15311 isInfiniteScroll: false
15312 }
15313 )
15314 ]
15315 },
15316 groupName
15317 )
15318 ) }),
15319 // Render a single grid with all data.
15320 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15321 CompositeGrid,
15322 {
15323 ...gridProps,
15324 data,
15325 isInfiniteScroll: !!isInfiniteScroll
15326 }
15327 ),
15328 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components9.Spinner, {}) })
15329 ]
15330 });
15331 }
15332 var grid_default = ViewGrid;
15333
15334 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
15335 var import_compose4 = __toESM(require_compose(), 1);
15336 var import_components10 = __toESM(require_components(), 1);
15337 var import_element56 = __toESM(require_element(), 1);
15338 var import_i18n15 = __toESM(require_i18n(), 1);
15339 var import_data3 = __toESM(require_data(), 1);
15340 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15341 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
15342 function generateItemWrapperCompositeId(idPrefix) {
15343 return `${idPrefix}-item-wrapper`;
15344 }
15345 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
15346 return `${idPrefix}-primary-action-${primaryActionId}`;
15347 }
15348 function generateDropdownTriggerCompositeId(idPrefix) {
15349 return `${idPrefix}-dropdown`;
15350 }
15351 function PrimaryActionGridCell({
15352 idPrefix,
15353 primaryAction,
15354 item
15355 }) {
15356 const registry = (0, import_data3.useRegistry)();
15357 const [isModalOpen, setIsModalOpen] = (0, import_element56.useState)(false);
15358 const compositeItemId = generatePrimaryActionCompositeId(
15359 idPrefix,
15360 primaryAction.id
15361 );
15362 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
15363 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15364 import_components10.Composite.Item,
15365 {
15366 id: compositeItemId,
15367 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15368 import_components10.Button,
15369 {
15370 disabled: !!primaryAction.disabled,
15371 accessibleWhenDisabled: true,
15372 text: label,
15373 size: "small",
15374 onClick: () => setIsModalOpen(true)
15375 }
15376 ),
15377 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15378 ActionModal,
15379 {
15380 action: primaryAction,
15381 items: [item],
15382 closeModal: () => setIsModalOpen(false)
15383 }
15384 )
15385 }
15386 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15387 import_components10.Composite.Item,
15388 {
15389 id: compositeItemId,
15390 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15391 import_components10.Button,
15392 {
15393 disabled: !!primaryAction.disabled,
15394 accessibleWhenDisabled: true,
15395 size: "small",
15396 onClick: () => {
15397 primaryAction.callback([item], { registry });
15398 },
15399 children: label
15400 }
15401 )
15402 }
15403 ) }, primaryAction.id);
15404 }
15405 function ListItem({
15406 view,
15407 actions,
15408 idPrefix,
15409 isSelected: isSelected2,
15410 item,
15411 titleField,
15412 mediaField,
15413 descriptionField,
15414 onSelect,
15415 otherFields,
15416 onDropdownTriggerKeyDown,
15417 posinset
15418 }) {
15419 const {
15420 showTitle = true,
15421 showMedia = true,
15422 showDescription = true,
15423 infiniteScrollEnabled
15424 } = view;
15425 const itemRef = (0, import_element56.useRef)(null);
15426 const labelId = `${idPrefix}-label`;
15427 const descriptionId = `${idPrefix}-description`;
15428 const registry = (0, import_data3.useRegistry)();
15429 const [isHovered, setIsHovered] = (0, import_element56.useState)(false);
15430 const [activeModalAction, setActiveModalAction] = (0, import_element56.useState)(
15431 null
15432 );
15433 const handleHover = ({ type }) => {
15434 const isHover = type === "mouseenter";
15435 setIsHovered(isHover);
15436 };
15437 const { paginationInfo } = (0, import_element56.useContext)(dataviews_context_default);
15438 (0, import_element56.useEffect)(() => {
15439 if (isSelected2) {
15440 itemRef.current?.scrollIntoView({
15441 behavior: "auto",
15442 block: "nearest",
15443 inline: "nearest"
15444 });
15445 }
15446 }, [isSelected2]);
15447 const { primaryAction, eligibleActions } = (0, import_element56.useMemo)(() => {
15448 const _eligibleActions = actions.filter(
15449 (action) => !action.isEligible || action.isEligible(item)
15450 );
15451 const _primaryActions = _eligibleActions.filter(
15452 (action) => action.isPrimary
15453 );
15454 return {
15455 primaryAction: _primaryActions[0],
15456 eligibleActions: _eligibleActions
15457 };
15458 }, [actions, item]);
15459 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
15460 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15461 mediaField.render,
15462 {
15463 item,
15464 field: mediaField,
15465 config: { sizes: "52px" }
15466 }
15467 ) }) : null;
15468 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(titleField.render, { item, field: titleField }) : null;
15469 const renderDescription = showDescription && descriptionField?.render;
15470 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
15471 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15472 Stack,
15473 {
15474 direction: "row",
15475 gap: "md",
15476 className: "dataviews-view-list__item-actions",
15477 children: [
15478 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15479 PrimaryActionGridCell,
15480 {
15481 idPrefix,
15482 primaryAction,
15483 item
15484 }
15485 ),
15486 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { role: "gridcell", children: [
15487 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Menu3, { placement: "bottom-end", children: [
15488 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15489 Menu3.TriggerButton,
15490 {
15491 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15492 import_components10.Composite.Item,
15493 {
15494 id: generateDropdownTriggerCompositeId(
15495 idPrefix
15496 ),
15497 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15498 import_components10.Button,
15499 {
15500 size: "small",
15501 icon: more_vertical_default,
15502 label: (0, import_i18n15.__)("Actions"),
15503 accessibleWhenDisabled: true,
15504 disabled: !actions.length,
15505 onKeyDown: onDropdownTriggerKeyDown
15506 }
15507 )
15508 }
15509 )
15510 }
15511 ),
15512 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15513 ActionsMenuGroup,
15514 {
15515 actions: eligibleActions,
15516 item,
15517 registry,
15518 setActiveModalAction
15519 }
15520 ) })
15521 ] }),
15522 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15523 ActionModal,
15524 {
15525 action: activeModalAction,
15526 items: [item],
15527 closeModal: () => setActiveModalAction(null)
15528 }
15529 )
15530 ] })
15531 ]
15532 }
15533 );
15534 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15535 import_components10.Composite.Row,
15536 {
15537 ref: itemRef,
15538 render: (
15539 /* aria-posinset breaks Composite.Row if passed to it directly. */
15540 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15541 "div",
15542 {
15543 "aria-posinset": posinset,
15544 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
15545 }
15546 )
15547 ),
15548 role: infiniteScrollEnabled ? "article" : "row",
15549 className: clsx_default({
15550 "is-selected": isSelected2,
15551 "is-hovered": isHovered
15552 }),
15553 onMouseEnter: handleHover,
15554 onMouseLeave: handleHover,
15555 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15556 Stack,
15557 {
15558 direction: "row",
15559 className: "dataviews-view-list__item-wrapper",
15560 children: [
15561 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15562 import_components10.Composite.Item,
15563 {
15564 id: generateItemWrapperCompositeId(idPrefix),
15565 "aria-pressed": isSelected2,
15566 "aria-labelledby": labelId,
15567 "aria-describedby": descriptionId,
15568 className: "dataviews-view-list__item",
15569 onClick: () => onSelect(item)
15570 }
15571 ) }),
15572 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15573 Stack,
15574 {
15575 direction: "row",
15576 gap: "md",
15577 justify: "start",
15578 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
15579 style: { flex: 1, minWidth: 0 },
15580 children: [
15581 renderedMediaField,
15582 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15583 Stack,
15584 {
15585 direction: "column",
15586 gap: "xs",
15587 className: "dataviews-view-list__field-wrapper",
15588 children: [
15589 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "row", align: "center", children: [
15590 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15591 "div",
15592 {
15593 className: "dataviews-title-field dataviews-view-list__title-field",
15594 id: labelId,
15595 children: renderedTitleField
15596 }
15597 ),
15598 usedActions
15599 ] }),
15600 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15601 descriptionField.render,
15602 {
15603 item,
15604 field: descriptionField
15605 }
15606 ) }),
15607 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15608 "div",
15609 {
15610 className: "dataviews-view-list__fields",
15611 id: descriptionId,
15612 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15613 "div",
15614 {
15615 className: "dataviews-view-list__field",
15616 children: [
15617 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15618 VisuallyHidden,
15619 {
15620 className: "dataviews-view-list__field-label",
15621 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {}),
15622 children: field.label
15623 }
15624 ),
15625 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15626 field.render,
15627 {
15628 item,
15629 field
15630 }
15631 ) })
15632 ]
15633 },
15634 field.id
15635 ))
15636 }
15637 )
15638 ]
15639 }
15640 )
15641 ]
15642 }
15643 )
15644 ]
15645 }
15646 )
15647 }
15648 );
15649 }
15650 function isDefined2(item) {
15651 return !!item;
15652 }
15653 function ViewList(props) {
15654 const {
15655 actions,
15656 data,
15657 fields,
15658 getItemId,
15659 isLoading,
15660 onChangeSelection,
15661 selection,
15662 view,
15663 className,
15664 empty
15665 } = props;
15666 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
15667 const isDelayedLoading = useDelayedLoading(!!isLoading);
15668 const selectedItem = data?.findLast(
15669 (item) => selection.includes(getItemId(item))
15670 );
15671 const titleField = fields.find((field) => field.id === view.titleField);
15672 const mediaField = fields.find((field) => field.id === view.mediaField);
15673 const descriptionField = fields.find(
15674 (field) => field.id === view.descriptionField
15675 );
15676 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
15677 const onSelect = (item) => onChangeSelection([getItemId(item)]);
15678 const generateCompositeItemIdPrefix = (0, import_element56.useCallback)(
15679 (item) => `${baseId}-${getItemId(item)}`,
15680 [baseId, getItemId]
15681 );
15682 const isActiveCompositeItem = (0, import_element56.useCallback)(
15683 (item, idToCheck) => {
15684 return idToCheck.startsWith(
15685 generateCompositeItemIdPrefix(item)
15686 );
15687 },
15688 [generateCompositeItemIdPrefix]
15689 );
15690 const [activeCompositeId, setActiveCompositeId] = (0, import_element56.useState)(void 0);
15691 const compositeRef = (0, import_element56.useRef)(null);
15692 (0, import_element56.useEffect)(() => {
15693 if (selectedItem) {
15694 setActiveCompositeId(
15695 generateItemWrapperCompositeId(
15696 generateCompositeItemIdPrefix(selectedItem)
15697 )
15698 );
15699 }
15700 }, [selectedItem, generateCompositeItemIdPrefix]);
15701 const activeItemIndex = data.findIndex(
15702 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
15703 );
15704 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
15705 const isActiveIdInList = activeItemIndex !== -1;
15706 const selectCompositeItem = (0, import_element56.useCallback)(
15707 (targetIndex, generateCompositeId) => {
15708 const clampedIndex = Math.min(
15709 data.length - 1,
15710 Math.max(0, targetIndex)
15711 );
15712 if (!data[clampedIndex]) {
15713 return;
15714 }
15715 const itemIdPrefix = generateCompositeItemIdPrefix(
15716 data[clampedIndex]
15717 );
15718 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
15719 setActiveCompositeId(targetCompositeItemId);
15720 if (compositeRef.current?.contains(
15721 compositeRef.current.ownerDocument.activeElement
15722 )) {
15723 document.getElementById(targetCompositeItemId)?.focus();
15724 }
15725 },
15726 [data, generateCompositeItemIdPrefix]
15727 );
15728 (0, import_element56.useEffect)(() => {
15729 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
15730 if (!isActiveIdInList && wasActiveIdInList) {
15731 selectCompositeItem(
15732 previousActiveItemIndex,
15733 generateItemWrapperCompositeId
15734 );
15735 }
15736 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
15737 const onDropdownTriggerKeyDown = (0, import_element56.useCallback)(
15738 (event) => {
15739 if (event.key === "ArrowDown") {
15740 event.preventDefault();
15741 selectCompositeItem(
15742 activeItemIndex + 1,
15743 generateDropdownTriggerCompositeId
15744 );
15745 }
15746 if (event.key === "ArrowUp") {
15747 event.preventDefault();
15748 selectCompositeItem(
15749 activeItemIndex - 1,
15750 generateDropdownTriggerCompositeId
15751 );
15752 }
15753 },
15754 [selectCompositeItem, activeItemIndex]
15755 );
15756 const hasData = !!data?.length;
15757 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
15758 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
15759 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
15760 if (!hasData) {
15761 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15762 "div",
15763 {
15764 className: clsx_default("dataviews-no-results", {
15765 "is-refreshing": isDelayedLoading
15766 }),
15767 children: empty
15768 }
15769 );
15770 }
15771 if (hasData && groupField && dataByGroup) {
15772 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15773 import_components10.Composite,
15774 {
15775 ref: compositeRef,
15776 id: `${baseId}`,
15777 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", {}),
15778 className: "dataviews-view-list__group",
15779 role: "grid",
15780 activeId: activeCompositeId,
15781 setActiveId: setActiveCompositeId,
15782 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15783 Stack,
15784 {
15785 direction: "column",
15786 gap: "lg",
15787 className: clsx_default("dataviews-view-list", className),
15788 children: Array.from(dataByGroup.entries()).map(
15789 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15790 Stack,
15791 {
15792 direction: "column",
15793 gap: "sm",
15794 children: [
15795 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n15.sprintf)(
15796 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15797 (0, import_i18n15.__)("%1$s: %2$s"),
15798 groupField.label,
15799 groupName
15800 ) }),
15801 groupItems.map((item) => {
15802 const id = generateCompositeItemIdPrefix(item);
15803 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15804 ListItem,
15805 {
15806 view,
15807 idPrefix: id,
15808 actions,
15809 item,
15810 isSelected: item === selectedItem,
15811 onSelect,
15812 mediaField,
15813 titleField,
15814 descriptionField,
15815 otherFields,
15816 onDropdownTriggerKeyDown
15817 },
15818 id
15819 );
15820 })
15821 ]
15822 },
15823 groupName
15824 )
15825 )
15826 }
15827 )
15828 }
15829 );
15830 }
15831 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [
15832 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15833 import_components10.Composite,
15834 {
15835 ref: compositeRef,
15836 id: baseId,
15837 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", {}),
15838 className: clsx_default("dataviews-view-list", className, {
15839 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
15840 view.layout.density
15841 ),
15842 "is-refreshing": !isInfiniteScroll && isDelayedLoading
15843 }),
15844 role: view.infiniteScrollEnabled ? "feed" : "grid",
15845 activeId: activeCompositeId,
15846 setActiveId: setActiveCompositeId,
15847 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
15848 children: data.map((item, index2) => {
15849 const id = generateCompositeItemIdPrefix(item);
15850 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15851 ListItem,
15852 {
15853 view,
15854 idPrefix: id,
15855 actions,
15856 item,
15857 isSelected: item === selectedItem,
15858 onSelect,
15859 mediaField,
15860 titleField,
15861 descriptionField,
15862 otherFields,
15863 onDropdownTriggerKeyDown,
15864 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
15865 },
15866 id
15867 );
15868 })
15869 }
15870 ),
15871 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components10.Spinner, {}) })
15872 ] });
15873 }
15874
15875 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
15876 var import_components11 = __toESM(require_components(), 1);
15877
15878 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
15879 var import_i18n16 = __toESM(require_i18n(), 1);
15880 var import_element57 = __toESM(require_element(), 1);
15881 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
15882 function ActivityGroup({
15883 groupName,
15884 groupData,
15885 groupField,
15886 showLabel = true,
15887 children
15888 }) {
15889 const groupHeader = showLabel ? (0, import_element57.createInterpolateElement)(
15890 // translators: %s: The label of the field e.g. "Status".
15891 (0, import_i18n16.sprintf)((0, import_i18n16.__)("%s: <groupName />"), groupField.label).trim(),
15892 {
15893 groupName: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15894 groupField.render,
15895 {
15896 item: groupData[0],
15897 field: groupField
15898 }
15899 )
15900 }
15901 ) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(groupField.render, { item: groupData[0], field: groupField });
15902 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
15903 Stack,
15904 {
15905 direction: "column",
15906 className: "dataviews-view-activity__group",
15907 children: [
15908 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
15909 children
15910 ]
15911 },
15912 groupName
15913 );
15914 }
15915
15916 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
15917 var import_element58 = __toESM(require_element(), 1);
15918 var import_data4 = __toESM(require_data(), 1);
15919 var import_compose5 = __toESM(require_compose(), 1);
15920 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15921 function ActivityItem(props) {
15922 const {
15923 view,
15924 actions,
15925 item,
15926 titleField,
15927 mediaField,
15928 descriptionField,
15929 otherFields,
15930 posinset,
15931 onClickItem,
15932 renderItemLink,
15933 isItemClickable
15934 } = props;
15935 const {
15936 showTitle = true,
15937 showMedia = true,
15938 showDescription = true,
15939 infiniteScrollEnabled
15940 } = view;
15941 const itemRef = (0, import_element58.useRef)(null);
15942 const registry = (0, import_data4.useRegistry)();
15943 const { paginationInfo } = (0, import_element58.useContext)(dataviews_context_default);
15944 const { primaryActions, eligibleActions } = (0, import_element58.useMemo)(() => {
15945 const _eligibleActions = actions.filter(
15946 (action) => !action.isEligible || action.isEligible(item)
15947 );
15948 const _primaryActions = _eligibleActions.filter(
15949 (action) => action.isPrimary
15950 );
15951 return {
15952 primaryActions: _primaryActions,
15953 eligibleActions: _eligibleActions
15954 };
15955 }, [actions, item]);
15956 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
15957 const density = view.layout?.density ?? "balanced";
15958 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15959 mediaField.render,
15960 {
15961 item,
15962 field: mediaField,
15963 config: {
15964 sizes: density === "comfortable" ? "32px" : "24px"
15965 }
15966 }
15967 ) : null;
15968 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15969 "span",
15970 {
15971 className: "dataviews-view-activity__item-bullet",
15972 "aria-hidden": "true"
15973 }
15974 ) });
15975 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(titleField.render, { item, field: titleField }) : null;
15976 const verticalGap = (0, import_element58.useMemo)(() => {
15977 switch (density) {
15978 case "comfortable":
15979 return "md";
15980 default:
15981 return "sm";
15982 }
15983 }, [density]);
15984 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15985 "div",
15986 {
15987 ref: itemRef,
15988 role: infiniteScrollEnabled ? "article" : void 0,
15989 "aria-posinset": posinset,
15990 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
15991 className: clsx_default(
15992 "dataviews-view-activity__item",
15993 density === "compact" && "is-compact",
15994 density === "balanced" && "is-balanced",
15995 density === "comfortable" && "is-comfortable"
15996 ),
15997 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
15998 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15999 Stack,
16000 {
16001 direction: "column",
16002 gap: "xs",
16003 align: "center",
16004 className: "dataviews-view-activity__item-type",
16005 children: renderedMediaField
16006 }
16007 ),
16008 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
16009 Stack,
16010 {
16011 direction: "column",
16012 gap: verticalGap,
16013 align: "flex-start",
16014 className: "dataviews-view-activity__item-content",
16015 children: [
16016 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16017 ItemClickWrapper,
16018 {
16019 item,
16020 isItemClickable,
16021 onClickItem,
16022 renderItemLink,
16023 className: "dataviews-view-activity__item-title",
16024 children: renderedTitleField
16025 }
16026 ),
16027 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16028 descriptionField.render,
16029 {
16030 item,
16031 field: descriptionField
16032 }
16033 ) }),
16034 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
16035 "div",
16036 {
16037 className: "dataviews-view-activity__item-field",
16038 children: [
16039 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16040 VisuallyHidden,
16041 {
16042 className: "dataviews-view-activity__item-field-label",
16043 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", {}),
16044 children: field.label
16045 }
16046 ),
16047 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16048 field.render,
16049 {
16050 item,
16051 field
16052 }
16053 ) })
16054 ]
16055 },
16056 field.id
16057 )) }),
16058 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16059 PrimaryActions,
16060 {
16061 item,
16062 actions: primaryActions,
16063 registry,
16064 buttonVariant: "secondary"
16065 }
16066 )
16067 ]
16068 }
16069 ),
16070 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
16071 // there if there are any actions at all.
16072 isMobileViewport && // At the same time, only show the menu if there are actions to show.
16073 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16074 ItemActions,
16075 {
16076 item,
16077 actions: eligibleActions,
16078 isCompact: true
16079 }
16080 ) })
16081 ] })
16082 }
16083 );
16084 }
16085 var activity_item_default = ActivityItem;
16086
16087 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
16088 var import_react15 = __toESM(require_react(), 1);
16089 function isDefined3(item) {
16090 return !!item;
16091 }
16092 function ActivityItems(props) {
16093 const { data, fields, getItemId, view } = props;
16094 const titleField = fields.find((field) => field.id === view.titleField);
16095 const mediaField = fields.find((field) => field.id === view.mediaField);
16096 const descriptionField = fields.find(
16097 (field) => field.id === view.descriptionField
16098 );
16099 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
16100 return data.map((item, index2) => {
16101 return /* @__PURE__ */ (0, import_react15.createElement)(
16102 activity_item_default,
16103 {
16104 ...props,
16105 key: getItemId(item),
16106 item,
16107 mediaField,
16108 titleField,
16109 descriptionField,
16110 otherFields,
16111 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
16112 }
16113 );
16114 });
16115 }
16116
16117 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
16118 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
16119 function ViewActivity(props) {
16120 const { empty, data, fields, isLoading, view, className } = props;
16121 const isDelayedLoading = useDelayedLoading(!!isLoading);
16122 const hasData = !!data?.length;
16123 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
16124 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
16125 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
16126 if (!hasData) {
16127 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16128 "div",
16129 {
16130 className: clsx_default("dataviews-no-results", {
16131 "is-refreshing": isDelayedLoading
16132 }),
16133 children: empty
16134 }
16135 );
16136 }
16137 const isInert = !isInfiniteScroll && !!isLoading;
16138 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
16139 "is-refreshing": !isInfiniteScroll && isDelayedLoading
16140 });
16141 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
16142 if (hasData && groupField && dataByGroup) {
16143 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16144 Stack,
16145 {
16146 direction: "column",
16147 gap: "sm",
16148 className: wrapperClassName,
16149 inert: isInert ? "true" : void 0,
16150 children: groupedEntries.map(
16151 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16152 ActivityGroup,
16153 {
16154 groupName,
16155 groupData,
16156 groupField,
16157 showLabel: view.groupBy?.showLabel !== false,
16158 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16159 ActivityItems,
16160 {
16161 ...props,
16162 data: groupData
16163 }
16164 )
16165 },
16166 groupName
16167 )
16168 )
16169 }
16170 );
16171 }
16172 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_jsx_runtime80.Fragment, { children: [
16173 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16174 "div",
16175 {
16176 className: wrapperClassName,
16177 role: view.infiniteScrollEnabled ? "feed" : void 0,
16178 inert: isInert ? "true" : void 0,
16179 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ActivityItems, { ...props })
16180 }
16181 ),
16182 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components11.Spinner, {}) })
16183 ] });
16184 }
16185
16186 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
16187 var import_components14 = __toESM(require_components(), 1);
16188 var import_i18n19 = __toESM(require_i18n(), 1);
16189 var import_compose6 = __toESM(require_compose(), 1);
16190 var import_element61 = __toESM(require_element(), 1);
16191
16192 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
16193 var import_components13 = __toESM(require_components(), 1);
16194 var import_data5 = __toESM(require_data(), 1);
16195 var import_element60 = __toESM(require_element(), 1);
16196 var import_i18n18 = __toESM(require_i18n(), 1);
16197
16198 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
16199 var import_components12 = __toESM(require_components(), 1);
16200 var import_element59 = __toESM(require_element(), 1);
16201 var import_i18n17 = __toESM(require_i18n(), 1);
16202 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
16203 function DataViewsPagination() {
16204 const {
16205 view,
16206 onChangeView,
16207 paginationInfo: { totalItems = 0, totalPages }
16208 } = (0, import_element59.useContext)(dataviews_context_default);
16209 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
16210 return null;
16211 }
16212 const currentPage = view.page ?? 1;
16213 const pageSelectOptions = Array.from(Array(totalPages)).map(
16214 (_, i2) => {
16215 const page = i2 + 1;
16216 return {
16217 value: page.toString(),
16218 label: page.toString(),
16219 "aria-label": currentPage === page ? (0, import_i18n17.sprintf)(
16220 // translators: 1: current page number. 2: total number of pages.
16221 (0, import_i18n17.__)("Page %1$d of %2$d"),
16222 currentPage,
16223 totalPages
16224 ) : page.toString()
16225 };
16226 }
16227 );
16228 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
16229 Stack,
16230 {
16231 direction: "row",
16232 className: "dataviews-pagination",
16233 justify: "end",
16234 align: "center",
16235 gap: "xl",
16236 children: [
16237 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16238 Stack,
16239 {
16240 direction: "row",
16241 justify: "flex-start",
16242 align: "center",
16243 gap: "xs",
16244 className: "dataviews-pagination__page-select",
16245 children: (0, import_element59.createInterpolateElement)(
16246 (0, import_i18n17.sprintf)(
16247 // translators: 1: Current page number, 2: Total number of pages.
16248 (0, import_i18n17._x)(
16249 "<div>Page</div>%1$s<div>of %2$d</div>",
16250 "paging"
16251 ),
16252 "<CurrentPage />",
16253 totalPages
16254 ),
16255 {
16256 div: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { "aria-hidden": true }),
16257 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
16258 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16259 import_components12.SelectControl,
16260 {
16261 "aria-label": (0, import_i18n17.__)("Current page"),
16262 value: currentPage.toString(),
16263 options: pageSelectOptions,
16264 onChange: (newValue) => {
16265 onChangeView({
16266 ...view,
16267 page: +newValue
16268 });
16269 },
16270 size: "small",
16271 variant: "minimal"
16272 }
16273 )
16274 }
16275 )
16276 }
16277 ),
16278 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
16279 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16280 import_components12.Button,
16281 {
16282 onClick: () => onChangeView({
16283 ...view,
16284 page: currentPage - 1
16285 }),
16286 disabled: currentPage === 1,
16287 accessibleWhenDisabled: true,
16288 label: (0, import_i18n17.__)("Previous page"),
16289 icon: (0, import_i18n17.isRTL)() ? next_default : previous_default,
16290 showTooltip: true,
16291 size: "compact",
16292 tooltipPosition: "top"
16293 }
16294 ),
16295 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16296 import_components12.Button,
16297 {
16298 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
16299 disabled: currentPage >= totalPages,
16300 accessibleWhenDisabled: true,
16301 label: (0, import_i18n17.__)("Next page"),
16302 icon: (0, import_i18n17.isRTL)() ? previous_default : next_default,
16303 showTooltip: true,
16304 size: "compact",
16305 tooltipPosition: "top"
16306 }
16307 )
16308 ] })
16309 ]
16310 }
16311 );
16312 }
16313 var dataviews_pagination_default = (0, import_element59.memo)(DataViewsPagination);
16314
16315 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
16316 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
16317 function useIsMultiselectPicker(actions) {
16318 return (0, import_element60.useMemo)(() => {
16319 return actions?.every((action) => action.supportsBulk);
16320 }, [actions]);
16321 }
16322
16323 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
16324 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
16325 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
16326 function GridItem3({
16327 view,
16328 multiselect,
16329 selection,
16330 onChangeSelection,
16331 getItemId,
16332 item,
16333 mediaField,
16334 titleField,
16335 descriptionField,
16336 regularFields,
16337 badgeFields,
16338 config,
16339 posinset,
16340 setsize
16341 }) {
16342 const { showTitle = true, showMedia = true, showDescription = true } = view;
16343 const id = getItemId(item);
16344 const elementRef = (0, import_element61.useRef)(null);
16345 const isSelected2 = selection.includes(id);
16346 useIntersectionObserver(elementRef, posinset);
16347 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16348 mediaField.render,
16349 {
16350 item,
16351 field: mediaField,
16352 config
16353 }
16354 ) : null;
16355 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(titleField.render, { item, field: titleField }) : null;
16356 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16357 import_components14.Composite.Item,
16358 {
16359 ref: elementRef,
16360 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n19.__)("(no title)") : void 0,
16361 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Stack, { direction: "column", children, ...props }),
16362 role: "option",
16363 "aria-posinset": posinset,
16364 "aria-setsize": setsize,
16365 className: clsx_default("dataviews-view-picker-grid__card", {
16366 "is-selected": isSelected2
16367 }),
16368 "aria-selected": isSelected2,
16369 onClick: () => {
16370 if (isSelected2) {
16371 onChangeSelection(
16372 selection.filter((itemId) => id !== itemId)
16373 );
16374 } else {
16375 const newSelection = multiselect ? [...selection, id] : [id];
16376 onChangeSelection(newSelection);
16377 }
16378 },
16379 children: [
16380 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
16381 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16382 DataViewsSelectionCheckbox,
16383 {
16384 item,
16385 selection,
16386 onChangeSelection,
16387 getItemId,
16388 titleField,
16389 disabled: false,
16390 "aria-hidden": true,
16391 tabIndex: -1
16392 }
16393 ),
16394 showTitle && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16395 Stack,
16396 {
16397 direction: "row",
16398 justify: "space-between",
16399 className: "dataviews-view-picker-grid__title-actions",
16400 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
16401 }
16402 ),
16403 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", gap: "xs", children: [
16404 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16405 descriptionField.render,
16406 {
16407 item,
16408 field: descriptionField
16409 }
16410 ),
16411 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16412 Stack,
16413 {
16414 direction: "row",
16415 className: "dataviews-view-picker-grid__badge-fields",
16416 gap: "sm",
16417 wrap: "wrap",
16418 align: "top",
16419 justify: "flex-start",
16420 children: badgeFields.map((field) => {
16421 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16422 WCBadge2,
16423 {
16424 className: "dataviews-view-picker-grid__field-value",
16425 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16426 field.render,
16427 {
16428 item,
16429 field
16430 }
16431 )
16432 },
16433 field.id
16434 );
16435 })
16436 }
16437 ),
16438 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16439 Stack,
16440 {
16441 direction: "column",
16442 className: "dataviews-view-picker-grid__fields",
16443 gap: "xs",
16444 children: regularFields.map((field) => {
16445 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16446 import_components14.Flex,
16447 {
16448 className: "dataviews-view-picker-grid__field",
16449 gap: 1,
16450 justify: "flex-start",
16451 expanded: true,
16452 style: { height: "auto" },
16453 direction: "row",
16454 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [
16455 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
16456 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16457 import_components14.FlexItem,
16458 {
16459 className: "dataviews-view-picker-grid__field-value",
16460 style: { maxHeight: "none" },
16461 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16462 field.render,
16463 {
16464 item,
16465 field
16466 }
16467 )
16468 }
16469 )
16470 ] })
16471 },
16472 field.id
16473 );
16474 })
16475 }
16476 )
16477 ] })
16478 ]
16479 },
16480 id
16481 );
16482 }
16483 function GridGroup({
16484 groupName,
16485 groupField,
16486 showLabel = true,
16487 children
16488 }) {
16489 const headerId = (0, import_compose6.useInstanceId)(
16490 GridGroup,
16491 "dataviews-view-picker-grid-group__header"
16492 );
16493 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16494 Stack,
16495 {
16496 direction: "column",
16497 gap: "sm",
16498 role: "group",
16499 "aria-labelledby": headerId,
16500 children: [
16501 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16502 "h3",
16503 {
16504 className: "dataviews-view-picker-grid-group__header",
16505 id: headerId,
16506 children: showLabel ? (0, import_i18n19.sprintf)(
16507 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
16508 (0, import_i18n19.__)("%1$s: %2$s"),
16509 groupField.label,
16510 groupName
16511 ) : groupName
16512 }
16513 ),
16514 children
16515 ]
16516 },
16517 groupName
16518 );
16519 }
16520 function ViewPickerGrid({
16521 actions,
16522 data,
16523 fields,
16524 getItemId,
16525 isLoading,
16526 onChangeSelection,
16527 selection,
16528 view,
16529 className,
16530 empty
16531 }) {
16532 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element61.useContext)(dataviews_context_default);
16533 const titleField = fields.find(
16534 (field) => field.id === view?.titleField
16535 );
16536 const mediaField = fields.find(
16537 (field) => field.id === view?.mediaField
16538 );
16539 const descriptionField = fields.find(
16540 (field) => field.id === view?.descriptionField
16541 );
16542 const otherFields = view.fields ?? [];
16543 const { regularFields, badgeFields } = otherFields.reduce(
16544 (accumulator, fieldId) => {
16545 const field = fields.find((f2) => f2.id === fieldId);
16546 if (!field) {
16547 return accumulator;
16548 }
16549 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
16550 accumulator[key].push(field);
16551 return accumulator;
16552 },
16553 { regularFields: [], badgeFields: [] }
16554 );
16555 const hasData = !!data?.length;
16556 const usedPreviewSize = view.layout?.previewSize;
16557 const isMultiselect = useIsMultiselectPicker(actions);
16558 const size4 = "900px";
16559 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
16560 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
16561 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
16562 const currentPage = view?.page ?? 1;
16563 const perPage = view?.perPage ?? 0;
16564 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
16565 const gridColumns = useGridColumns();
16566 const placeholdersNeeded = usePlaceholdersNeeded(
16567 data,
16568 isInfiniteScroll,
16569 gridColumns
16570 );
16571 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, {
16572 // Render multiple groups.
16573 children: [
16574 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16575 import_components14.Composite,
16576 {
16577 virtualFocus: true,
16578 orientation: "horizontal",
16579 role: "listbox",
16580 "aria-multiselectable": isMultiselect,
16581 className: clsx_default(
16582 "dataviews-view-picker-grid",
16583 className,
16584 {
16585 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
16586 view.layout.density
16587 )
16588 }
16589 ),
16590 "aria-label": itemListLabel,
16591 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16592 Stack,
16593 {
16594 direction: "column",
16595 gap: "lg",
16596 children,
16597 ...props
16598 }
16599 ),
16600 children: Array.from(dataByGroup.entries()).map(
16601 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16602 GridGroup,
16603 {
16604 groupName,
16605 groupField,
16606 showLabel: view.groupBy?.showLabel !== false,
16607 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16608 GridItems,
16609 {
16610 previewSize: usedPreviewSize,
16611 style: {
16612 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
16613 },
16614 "aria-busy": isLoading,
16615 ref: resizeObserverRef,
16616 children: groupItems.map((item) => {
16617 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
16618 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16619 GridItem3,
16620 {
16621 view,
16622 multiselect: isMultiselect,
16623 selection,
16624 onChangeSelection,
16625 getItemId,
16626 item,
16627 mediaField,
16628 titleField,
16629 descriptionField,
16630 regularFields,
16631 badgeFields,
16632 config: {
16633 sizes: size4
16634 },
16635 posinset: posInSet,
16636 setsize: setSize
16637 },
16638 getItemId(item)
16639 );
16640 })
16641 }
16642 )
16643 },
16644 groupName
16645 )
16646 )
16647 }
16648 ),
16649 // Render a single grid with all data.
16650 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16651 import_components14.Composite,
16652 {
16653 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16654 GridItems,
16655 {
16656 className: clsx_default(
16657 "dataviews-view-picker-grid",
16658 className,
16659 {
16660 [`has-${view.layout?.density}-density`]: view.layout?.density && [
16661 "compact",
16662 "comfortable"
16663 ].includes(view.layout.density)
16664 }
16665 ),
16666 previewSize: usedPreviewSize,
16667 "aria-busy": isLoading,
16668 ref: resizeObserverRef
16669 }
16670 ),
16671 virtualFocus: true,
16672 orientation: "horizontal",
16673 role: "listbox",
16674 "aria-multiselectable": isMultiselect,
16675 "aria-label": itemListLabel,
16676 children: [
16677 Array.from({ length: placeholdersNeeded }).map(
16678 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16679 import_components14.Composite.Item,
16680 {
16681 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16682 Stack,
16683 {
16684 direction: "column",
16685 children,
16686 ...props
16687 }
16688 ),
16689 role: "option",
16690 "aria-hidden": true,
16691 tabIndex: -1,
16692 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
16693 },
16694 `placeholder-${index2}`
16695 )
16696 ),
16697 data.map((item) => {
16698 const posinset = item.position;
16699 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16700 GridItem3,
16701 {
16702 view,
16703 multiselect: isMultiselect,
16704 selection,
16705 onChangeSelection,
16706 getItemId,
16707 item,
16708 mediaField,
16709 titleField,
16710 descriptionField,
16711 regularFields,
16712 badgeFields,
16713 config: {
16714 sizes: size4
16715 },
16716 posinset,
16717 setsize: setSize
16718 },
16719 getItemId(item)
16720 );
16721 })
16722 ]
16723 }
16724 ),
16725 // Render empty state.
16726 !hasData && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16727 "div",
16728 {
16729 className: clsx_default({
16730 "dataviews-loading": isLoading,
16731 "dataviews-no-results": !isLoading
16732 }),
16733 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.Spinner, {}) }) : empty
16734 }
16735 ),
16736 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.Spinner, {}) })
16737 ]
16738 });
16739 }
16740 var picker_grid_default = ViewPickerGrid;
16741
16742 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
16743 var import_i18n20 = __toESM(require_i18n(), 1);
16744 var import_components15 = __toESM(require_components(), 1);
16745 var import_element62 = __toESM(require_element(), 1);
16746 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
16747 function TableColumnField2({
16748 item,
16749 fields,
16750 column,
16751 align
16752 }) {
16753 const field = fields.find((f2) => f2.id === column);
16754 if (!field) {
16755 return null;
16756 }
16757 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
16758 "dataviews-view-table__cell-align-end": align === "end",
16759 "dataviews-view-table__cell-align-center": align === "center"
16760 });
16761 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(field.render, { item, field }) });
16762 }
16763 function TableRow2({
16764 item,
16765 fields,
16766 id,
16767 view,
16768 titleField,
16769 mediaField,
16770 descriptionField,
16771 selection,
16772 getItemId,
16773 onChangeSelection,
16774 multiselect,
16775 posinset
16776 }) {
16777 const { paginationInfo } = (0, import_element62.useContext)(dataviews_context_default);
16778 const isSelected2 = selection.includes(id);
16779 const [isHovered, setIsHovered] = (0, import_element62.useState)(false);
16780 const elementRef = (0, import_element62.useRef)(null);
16781 useIntersectionObserver(elementRef, posinset);
16782 const {
16783 showTitle = true,
16784 showMedia = true,
16785 showDescription = true,
16786 infiniteScrollEnabled
16787 } = view;
16788 const handleMouseEnter = () => {
16789 setIsHovered(true);
16790 };
16791 const handleMouseLeave = () => {
16792 setIsHovered(false);
16793 };
16794 const columns = view.fields ?? [];
16795 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
16796 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
16797 import_components15.Composite.Item,
16798 {
16799 ref: elementRef,
16800 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16801 "tr",
16802 {
16803 className: clsx_default("dataviews-view-table__row", {
16804 "is-selected": isSelected2,
16805 "is-hovered": isHovered
16806 }),
16807 onMouseEnter: handleMouseEnter,
16808 onMouseLeave: handleMouseLeave,
16809 children,
16810 ...props
16811 }
16812 ),
16813 "aria-selected": isSelected2,
16814 "aria-setsize": paginationInfo.totalItems || void 0,
16815 "aria-posinset": posinset,
16816 role: infiniteScrollEnabled ? "article" : "option",
16817 onMouseDown: (event) => {
16818 if (event.button !== 0) {
16819 return;
16820 }
16821 event.currentTarget.parentElement?.focus({
16822 preventScroll: true
16823 });
16824 },
16825 onClick: () => {
16826 if (isSelected2) {
16827 onChangeSelection(
16828 selection.filter((itemId) => id !== itemId)
16829 );
16830 } else {
16831 const newSelection = multiselect ? [...selection, id] : [id];
16832 onChangeSelection(newSelection);
16833 }
16834 },
16835 children: [
16836 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16837 "td",
16838 {
16839 className: "dataviews-view-table__checkbox-column",
16840 role: "presentation",
16841 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16842 DataViewsSelectionCheckbox,
16843 {
16844 item,
16845 selection,
16846 onChangeSelection,
16847 getItemId,
16848 titleField,
16849 disabled: false,
16850 "aria-hidden": true,
16851 tabIndex: -1
16852 }
16853 ) })
16854 }
16855 ),
16856 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16857 "td",
16858 {
16859 role: "presentation",
16860 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16861 column_primary_default,
16862 {
16863 item,
16864 titleField: showTitle ? titleField : void 0,
16865 mediaField: showMedia ? mediaField : void 0,
16866 descriptionField: showDescription ? descriptionField : void 0,
16867 isItemClickable: () => false
16868 }
16869 )
16870 }
16871 ),
16872 columns.map((column) => {
16873 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
16874 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16875 "td",
16876 {
16877 style: {
16878 width,
16879 maxWidth,
16880 minWidth
16881 },
16882 role: "presentation",
16883 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16884 TableColumnField2,
16885 {
16886 fields,
16887 item,
16888 column,
16889 align
16890 }
16891 )
16892 },
16893 column
16894 );
16895 })
16896 ]
16897 },
16898 id
16899 );
16900 }
16901 function ViewPickerTable({
16902 actions,
16903 data,
16904 fields,
16905 getItemId,
16906 isLoading = false,
16907 onChangeView,
16908 onChangeSelection,
16909 selection,
16910 setOpenedFilter,
16911 view,
16912 className,
16913 empty
16914 }) {
16915 const headerMenuRefs = (0, import_element62.useRef)(/* @__PURE__ */ new Map());
16916 const headerMenuToFocusRef = (0, import_element62.useRef)(void 0);
16917 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element62.useState)();
16918 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
16919 (0, import_element62.useEffect)(() => {
16920 if (headerMenuToFocusRef.current) {
16921 headerMenuToFocusRef.current.focus();
16922 headerMenuToFocusRef.current = void 0;
16923 }
16924 });
16925 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
16926 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
16927 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
16928 const tableNoticeId = (0, import_element62.useId)();
16929 if (nextHeaderMenuToFocus) {
16930 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
16931 setNextHeaderMenuToFocus(void 0);
16932 return;
16933 }
16934 const onHide = (field) => {
16935 const hidden = headerMenuRefs.current.get(field.id);
16936 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
16937 setNextHeaderMenuToFocus(fallback?.node);
16938 };
16939 const hasData = !!data?.length;
16940 const titleField = fields.find((field) => field.id === view.titleField);
16941 const mediaField = fields.find((field) => field.id === view.mediaField);
16942 const descriptionField = fields.find(
16943 (field) => field.id === view.descriptionField
16944 );
16945 const { showTitle = true, showMedia = true, showDescription = true } = view;
16946 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
16947 const columns = view.fields ?? [];
16948 const headerMenuRef = (column, index2) => (node) => {
16949 if (node) {
16950 headerMenuRefs.current.set(column, {
16951 node,
16952 fallback: columns[index2 > 0 ? index2 - 1 : 1]
16953 });
16954 } else {
16955 headerMenuRefs.current.delete(column);
16956 }
16957 };
16958 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_jsx_runtime84.Fragment, { children: [
16959 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
16960 "table",
16961 {
16962 className: clsx_default(
16963 "dataviews-view-table",
16964 "dataviews-view-picker-table",
16965 className,
16966 {
16967 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
16968 view.layout.density
16969 )
16970 }
16971 ),
16972 "aria-busy": isLoading,
16973 "aria-describedby": tableNoticeId,
16974 role: isInfiniteScroll ? "feed" : "listbox",
16975 children: [
16976 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
16977 "tr",
16978 {
16979 className: "dataviews-view-table__row",
16980 role: "presentation",
16981 children: [
16982 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16983 BulkSelectionCheckbox,
16984 {
16985 selection,
16986 onChangeSelection,
16987 data,
16988 actions,
16989 getItemId,
16990 disableSelectAll: isInfiniteScroll
16991 }
16992 ) }),
16993 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16994 column_header_menu_default,
16995 {
16996 ref: headerMenuRef(
16997 titleField.id,
16998 0
16999 ),
17000 fieldId: titleField.id,
17001 view,
17002 fields,
17003 onChangeView,
17004 onHide,
17005 setOpenedFilter,
17006 canMove: false
17007 }
17008 ) }),
17009 columns.map((column, index2) => {
17010 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
17011 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17012 "th",
17013 {
17014 style: {
17015 width,
17016 maxWidth,
17017 minWidth,
17018 textAlign: align
17019 },
17020 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
17021 scope: "col",
17022 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17023 column_header_menu_default,
17024 {
17025 ref: headerMenuRef(column, index2),
17026 fieldId: column,
17027 view,
17028 fields,
17029 onChangeView,
17030 onHide,
17031 setOpenedFilter,
17032 canMove: view.layout?.enableMoving ?? true
17033 }
17034 )
17035 },
17036 column
17037 );
17038 })
17039 ]
17040 }
17041 ) }),
17042 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
17043 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17044 import_components15.Composite,
17045 {
17046 virtualFocus: true,
17047 orientation: "vertical",
17048 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("tbody", { role: "group" }),
17049 children: [
17050 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17051 "tr",
17052 {
17053 className: "dataviews-view-table__group-header-row",
17054 role: "presentation",
17055 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17056 "td",
17057 {
17058 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
17059 className: "dataviews-view-table__group-header-cell",
17060 role: "presentation",
17061 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n20.sprintf)(
17062 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
17063 (0, import_i18n20.__)("%1$s: %2$s"),
17064 groupField.label,
17065 groupName
17066 )
17067 }
17068 )
17069 }
17070 ),
17071 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17072 TableRow2,
17073 {
17074 item,
17075 fields,
17076 id: getItemId(item) || index2.toString(),
17077 view,
17078 titleField,
17079 mediaField,
17080 descriptionField,
17081 selection,
17082 getItemId,
17083 onChangeSelection,
17084 multiselect: isMultiselect
17085 },
17086 getItemId(item)
17087 ))
17088 ]
17089 },
17090 `group-${groupName}`
17091 )
17092 ) : /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17093 import_components15.Composite,
17094 {
17095 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("tbody", { role: "presentation" }),
17096 virtualFocus: true,
17097 orientation: "vertical",
17098 children: hasData && data.map((item, index2) => {
17099 const itemId = getItemId(item);
17100 const posinset = item.position;
17101 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17102 TableRow2,
17103 {
17104 item,
17105 fields,
17106 id: itemId || index2.toString(),
17107 view,
17108 titleField,
17109 mediaField,
17110 descriptionField,
17111 selection,
17112 getItemId,
17113 onChangeSelection,
17114 multiselect: isMultiselect,
17115 posinset
17116 },
17117 itemId
17118 );
17119 })
17120 }
17121 )
17122 ]
17123 }
17124 ),
17125 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17126 "div",
17127 {
17128 className: clsx_default({
17129 "dataviews-loading": isLoading,
17130 "dataviews-no-results": !hasData && !isLoading
17131 }),
17132 id: tableNoticeId,
17133 children: [
17134 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components15.Spinner, {}) }) : empty),
17135 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components15.Spinner, {}) })
17136 ]
17137 }
17138 )
17139 ] });
17140 }
17141 var picker_table_default = ViewPickerTable;
17142
17143 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
17144 var import_components16 = __toESM(require_components(), 1);
17145 var import_element63 = __toESM(require_element(), 1);
17146 var import_compose7 = __toESM(require_compose(), 1);
17147 var import_i18n21 = __toESM(require_i18n(), 1);
17148 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
17149 function isDefined4(item) {
17150 return !!item;
17151 }
17152 function PickerActivityItem({
17153 view,
17154 multiselect,
17155 selection,
17156 onChangeSelection,
17157 getItemId,
17158 item,
17159 titleField,
17160 mediaField,
17161 descriptionField,
17162 otherFields,
17163 posinset,
17164 setsize
17165 }) {
17166 const elementRef = (0, import_element63.useRef)(null);
17167 useIntersectionObserver(elementRef, posinset);
17168 const { showTitle = true, showMedia = true, showDescription = true } = view;
17169 const id = getItemId(item);
17170 const isSelected2 = selection.includes(id);
17171 const density = view.layout?.density ?? "balanced";
17172 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17173 mediaField.render,
17174 {
17175 item,
17176 field: mediaField,
17177 config: {
17178 sizes: density === "comfortable" ? "32px" : "24px"
17179 }
17180 }
17181 ) : null;
17182 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17183 "span",
17184 {
17185 className: "dataviews-view-picker-activity__item-bullet",
17186 "aria-hidden": "true"
17187 }
17188 ) });
17189 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(titleField.render, { item, field: titleField }) : null;
17190 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
17191 const verticalGap = (0, import_element63.useMemo)(() => {
17192 switch (density) {
17193 case "comfortable":
17194 return "md";
17195 default:
17196 return "sm";
17197 }
17198 }, [density]);
17199 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17200 import_components16.Composite.Item,
17201 {
17202 ref: elementRef,
17203 role: "option",
17204 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
17205 "aria-posinset": posinset,
17206 "aria-setsize": setsize,
17207 "aria-selected": isSelected2,
17208 className: clsx_default(
17209 "dataviews-view-picker-activity__item",
17210 density === "compact" && "is-compact",
17211 density === "balanced" && "is-balanced",
17212 density === "comfortable" && "is-comfortable",
17213 isSelected2 && "is-selected"
17214 ),
17215 onClick: () => {
17216 if (isSelected2) {
17217 onChangeSelection(
17218 selection.filter((itemId) => id !== itemId)
17219 );
17220 } else {
17221 const newSelection = multiselect ? [...selection, id] : [id];
17222 onChangeSelection(newSelection);
17223 }
17224 },
17225 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", {}),
17226 children: /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
17227 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17228 Stack,
17229 {
17230 direction: "column",
17231 gap: "xs",
17232 align: "center",
17233 className: "dataviews-view-picker-activity__item-type",
17234 children: renderedMediaField
17235 }
17236 ),
17237 /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17238 Stack,
17239 {
17240 direction: "column",
17241 gap: verticalGap,
17242 align: "flex-start",
17243 className: "dataviews-view-picker-activity__item-content",
17244 children: [
17245 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
17246 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
17247 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17248 "div",
17249 {
17250 className: "dataviews-view-picker-activity__item-field",
17251 children: [
17252 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17253 VisuallyHidden,
17254 {
17255 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", {}),
17256 className: "dataviews-view-picker-activity__item-field-label",
17257 children: field.label
17258 }
17259 ),
17260 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17261 field.render,
17262 {
17263 item,
17264 field
17265 }
17266 ) })
17267 ]
17268 },
17269 field.id
17270 )) })
17271 ]
17272 }
17273 )
17274 ] })
17275 }
17276 );
17277 }
17278 function PickerActivityGroup({
17279 groupName,
17280 groupField,
17281 showLabel = true,
17282 children
17283 }) {
17284 const headerId = (0, import_compose7.useInstanceId)(
17285 PickerActivityGroup,
17286 "dataviews-view-picker-activity-group__header"
17287 );
17288 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17289 Stack,
17290 {
17291 direction: "column",
17292 role: "group",
17293 "aria-labelledby": headerId,
17294 className: "dataviews-view-picker-activity-group",
17295 children: [
17296 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17297 "h3",
17298 {
17299 className: "dataviews-view-picker-activity-group__header",
17300 id: headerId,
17301 children: showLabel ? (0, import_i18n21.sprintf)(
17302 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
17303 (0, import_i18n21.__)("%1$s: %2$s"),
17304 groupField.label,
17305 groupName
17306 ) : groupName
17307 }
17308 ),
17309 children
17310 ]
17311 }
17312 );
17313 }
17314 function ViewPickerActivity({
17315 data,
17316 fields,
17317 getItemId,
17318 isLoading,
17319 onChangeSelection,
17320 selection,
17321 view,
17322 actions,
17323 className,
17324 empty
17325 }) {
17326 const { itemListLabel, paginationInfo } = (0, import_element63.useContext)(dataviews_context_default);
17327 const isMultiselect = useIsMultiselectPicker(actions);
17328 const titleField = fields.find(
17329 (field) => field.id === view?.titleField
17330 );
17331 const mediaField = fields.find(
17332 (field) => field.id === view?.mediaField
17333 );
17334 const descriptionField = fields.find(
17335 (field) => field.id === view?.descriptionField
17336 );
17337 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
17338 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
17339 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
17340 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
17341 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
17342 const hasData = !!data?.length;
17343 const isGrouped = !!(groupField && dataByGroup);
17344 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17345 PickerActivityItem,
17346 {
17347 view,
17348 multiselect: isMultiselect,
17349 selection,
17350 onChangeSelection,
17351 getItemId,
17352 item,
17353 titleField,
17354 mediaField,
17355 descriptionField,
17356 otherFields,
17357 posinset: item.position,
17358 setsize
17359 },
17360 getItemId(item)
17361 );
17362 if (!hasData) {
17363 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17364 "div",
17365 {
17366 className: clsx_default({
17367 "dataviews-loading": isLoading,
17368 "dataviews-no-results": !isLoading
17369 }),
17370 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components16.Spinner, {}) }) : empty
17371 }
17372 );
17373 }
17374 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
17375 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17376 import_components16.Composite,
17377 {
17378 virtualFocus: true,
17379 orientation: "vertical",
17380 role: "listbox",
17381 "aria-multiselectable": isMultiselect,
17382 "aria-label": itemListLabel,
17383 "aria-busy": isLoading,
17384 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
17385 className: clsx_default(
17386 "dataviews-view-picker-activity",
17387 className
17388 ),
17389 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
17390 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17391 PickerActivityGroup,
17392 {
17393 groupName,
17394 groupField,
17395 showLabel: view.groupBy?.showLabel !== false,
17396 children: groupItems.map(renderItem)
17397 },
17398 groupName
17399 )
17400 ) : data.map(renderItem)
17401 }
17402 ),
17403 isLoading && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components16.Spinner, {}) })
17404 ] });
17405 }
17406
17407 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
17408 var import_components17 = __toESM(require_components(), 1);
17409 var import_i18n22 = __toESM(require_i18n(), 1);
17410 var import_element64 = __toESM(require_element(), 1);
17411 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
17412 function DensityPicker() {
17413 const context = (0, import_element64.useContext)(dataviews_context_default);
17414 const view = context.view;
17415 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
17416 import_components17.__experimentalToggleGroupControl,
17417 {
17418 size: "__unstable-large",
17419 label: (0, import_i18n22.__)("Density"),
17420 value: view.layout?.density || "balanced",
17421 onChange: (value) => {
17422 context.onChangeView({
17423 ...view,
17424 layout: {
17425 ...view.layout,
17426 density: value
17427 }
17428 });
17429 },
17430 isBlock: true,
17431 children: [
17432 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17433 import_components17.__experimentalToggleGroupControlOption,
17434 {
17435 value: "comfortable",
17436 label: (0, import_i18n22._x)(
17437 "Comfortable",
17438 "Density option for DataView layout"
17439 )
17440 },
17441 "comfortable"
17442 ),
17443 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17444 import_components17.__experimentalToggleGroupControlOption,
17445 {
17446 value: "balanced",
17447 label: (0, import_i18n22._x)("Balanced", "Density option for DataView layout")
17448 },
17449 "balanced"
17450 ),
17451 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17452 import_components17.__experimentalToggleGroupControlOption,
17453 {
17454 value: "compact",
17455 label: (0, import_i18n22._x)("Compact", "Density option for DataView layout")
17456 },
17457 "compact"
17458 )
17459 ]
17460 }
17461 );
17462 }
17463
17464 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
17465 var import_components18 = __toESM(require_components(), 1);
17466 var import_i18n23 = __toESM(require_i18n(), 1);
17467 var import_element65 = __toESM(require_element(), 1);
17468 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
17469 var imageSizes2 = [
17470 {
17471 value: 120,
17472 breakpoint: 1
17473 },
17474 {
17475 value: 170,
17476 breakpoint: 1
17477 },
17478 {
17479 value: 230,
17480 breakpoint: 1
17481 },
17482 {
17483 value: 290,
17484 breakpoint: 1112
17485 // at minimum image width, 4 images display at this container size
17486 },
17487 {
17488 value: 350,
17489 breakpoint: 1636
17490 // at minimum image width, 6 images display at this container size
17491 },
17492 {
17493 value: 430,
17494 breakpoint: 588
17495 // at minimum image width, 2 images display at this container size
17496 }
17497 ];
17498 function PreviewSizePicker() {
17499 const context = (0, import_element65.useContext)(dataviews_context_default);
17500 const view = context.view;
17501 const breakValues = imageSizes2.filter((size4) => {
17502 return context.containerWidth >= size4.breakpoint;
17503 });
17504 const layoutPreviewSize = view.layout?.previewSize ?? 230;
17505 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
17506 const marks = breakValues.map((size4, index2) => {
17507 return {
17508 value: index2
17509 };
17510 });
17511 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
17512 import_components18.RangeControl,
17513 {
17514 __next40pxDefaultSize: true,
17515 showTooltip: false,
17516 label: (0, import_i18n23.__)("Preview size"),
17517 value: previewSizeToUse,
17518 min: 0,
17519 max: breakValues.length - 1,
17520 withInputField: false,
17521 onChange: (value = 0) => {
17522 context.onChangeView({
17523 ...view,
17524 layout: {
17525 ...view.layout,
17526 previewSize: breakValues[value].value
17527 }
17528 });
17529 },
17530 step: 1,
17531 marks
17532 }
17533 );
17534 }
17535
17536 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
17537 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
17538 function GridConfigOptions() {
17539 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
17540 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(DensityPicker, {}),
17541 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(PreviewSizePicker, {})
17542 ] });
17543 }
17544
17545 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
17546 var VIEW_LAYOUTS = [
17547 {
17548 type: LAYOUT_TABLE,
17549 label: (0, import_i18n24.__)("Table"),
17550 component: table_default,
17551 icon: block_table_default,
17552 viewConfigOptions: DensityPicker
17553 },
17554 {
17555 type: LAYOUT_GRID,
17556 label: (0, import_i18n24.__)("Grid"),
17557 component: grid_default,
17558 icon: category_default,
17559 viewConfigOptions: GridConfigOptions
17560 },
17561 {
17562 type: LAYOUT_LIST,
17563 label: (0, import_i18n24.__)("List"),
17564 component: ViewList,
17565 icon: (0, import_i18n24.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
17566 viewConfigOptions: DensityPicker
17567 },
17568 {
17569 type: LAYOUT_ACTIVITY,
17570 label: (0, import_i18n24.__)("Activity"),
17571 component: ViewActivity,
17572 icon: scheduled_default,
17573 viewConfigOptions: DensityPicker
17574 },
17575 {
17576 type: LAYOUT_PICKER_GRID,
17577 label: (0, import_i18n24.__)("Grid"),
17578 component: picker_grid_default,
17579 icon: category_default,
17580 viewConfigOptions: GridConfigOptions,
17581 isPicker: true
17582 },
17583 {
17584 type: LAYOUT_PICKER_TABLE,
17585 label: (0, import_i18n24.__)("Table"),
17586 component: picker_table_default,
17587 icon: block_table_default,
17588 viewConfigOptions: DensityPicker,
17589 isPicker: true
17590 },
17591 {
17592 type: LAYOUT_PICKER_ACTIVITY,
17593 label: (0, import_i18n24.__)("Activity"),
17594 component: ViewPickerActivity,
17595 icon: scheduled_default,
17596 viewConfigOptions: DensityPicker,
17597 isPicker: true
17598 }
17599 ];
17600
17601 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
17602 var import_element73 = __toESM(require_element(), 1);
17603
17604 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
17605 var import_components21 = __toESM(require_components(), 1);
17606 var import_i18n27 = __toESM(require_i18n(), 1);
17607 var import_element70 = __toESM(require_element(), 1);
17608
17609 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
17610 function noop4(..._) {
17611 }
17612 function applyState(argument, currentValue) {
17613 if (isUpdater(argument)) {
17614 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
17615 return argument(value);
17616 }
17617 return argument;
17618 }
17619 function isUpdater(argument) {
17620 return typeof argument === "function";
17621 }
17622 function isLazyValue(value) {
17623 return typeof value === "function";
17624 }
17625 function hasOwnProperty(object, prop) {
17626 if (typeof Object.hasOwn === "function") {
17627 return Object.hasOwn(object, prop);
17628 }
17629 return Object.prototype.hasOwnProperty.call(object, prop);
17630 }
17631 function chain(...fns) {
17632 return (...args) => {
17633 for (const fn of fns) {
17634 if (typeof fn === "function") {
17635 fn(...args);
17636 }
17637 }
17638 };
17639 }
17640 function normalizeString(str) {
17641 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
17642 }
17643 function omit(object, keys) {
17644 const result = { ...object };
17645 for (const key of keys) {
17646 if (hasOwnProperty(result, key)) {
17647 delete result[key];
17648 }
17649 }
17650 return result;
17651 }
17652 function pick(object, paths) {
17653 const result = {};
17654 for (const key of paths) {
17655 if (hasOwnProperty(object, key)) {
17656 result[key] = object[key];
17657 }
17658 }
17659 return result;
17660 }
17661 function identity(value) {
17662 return value;
17663 }
17664 function invariant(condition, message2) {
17665 if (condition) return;
17666 if (typeof message2 !== "string") throw new Error("Invariant failed");
17667 throw new Error(message2);
17668 }
17669 function getKeys(obj) {
17670 return Object.keys(obj);
17671 }
17672 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
17673 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
17674 if (result == null) return false;
17675 return !result;
17676 }
17677 function disabledFromProps(props) {
17678 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
17679 }
17680 function removeUndefinedValues(obj) {
17681 const result = {};
17682 for (const key in obj) {
17683 if (obj[key] !== void 0) {
17684 result[key] = obj[key];
17685 }
17686 }
17687 return result;
17688 }
17689 function defaultValue(...values) {
17690 for (const value of values) {
17691 if (value !== void 0) return value;
17692 }
17693 return void 0;
17694 }
17695
17696 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
17697 var import_react16 = __toESM(require_react(), 1);
17698 function setRef(ref, value) {
17699 if (typeof ref === "function") {
17700 ref(value);
17701 } else if (ref) {
17702 ref.current = value;
17703 }
17704 }
17705 function isValidElementWithRef(element) {
17706 if (!element) return false;
17707 if (!(0, import_react16.isValidElement)(element)) return false;
17708 if ("ref" in element.props) return true;
17709 if ("ref" in element) return true;
17710 return false;
17711 }
17712 function getRefProperty(element) {
17713 if (!isValidElementWithRef(element)) return null;
17714 const props = { ...element.props };
17715 return props.ref || element.ref;
17716 }
17717 function mergeProps2(base, overrides) {
17718 const props = { ...base };
17719 for (const key in overrides) {
17720 if (!hasOwnProperty(overrides, key)) continue;
17721 if (key === "className") {
17722 const prop = "className";
17723 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
17724 continue;
17725 }
17726 if (key === "style") {
17727 const prop = "style";
17728 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
17729 continue;
17730 }
17731 const overrideValue = overrides[key];
17732 if (typeof overrideValue === "function" && key.startsWith("on")) {
17733 const baseValue = base[key];
17734 if (typeof baseValue === "function") {
17735 props[key] = (...args) => {
17736 overrideValue(...args);
17737 baseValue(...args);
17738 };
17739 continue;
17740 }
17741 }
17742 props[key] = overrideValue;
17743 }
17744 return props;
17745 }
17746
17747 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
17748 var canUseDOM = checkIsBrowser();
17749 function checkIsBrowser() {
17750 var _a;
17751 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
17752 }
17753 function getDocument(node) {
17754 if (!node) return document;
17755 if ("self" in node) return node.document;
17756 return node.ownerDocument || document;
17757 }
17758 function getActiveElement(node, activeDescendant = false) {
17759 var _a;
17760 const { activeElement: activeElement2 } = getDocument(node);
17761 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
17762 return null;
17763 }
17764 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
17765 return getActiveElement(
17766 activeElement2.contentDocument.body,
17767 activeDescendant
17768 );
17769 }
17770 if (activeDescendant) {
17771 const id = activeElement2.getAttribute("aria-activedescendant");
17772 if (id) {
17773 const element = getDocument(activeElement2).getElementById(id);
17774 if (element) {
17775 return element;
17776 }
17777 }
17778 }
17779 return activeElement2;
17780 }
17781 function contains2(parent, child) {
17782 return parent === child || parent.contains(child);
17783 }
17784 function isFrame(element) {
17785 return element.tagName === "IFRAME";
17786 }
17787 function isButton(element) {
17788 const tagName = element.tagName.toLowerCase();
17789 if (tagName === "button") return true;
17790 if (tagName === "input" && element.type) {
17791 return buttonInputTypes.indexOf(element.type) !== -1;
17792 }
17793 return false;
17794 }
17795 var buttonInputTypes = [
17796 "button",
17797 "color",
17798 "file",
17799 "image",
17800 "reset",
17801 "submit"
17802 ];
17803 function isVisible(element) {
17804 if (typeof element.checkVisibility === "function") {
17805 return element.checkVisibility();
17806 }
17807 const htmlElement = element;
17808 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
17809 }
17810 function isTextField(element) {
17811 try {
17812 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
17813 const isTextArea = element.tagName === "TEXTAREA";
17814 return isTextInput || isTextArea || false;
17815 } catch (_error) {
17816 return false;
17817 }
17818 }
17819 function isTextbox(element) {
17820 return element.isContentEditable || isTextField(element);
17821 }
17822 function getTextboxValue(element) {
17823 if (isTextField(element)) {
17824 return element.value;
17825 }
17826 if (element.isContentEditable) {
17827 const range = getDocument(element).createRange();
17828 range.selectNodeContents(element);
17829 return range.toString();
17830 }
17831 return "";
17832 }
17833 function getTextboxSelection(element) {
17834 let start = 0;
17835 let end = 0;
17836 if (isTextField(element)) {
17837 start = element.selectionStart || 0;
17838 end = element.selectionEnd || 0;
17839 } else if (element.isContentEditable) {
17840 const selection = getDocument(element).getSelection();
17841 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
17842 const range = selection.getRangeAt(0);
17843 const nextRange = range.cloneRange();
17844 nextRange.selectNodeContents(element);
17845 nextRange.setEnd(range.startContainer, range.startOffset);
17846 start = nextRange.toString().length;
17847 nextRange.setEnd(range.endContainer, range.endOffset);
17848 end = nextRange.toString().length;
17849 }
17850 }
17851 return { start, end };
17852 }
17853 function getPopupRole(element, fallback) {
17854 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
17855 const role = element == null ? void 0 : element.getAttribute("role");
17856 if (role && allowedPopupRoles.indexOf(role) !== -1) {
17857 return role;
17858 }
17859 return fallback;
17860 }
17861 function getScrollingElement(element) {
17862 if (!element) return null;
17863 const isScrollableOverflow = (overflow) => {
17864 if (overflow === "auto") return true;
17865 if (overflow === "scroll") return true;
17866 return false;
17867 };
17868 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
17869 const { overflowY } = getComputedStyle(element);
17870 if (isScrollableOverflow(overflowY)) return element;
17871 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
17872 const { overflowX } = getComputedStyle(element);
17873 if (isScrollableOverflow(overflowX)) return element;
17874 }
17875 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
17876 }
17877 function setSelectionRange(element, ...args) {
17878 if (/text|search|password|tel|url/i.test(element.type)) {
17879 element.setSelectionRange(...args);
17880 }
17881 }
17882 function sortBasedOnDOMPosition(items, getElement) {
17883 const pairs = items.map((item, index2) => [index2, item]);
17884 let isOrderDifferent = false;
17885 pairs.sort(([indexA, a2], [indexB, b2]) => {
17886 const elementA = getElement(a2);
17887 const elementB = getElement(b2);
17888 if (elementA === elementB) return 0;
17889 if (!elementA || !elementB) return 0;
17890 if (isElementPreceding(elementA, elementB)) {
17891 if (indexA > indexB) {
17892 isOrderDifferent = true;
17893 }
17894 return -1;
17895 }
17896 if (indexA < indexB) {
17897 isOrderDifferent = true;
17898 }
17899 return 1;
17900 });
17901 if (isOrderDifferent) {
17902 return pairs.map(([_, item]) => item);
17903 }
17904 return items;
17905 }
17906 function isElementPreceding(a2, b2) {
17907 return Boolean(
17908 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
17909 );
17910 }
17911
17912 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
17913 function isTouchDevice() {
17914 return canUseDOM && !!navigator.maxTouchPoints;
17915 }
17916 function isApple() {
17917 if (!canUseDOM) return false;
17918 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
17919 }
17920 function isSafari2() {
17921 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
17922 }
17923 function isFirefox2() {
17924 return canUseDOM && /firefox\//i.test(navigator.userAgent);
17925 }
17926
17927 // node_modules/@ariakit/core/esm/utils/events.js
17928 function isPortalEvent(event) {
17929 return Boolean(
17930 event.currentTarget && !contains2(event.currentTarget, event.target)
17931 );
17932 }
17933 function isSelfTarget(event) {
17934 return event.target === event.currentTarget;
17935 }
17936 function isOpeningInNewTab(event) {
17937 const element = event.currentTarget;
17938 if (!element) return false;
17939 const isAppleDevice = isApple();
17940 if (isAppleDevice && !event.metaKey) return false;
17941 if (!isAppleDevice && !event.ctrlKey) return false;
17942 const tagName = element.tagName.toLowerCase();
17943 if (tagName === "a") return true;
17944 if (tagName === "button" && element.type === "submit") return true;
17945 if (tagName === "input" && element.type === "submit") return true;
17946 return false;
17947 }
17948 function isDownloading(event) {
17949 const element = event.currentTarget;
17950 if (!element) return false;
17951 const tagName = element.tagName.toLowerCase();
17952 if (!event.altKey) return false;
17953 if (tagName === "a") return true;
17954 if (tagName === "button" && element.type === "submit") return true;
17955 if (tagName === "input" && element.type === "submit") return true;
17956 return false;
17957 }
17958 function fireBlurEvent(element, eventInit) {
17959 const event = new FocusEvent("blur", eventInit);
17960 const defaultAllowed = element.dispatchEvent(event);
17961 const bubbleInit = { ...eventInit, bubbles: true };
17962 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
17963 return defaultAllowed;
17964 }
17965 function fireKeyboardEvent(element, type, eventInit) {
17966 const event = new KeyboardEvent(type, eventInit);
17967 return element.dispatchEvent(event);
17968 }
17969 function fireClickEvent(element, eventInit) {
17970 const event = new MouseEvent("click", eventInit);
17971 return element.dispatchEvent(event);
17972 }
17973 function isFocusEventOutside(event, container) {
17974 const containerElement = container || event.currentTarget;
17975 const relatedTarget = event.relatedTarget;
17976 return !relatedTarget || !contains2(containerElement, relatedTarget);
17977 }
17978 function queueBeforeEvent(element, type, callback, timeout) {
17979 const createTimer = (callback2) => {
17980 if (timeout) {
17981 const timerId2 = setTimeout(callback2, timeout);
17982 return () => clearTimeout(timerId2);
17983 }
17984 const timerId = requestAnimationFrame(callback2);
17985 return () => cancelAnimationFrame(timerId);
17986 };
17987 const cancelTimer = createTimer(() => {
17988 element.removeEventListener(type, callSync, true);
17989 callback();
17990 });
17991 const callSync = () => {
17992 cancelTimer();
17993 callback();
17994 };
17995 element.addEventListener(type, callSync, { once: true, capture: true });
17996 return cancelTimer;
17997 }
17998 function addGlobalEventListener(type, listener, options, scope = window) {
17999 const children = [];
18000 try {
18001 scope.document.addEventListener(type, listener, options);
18002 for (const frame of Array.from(scope.frames)) {
18003 children.push(addGlobalEventListener(type, listener, options, frame));
18004 }
18005 } catch (e2) {
18006 }
18007 const removeEventListener = () => {
18008 try {
18009 scope.document.removeEventListener(type, listener, options);
18010 } catch (e2) {
18011 }
18012 for (const remove of children) {
18013 remove();
18014 }
18015 };
18016 return removeEventListener;
18017 }
18018
18019 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
18020 var React58 = __toESM(require_react(), 1);
18021 var import_react17 = __toESM(require_react(), 1);
18022 var _React = { ...React58 };
18023 var useReactId = _React.useId;
18024 var useReactDeferredValue = _React.useDeferredValue;
18025 var useReactInsertionEffect = _React.useInsertionEffect;
18026 var useSafeLayoutEffect = canUseDOM ? import_react17.useLayoutEffect : import_react17.useEffect;
18027 function useInitialValue(value) {
18028 const [initialValue] = (0, import_react17.useState)(value);
18029 return initialValue;
18030 }
18031 function useLiveRef(value) {
18032 const ref = (0, import_react17.useRef)(value);
18033 useSafeLayoutEffect(() => {
18034 ref.current = value;
18035 });
18036 return ref;
18037 }
18038 function useEvent(callback) {
18039 const ref = (0, import_react17.useRef)(() => {
18040 throw new Error("Cannot call an event handler while rendering.");
18041 });
18042 if (useReactInsertionEffect) {
18043 useReactInsertionEffect(() => {
18044 ref.current = callback;
18045 });
18046 } else {
18047 ref.current = callback;
18048 }
18049 return (0, import_react17.useCallback)((...args) => {
18050 var _a;
18051 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
18052 }, []);
18053 }
18054 function useTransactionState(callback) {
18055 const [state, setState] = (0, import_react17.useState)(null);
18056 useSafeLayoutEffect(() => {
18057 if (state == null) return;
18058 if (!callback) return;
18059 let prevState = null;
18060 callback((prev) => {
18061 prevState = prev;
18062 return state;
18063 });
18064 return () => {
18065 callback(prevState);
18066 };
18067 }, [state, callback]);
18068 return [state, setState];
18069 }
18070 function useMergeRefs(...refs) {
18071 return (0, import_react17.useMemo)(() => {
18072 if (!refs.some(Boolean)) return;
18073 return (value) => {
18074 for (const ref of refs) {
18075 setRef(ref, value);
18076 }
18077 };
18078 }, refs);
18079 }
18080 function useId5(defaultId) {
18081 if (useReactId) {
18082 const reactId = useReactId();
18083 if (defaultId) return defaultId;
18084 return reactId;
18085 }
18086 const [id, setId] = (0, import_react17.useState)(defaultId);
18087 useSafeLayoutEffect(() => {
18088 if (defaultId || id) return;
18089 const random = Math.random().toString(36).slice(2, 8);
18090 setId(`id-${random}`);
18091 }, [defaultId, id]);
18092 return defaultId || id;
18093 }
18094 function useTagName(refOrElement, type) {
18095 const stringOrUndefined = (type2) => {
18096 if (typeof type2 !== "string") return;
18097 return type2;
18098 };
18099 const [tagName, setTagName] = (0, import_react17.useState)(() => stringOrUndefined(type));
18100 useSafeLayoutEffect(() => {
18101 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
18102 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
18103 }, [refOrElement, type]);
18104 return tagName;
18105 }
18106 function useAttribute(refOrElement, attributeName, defaultValue2) {
18107 const initialValue = useInitialValue(defaultValue2);
18108 const [attribute, setAttribute] = (0, import_react17.useState)(initialValue);
18109 (0, import_react17.useEffect)(() => {
18110 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
18111 if (!element) return;
18112 const callback = () => {
18113 const value = element.getAttribute(attributeName);
18114 setAttribute(value == null ? initialValue : value);
18115 };
18116 const observer = new MutationObserver(callback);
18117 observer.observe(element, { attributeFilter: [attributeName] });
18118 callback();
18119 return () => observer.disconnect();
18120 }, [refOrElement, attributeName, initialValue]);
18121 return attribute;
18122 }
18123 function useUpdateEffect(effect, deps) {
18124 const mounted = (0, import_react17.useRef)(false);
18125 (0, import_react17.useEffect)(() => {
18126 if (mounted.current) {
18127 return effect();
18128 }
18129 mounted.current = true;
18130 }, deps);
18131 (0, import_react17.useEffect)(
18132 () => () => {
18133 mounted.current = false;
18134 },
18135 []
18136 );
18137 }
18138 function useUpdateLayoutEffect(effect, deps) {
18139 const mounted = (0, import_react17.useRef)(false);
18140 useSafeLayoutEffect(() => {
18141 if (mounted.current) {
18142 return effect();
18143 }
18144 mounted.current = true;
18145 }, deps);
18146 useSafeLayoutEffect(
18147 () => () => {
18148 mounted.current = false;
18149 },
18150 []
18151 );
18152 }
18153 function useForceUpdate() {
18154 return (0, import_react17.useReducer)(() => [], []);
18155 }
18156 function useBooleanEvent(booleanOrCallback) {
18157 return useEvent(
18158 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
18159 );
18160 }
18161 function useWrapElement(props, callback, deps = []) {
18162 const wrapElement = (0, import_react17.useCallback)(
18163 (element) => {
18164 if (props.wrapElement) {
18165 element = props.wrapElement(element);
18166 }
18167 return callback(element);
18168 },
18169 [...deps, props.wrapElement]
18170 );
18171 return { ...props, wrapElement };
18172 }
18173 function useMetadataProps(props, key, value) {
18174 const parent = props.onLoadedMetadataCapture;
18175 const onLoadedMetadataCapture = (0, import_react17.useMemo)(() => {
18176 return Object.assign(() => {
18177 }, { ...parent, [key]: value });
18178 }, [parent, key, value]);
18179 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
18180 }
18181 var hasInstalledGlobalEventListeners = false;
18182 function useIsMouseMoving() {
18183 (0, import_react17.useEffect)(() => {
18184 if (hasInstalledGlobalEventListeners) return;
18185 addGlobalEventListener("mousemove", setMouseMoving, true);
18186 addGlobalEventListener("mousedown", resetMouseMoving, true);
18187 addGlobalEventListener("mouseup", resetMouseMoving, true);
18188 addGlobalEventListener("keydown", resetMouseMoving, true);
18189 addGlobalEventListener("scroll", resetMouseMoving, true);
18190 hasInstalledGlobalEventListeners = true;
18191 }, []);
18192 const isMouseMoving = useEvent(() => mouseMoving);
18193 return isMouseMoving;
18194 }
18195 var mouseMoving = false;
18196 var previousScreenX = 0;
18197 var previousScreenY = 0;
18198 function hasMouseMovement(event) {
18199 const movementX = event.movementX || event.screenX - previousScreenX;
18200 const movementY = event.movementY || event.screenY - previousScreenY;
18201 previousScreenX = event.screenX;
18202 previousScreenY = event.screenY;
18203 return movementX || movementY || false;
18204 }
18205 function setMouseMoving(event) {
18206 if (!hasMouseMovement(event)) return;
18207 mouseMoving = true;
18208 }
18209 function resetMouseMoving() {
18210 mouseMoving = false;
18211 }
18212
18213 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
18214 var React59 = __toESM(require_react(), 1);
18215 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
18216 function forwardRef210(render4) {
18217 const Role = React59.forwardRef(
18218 // @ts-ignore Incompatible with React 19 types. Ignore for now.
18219 (props, ref) => render4({ ...props, ref })
18220 );
18221 Role.displayName = render4.displayName || render4.name;
18222 return Role;
18223 }
18224 function memo22(Component, propsAreEqual) {
18225 return React59.memo(Component, propsAreEqual);
18226 }
18227 function createElement3(Type, props) {
18228 const { wrapElement, render: render4, ...rest } = props;
18229 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
18230 let element;
18231 if (React59.isValidElement(render4)) {
18232 const renderProps = {
18233 // @ts-ignore Incompatible with React 19 types. Ignore for now.
18234 ...render4.props,
18235 ref: mergedRef
18236 };
18237 element = React59.cloneElement(render4, mergeProps2(rest, renderProps));
18238 } else if (render4) {
18239 element = render4(rest);
18240 } else {
18241 element = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Type, { ...rest });
18242 }
18243 if (wrapElement) {
18244 return wrapElement(element);
18245 }
18246 return element;
18247 }
18248 function createHook(useProps) {
18249 const useRole = (props = {}) => {
18250 return useProps(props);
18251 };
18252 useRole.displayName = useProps.name;
18253 return useRole;
18254 }
18255 function createStoreContext(providers = [], scopedProviders = []) {
18256 const context = React59.createContext(void 0);
18257 const scopedContext = React59.createContext(void 0);
18258 const useContext210 = () => React59.useContext(context);
18259 const useScopedContext = (onlyScoped = false) => {
18260 const scoped = React59.useContext(scopedContext);
18261 const store = useContext210();
18262 if (onlyScoped) return scoped;
18263 return scoped || store;
18264 };
18265 const useProviderContext = () => {
18266 const scoped = React59.useContext(scopedContext);
18267 const store = useContext210();
18268 if (scoped && scoped === store) return;
18269 return store;
18270 };
18271 const ContextProvider = (props) => {
18272 return providers.reduceRight(
18273 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Provider2, { ...props, children }),
18274 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(context.Provider, { ...props })
18275 );
18276 };
18277 const ScopedContextProvider = (props) => {
18278 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
18279 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Provider2, { ...props, children }),
18280 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(scopedContext.Provider, { ...props })
18281 ) });
18282 };
18283 return {
18284 context,
18285 scopedContext,
18286 useContext: useContext210,
18287 useScopedContext,
18288 useProviderContext,
18289 ContextProvider,
18290 ScopedContextProvider
18291 };
18292 }
18293
18294 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
18295 var ctx = createStoreContext();
18296 var useCollectionContext = ctx.useContext;
18297 var useCollectionScopedContext = ctx.useScopedContext;
18298 var useCollectionProviderContext = ctx.useProviderContext;
18299 var CollectionContextProvider = ctx.ContextProvider;
18300 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
18301
18302 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
18303 var import_react18 = __toESM(require_react(), 1);
18304 var ctx2 = createStoreContext(
18305 [CollectionContextProvider],
18306 [CollectionScopedContextProvider]
18307 );
18308 var useCompositeContext = ctx2.useContext;
18309 var useCompositeScopedContext = ctx2.useScopedContext;
18310 var useCompositeProviderContext = ctx2.useProviderContext;
18311 var CompositeContextProvider = ctx2.ContextProvider;
18312 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
18313 var CompositeItemContext = (0, import_react18.createContext)(
18314 void 0
18315 );
18316 var CompositeRowContext = (0, import_react18.createContext)(
18317 void 0
18318 );
18319
18320 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
18321 function findFirstEnabledItem(items, excludeId) {
18322 return items.find((item) => {
18323 if (excludeId) {
18324 return !item.disabled && item.id !== excludeId;
18325 }
18326 return !item.disabled;
18327 });
18328 }
18329 function getEnabledItem(store, id) {
18330 if (!id) return null;
18331 return store.item(id) || null;
18332 }
18333 function groupItemsByRows(items) {
18334 const rows = [];
18335 for (const item of items) {
18336 const row = rows.find((currentRow) => {
18337 var _a;
18338 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
18339 });
18340 if (row) {
18341 row.push(item);
18342 } else {
18343 rows.push([item]);
18344 }
18345 }
18346 return rows;
18347 }
18348 function selectTextField(element, collapseToEnd = false) {
18349 if (isTextField(element)) {
18350 element.setSelectionRange(
18351 collapseToEnd ? element.value.length : 0,
18352 element.value.length
18353 );
18354 } else if (element.isContentEditable) {
18355 const selection = getDocument(element).getSelection();
18356 selection == null ? void 0 : selection.selectAllChildren(element);
18357 if (collapseToEnd) {
18358 selection == null ? void 0 : selection.collapseToEnd();
18359 }
18360 }
18361 }
18362 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
18363 function focusSilently(element) {
18364 element[FOCUS_SILENTLY] = true;
18365 element.focus({ preventScroll: true });
18366 }
18367 function silentlyFocused(element) {
18368 const isSilentlyFocused = element[FOCUS_SILENTLY];
18369 delete element[FOCUS_SILENTLY];
18370 return isSilentlyFocused;
18371 }
18372 function isItem(store, element, exclude) {
18373 if (!element) return false;
18374 if (element === exclude) return false;
18375 const item = store.item(element.id);
18376 if (!item) return false;
18377 if (exclude && item.element === exclude) return false;
18378 return true;
18379 }
18380
18381 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
18382 var import_react19 = __toESM(require_react(), 1);
18383 var TagName = "div";
18384 var useCollectionItem = createHook(
18385 function useCollectionItem2({
18386 store,
18387 shouldRegisterItem = true,
18388 getItem = identity,
18389 // @ts-expect-error This prop may come from a collection renderer.
18390 element,
18391 ...props
18392 }) {
18393 const context = useCollectionContext();
18394 store = store || context;
18395 const id = useId5(props.id);
18396 const ref = (0, import_react19.useRef)(element);
18397 (0, import_react19.useEffect)(() => {
18398 const element2 = ref.current;
18399 if (!id) return;
18400 if (!element2) return;
18401 if (!shouldRegisterItem) return;
18402 const item = getItem({ id, element: element2 });
18403 return store == null ? void 0 : store.renderItem(item);
18404 }, [id, shouldRegisterItem, getItem, store]);
18405 props = {
18406 ...props,
18407 ref: useMergeRefs(ref, props.ref)
18408 };
18409 return removeUndefinedValues(props);
18410 }
18411 );
18412 var CollectionItem = forwardRef210(function CollectionItem2(props) {
18413 const htmlProps = useCollectionItem(props);
18414 return createElement3(TagName, htmlProps);
18415 });
18416
18417 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
18418 var import_react20 = __toESM(require_react(), 1);
18419 var FocusableContext = (0, import_react20.createContext)(true);
18420
18421 // node_modules/@ariakit/core/esm/utils/focus.js
18422 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'])";
18423 function isFocusable(element) {
18424 if (!element.matches(selector)) return false;
18425 if (!isVisible(element)) return false;
18426 if (element.closest("[inert]")) return false;
18427 return true;
18428 }
18429 function getClosestFocusable(element) {
18430 while (element && !isFocusable(element)) {
18431 element = element.closest(selector);
18432 }
18433 return element || null;
18434 }
18435 function hasFocus(element) {
18436 const activeElement2 = getActiveElement(element);
18437 if (!activeElement2) return false;
18438 if (activeElement2 === element) return true;
18439 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
18440 if (!activeDescendant) return false;
18441 return activeDescendant === element.id;
18442 }
18443 function hasFocusWithin(element) {
18444 const activeElement2 = getActiveElement(element);
18445 if (!activeElement2) return false;
18446 if (contains2(element, activeElement2)) return true;
18447 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
18448 if (!activeDescendant) return false;
18449 if (!("id" in element)) return false;
18450 if (activeDescendant === element.id) return true;
18451 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
18452 }
18453 function focusIfNeeded(element) {
18454 if (!hasFocusWithin(element) && isFocusable(element)) {
18455 element.focus();
18456 }
18457 }
18458 function focusIntoView(element, options) {
18459 if (!("scrollIntoView" in element)) {
18460 element.focus();
18461 } else {
18462 element.focus({ preventScroll: true });
18463 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
18464 }
18465 }
18466
18467 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
18468 var import_react21 = __toESM(require_react(), 1);
18469 var TagName2 = "div";
18470 var isSafariBrowser = isSafari2();
18471 var alwaysFocusVisibleInputTypes = [
18472 "text",
18473 "search",
18474 "url",
18475 "tel",
18476 "email",
18477 "password",
18478 "number",
18479 "date",
18480 "month",
18481 "week",
18482 "time",
18483 "datetime",
18484 "datetime-local"
18485 ];
18486 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
18487 function markSafariFocusAncestor(element, value) {
18488 if (!element) return;
18489 element[safariFocusAncestorSymbol] = value;
18490 }
18491 function isAlwaysFocusVisible(element) {
18492 const { tagName, readOnly, type } = element;
18493 if (tagName === "TEXTAREA" && !readOnly) return true;
18494 if (tagName === "SELECT" && !readOnly) return true;
18495 if (tagName === "INPUT" && !readOnly) {
18496 return alwaysFocusVisibleInputTypes.includes(type);
18497 }
18498 if (element.isContentEditable) return true;
18499 const role = element.getAttribute("role");
18500 if (role === "combobox" && element.dataset.name) {
18501 return true;
18502 }
18503 return false;
18504 }
18505 function getLabels(element) {
18506 if ("labels" in element) {
18507 return element.labels;
18508 }
18509 return null;
18510 }
18511 function isNativeCheckboxOrRadio(element) {
18512 const tagName = element.tagName.toLowerCase();
18513 if (tagName === "input" && element.type) {
18514 return element.type === "radio" || element.type === "checkbox";
18515 }
18516 return false;
18517 }
18518 function isNativeTabbable(tagName) {
18519 if (!tagName) return true;
18520 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
18521 }
18522 function supportsDisabledAttribute(tagName) {
18523 if (!tagName) return true;
18524 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
18525 }
18526 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
18527 if (!focusable2) {
18528 return tabIndexProp;
18529 }
18530 if (trulyDisabled) {
18531 if (nativeTabbable && !supportsDisabled) {
18532 return -1;
18533 }
18534 return;
18535 }
18536 if (nativeTabbable) {
18537 return tabIndexProp;
18538 }
18539 return tabIndexProp || 0;
18540 }
18541 function useDisableEvent(onEvent, disabled2) {
18542 return useEvent((event) => {
18543 onEvent == null ? void 0 : onEvent(event);
18544 if (event.defaultPrevented) return;
18545 if (disabled2) {
18546 event.stopPropagation();
18547 event.preventDefault();
18548 }
18549 });
18550 }
18551 var hasInstalledGlobalEventListeners2 = false;
18552 var isKeyboardModality = true;
18553 function onGlobalMouseDown(event) {
18554 const target = event.target;
18555 if (target && "hasAttribute" in target) {
18556 if (!target.hasAttribute("data-focus-visible")) {
18557 isKeyboardModality = false;
18558 }
18559 }
18560 }
18561 function onGlobalKeyDown(event) {
18562 if (event.metaKey) return;
18563 if (event.ctrlKey) return;
18564 if (event.altKey) return;
18565 isKeyboardModality = true;
18566 }
18567 var useFocusable = createHook(
18568 function useFocusable2({
18569 focusable: focusable2 = true,
18570 accessibleWhenDisabled,
18571 autoFocus,
18572 onFocusVisible,
18573 ...props
18574 }) {
18575 const ref = (0, import_react21.useRef)(null);
18576 (0, import_react21.useEffect)(() => {
18577 if (!focusable2) return;
18578 if (hasInstalledGlobalEventListeners2) return;
18579 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
18580 addGlobalEventListener("keydown", onGlobalKeyDown, true);
18581 hasInstalledGlobalEventListeners2 = true;
18582 }, [focusable2]);
18583 if (isSafariBrowser) {
18584 (0, import_react21.useEffect)(() => {
18585 if (!focusable2) return;
18586 const element = ref.current;
18587 if (!element) return;
18588 if (!isNativeCheckboxOrRadio(element)) return;
18589 const labels = getLabels(element);
18590 if (!labels) return;
18591 const onMouseUp = () => queueMicrotask(() => element.focus());
18592 for (const label of labels) {
18593 label.addEventListener("mouseup", onMouseUp);
18594 }
18595 return () => {
18596 for (const label of labels) {
18597 label.removeEventListener("mouseup", onMouseUp);
18598 }
18599 };
18600 }, [focusable2]);
18601 }
18602 const disabled2 = focusable2 && disabledFromProps(props);
18603 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
18604 const [focusVisible, setFocusVisible] = (0, import_react21.useState)(false);
18605 (0, import_react21.useEffect)(() => {
18606 if (!focusable2) return;
18607 if (trulyDisabled && focusVisible) {
18608 setFocusVisible(false);
18609 }
18610 }, [focusable2, trulyDisabled, focusVisible]);
18611 (0, import_react21.useEffect)(() => {
18612 if (!focusable2) return;
18613 if (!focusVisible) return;
18614 const element = ref.current;
18615 if (!element) return;
18616 if (typeof IntersectionObserver === "undefined") return;
18617 const observer = new IntersectionObserver(() => {
18618 if (!isFocusable(element)) {
18619 setFocusVisible(false);
18620 }
18621 });
18622 observer.observe(element);
18623 return () => observer.disconnect();
18624 }, [focusable2, focusVisible]);
18625 const onKeyPressCapture = useDisableEvent(
18626 props.onKeyPressCapture,
18627 disabled2
18628 );
18629 const onMouseDownCapture = useDisableEvent(
18630 props.onMouseDownCapture,
18631 disabled2
18632 );
18633 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
18634 const onMouseDownProp = props.onMouseDown;
18635 const onMouseDown = useEvent((event) => {
18636 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
18637 if (event.defaultPrevented) return;
18638 if (!focusable2) return;
18639 const element = event.currentTarget;
18640 if (!isSafariBrowser) return;
18641 if (isPortalEvent(event)) return;
18642 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
18643 let receivedFocus = false;
18644 const onFocus = () => {
18645 receivedFocus = true;
18646 };
18647 const options = { capture: true, once: true };
18648 element.addEventListener("focusin", onFocus, options);
18649 const focusableContainer = getClosestFocusable(element.parentElement);
18650 markSafariFocusAncestor(focusableContainer, true);
18651 queueBeforeEvent(element, "mouseup", () => {
18652 element.removeEventListener("focusin", onFocus, true);
18653 markSafariFocusAncestor(focusableContainer, false);
18654 if (receivedFocus) return;
18655 focusIfNeeded(element);
18656 });
18657 });
18658 const handleFocusVisible = (event, currentTarget) => {
18659 if (currentTarget) {
18660 event.currentTarget = currentTarget;
18661 }
18662 if (!focusable2) return;
18663 const element = event.currentTarget;
18664 if (!element) return;
18665 if (!hasFocus(element)) return;
18666 onFocusVisible == null ? void 0 : onFocusVisible(event);
18667 if (event.defaultPrevented) return;
18668 element.dataset.focusVisible = "true";
18669 setFocusVisible(true);
18670 };
18671 const onKeyDownCaptureProp = props.onKeyDownCapture;
18672 const onKeyDownCapture = useEvent((event) => {
18673 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
18674 if (event.defaultPrevented) return;
18675 if (!focusable2) return;
18676 if (focusVisible) return;
18677 if (event.metaKey) return;
18678 if (event.altKey) return;
18679 if (event.ctrlKey) return;
18680 if (!isSelfTarget(event)) return;
18681 const element = event.currentTarget;
18682 const applyFocusVisible = () => handleFocusVisible(event, element);
18683 queueBeforeEvent(element, "focusout", applyFocusVisible);
18684 });
18685 const onFocusCaptureProp = props.onFocusCapture;
18686 const onFocusCapture = useEvent((event) => {
18687 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
18688 if (event.defaultPrevented) return;
18689 if (!focusable2) return;
18690 if (!isSelfTarget(event)) {
18691 setFocusVisible(false);
18692 return;
18693 }
18694 const element = event.currentTarget;
18695 const applyFocusVisible = () => handleFocusVisible(event, element);
18696 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
18697 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
18698 } else {
18699 setFocusVisible(false);
18700 }
18701 });
18702 const onBlurProp = props.onBlur;
18703 const onBlur = useEvent((event) => {
18704 onBlurProp == null ? void 0 : onBlurProp(event);
18705 if (!focusable2) return;
18706 if (!isFocusEventOutside(event)) return;
18707 event.currentTarget.removeAttribute("data-focus-visible");
18708 setFocusVisible(false);
18709 });
18710 const autoFocusOnShow = (0, import_react21.useContext)(FocusableContext);
18711 const autoFocusRef = useEvent((element) => {
18712 if (!focusable2) return;
18713 if (!autoFocus) return;
18714 if (!element) return;
18715 if (!autoFocusOnShow) return;
18716 queueMicrotask(() => {
18717 if (hasFocus(element)) return;
18718 if (!isFocusable(element)) return;
18719 element.focus();
18720 });
18721 });
18722 const tagName = useTagName(ref);
18723 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
18724 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
18725 const styleProp = props.style;
18726 const style = (0, import_react21.useMemo)(() => {
18727 if (trulyDisabled) {
18728 return { pointerEvents: "none", ...styleProp };
18729 }
18730 return styleProp;
18731 }, [trulyDisabled, styleProp]);
18732 props = {
18733 "data-focus-visible": focusable2 && focusVisible || void 0,
18734 "data-autofocus": autoFocus || void 0,
18735 "aria-disabled": disabled2 || void 0,
18736 ...props,
18737 ref: useMergeRefs(ref, autoFocusRef, props.ref),
18738 style,
18739 tabIndex: getTabIndex2(
18740 focusable2,
18741 trulyDisabled,
18742 nativeTabbable,
18743 supportsDisabled,
18744 props.tabIndex
18745 ),
18746 disabled: supportsDisabled && trulyDisabled ? true : void 0,
18747 // TODO: Test Focusable contentEditable.
18748 contentEditable: disabled2 ? void 0 : props.contentEditable,
18749 onKeyPressCapture,
18750 onClickCapture,
18751 onMouseDownCapture,
18752 onMouseDown,
18753 onKeyDownCapture,
18754 onFocusCapture,
18755 onBlur
18756 };
18757 return removeUndefinedValues(props);
18758 }
18759 );
18760 var Focusable = forwardRef210(function Focusable2(props) {
18761 const htmlProps = useFocusable(props);
18762 return createElement3(TagName2, htmlProps);
18763 });
18764
18765 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
18766 var import_react22 = __toESM(require_react(), 1);
18767 var TagName3 = "button";
18768 function isNativeClick(event) {
18769 if (!event.isTrusted) return false;
18770 const element = event.currentTarget;
18771 if (event.key === "Enter") {
18772 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
18773 }
18774 if (event.key === " ") {
18775 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
18776 }
18777 return false;
18778 }
18779 var symbol = /* @__PURE__ */ Symbol("command");
18780 var useCommand = createHook(
18781 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
18782 const ref = (0, import_react22.useRef)(null);
18783 const [isNativeButton, setIsNativeButton] = (0, import_react22.useState)(false);
18784 (0, import_react22.useEffect)(() => {
18785 if (!ref.current) return;
18786 setIsNativeButton(isButton(ref.current));
18787 }, []);
18788 const [active, setActive] = (0, import_react22.useState)(false);
18789 const activeRef = (0, import_react22.useRef)(false);
18790 const disabled2 = disabledFromProps(props);
18791 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
18792 const onKeyDownProp = props.onKeyDown;
18793 const onKeyDown = useEvent((event) => {
18794 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18795 const element = event.currentTarget;
18796 if (event.defaultPrevented) return;
18797 if (isDuplicate) return;
18798 if (disabled2) return;
18799 if (!isSelfTarget(event)) return;
18800 if (isTextField(element)) return;
18801 if (element.isContentEditable) return;
18802 const isEnter = clickOnEnter && event.key === "Enter";
18803 const isSpace = clickOnSpace && event.key === " ";
18804 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
18805 const shouldPreventSpace = event.key === " " && !clickOnSpace;
18806 if (shouldPreventEnter || shouldPreventSpace) {
18807 event.preventDefault();
18808 return;
18809 }
18810 if (isEnter || isSpace) {
18811 const nativeClick = isNativeClick(event);
18812 if (isEnter) {
18813 if (!nativeClick) {
18814 event.preventDefault();
18815 const { view, ...eventInit } = event;
18816 const click = () => fireClickEvent(element, eventInit);
18817 if (isFirefox2()) {
18818 queueBeforeEvent(element, "keyup", click);
18819 } else {
18820 queueMicrotask(click);
18821 }
18822 }
18823 } else if (isSpace) {
18824 activeRef.current = true;
18825 if (!nativeClick) {
18826 event.preventDefault();
18827 setActive(true);
18828 }
18829 }
18830 }
18831 });
18832 const onKeyUpProp = props.onKeyUp;
18833 const onKeyUp = useEvent((event) => {
18834 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
18835 if (event.defaultPrevented) return;
18836 if (isDuplicate) return;
18837 if (disabled2) return;
18838 if (event.metaKey) return;
18839 const isSpace = clickOnSpace && event.key === " ";
18840 if (activeRef.current && isSpace) {
18841 activeRef.current = false;
18842 if (!isNativeClick(event)) {
18843 event.preventDefault();
18844 setActive(false);
18845 const element = event.currentTarget;
18846 const { view, ...eventInit } = event;
18847 queueMicrotask(() => fireClickEvent(element, eventInit));
18848 }
18849 }
18850 });
18851 props = {
18852 "data-active": active || void 0,
18853 type: isNativeButton ? "button" : void 0,
18854 ...metadataProps,
18855 ...props,
18856 ref: useMergeRefs(ref, props.ref),
18857 onKeyDown,
18858 onKeyUp
18859 };
18860 props = useFocusable(props);
18861 return props;
18862 }
18863 );
18864 var Command = forwardRef210(function Command2(props) {
18865 const htmlProps = useCommand(props);
18866 return createElement3(TagName3, htmlProps);
18867 });
18868
18869 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
18870 function getInternal(store, key) {
18871 const internals = store.__unstableInternals;
18872 invariant(internals, "Invalid store");
18873 return internals[key];
18874 }
18875 function createStore(initialState, ...stores) {
18876 let state = initialState;
18877 let prevStateBatch = state;
18878 let lastUpdate = /* @__PURE__ */ Symbol();
18879 let destroy = noop4;
18880 const instances = /* @__PURE__ */ new Set();
18881 const updatedKeys = /* @__PURE__ */ new Set();
18882 const setups = /* @__PURE__ */ new Set();
18883 const listeners = /* @__PURE__ */ new Set();
18884 const batchListeners = /* @__PURE__ */ new Set();
18885 const disposables = /* @__PURE__ */ new WeakMap();
18886 const listenerKeys = /* @__PURE__ */ new WeakMap();
18887 const storeSetup = (callback) => {
18888 setups.add(callback);
18889 return () => setups.delete(callback);
18890 };
18891 const storeInit = () => {
18892 const initialized = instances.size;
18893 const instance = /* @__PURE__ */ Symbol();
18894 instances.add(instance);
18895 const maybeDestroy = () => {
18896 instances.delete(instance);
18897 if (instances.size) return;
18898 destroy();
18899 };
18900 if (initialized) return maybeDestroy;
18901 const desyncs = getKeys(state).map(
18902 (key) => chain(
18903 ...stores.map((store) => {
18904 var _a;
18905 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
18906 if (!storeState) return;
18907 if (!hasOwnProperty(storeState, key)) return;
18908 return sync(store, [key], (state2) => {
18909 setState(
18910 key,
18911 state2[key],
18912 // @ts-expect-error - Not public API. This is just to prevent
18913 // infinite loops.
18914 true
18915 );
18916 });
18917 })
18918 )
18919 );
18920 const teardowns = [];
18921 for (const setup2 of setups) {
18922 teardowns.push(setup2());
18923 }
18924 const cleanups = stores.map(init);
18925 destroy = chain(...desyncs, ...teardowns, ...cleanups);
18926 return maybeDestroy;
18927 };
18928 const sub = (keys, listener, set3 = listeners) => {
18929 set3.add(listener);
18930 listenerKeys.set(listener, keys);
18931 return () => {
18932 var _a;
18933 (_a = disposables.get(listener)) == null ? void 0 : _a();
18934 disposables.delete(listener);
18935 listenerKeys.delete(listener);
18936 set3.delete(listener);
18937 };
18938 };
18939 const storeSubscribe = (keys, listener) => sub(keys, listener);
18940 const storeSync = (keys, listener) => {
18941 disposables.set(listener, listener(state, state));
18942 return sub(keys, listener);
18943 };
18944 const storeBatch = (keys, listener) => {
18945 disposables.set(listener, listener(state, prevStateBatch));
18946 return sub(keys, listener, batchListeners);
18947 };
18948 const storePick = (keys) => createStore(pick(state, keys), finalStore);
18949 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
18950 const getState = () => state;
18951 const setState = (key, value, fromStores = false) => {
18952 var _a;
18953 if (!hasOwnProperty(state, key)) return;
18954 const nextValue = applyState(value, state[key]);
18955 if (nextValue === state[key]) return;
18956 if (!fromStores) {
18957 for (const store of stores) {
18958 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
18959 }
18960 }
18961 const prevState = state;
18962 state = { ...state, [key]: nextValue };
18963 const thisUpdate = /* @__PURE__ */ Symbol();
18964 lastUpdate = thisUpdate;
18965 updatedKeys.add(key);
18966 const run = (listener, prev, uKeys) => {
18967 var _a2;
18968 const keys = listenerKeys.get(listener);
18969 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
18970 if (!keys || keys.some(updated)) {
18971 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
18972 disposables.set(listener, listener(state, prev));
18973 }
18974 };
18975 for (const listener of listeners) {
18976 run(listener, prevState);
18977 }
18978 queueMicrotask(() => {
18979 if (lastUpdate !== thisUpdate) return;
18980 const snapshot = state;
18981 for (const listener of batchListeners) {
18982 run(listener, prevStateBatch, updatedKeys);
18983 }
18984 prevStateBatch = snapshot;
18985 updatedKeys.clear();
18986 });
18987 };
18988 const finalStore = {
18989 getState,
18990 setState,
18991 __unstableInternals: {
18992 setup: storeSetup,
18993 init: storeInit,
18994 subscribe: storeSubscribe,
18995 sync: storeSync,
18996 batch: storeBatch,
18997 pick: storePick,
18998 omit: storeOmit
18999 }
19000 };
19001 return finalStore;
19002 }
19003 function setup(store, ...args) {
19004 if (!store) return;
19005 return getInternal(store, "setup")(...args);
19006 }
19007 function init(store, ...args) {
19008 if (!store) return;
19009 return getInternal(store, "init")(...args);
19010 }
19011 function subscribe(store, ...args) {
19012 if (!store) return;
19013 return getInternal(store, "subscribe")(...args);
19014 }
19015 function sync(store, ...args) {
19016 if (!store) return;
19017 return getInternal(store, "sync")(...args);
19018 }
19019 function batch(store, ...args) {
19020 if (!store) return;
19021 return getInternal(store, "batch")(...args);
19022 }
19023 function omit2(store, ...args) {
19024 if (!store) return;
19025 return getInternal(store, "omit")(...args);
19026 }
19027 function pick2(store, ...args) {
19028 if (!store) return;
19029 return getInternal(store, "pick")(...args);
19030 }
19031 function mergeStore(...stores) {
19032 var _a;
19033 const initialState = {};
19034 for (const store2 of stores) {
19035 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
19036 if (nextState) {
19037 Object.assign(initialState, nextState);
19038 }
19039 }
19040 const store = createStore(initialState, ...stores);
19041 return Object.assign({}, ...stores, store);
19042 }
19043 function throwOnConflictingProps(props, store) {
19044 if (false) return;
19045 if (!store) return;
19046 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
19047 var _a;
19048 const stateKey = key.replace("default", "");
19049 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
19050 });
19051 if (!defaultKeys.length) return;
19052 const storeState = store.getState();
19053 const conflictingProps = defaultKeys.filter(
19054 (key) => hasOwnProperty(storeState, key)
19055 );
19056 if (!conflictingProps.length) return;
19057 throw new Error(
19058 `Passing a store prop in conjunction with a default state is not supported.
19059
19060 const store = useSelectStore();
19061 <SelectProvider store={store} defaultValue="Apple" />
19062 ^ ^
19063
19064 Instead, pass the default state to the topmost store:
19065
19066 const store = useSelectStore({ defaultValue: "Apple" });
19067 <SelectProvider store={store} />
19068
19069 See https://github.com/ariakit/ariakit/pull/2745 for more details.
19070
19071 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
19072 `
19073 );
19074 }
19075
19076 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
19077 var React60 = __toESM(require_react(), 1);
19078 var import_shim2 = __toESM(require_shim(), 1);
19079 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
19080 var noopSubscribe = () => () => {
19081 };
19082 function useStoreState(store, keyOrSelector = identity) {
19083 const storeSubscribe = React60.useCallback(
19084 (callback) => {
19085 if (!store) return noopSubscribe();
19086 return subscribe(store, null, callback);
19087 },
19088 [store]
19089 );
19090 const getSnapshot = () => {
19091 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
19092 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
19093 const state = store == null ? void 0 : store.getState();
19094 if (selector2) return selector2(state);
19095 if (!state) return;
19096 if (!key) return;
19097 if (!hasOwnProperty(state, key)) return;
19098 return state[key];
19099 };
19100 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
19101 }
19102 function useStoreStateObject(store, object) {
19103 const objRef = React60.useRef(
19104 {}
19105 );
19106 const storeSubscribe = React60.useCallback(
19107 (callback) => {
19108 if (!store) return noopSubscribe();
19109 return subscribe(store, null, callback);
19110 },
19111 [store]
19112 );
19113 const getSnapshot = () => {
19114 const state = store == null ? void 0 : store.getState();
19115 let updated = false;
19116 const obj = objRef.current;
19117 for (const prop in object) {
19118 const keyOrSelector = object[prop];
19119 if (typeof keyOrSelector === "function") {
19120 const value = keyOrSelector(state);
19121 if (value !== obj[prop]) {
19122 obj[prop] = value;
19123 updated = true;
19124 }
19125 }
19126 if (typeof keyOrSelector === "string") {
19127 if (!state) continue;
19128 if (!hasOwnProperty(state, keyOrSelector)) continue;
19129 const value = state[keyOrSelector];
19130 if (value !== obj[prop]) {
19131 obj[prop] = value;
19132 updated = true;
19133 }
19134 }
19135 }
19136 if (updated) {
19137 objRef.current = { ...obj };
19138 }
19139 return objRef.current;
19140 };
19141 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
19142 }
19143 function useStoreProps(store, props, key, setKey) {
19144 const value = hasOwnProperty(props, key) ? props[key] : void 0;
19145 const setValue = setKey ? props[setKey] : void 0;
19146 const propsRef = useLiveRef({ value, setValue });
19147 useSafeLayoutEffect(() => {
19148 return sync(store, [key], (state, prev) => {
19149 const { value: value2, setValue: setValue2 } = propsRef.current;
19150 if (!setValue2) return;
19151 if (state[key] === prev[key]) return;
19152 if (state[key] === value2) return;
19153 setValue2(state[key]);
19154 });
19155 }, [store, key]);
19156 useSafeLayoutEffect(() => {
19157 if (value === void 0) return;
19158 store.setState(key, value);
19159 return batch(store, [key], () => {
19160 if (value === void 0) return;
19161 store.setState(key, value);
19162 });
19163 });
19164 }
19165 function useStore2(createStore2, props) {
19166 const [store, setStore] = React60.useState(() => createStore2(props));
19167 useSafeLayoutEffect(() => init(store), [store]);
19168 const useState210 = React60.useCallback(
19169 (keyOrSelector) => useStoreState(store, keyOrSelector),
19170 [store]
19171 );
19172 const memoizedStore = React60.useMemo(
19173 () => ({ ...store, useState: useState210 }),
19174 [store, useState210]
19175 );
19176 const updateStore = useEvent(() => {
19177 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
19178 });
19179 return [memoizedStore, updateStore];
19180 }
19181
19182 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
19183 var import_react23 = __toESM(require_react(), 1);
19184 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
19185 var TagName4 = "button";
19186 function isEditableElement(element) {
19187 if (isTextbox(element)) return true;
19188 return element.tagName === "INPUT" && !isButton(element);
19189 }
19190 function getNextPageOffset(scrollingElement, pageUp = false) {
19191 const height = scrollingElement.clientHeight;
19192 const { top } = scrollingElement.getBoundingClientRect();
19193 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
19194 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
19195 if (scrollingElement.tagName === "HTML") {
19196 return pageOffset + scrollingElement.scrollTop;
19197 }
19198 return pageOffset;
19199 }
19200 function getItemOffset(itemElement, pageUp = false) {
19201 const { top } = itemElement.getBoundingClientRect();
19202 if (pageUp) {
19203 return top + itemElement.clientHeight;
19204 }
19205 return top;
19206 }
19207 function findNextPageItemId(element, store, next, pageUp = false) {
19208 var _a;
19209 if (!store) return;
19210 if (!next) return;
19211 const { renderedItems } = store.getState();
19212 const scrollingElement = getScrollingElement(element);
19213 if (!scrollingElement) return;
19214 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
19215 let id;
19216 let prevDifference;
19217 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
19218 const previousId = id;
19219 id = next(i2);
19220 if (!id) break;
19221 if (id === previousId) continue;
19222 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
19223 if (!itemElement) continue;
19224 const itemOffset = getItemOffset(itemElement, pageUp);
19225 const difference = itemOffset - nextPageOffset;
19226 const absDifference = Math.abs(difference);
19227 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
19228 if (prevDifference !== void 0 && prevDifference < absDifference) {
19229 id = previousId;
19230 }
19231 break;
19232 }
19233 prevDifference = absDifference;
19234 }
19235 return id;
19236 }
19237 function targetIsAnotherItem(event, store) {
19238 if (isSelfTarget(event)) return false;
19239 return isItem(store, event.target);
19240 }
19241 var useCompositeItem = createHook(
19242 function useCompositeItem2({
19243 store,
19244 rowId: rowIdProp,
19245 preventScrollOnKeyDown = false,
19246 moveOnKeyPress = true,
19247 tabbable: tabbable2 = false,
19248 getItem: getItemProp,
19249 "aria-setsize": ariaSetSizeProp,
19250 "aria-posinset": ariaPosInSetProp,
19251 ...props
19252 }) {
19253 const context = useCompositeContext();
19254 store = store || context;
19255 const id = useId5(props.id);
19256 const ref = (0, import_react23.useRef)(null);
19257 const row = (0, import_react23.useContext)(CompositeRowContext);
19258 const disabled2 = disabledFromProps(props);
19259 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
19260 const {
19261 rowId,
19262 baseElement,
19263 isActiveItem,
19264 ariaSetSize,
19265 ariaPosInSet,
19266 isTabbable
19267 } = useStoreStateObject(store, {
19268 rowId(state) {
19269 if (rowIdProp) return rowIdProp;
19270 if (!state) return;
19271 if (!(row == null ? void 0 : row.baseElement)) return;
19272 if (row.baseElement !== state.baseElement) return;
19273 return row.id;
19274 },
19275 baseElement(state) {
19276 return (state == null ? void 0 : state.baseElement) || void 0;
19277 },
19278 isActiveItem(state) {
19279 return !!state && state.activeId === id;
19280 },
19281 ariaSetSize(state) {
19282 if (ariaSetSizeProp != null) return ariaSetSizeProp;
19283 if (!state) return;
19284 if (!(row == null ? void 0 : row.ariaSetSize)) return;
19285 if (row.baseElement !== state.baseElement) return;
19286 return row.ariaSetSize;
19287 },
19288 ariaPosInSet(state) {
19289 if (ariaPosInSetProp != null) return ariaPosInSetProp;
19290 if (!state) return;
19291 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
19292 if (row.baseElement !== state.baseElement) return;
19293 const itemsInRow = state.renderedItems.filter(
19294 (item) => item.rowId === rowId
19295 );
19296 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
19297 },
19298 isTabbable(state) {
19299 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
19300 if (state.virtualFocus) return false;
19301 if (tabbable2) return true;
19302 if (state.activeId === null) return false;
19303 const item = store == null ? void 0 : store.item(state.activeId);
19304 if (item == null ? void 0 : item.disabled) return true;
19305 if (!(item == null ? void 0 : item.element)) return true;
19306 return state.activeId === id;
19307 }
19308 });
19309 const getItem = (0, import_react23.useCallback)(
19310 (item) => {
19311 var _a;
19312 const nextItem = {
19313 ...item,
19314 id: id || item.id,
19315 rowId,
19316 disabled: !!trulyDisabled,
19317 children: (_a = item.element) == null ? void 0 : _a.textContent
19318 };
19319 if (getItemProp) {
19320 return getItemProp(nextItem);
19321 }
19322 return nextItem;
19323 },
19324 [id, rowId, trulyDisabled, getItemProp]
19325 );
19326 const onFocusProp = props.onFocus;
19327 const hasFocusedComposite = (0, import_react23.useRef)(false);
19328 const onFocus = useEvent((event) => {
19329 onFocusProp == null ? void 0 : onFocusProp(event);
19330 if (event.defaultPrevented) return;
19331 if (isPortalEvent(event)) return;
19332 if (!id) return;
19333 if (!store) return;
19334 if (targetIsAnotherItem(event, store)) return;
19335 const { virtualFocus, baseElement: baseElement2 } = store.getState();
19336 store.setActiveId(id);
19337 if (isTextbox(event.currentTarget)) {
19338 selectTextField(event.currentTarget);
19339 }
19340 if (!virtualFocus) return;
19341 if (!isSelfTarget(event)) return;
19342 if (isEditableElement(event.currentTarget)) return;
19343 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
19344 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
19345 event.currentTarget.scrollIntoView({
19346 block: "nearest",
19347 inline: "nearest"
19348 });
19349 }
19350 hasFocusedComposite.current = true;
19351 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
19352 if (fromComposite) {
19353 focusSilently(baseElement2);
19354 } else {
19355 baseElement2.focus();
19356 }
19357 });
19358 const onBlurCaptureProp = props.onBlurCapture;
19359 const onBlurCapture = useEvent((event) => {
19360 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
19361 if (event.defaultPrevented) return;
19362 const state = store == null ? void 0 : store.getState();
19363 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
19364 hasFocusedComposite.current = false;
19365 event.preventDefault();
19366 event.stopPropagation();
19367 }
19368 });
19369 const onKeyDownProp = props.onKeyDown;
19370 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
19371 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19372 const onKeyDown = useEvent((event) => {
19373 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
19374 if (event.defaultPrevented) return;
19375 if (!isSelfTarget(event)) return;
19376 if (!store) return;
19377 const { currentTarget } = event;
19378 const state = store.getState();
19379 const item = store.item(id);
19380 const isGrid2 = !!(item == null ? void 0 : item.rowId);
19381 const isVertical = state.orientation !== "horizontal";
19382 const isHorizontal = state.orientation !== "vertical";
19383 const canHomeEnd = () => {
19384 if (isGrid2) return true;
19385 if (isHorizontal) return true;
19386 if (!state.baseElement) return true;
19387 if (!isTextField(state.baseElement)) return true;
19388 return false;
19389 };
19390 const keyMap = {
19391 ArrowUp: (isGrid2 || isVertical) && store.up,
19392 ArrowRight: (isGrid2 || isHorizontal) && store.next,
19393 ArrowDown: (isGrid2 || isVertical) && store.down,
19394 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
19395 Home: () => {
19396 if (!canHomeEnd()) return;
19397 if (!isGrid2 || event.ctrlKey) {
19398 return store == null ? void 0 : store.first();
19399 }
19400 return store == null ? void 0 : store.previous(-1);
19401 },
19402 End: () => {
19403 if (!canHomeEnd()) return;
19404 if (!isGrid2 || event.ctrlKey) {
19405 return store == null ? void 0 : store.last();
19406 }
19407 return store == null ? void 0 : store.next(-1);
19408 },
19409 PageUp: () => {
19410 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
19411 },
19412 PageDown: () => {
19413 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
19414 }
19415 };
19416 const action = keyMap[event.key];
19417 if (action) {
19418 if (isTextbox(currentTarget)) {
19419 const selection = getTextboxSelection(currentTarget);
19420 const isLeft = isHorizontal && event.key === "ArrowLeft";
19421 const isRight = isHorizontal && event.key === "ArrowRight";
19422 const isUp = isVertical && event.key === "ArrowUp";
19423 const isDown = isVertical && event.key === "ArrowDown";
19424 if (isRight || isDown) {
19425 const { length: valueLength } = getTextboxValue(currentTarget);
19426 if (selection.end !== valueLength) return;
19427 } else if ((isLeft || isUp) && selection.start !== 0) return;
19428 }
19429 const nextId = action();
19430 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
19431 if (!moveOnKeyPressProp(event)) return;
19432 event.preventDefault();
19433 store.move(nextId);
19434 }
19435 }
19436 });
19437 const providerValue = (0, import_react23.useMemo)(
19438 () => ({ id, baseElement }),
19439 [id, baseElement]
19440 );
19441 props = useWrapElement(
19442 props,
19443 (element) => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
19444 [providerValue]
19445 );
19446 props = {
19447 id,
19448 "data-active-item": isActiveItem || void 0,
19449 ...props,
19450 ref: useMergeRefs(ref, props.ref),
19451 tabIndex: isTabbable ? props.tabIndex : -1,
19452 onFocus,
19453 onBlurCapture,
19454 onKeyDown
19455 };
19456 props = useCommand(props);
19457 props = useCollectionItem({
19458 store,
19459 ...props,
19460 getItem,
19461 shouldRegisterItem: id ? props.shouldRegisterItem : false
19462 });
19463 return removeUndefinedValues({
19464 ...props,
19465 "aria-setsize": ariaSetSize,
19466 "aria-posinset": ariaPosInSet
19467 });
19468 }
19469 );
19470 var CompositeItem = memo22(
19471 forwardRef210(function CompositeItem2(props) {
19472 const htmlProps = useCompositeItem(props);
19473 return createElement3(TagName4, htmlProps);
19474 })
19475 );
19476
19477 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
19478 function toArray(arg) {
19479 if (Array.isArray(arg)) {
19480 return arg;
19481 }
19482 return typeof arg !== "undefined" ? [arg] : [];
19483 }
19484 function flatten2DArray(array) {
19485 const flattened = [];
19486 for (const row of array) {
19487 flattened.push(...row);
19488 }
19489 return flattened;
19490 }
19491 function reverseArray(array) {
19492 return array.slice().reverse();
19493 }
19494
19495 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
19496 var import_react24 = __toESM(require_react(), 1);
19497 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
19498 var TagName5 = "div";
19499 function isGrid(items) {
19500 return items.some((item) => !!item.rowId);
19501 }
19502 function isPrintableKey(event) {
19503 const target = event.target;
19504 if (target && !isTextField(target)) return false;
19505 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
19506 }
19507 function isModifierKey(event) {
19508 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
19509 }
19510 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
19511 return useEvent((event) => {
19512 var _a;
19513 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
19514 if (event.defaultPrevented) return;
19515 if (event.isPropagationStopped()) return;
19516 if (!isSelfTarget(event)) return;
19517 if (isModifierKey(event)) return;
19518 if (isPrintableKey(event)) return;
19519 const state = store.getState();
19520 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
19521 if (!activeElement2) return;
19522 const { view, ...eventInit } = event;
19523 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
19524 if (activeElement2 !== previousElement) {
19525 activeElement2.focus();
19526 }
19527 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
19528 event.preventDefault();
19529 }
19530 if (event.currentTarget.contains(activeElement2)) {
19531 event.stopPropagation();
19532 }
19533 });
19534 }
19535 function findFirstEnabledItemInTheLastRow(items) {
19536 return findFirstEnabledItem(
19537 flatten2DArray(reverseArray(groupItemsByRows(items)))
19538 );
19539 }
19540 function useScheduleFocus(store) {
19541 const [scheduled, setScheduled] = (0, import_react24.useState)(false);
19542 const schedule = (0, import_react24.useCallback)(() => setScheduled(true), []);
19543 const activeItem = store.useState(
19544 (state) => getEnabledItem(store, state.activeId)
19545 );
19546 (0, import_react24.useEffect)(() => {
19547 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
19548 if (!scheduled) return;
19549 if (!activeElement2) return;
19550 setScheduled(false);
19551 activeElement2.focus({ preventScroll: true });
19552 }, [activeItem, scheduled]);
19553 return schedule;
19554 }
19555 var useComposite = createHook(
19556 function useComposite2({
19557 store,
19558 composite = true,
19559 focusOnMove = composite,
19560 moveOnKeyPress = true,
19561 ...props
19562 }) {
19563 const context = useCompositeProviderContext();
19564 store = store || context;
19565 invariant(
19566 store,
19567 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
19568 );
19569 const ref = (0, import_react24.useRef)(null);
19570 const previousElementRef = (0, import_react24.useRef)(null);
19571 const scheduleFocus = useScheduleFocus(store);
19572 const moves = store.useState("moves");
19573 const [, setBaseElement] = useTransactionState(
19574 composite ? store.setBaseElement : null
19575 );
19576 (0, import_react24.useEffect)(() => {
19577 var _a;
19578 if (!store) return;
19579 if (!moves) return;
19580 if (!composite) return;
19581 if (!focusOnMove) return;
19582 const { activeId: activeId2 } = store.getState();
19583 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
19584 if (!itemElement) return;
19585 focusIntoView(itemElement);
19586 }, [store, moves, composite, focusOnMove]);
19587 useSafeLayoutEffect(() => {
19588 if (!store) return;
19589 if (!moves) return;
19590 if (!composite) return;
19591 const { baseElement, activeId: activeId2 } = store.getState();
19592 const isSelfAcive = activeId2 === null;
19593 if (!isSelfAcive) return;
19594 if (!baseElement) return;
19595 const previousElement = previousElementRef.current;
19596 previousElementRef.current = null;
19597 if (previousElement) {
19598 fireBlurEvent(previousElement, { relatedTarget: baseElement });
19599 }
19600 if (!hasFocus(baseElement)) {
19601 baseElement.focus();
19602 }
19603 }, [store, moves, composite]);
19604 const activeId = store.useState("activeId");
19605 const virtualFocus = store.useState("virtualFocus");
19606 useSafeLayoutEffect(() => {
19607 var _a;
19608 if (!store) return;
19609 if (!composite) return;
19610 if (!virtualFocus) return;
19611 const previousElement = previousElementRef.current;
19612 previousElementRef.current = null;
19613 if (!previousElement) return;
19614 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
19615 const relatedTarget = activeElement2 || getActiveElement(previousElement);
19616 if (relatedTarget === previousElement) return;
19617 fireBlurEvent(previousElement, { relatedTarget });
19618 }, [store, activeId, virtualFocus, composite]);
19619 const onKeyDownCapture = useKeyboardEventProxy(
19620 store,
19621 props.onKeyDownCapture,
19622 previousElementRef
19623 );
19624 const onKeyUpCapture = useKeyboardEventProxy(
19625 store,
19626 props.onKeyUpCapture,
19627 previousElementRef
19628 );
19629 const onFocusCaptureProp = props.onFocusCapture;
19630 const onFocusCapture = useEvent((event) => {
19631 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
19632 if (event.defaultPrevented) return;
19633 if (!store) return;
19634 const { virtualFocus: virtualFocus2 } = store.getState();
19635 if (!virtualFocus2) return;
19636 const previousActiveElement = event.relatedTarget;
19637 const isSilentlyFocused = silentlyFocused(event.currentTarget);
19638 if (isSelfTarget(event) && isSilentlyFocused) {
19639 event.stopPropagation();
19640 previousElementRef.current = previousActiveElement;
19641 }
19642 });
19643 const onFocusProp = props.onFocus;
19644 const onFocus = useEvent((event) => {
19645 onFocusProp == null ? void 0 : onFocusProp(event);
19646 if (event.defaultPrevented) return;
19647 if (!composite) return;
19648 if (!store) return;
19649 const { relatedTarget } = event;
19650 const { virtualFocus: virtualFocus2 } = store.getState();
19651 if (virtualFocus2) {
19652 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
19653 queueMicrotask(scheduleFocus);
19654 }
19655 } else if (isSelfTarget(event)) {
19656 store.setActiveId(null);
19657 }
19658 });
19659 const onBlurCaptureProp = props.onBlurCapture;
19660 const onBlurCapture = useEvent((event) => {
19661 var _a;
19662 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
19663 if (event.defaultPrevented) return;
19664 if (!store) return;
19665 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
19666 if (!virtualFocus2) return;
19667 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
19668 const nextActiveElement = event.relatedTarget;
19669 const nextActiveElementIsItem = isItem(store, nextActiveElement);
19670 const previousElement = previousElementRef.current;
19671 previousElementRef.current = null;
19672 if (isSelfTarget(event) && nextActiveElementIsItem) {
19673 if (nextActiveElement === activeElement2) {
19674 if (previousElement && previousElement !== nextActiveElement) {
19675 fireBlurEvent(previousElement, event);
19676 }
19677 } else if (activeElement2) {
19678 fireBlurEvent(activeElement2, event);
19679 } else if (previousElement) {
19680 fireBlurEvent(previousElement, event);
19681 }
19682 event.stopPropagation();
19683 } else {
19684 const targetIsItem = isItem(store, event.target);
19685 if (!targetIsItem && activeElement2) {
19686 fireBlurEvent(activeElement2, event);
19687 }
19688 }
19689 });
19690 const onKeyDownProp = props.onKeyDown;
19691 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19692 const onKeyDown = useEvent((event) => {
19693 var _a;
19694 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
19695 if (event.nativeEvent.isComposing) return;
19696 if (event.defaultPrevented) return;
19697 if (!store) return;
19698 if (!isSelfTarget(event)) return;
19699 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
19700 const activeItem = getEnabledItem(store, activeId2);
19701 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
19702 const isVertical = orientation !== "horizontal";
19703 const isHorizontal = orientation !== "vertical";
19704 const grid = isGrid(renderedItems);
19705 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
19706 if (isHorizontalKey && isTextField(event.currentTarget)) return;
19707 const up = () => {
19708 if (grid) {
19709 const item = findFirstEnabledItemInTheLastRow(renderedItems);
19710 return item == null ? void 0 : item.id;
19711 }
19712 return store == null ? void 0 : store.last();
19713 };
19714 const keyMap = {
19715 ArrowUp: (grid || isVertical) && up,
19716 ArrowRight: (grid || isHorizontal) && store.first,
19717 ArrowDown: (grid || isVertical) && store.first,
19718 ArrowLeft: (grid || isHorizontal) && store.last,
19719 Home: store.first,
19720 End: store.last,
19721 PageUp: store.first,
19722 PageDown: store.last
19723 };
19724 const action = keyMap[event.key];
19725 if (action) {
19726 const id = action();
19727 if (id !== void 0) {
19728 if (!moveOnKeyPressProp(event)) return;
19729 event.preventDefault();
19730 store.move(id);
19731 }
19732 }
19733 });
19734 props = useWrapElement(
19735 props,
19736 (element) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(CompositeContextProvider, { value: store, children: element }),
19737 [store]
19738 );
19739 const activeDescendant = store.useState((state) => {
19740 var _a;
19741 if (!store) return;
19742 if (!composite) return;
19743 if (!state.virtualFocus) return;
19744 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
19745 });
19746 props = {
19747 "aria-activedescendant": activeDescendant,
19748 ...props,
19749 ref: useMergeRefs(ref, setBaseElement, props.ref),
19750 onKeyDownCapture,
19751 onKeyUpCapture,
19752 onFocusCapture,
19753 onFocus,
19754 onBlurCapture,
19755 onKeyDown
19756 };
19757 const focusable2 = store.useState(
19758 (state) => composite && (state.virtualFocus || state.activeId === null)
19759 );
19760 props = useFocusable({ focusable: focusable2, ...props });
19761 return props;
19762 }
19763 );
19764 var Composite6 = forwardRef210(function Composite22(props) {
19765 const htmlProps = useComposite(props);
19766 return createElement3(TagName5, htmlProps);
19767 });
19768
19769 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
19770 var ctx3 = createStoreContext();
19771 var useDisclosureContext = ctx3.useContext;
19772 var useDisclosureScopedContext = ctx3.useScopedContext;
19773 var useDisclosureProviderContext = ctx3.useProviderContext;
19774 var DisclosureContextProvider = ctx3.ContextProvider;
19775 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
19776
19777 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
19778 var import_react25 = __toESM(require_react(), 1);
19779 var ctx4 = createStoreContext(
19780 [DisclosureContextProvider],
19781 [DisclosureScopedContextProvider]
19782 );
19783 var useDialogContext = ctx4.useContext;
19784 var useDialogScopedContext = ctx4.useScopedContext;
19785 var useDialogProviderContext = ctx4.useProviderContext;
19786 var DialogContextProvider = ctx4.ContextProvider;
19787 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
19788 var DialogHeadingContext = (0, import_react25.createContext)(void 0);
19789 var DialogDescriptionContext = (0, import_react25.createContext)(void 0);
19790
19791 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
19792 var import_react26 = __toESM(require_react(), 1);
19793 var import_react_dom4 = __toESM(require_react_dom(), 1);
19794 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
19795 var TagName6 = "div";
19796 function afterTimeout(timeoutMs, cb) {
19797 const timeoutId = setTimeout(cb, timeoutMs);
19798 return () => clearTimeout(timeoutId);
19799 }
19800 function afterPaint2(cb) {
19801 let raf = requestAnimationFrame(() => {
19802 raf = requestAnimationFrame(cb);
19803 });
19804 return () => cancelAnimationFrame(raf);
19805 }
19806 function parseCSSTime(...times) {
19807 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
19808 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
19809 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
19810 if (currentTime > longestTime) return currentTime;
19811 return longestTime;
19812 }, 0);
19813 }
19814 function isHidden(mounted, hidden, alwaysVisible) {
19815 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
19816 }
19817 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
19818 const context = useDisclosureProviderContext();
19819 store = store || context;
19820 invariant(
19821 store,
19822 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
19823 );
19824 const ref = (0, import_react26.useRef)(null);
19825 const id = useId5(props.id);
19826 const [transition, setTransition] = (0, import_react26.useState)(null);
19827 const open = store.useState("open");
19828 const mounted = store.useState("mounted");
19829 const animated = store.useState("animated");
19830 const contentElement = store.useState("contentElement");
19831 const otherElement = useStoreState(store.disclosure, "contentElement");
19832 useSafeLayoutEffect(() => {
19833 if (!ref.current) return;
19834 store == null ? void 0 : store.setContentElement(ref.current);
19835 }, [store]);
19836 useSafeLayoutEffect(() => {
19837 let previousAnimated;
19838 store == null ? void 0 : store.setState("animated", (animated2) => {
19839 previousAnimated = animated2;
19840 return true;
19841 });
19842 return () => {
19843 if (previousAnimated === void 0) return;
19844 store == null ? void 0 : store.setState("animated", previousAnimated);
19845 };
19846 }, [store]);
19847 useSafeLayoutEffect(() => {
19848 if (!animated) return;
19849 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
19850 setTransition(null);
19851 return;
19852 }
19853 return afterPaint2(() => {
19854 setTransition(open ? "enter" : mounted ? "leave" : null);
19855 });
19856 }, [animated, contentElement, open, mounted]);
19857 useSafeLayoutEffect(() => {
19858 if (!store) return;
19859 if (!animated) return;
19860 if (!transition) return;
19861 if (!contentElement) return;
19862 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
19863 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
19864 if (transition === "leave" && open) return;
19865 if (transition === "enter" && !open) return;
19866 if (typeof animated === "number") {
19867 const timeout2 = animated;
19868 return afterTimeout(timeout2, stopAnimationSync);
19869 }
19870 const {
19871 transitionDuration,
19872 animationDuration,
19873 transitionDelay,
19874 animationDelay
19875 } = getComputedStyle(contentElement);
19876 const {
19877 transitionDuration: transitionDuration2 = "0",
19878 animationDuration: animationDuration2 = "0",
19879 transitionDelay: transitionDelay2 = "0",
19880 animationDelay: animationDelay2 = "0"
19881 } = otherElement ? getComputedStyle(otherElement) : {};
19882 const delay = parseCSSTime(
19883 transitionDelay,
19884 animationDelay,
19885 transitionDelay2,
19886 animationDelay2
19887 );
19888 const duration = parseCSSTime(
19889 transitionDuration,
19890 animationDuration,
19891 transitionDuration2,
19892 animationDuration2
19893 );
19894 const timeout = delay + duration;
19895 if (!timeout) {
19896 if (transition === "enter") {
19897 store.setState("animated", false);
19898 }
19899 stopAnimation();
19900 return;
19901 }
19902 const frameRate = 1e3 / 60;
19903 const maxTimeout = Math.max(timeout - frameRate, 0);
19904 return afterTimeout(maxTimeout, stopAnimationSync);
19905 }, [store, animated, contentElement, otherElement, open, transition]);
19906 props = useWrapElement(
19907 props,
19908 (element) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DialogScopedContextProvider, { value: store, children: element }),
19909 [store]
19910 );
19911 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
19912 const styleProp = props.style;
19913 const style = (0, import_react26.useMemo)(() => {
19914 if (hidden) {
19915 return { ...styleProp, display: "none" };
19916 }
19917 return styleProp;
19918 }, [hidden, styleProp]);
19919 props = {
19920 id,
19921 "data-open": open || void 0,
19922 "data-enter": transition === "enter" || void 0,
19923 "data-leave": transition === "leave" || void 0,
19924 hidden,
19925 ...props,
19926 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
19927 style
19928 };
19929 return removeUndefinedValues(props);
19930 });
19931 var DisclosureContentImpl = forwardRef210(function DisclosureContentImpl2(props) {
19932 const htmlProps = useDisclosureContent(props);
19933 return createElement3(TagName6, htmlProps);
19934 });
19935 var DisclosureContent = forwardRef210(function DisclosureContent2({
19936 unmountOnHide,
19937 ...props
19938 }) {
19939 const context = useDisclosureProviderContext();
19940 const store = props.store || context;
19941 const mounted = useStoreState(
19942 store,
19943 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
19944 );
19945 if (mounted === false) return null;
19946 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DisclosureContentImpl, { ...props });
19947 });
19948
19949 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
19950 function createDisclosureStore(props = {}) {
19951 const store = mergeStore(
19952 props.store,
19953 omit2(props.disclosure, ["contentElement", "disclosureElement"])
19954 );
19955 throwOnConflictingProps(props, store);
19956 const syncState = store == null ? void 0 : store.getState();
19957 const open = defaultValue(
19958 props.open,
19959 syncState == null ? void 0 : syncState.open,
19960 props.defaultOpen,
19961 false
19962 );
19963 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
19964 const initialState = {
19965 open,
19966 animated,
19967 animating: !!animated && open,
19968 mounted: open,
19969 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
19970 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
19971 };
19972 const disclosure = createStore(initialState, store);
19973 setup(
19974 disclosure,
19975 () => sync(disclosure, ["animated", "animating"], (state) => {
19976 if (state.animated) return;
19977 disclosure.setState("animating", false);
19978 })
19979 );
19980 setup(
19981 disclosure,
19982 () => subscribe(disclosure, ["open"], () => {
19983 if (!disclosure.getState().animated) return;
19984 disclosure.setState("animating", true);
19985 })
19986 );
19987 setup(
19988 disclosure,
19989 () => sync(disclosure, ["open", "animating"], (state) => {
19990 disclosure.setState("mounted", state.open || state.animating);
19991 })
19992 );
19993 return {
19994 ...disclosure,
19995 disclosure: props.disclosure,
19996 setOpen: (value) => disclosure.setState("open", value),
19997 show: () => disclosure.setState("open", true),
19998 hide: () => disclosure.setState("open", false),
19999 toggle: () => disclosure.setState("open", (open2) => !open2),
20000 stopAnimation: () => disclosure.setState("animating", false),
20001 setContentElement: (value) => disclosure.setState("contentElement", value),
20002 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
20003 };
20004 }
20005
20006 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
20007 function useDisclosureStoreProps(store, update2, props) {
20008 useUpdateEffect(update2, [props.store, props.disclosure]);
20009 useStoreProps(store, props, "open", "setOpen");
20010 useStoreProps(store, props, "mounted", "setMounted");
20011 useStoreProps(store, props, "animated");
20012 return Object.assign(store, { disclosure: props.disclosure });
20013 }
20014
20015 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
20016 var ctx5 = createStoreContext(
20017 [DialogContextProvider],
20018 [DialogScopedContextProvider]
20019 );
20020 var usePopoverContext = ctx5.useContext;
20021 var usePopoverScopedContext = ctx5.useScopedContext;
20022 var usePopoverProviderContext = ctx5.useProviderContext;
20023 var PopoverContextProvider = ctx5.ContextProvider;
20024 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
20025
20026 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
20027 function getCommonParent(items) {
20028 var _a;
20029 const firstItem = items.find((item) => !!item.element);
20030 const lastItem = [...items].reverse().find((item) => !!item.element);
20031 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
20032 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
20033 const parent = parentElement;
20034 if (lastItem && parent.contains(lastItem.element)) {
20035 return parentElement;
20036 }
20037 parentElement = parentElement.parentElement;
20038 }
20039 return getDocument(parentElement).body;
20040 }
20041 function getPrivateStore(store) {
20042 return store == null ? void 0 : store.__unstablePrivateStore;
20043 }
20044 function createCollectionStore(props = {}) {
20045 var _a;
20046 throwOnConflictingProps(props, props.store);
20047 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
20048 const items = defaultValue(
20049 props.items,
20050 syncState == null ? void 0 : syncState.items,
20051 props.defaultItems,
20052 []
20053 );
20054 const itemsMap = new Map(items.map((item) => [item.id, item]));
20055 const initialState = {
20056 items,
20057 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
20058 };
20059 const syncPrivateStore = getPrivateStore(props.store);
20060 const privateStore = createStore(
20061 { items, renderedItems: initialState.renderedItems },
20062 syncPrivateStore
20063 );
20064 const collection = createStore(initialState, props.store);
20065 const sortItems = (renderedItems) => {
20066 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
20067 privateStore.setState("renderedItems", sortedItems);
20068 collection.setState("renderedItems", sortedItems);
20069 };
20070 setup(collection, () => init(privateStore));
20071 setup(privateStore, () => {
20072 return batch(privateStore, ["items"], (state) => {
20073 collection.setState("items", state.items);
20074 });
20075 });
20076 setup(privateStore, () => {
20077 return batch(privateStore, ["renderedItems"], (state) => {
20078 let firstRun = true;
20079 let raf = requestAnimationFrame(() => {
20080 const { renderedItems } = collection.getState();
20081 if (state.renderedItems === renderedItems) return;
20082 sortItems(state.renderedItems);
20083 });
20084 if (typeof IntersectionObserver !== "function") {
20085 return () => cancelAnimationFrame(raf);
20086 }
20087 const ioCallback = () => {
20088 if (firstRun) {
20089 firstRun = false;
20090 return;
20091 }
20092 cancelAnimationFrame(raf);
20093 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
20094 };
20095 const root = getCommonParent(state.renderedItems);
20096 const observer = new IntersectionObserver(ioCallback, { root });
20097 for (const item of state.renderedItems) {
20098 if (!item.element) continue;
20099 observer.observe(item.element);
20100 }
20101 return () => {
20102 cancelAnimationFrame(raf);
20103 observer.disconnect();
20104 };
20105 });
20106 });
20107 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
20108 let prevItem;
20109 setItems((items2) => {
20110 const index2 = items2.findIndex(({ id }) => id === item.id);
20111 const nextItems = items2.slice();
20112 if (index2 !== -1) {
20113 prevItem = items2[index2];
20114 const nextItem = { ...prevItem, ...item };
20115 nextItems[index2] = nextItem;
20116 itemsMap.set(item.id, nextItem);
20117 } else {
20118 nextItems.push(item);
20119 itemsMap.set(item.id, item);
20120 }
20121 return nextItems;
20122 });
20123 const unmergeItem = () => {
20124 setItems((items2) => {
20125 if (!prevItem) {
20126 if (canDeleteFromMap) {
20127 itemsMap.delete(item.id);
20128 }
20129 return items2.filter(({ id }) => id !== item.id);
20130 }
20131 const index2 = items2.findIndex(({ id }) => id === item.id);
20132 if (index2 === -1) return items2;
20133 const nextItems = items2.slice();
20134 nextItems[index2] = prevItem;
20135 itemsMap.set(item.id, prevItem);
20136 return nextItems;
20137 });
20138 };
20139 return unmergeItem;
20140 };
20141 const registerItem = (item) => mergeItem(
20142 item,
20143 (getItems) => privateStore.setState("items", getItems),
20144 true
20145 );
20146 return {
20147 ...collection,
20148 registerItem,
20149 renderItem: (item) => chain(
20150 registerItem(item),
20151 mergeItem(
20152 item,
20153 (getItems) => privateStore.setState("renderedItems", getItems)
20154 )
20155 ),
20156 item: (id) => {
20157 if (!id) return null;
20158 let item = itemsMap.get(id);
20159 if (!item) {
20160 const { items: items2 } = privateStore.getState();
20161 item = items2.find((item2) => item2.id === id);
20162 if (item) {
20163 itemsMap.set(id, item);
20164 }
20165 }
20166 return item || null;
20167 },
20168 // @ts-expect-error Internal
20169 __unstablePrivateStore: privateStore
20170 };
20171 }
20172
20173 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
20174 function useCollectionStoreProps(store, update2, props) {
20175 useUpdateEffect(update2, [props.store]);
20176 useStoreProps(store, props, "items", "setItems");
20177 return store;
20178 }
20179
20180 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
20181 var NULL_ITEM = { id: null };
20182 function findFirstEnabledItem2(items, excludeId) {
20183 return items.find((item) => {
20184 if (excludeId) {
20185 return !item.disabled && item.id !== excludeId;
20186 }
20187 return !item.disabled;
20188 });
20189 }
20190 function getEnabledItems(items, excludeId) {
20191 return items.filter((item) => {
20192 if (excludeId) {
20193 return !item.disabled && item.id !== excludeId;
20194 }
20195 return !item.disabled;
20196 });
20197 }
20198 function getItemsInRow(items, rowId) {
20199 return items.filter((item) => item.rowId === rowId);
20200 }
20201 function flipItems(items, activeId, shouldInsertNullItem = false) {
20202 const index2 = items.findIndex((item) => item.id === activeId);
20203 return [
20204 ...items.slice(index2 + 1),
20205 ...shouldInsertNullItem ? [NULL_ITEM] : [],
20206 ...items.slice(0, index2)
20207 ];
20208 }
20209 function groupItemsByRows2(items) {
20210 const rows = [];
20211 for (const item of items) {
20212 const row = rows.find((currentRow) => {
20213 var _a;
20214 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
20215 });
20216 if (row) {
20217 row.push(item);
20218 } else {
20219 rows.push([item]);
20220 }
20221 }
20222 return rows;
20223 }
20224 function getMaxRowLength(array) {
20225 let maxLength = 0;
20226 for (const { length } of array) {
20227 if (length > maxLength) {
20228 maxLength = length;
20229 }
20230 }
20231 return maxLength;
20232 }
20233 function createEmptyItem(rowId) {
20234 return {
20235 id: "__EMPTY_ITEM__",
20236 disabled: true,
20237 rowId
20238 };
20239 }
20240 function normalizeRows(rows, activeId, focusShift) {
20241 const maxLength = getMaxRowLength(rows);
20242 for (const row of rows) {
20243 for (let i2 = 0; i2 < maxLength; i2 += 1) {
20244 const item = row[i2];
20245 if (!item || focusShift && item.disabled) {
20246 const isFirst = i2 === 0;
20247 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
20248 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
20249 }
20250 }
20251 }
20252 return rows;
20253 }
20254 function verticalizeItems(items) {
20255 const rows = groupItemsByRows2(items);
20256 const maxLength = getMaxRowLength(rows);
20257 const verticalized = [];
20258 for (let i2 = 0; i2 < maxLength; i2 += 1) {
20259 for (const row of rows) {
20260 const item = row[i2];
20261 if (item) {
20262 verticalized.push({
20263 ...item,
20264 // If there's no rowId, it means that it's not a grid composite, but
20265 // a single row instead. So, instead of verticalizing it, that is,
20266 // assigning a different rowId based on the column index, we keep it
20267 // undefined so they will be part of the same row. This is useful
20268 // when using up/down on one-dimensional composites.
20269 rowId: item.rowId ? `${i2}` : void 0
20270 });
20271 }
20272 }
20273 }
20274 return verticalized;
20275 }
20276 function createCompositeStore(props = {}) {
20277 var _a;
20278 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
20279 const collection = createCollectionStore(props);
20280 const activeId = defaultValue(
20281 props.activeId,
20282 syncState == null ? void 0 : syncState.activeId,
20283 props.defaultActiveId
20284 );
20285 const initialState = {
20286 ...collection.getState(),
20287 id: defaultValue(
20288 props.id,
20289 syncState == null ? void 0 : syncState.id,
20290 `id-${Math.random().toString(36).slice(2, 8)}`
20291 ),
20292 activeId,
20293 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
20294 includesBaseElement: defaultValue(
20295 props.includesBaseElement,
20296 syncState == null ? void 0 : syncState.includesBaseElement,
20297 activeId === null
20298 ),
20299 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
20300 orientation: defaultValue(
20301 props.orientation,
20302 syncState == null ? void 0 : syncState.orientation,
20303 "both"
20304 ),
20305 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
20306 virtualFocus: defaultValue(
20307 props.virtualFocus,
20308 syncState == null ? void 0 : syncState.virtualFocus,
20309 false
20310 ),
20311 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
20312 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
20313 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
20314 };
20315 const composite = createStore(initialState, collection, props.store);
20316 setup(
20317 composite,
20318 () => sync(composite, ["renderedItems", "activeId"], (state) => {
20319 composite.setState("activeId", (activeId2) => {
20320 var _a2;
20321 if (activeId2 !== void 0) return activeId2;
20322 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
20323 });
20324 })
20325 );
20326 const getNextId = (direction = "next", options = {}) => {
20327 var _a2, _b;
20328 const defaultState = composite.getState();
20329 const {
20330 skip = 0,
20331 activeId: activeId2 = defaultState.activeId,
20332 focusShift = defaultState.focusShift,
20333 focusLoop = defaultState.focusLoop,
20334 focusWrap = defaultState.focusWrap,
20335 includesBaseElement = defaultState.includesBaseElement,
20336 renderedItems = defaultState.renderedItems,
20337 rtl = defaultState.rtl
20338 } = options;
20339 const isVerticalDirection = direction === "up" || direction === "down";
20340 const isNextDirection = direction === "next" || direction === "down";
20341 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
20342 const canShift = focusShift && !skip;
20343 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
20344 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
20345 );
20346 items = canReverse ? reverseArray(items) : items;
20347 items = isVerticalDirection ? verticalizeItems(items) : items;
20348 if (activeId2 == null) {
20349 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
20350 }
20351 const activeItem = items.find((item) => item.id === activeId2);
20352 if (!activeItem) {
20353 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
20354 }
20355 const isGrid2 = items.some((item) => item.rowId);
20356 const activeIndex = items.indexOf(activeItem);
20357 const nextItems = items.slice(activeIndex + 1);
20358 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
20359 if (skip) {
20360 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
20361 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
20362 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
20363 return nextItem2 == null ? void 0 : nextItem2.id;
20364 }
20365 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
20366 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
20367 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
20368 if (canLoop) {
20369 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
20370 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
20371 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
20372 return nextItem2 == null ? void 0 : nextItem2.id;
20373 }
20374 if (canWrap) {
20375 const nextItem2 = findFirstEnabledItem2(
20376 // We can use nextItems, which contains all the next items, including
20377 // items from other rows, to wrap between rows. However, if there is a
20378 // null item (the composite container), we'll only use the next items in
20379 // the row. So moving next from the last item will focus on the
20380 // composite container. On grid composites, horizontal navigation never
20381 // focuses on the composite container, only vertical.
20382 hasNullItem ? nextItemsInRow : nextItems,
20383 activeId2
20384 );
20385 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
20386 return nextId;
20387 }
20388 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
20389 if (!nextItem && hasNullItem) {
20390 return null;
20391 }
20392 return nextItem == null ? void 0 : nextItem.id;
20393 };
20394 return {
20395 ...collection,
20396 ...composite,
20397 setBaseElement: (element) => composite.setState("baseElement", element),
20398 setActiveId: (id) => composite.setState("activeId", id),
20399 move: (id) => {
20400 if (id === void 0) return;
20401 composite.setState("activeId", id);
20402 composite.setState("moves", (moves) => moves + 1);
20403 },
20404 first: () => {
20405 var _a2;
20406 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
20407 },
20408 last: () => {
20409 var _a2;
20410 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
20411 },
20412 next: (options) => {
20413 if (options !== void 0 && typeof options === "number") {
20414 options = { skip: options };
20415 }
20416 return getNextId("next", options);
20417 },
20418 previous: (options) => {
20419 if (options !== void 0 && typeof options === "number") {
20420 options = { skip: options };
20421 }
20422 return getNextId("previous", options);
20423 },
20424 down: (options) => {
20425 if (options !== void 0 && typeof options === "number") {
20426 options = { skip: options };
20427 }
20428 return getNextId("down", options);
20429 },
20430 up: (options) => {
20431 if (options !== void 0 && typeof options === "number") {
20432 options = { skip: options };
20433 }
20434 return getNextId("up", options);
20435 }
20436 };
20437 }
20438
20439 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
20440 function useCompositeStoreOptions(props) {
20441 const id = useId5(props.id);
20442 return { id, ...props };
20443 }
20444 function useCompositeStoreProps(store, update2, props) {
20445 store = useCollectionStoreProps(store, update2, props);
20446 useStoreProps(store, props, "activeId", "setActiveId");
20447 useStoreProps(store, props, "includesBaseElement");
20448 useStoreProps(store, props, "virtualFocus");
20449 useStoreProps(store, props, "orientation");
20450 useStoreProps(store, props, "rtl");
20451 useStoreProps(store, props, "focusLoop");
20452 useStoreProps(store, props, "focusWrap");
20453 useStoreProps(store, props, "focusShift");
20454 return store;
20455 }
20456
20457 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
20458 var import_react27 = __toESM(require_react(), 1);
20459 var ComboboxListRoleContext = (0, import_react27.createContext)(
20460 void 0
20461 );
20462 var ctx6 = createStoreContext(
20463 [PopoverContextProvider, CompositeContextProvider],
20464 [PopoverScopedContextProvider, CompositeScopedContextProvider]
20465 );
20466 var useComboboxContext = ctx6.useContext;
20467 var useComboboxScopedContext = ctx6.useScopedContext;
20468 var useComboboxProviderContext = ctx6.useProviderContext;
20469 var ComboboxContextProvider = ctx6.ContextProvider;
20470 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
20471 var ComboboxItemValueContext = (0, import_react27.createContext)(
20472 void 0
20473 );
20474 var ComboboxItemCheckedContext = (0, import_react27.createContext)(false);
20475
20476 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
20477 function createDialogStore(props = {}) {
20478 return createDisclosureStore(props);
20479 }
20480
20481 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
20482 function useDialogStoreProps(store, update2, props) {
20483 return useDisclosureStoreProps(store, update2, props);
20484 }
20485
20486 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
20487 function createPopoverStore({
20488 popover: otherPopover,
20489 ...props
20490 } = {}) {
20491 const store = mergeStore(
20492 props.store,
20493 omit2(otherPopover, [
20494 "arrowElement",
20495 "anchorElement",
20496 "contentElement",
20497 "popoverElement",
20498 "disclosureElement"
20499 ])
20500 );
20501 throwOnConflictingProps(props, store);
20502 const syncState = store == null ? void 0 : store.getState();
20503 const dialog = createDialogStore({ ...props, store });
20504 const placement = defaultValue(
20505 props.placement,
20506 syncState == null ? void 0 : syncState.placement,
20507 "bottom"
20508 );
20509 const initialState = {
20510 ...dialog.getState(),
20511 placement,
20512 currentPlacement: placement,
20513 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
20514 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
20515 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
20516 rendered: /* @__PURE__ */ Symbol("rendered")
20517 };
20518 const popover = createStore(initialState, dialog, store);
20519 return {
20520 ...dialog,
20521 ...popover,
20522 setAnchorElement: (element) => popover.setState("anchorElement", element),
20523 setPopoverElement: (element) => popover.setState("popoverElement", element),
20524 setArrowElement: (element) => popover.setState("arrowElement", element),
20525 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
20526 };
20527 }
20528
20529 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
20530 function usePopoverStoreProps(store, update2, props) {
20531 useUpdateEffect(update2, [props.popover]);
20532 useStoreProps(store, props, "placement");
20533 return useDialogStoreProps(store, update2, props);
20534 }
20535
20536 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
20537 var TagName7 = "div";
20538 var usePopoverAnchor = createHook(
20539 function usePopoverAnchor2({ store, ...props }) {
20540 const context = usePopoverProviderContext();
20541 store = store || context;
20542 props = {
20543 ...props,
20544 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
20545 };
20546 return props;
20547 }
20548 );
20549 var PopoverAnchor = forwardRef210(function PopoverAnchor2(props) {
20550 const htmlProps = usePopoverAnchor(props);
20551 return createElement3(TagName7, htmlProps);
20552 });
20553
20554 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
20555 var import_react28 = __toESM(require_react(), 1);
20556 var TagName8 = "div";
20557 function getMouseDestination(event) {
20558 const relatedTarget = event.relatedTarget;
20559 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
20560 return relatedTarget;
20561 }
20562 return null;
20563 }
20564 function hoveringInside(event) {
20565 const nextElement = getMouseDestination(event);
20566 if (!nextElement) return false;
20567 return contains2(event.currentTarget, nextElement);
20568 }
20569 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
20570 function movingToAnotherItem(event) {
20571 let dest = getMouseDestination(event);
20572 if (!dest) return false;
20573 do {
20574 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
20575 dest = dest.parentElement;
20576 } while (dest);
20577 return false;
20578 }
20579 var useCompositeHover = createHook(
20580 function useCompositeHover2({
20581 store,
20582 focusOnHover = true,
20583 blurOnHoverEnd = !!focusOnHover,
20584 ...props
20585 }) {
20586 const context = useCompositeContext();
20587 store = store || context;
20588 invariant(
20589 store,
20590 "CompositeHover must be wrapped in a Composite component."
20591 );
20592 const isMouseMoving = useIsMouseMoving();
20593 const onMouseMoveProp = props.onMouseMove;
20594 const focusOnHoverProp = useBooleanEvent(focusOnHover);
20595 const onMouseMove = useEvent((event) => {
20596 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
20597 if (event.defaultPrevented) return;
20598 if (!isMouseMoving()) return;
20599 if (!focusOnHoverProp(event)) return;
20600 if (!hasFocusWithin(event.currentTarget)) {
20601 const baseElement = store == null ? void 0 : store.getState().baseElement;
20602 if (baseElement && !hasFocus(baseElement)) {
20603 baseElement.focus();
20604 }
20605 }
20606 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
20607 });
20608 const onMouseLeaveProp = props.onMouseLeave;
20609 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
20610 const onMouseLeave = useEvent((event) => {
20611 var _a;
20612 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
20613 if (event.defaultPrevented) return;
20614 if (!isMouseMoving()) return;
20615 if (hoveringInside(event)) return;
20616 if (movingToAnotherItem(event)) return;
20617 if (!focusOnHoverProp(event)) return;
20618 if (!blurOnHoverEndProp(event)) return;
20619 store == null ? void 0 : store.setActiveId(null);
20620 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
20621 });
20622 const ref = (0, import_react28.useCallback)((element) => {
20623 if (!element) return;
20624 element[symbol2] = true;
20625 }, []);
20626 props = {
20627 ...props,
20628 ref: useMergeRefs(ref, props.ref),
20629 onMouseMove,
20630 onMouseLeave
20631 };
20632 return removeUndefinedValues(props);
20633 }
20634 );
20635 var CompositeHover = memo22(
20636 forwardRef210(function CompositeHover2(props) {
20637 const htmlProps = useCompositeHover(props);
20638 return createElement3(TagName8, htmlProps);
20639 })
20640 );
20641
20642 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
20643 var import_react29 = __toESM(require_react(), 1);
20644 var TagName9 = "input";
20645 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
20646 if (!autoSelect) return false;
20647 const firstItem = items.find((item) => !item.disabled && item.value);
20648 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
20649 }
20650 function hasCompletionString(value, activeValue) {
20651 if (!activeValue) return false;
20652 if (value == null) return false;
20653 value = normalizeString(value);
20654 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
20655 }
20656 function isInputEvent(event) {
20657 return event.type === "input";
20658 }
20659 function isAriaAutoCompleteValue(value) {
20660 return value === "inline" || value === "list" || value === "both" || value === "none";
20661 }
20662 function getDefaultAutoSelectId(items) {
20663 const item = items.find((item2) => {
20664 var _a;
20665 if (item2.disabled) return false;
20666 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
20667 });
20668 return item == null ? void 0 : item.id;
20669 }
20670 var useCombobox = createHook(
20671 function useCombobox2({
20672 store,
20673 focusable: focusable2 = true,
20674 autoSelect: autoSelectProp = false,
20675 getAutoSelectId,
20676 setValueOnChange,
20677 showMinLength = 0,
20678 showOnChange,
20679 showOnMouseDown,
20680 showOnClick = showOnMouseDown,
20681 showOnKeyDown,
20682 showOnKeyPress = showOnKeyDown,
20683 blurActiveItemOnClick,
20684 setValueOnClick = true,
20685 moveOnKeyPress = true,
20686 autoComplete = "list",
20687 ...props
20688 }) {
20689 const context = useComboboxProviderContext();
20690 store = store || context;
20691 invariant(
20692 store,
20693 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
20694 );
20695 const ref = (0, import_react29.useRef)(null);
20696 const [valueUpdated, forceValueUpdate] = useForceUpdate();
20697 const canAutoSelectRef = (0, import_react29.useRef)(false);
20698 const composingRef = (0, import_react29.useRef)(false);
20699 const autoSelect = store.useState(
20700 (state) => state.virtualFocus && autoSelectProp
20701 );
20702 const inline4 = autoComplete === "inline" || autoComplete === "both";
20703 const [canInline, setCanInline] = (0, import_react29.useState)(inline4);
20704 useUpdateLayoutEffect(() => {
20705 if (!inline4) return;
20706 setCanInline(true);
20707 }, [inline4]);
20708 const storeValue = store.useState("value");
20709 const prevSelectedValueRef = (0, import_react29.useRef)(void 0);
20710 (0, import_react29.useEffect)(() => {
20711 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
20712 prevSelectedValueRef.current = prev.selectedValue;
20713 });
20714 }, []);
20715 const inlineActiveValue = store.useState((state) => {
20716 var _a;
20717 if (!inline4) return;
20718 if (!canInline) return;
20719 if (state.activeValue && Array.isArray(state.selectedValue)) {
20720 if (state.selectedValue.includes(state.activeValue)) return;
20721 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
20722 }
20723 return state.activeValue;
20724 });
20725 const items = store.useState("renderedItems");
20726 const open = store.useState("open");
20727 const contentElement = store.useState("contentElement");
20728 const value = (0, import_react29.useMemo)(() => {
20729 if (!inline4) return storeValue;
20730 if (!canInline) return storeValue;
20731 const firstItemAutoSelected = isFirstItemAutoSelected(
20732 items,
20733 inlineActiveValue,
20734 autoSelect
20735 );
20736 if (firstItemAutoSelected) {
20737 if (hasCompletionString(storeValue, inlineActiveValue)) {
20738 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
20739 return storeValue + slice;
20740 }
20741 return storeValue;
20742 }
20743 return inlineActiveValue || storeValue;
20744 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
20745 (0, import_react29.useEffect)(() => {
20746 const element = ref.current;
20747 if (!element) return;
20748 const onCompositeItemMove = () => setCanInline(true);
20749 element.addEventListener("combobox-item-move", onCompositeItemMove);
20750 return () => {
20751 element.removeEventListener("combobox-item-move", onCompositeItemMove);
20752 };
20753 }, []);
20754 (0, import_react29.useEffect)(() => {
20755 if (!inline4) return;
20756 if (!canInline) return;
20757 if (!inlineActiveValue) return;
20758 const firstItemAutoSelected = isFirstItemAutoSelected(
20759 items,
20760 inlineActiveValue,
20761 autoSelect
20762 );
20763 if (!firstItemAutoSelected) return;
20764 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
20765 let cleanup = noop4;
20766 queueMicrotask(() => {
20767 const element = ref.current;
20768 if (!element) return;
20769 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
20770 const nextStart = storeValue.length;
20771 const nextEnd = inlineActiveValue.length;
20772 setSelectionRange(element, nextStart, nextEnd);
20773 cleanup = () => {
20774 if (!hasFocus(element)) return;
20775 const { start, end } = getTextboxSelection(element);
20776 if (start !== nextStart) return;
20777 if (end !== nextEnd) return;
20778 setSelectionRange(element, prevStart, prevEnd);
20779 };
20780 });
20781 return () => cleanup();
20782 }, [
20783 valueUpdated,
20784 inline4,
20785 canInline,
20786 inlineActiveValue,
20787 items,
20788 autoSelect,
20789 storeValue
20790 ]);
20791 const scrollingElementRef = (0, import_react29.useRef)(null);
20792 const getAutoSelectIdProp = useEvent(getAutoSelectId);
20793 const autoSelectIdRef = (0, import_react29.useRef)(null);
20794 (0, import_react29.useEffect)(() => {
20795 if (!open) return;
20796 if (!contentElement) return;
20797 const scrollingElement = getScrollingElement(contentElement);
20798 if (!scrollingElement) return;
20799 scrollingElementRef.current = scrollingElement;
20800 const onUserScroll = () => {
20801 canAutoSelectRef.current = false;
20802 };
20803 const onScroll = () => {
20804 if (!store) return;
20805 if (!canAutoSelectRef.current) return;
20806 const { activeId } = store.getState();
20807 if (activeId === null) return;
20808 if (activeId === autoSelectIdRef.current) return;
20809 canAutoSelectRef.current = false;
20810 };
20811 const options = { passive: true, capture: true };
20812 scrollingElement.addEventListener("wheel", onUserScroll, options);
20813 scrollingElement.addEventListener("touchmove", onUserScroll, options);
20814 scrollingElement.addEventListener("scroll", onScroll, options);
20815 return () => {
20816 scrollingElement.removeEventListener("wheel", onUserScroll, true);
20817 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
20818 scrollingElement.removeEventListener("scroll", onScroll, true);
20819 };
20820 }, [open, contentElement, store]);
20821 useSafeLayoutEffect(() => {
20822 if (!storeValue) return;
20823 if (composingRef.current) return;
20824 canAutoSelectRef.current = true;
20825 }, [storeValue]);
20826 useSafeLayoutEffect(() => {
20827 if (autoSelect !== "always" && open) return;
20828 canAutoSelectRef.current = open;
20829 }, [autoSelect, open]);
20830 const resetValueOnSelect = store.useState("resetValueOnSelect");
20831 useUpdateEffect(() => {
20832 var _a, _b;
20833 const canAutoSelect = canAutoSelectRef.current;
20834 if (!store) return;
20835 if (!open) return;
20836 if (!canAutoSelect && !resetValueOnSelect) return;
20837 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
20838 if (baseElement && !hasFocus(baseElement)) return;
20839 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
20840 const observer = new MutationObserver(forceValueUpdate);
20841 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
20842 return () => observer.disconnect();
20843 }
20844 if (autoSelect && canAutoSelect) {
20845 const userAutoSelectId = getAutoSelectIdProp(items);
20846 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
20847 autoSelectIdRef.current = autoSelectId;
20848 store.move(autoSelectId != null ? autoSelectId : null);
20849 } else {
20850 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
20851 if (element && "scrollIntoView" in element) {
20852 element.scrollIntoView({ block: "nearest", inline: "nearest" });
20853 }
20854 }
20855 return;
20856 }, [
20857 store,
20858 open,
20859 valueUpdated,
20860 storeValue,
20861 autoSelect,
20862 resetValueOnSelect,
20863 getAutoSelectIdProp,
20864 items
20865 ]);
20866 (0, import_react29.useEffect)(() => {
20867 if (!inline4) return;
20868 const combobox = ref.current;
20869 if (!combobox) return;
20870 const elements = [combobox, contentElement].filter(
20871 (value2) => !!value2
20872 );
20873 const onBlur2 = (event) => {
20874 if (elements.every((el) => isFocusEventOutside(event, el))) {
20875 store == null ? void 0 : store.setValue(value);
20876 }
20877 };
20878 for (const element of elements) {
20879 element.addEventListener("focusout", onBlur2);
20880 }
20881 return () => {
20882 for (const element of elements) {
20883 element.removeEventListener("focusout", onBlur2);
20884 }
20885 };
20886 }, [inline4, contentElement, store, value]);
20887 const canShow = (event) => {
20888 const currentTarget = event.currentTarget;
20889 return currentTarget.value.length >= showMinLength;
20890 };
20891 const onChangeProp = props.onChange;
20892 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
20893 const setValueOnChangeProp = useBooleanEvent(
20894 // If the combobox is combined with tags, the value will be set by the tag
20895 // input component.
20896 setValueOnChange != null ? setValueOnChange : !store.tag
20897 );
20898 const onChange = useEvent((event) => {
20899 onChangeProp == null ? void 0 : onChangeProp(event);
20900 if (event.defaultPrevented) return;
20901 if (!store) return;
20902 const currentTarget = event.currentTarget;
20903 const { value: value2, selectionStart, selectionEnd } = currentTarget;
20904 const nativeEvent = event.nativeEvent;
20905 canAutoSelectRef.current = true;
20906 if (isInputEvent(nativeEvent)) {
20907 if (nativeEvent.isComposing) {
20908 canAutoSelectRef.current = false;
20909 composingRef.current = true;
20910 }
20911 if (inline4) {
20912 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
20913 const caretAtEnd = selectionStart === value2.length;
20914 setCanInline(textInserted && caretAtEnd);
20915 }
20916 }
20917 if (setValueOnChangeProp(event)) {
20918 const isSameValue = value2 === store.getState().value;
20919 store.setValue(value2);
20920 queueMicrotask(() => {
20921 setSelectionRange(currentTarget, selectionStart, selectionEnd);
20922 });
20923 if (inline4 && autoSelect && isSameValue) {
20924 forceValueUpdate();
20925 }
20926 }
20927 if (showOnChangeProp(event)) {
20928 store.show();
20929 }
20930 if (!autoSelect || !canAutoSelectRef.current) {
20931 store.setActiveId(null);
20932 }
20933 });
20934 const onCompositionEndProp = props.onCompositionEnd;
20935 const onCompositionEnd = useEvent((event) => {
20936 canAutoSelectRef.current = true;
20937 composingRef.current = false;
20938 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
20939 if (event.defaultPrevented) return;
20940 if (!autoSelect) return;
20941 forceValueUpdate();
20942 });
20943 const onMouseDownProp = props.onMouseDown;
20944 const blurActiveItemOnClickProp = useBooleanEvent(
20945 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
20946 );
20947 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
20948 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
20949 const onMouseDown = useEvent((event) => {
20950 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
20951 if (event.defaultPrevented) return;
20952 if (event.button) return;
20953 if (event.ctrlKey) return;
20954 if (!store) return;
20955 if (blurActiveItemOnClickProp(event)) {
20956 store.setActiveId(null);
20957 }
20958 if (setValueOnClickProp(event)) {
20959 store.setValue(value);
20960 }
20961 if (showOnClickProp(event)) {
20962 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
20963 }
20964 });
20965 const onKeyDownProp = props.onKeyDown;
20966 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
20967 const onKeyDown = useEvent((event) => {
20968 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
20969 if (!event.repeat) {
20970 canAutoSelectRef.current = false;
20971 }
20972 if (event.defaultPrevented) return;
20973 if (event.ctrlKey) return;
20974 if (event.altKey) return;
20975 if (event.shiftKey) return;
20976 if (event.metaKey) return;
20977 if (!store) return;
20978 const { open: open2 } = store.getState();
20979 if (open2) return;
20980 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
20981 if (showOnKeyPressProp(event)) {
20982 event.preventDefault();
20983 store.show();
20984 }
20985 }
20986 });
20987 const onBlurProp = props.onBlur;
20988 const onBlur = useEvent((event) => {
20989 canAutoSelectRef.current = false;
20990 onBlurProp == null ? void 0 : onBlurProp(event);
20991 if (event.defaultPrevented) return;
20992 });
20993 const id = useId5(props.id);
20994 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
20995 const isActiveItem = store.useState((state) => state.activeId === null);
20996 props = {
20997 id,
20998 role: "combobox",
20999 "aria-autocomplete": ariaAutoComplete,
21000 "aria-haspopup": getPopupRole(contentElement, "listbox"),
21001 "aria-expanded": open,
21002 "aria-controls": contentElement == null ? void 0 : contentElement.id,
21003 "data-active-item": isActiveItem || void 0,
21004 value,
21005 ...props,
21006 ref: useMergeRefs(ref, props.ref),
21007 onChange,
21008 onCompositionEnd,
21009 onMouseDown,
21010 onKeyDown,
21011 onBlur
21012 };
21013 props = useComposite({
21014 store,
21015 focusable: focusable2,
21016 ...props,
21017 // Enable inline autocomplete when the user moves from the combobox input
21018 // to an item.
21019 moveOnKeyPress: (event) => {
21020 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
21021 if (inline4) setCanInline(true);
21022 return true;
21023 }
21024 });
21025 props = usePopoverAnchor({ store, ...props });
21026 return { autoComplete: "off", ...props };
21027 }
21028 );
21029 var Combobox = forwardRef210(function Combobox2(props) {
21030 const htmlProps = useCombobox(props);
21031 return createElement3(TagName9, htmlProps);
21032 });
21033
21034 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
21035 var import_react30 = __toESM(require_react(), 1);
21036 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
21037 var TagName10 = "div";
21038 function isSelected(storeValue, itemValue) {
21039 if (itemValue == null) return;
21040 if (storeValue == null) return false;
21041 if (Array.isArray(storeValue)) {
21042 return storeValue.includes(itemValue);
21043 }
21044 return storeValue === itemValue;
21045 }
21046 function getItemRole(popupRole) {
21047 var _a;
21048 const itemRoleByPopupRole = {
21049 menu: "menuitem",
21050 listbox: "option",
21051 tree: "treeitem"
21052 };
21053 const key = popupRole;
21054 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
21055 }
21056 var useComboboxItem = createHook(
21057 function useComboboxItem2({
21058 store,
21059 value,
21060 hideOnClick,
21061 setValueOnClick,
21062 selectValueOnClick = true,
21063 resetValueOnSelect,
21064 focusOnHover = false,
21065 moveOnKeyPress = true,
21066 getItem: getItemProp,
21067 ...props
21068 }) {
21069 var _a;
21070 const context = useComboboxScopedContext();
21071 store = store || context;
21072 invariant(
21073 store,
21074 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
21075 );
21076 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
21077 resetValueOnSelectState: "resetValueOnSelect",
21078 multiSelectable(state) {
21079 return Array.isArray(state.selectedValue);
21080 },
21081 selected(state) {
21082 return isSelected(state.selectedValue, value);
21083 }
21084 });
21085 const getItem = (0, import_react30.useCallback)(
21086 (item) => {
21087 const nextItem = { ...item, value };
21088 if (getItemProp) {
21089 return getItemProp(nextItem);
21090 }
21091 return nextItem;
21092 },
21093 [value, getItemProp]
21094 );
21095 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
21096 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
21097 const onClickProp = props.onClick;
21098 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
21099 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
21100 const resetValueOnSelectProp = useBooleanEvent(
21101 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
21102 );
21103 const hideOnClickProp = useBooleanEvent(hideOnClick);
21104 const onClick = useEvent((event) => {
21105 onClickProp == null ? void 0 : onClickProp(event);
21106 if (event.defaultPrevented) return;
21107 if (isDownloading(event)) return;
21108 if (isOpeningInNewTab(event)) return;
21109 if (value != null) {
21110 if (selectValueOnClickProp(event)) {
21111 if (resetValueOnSelectProp(event)) {
21112 store == null ? void 0 : store.resetValue();
21113 }
21114 store == null ? void 0 : store.setSelectedValue((prevValue) => {
21115 if (!Array.isArray(prevValue)) return value;
21116 if (prevValue.includes(value)) {
21117 return prevValue.filter((v2) => v2 !== value);
21118 }
21119 return [...prevValue, value];
21120 });
21121 }
21122 if (setValueOnClickProp(event)) {
21123 store == null ? void 0 : store.setValue(value);
21124 }
21125 }
21126 if (hideOnClickProp(event)) {
21127 store == null ? void 0 : store.hide();
21128 }
21129 });
21130 const onKeyDownProp = props.onKeyDown;
21131 const onKeyDown = useEvent((event) => {
21132 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
21133 if (event.defaultPrevented) return;
21134 const baseElement = store == null ? void 0 : store.getState().baseElement;
21135 if (!baseElement) return;
21136 if (hasFocus(baseElement)) return;
21137 const printable = event.key.length === 1;
21138 if (printable || event.key === "Backspace" || event.key === "Delete") {
21139 queueMicrotask(() => baseElement.focus());
21140 if (isTextField(baseElement)) {
21141 store == null ? void 0 : store.setValue(baseElement.value);
21142 }
21143 }
21144 });
21145 if (multiSelectable && selected != null) {
21146 props = {
21147 "aria-selected": selected,
21148 ...props
21149 };
21150 }
21151 props = useWrapElement(
21152 props,
21153 (element) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
21154 [value, selected]
21155 );
21156 const popupRole = (0, import_react30.useContext)(ComboboxListRoleContext);
21157 props = {
21158 role: getItemRole(popupRole),
21159 children: value,
21160 ...props,
21161 onClick,
21162 onKeyDown
21163 };
21164 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
21165 props = useCompositeItem({
21166 store,
21167 ...props,
21168 getItem,
21169 // Dispatch a custom event on the combobox input when moving to an item
21170 // with the keyboard so the Combobox component can enable inline
21171 // autocompletion.
21172 moveOnKeyPress: (event) => {
21173 if (!moveOnKeyPressProp(event)) return false;
21174 const moveEvent = new Event("combobox-item-move");
21175 const baseElement = store == null ? void 0 : store.getState().baseElement;
21176 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
21177 return true;
21178 }
21179 });
21180 props = useCompositeHover({ store, focusOnHover, ...props });
21181 return props;
21182 }
21183 );
21184 var ComboboxItem = memo22(
21185 forwardRef210(function ComboboxItem2(props) {
21186 const htmlProps = useComboboxItem(props);
21187 return createElement3(TagName10, htmlProps);
21188 })
21189 );
21190
21191 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
21192 var import_react31 = __toESM(require_react(), 1);
21193 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
21194 var TagName11 = "span";
21195 function normalizeValue(value) {
21196 return normalizeString(value).toLowerCase();
21197 }
21198 function getOffsets(string, values) {
21199 const offsets = [];
21200 for (const value of values) {
21201 let pos = 0;
21202 const length = value.length;
21203 while (string.indexOf(value, pos) !== -1) {
21204 const index2 = string.indexOf(value, pos);
21205 if (index2 !== -1) {
21206 offsets.push([index2, length]);
21207 }
21208 pos = index2 + 1;
21209 }
21210 }
21211 return offsets;
21212 }
21213 function filterOverlappingOffsets(offsets) {
21214 return offsets.filter(([offset4, length], i2, arr) => {
21215 return !arr.some(
21216 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
21217 );
21218 });
21219 }
21220 function sortOffsets(offsets) {
21221 return offsets.sort(([a2], [b2]) => a2 - b2);
21222 }
21223 function splitValue(itemValue, userValue) {
21224 if (!itemValue) return itemValue;
21225 if (!userValue) return itemValue;
21226 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
21227 const parts = [];
21228 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
21229 "span",
21230 {
21231 "data-autocomplete-value": autocomplete ? "" : void 0,
21232 "data-user-value": autocomplete ? void 0 : "",
21233 children: value
21234 },
21235 parts.length
21236 );
21237 const offsets = sortOffsets(
21238 filterOverlappingOffsets(
21239 // Convert userValues into a set to avoid duplicates
21240 getOffsets(normalizeValue(itemValue), new Set(userValues))
21241 )
21242 );
21243 if (!offsets.length) {
21244 parts.push(span(itemValue, true));
21245 return parts;
21246 }
21247 const [firstOffset] = offsets[0];
21248 const values = [
21249 itemValue.slice(0, firstOffset),
21250 ...offsets.flatMap(([offset4, length], i2) => {
21251 var _a;
21252 const value = itemValue.slice(offset4, offset4 + length);
21253 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
21254 const nextValue = itemValue.slice(offset4 + length, nextOffset);
21255 return [value, nextValue];
21256 })
21257 ];
21258 values.forEach((value, i2) => {
21259 if (!value) return;
21260 parts.push(span(value, i2 % 2 === 0));
21261 });
21262 return parts;
21263 }
21264 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
21265 const context = useComboboxScopedContext();
21266 store = store || context;
21267 const itemContext = (0, import_react31.useContext)(ComboboxItemValueContext);
21268 const itemValue = value != null ? value : itemContext;
21269 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
21270 const children = (0, import_react31.useMemo)(() => {
21271 if (!itemValue) return;
21272 if (!inputValue) return itemValue;
21273 return splitValue(itemValue, inputValue);
21274 }, [itemValue, inputValue]);
21275 props = {
21276 children,
21277 ...props
21278 };
21279 return removeUndefinedValues(props);
21280 });
21281 var ComboboxItemValue = forwardRef210(function ComboboxItemValue2(props) {
21282 const htmlProps = useComboboxItemValue(props);
21283 return createElement3(TagName11, htmlProps);
21284 });
21285
21286 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
21287 var TagName12 = "label";
21288 var useComboboxLabel = createHook(
21289 function useComboboxLabel2({ store, ...props }) {
21290 const context = useComboboxProviderContext();
21291 store = store || context;
21292 invariant(
21293 store,
21294 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
21295 );
21296 const comboboxId = store.useState((state) => {
21297 var _a;
21298 return (_a = state.baseElement) == null ? void 0 : _a.id;
21299 });
21300 props = {
21301 htmlFor: comboboxId,
21302 ...props
21303 };
21304 return removeUndefinedValues(props);
21305 }
21306 );
21307 var ComboboxLabel = memo22(
21308 forwardRef210(function ComboboxLabel2(props) {
21309 const htmlProps = useComboboxLabel(props);
21310 return createElement3(TagName12, htmlProps);
21311 })
21312 );
21313
21314 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
21315 var import_react32 = __toESM(require_react(), 1);
21316 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
21317 var TagName13 = "div";
21318 var useComboboxList = createHook(
21319 function useComboboxList2({ store, alwaysVisible, ...props }) {
21320 const scopedContext = useComboboxScopedContext(true);
21321 const context = useComboboxContext();
21322 store = store || context;
21323 const scopedContextSameStore = !!store && store === scopedContext;
21324 invariant(
21325 store,
21326 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
21327 );
21328 const ref = (0, import_react32.useRef)(null);
21329 const id = useId5(props.id);
21330 const mounted = store.useState("mounted");
21331 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
21332 const style = hidden ? { ...props.style, display: "none" } : props.style;
21333 const multiSelectable = store.useState(
21334 (state) => Array.isArray(state.selectedValue)
21335 );
21336 const role = useAttribute(ref, "role", props.role);
21337 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
21338 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
21339 const [hasListboxInside, setHasListboxInside] = (0, import_react32.useState)(false);
21340 const contentElement = store.useState("contentElement");
21341 useSafeLayoutEffect(() => {
21342 if (!mounted) return;
21343 const element = ref.current;
21344 if (!element) return;
21345 if (contentElement !== element) return;
21346 const callback = () => {
21347 setHasListboxInside(!!element.querySelector("[role='listbox']"));
21348 };
21349 const observer = new MutationObserver(callback);
21350 observer.observe(element, {
21351 subtree: true,
21352 childList: true,
21353 attributeFilter: ["role"]
21354 });
21355 callback();
21356 return () => observer.disconnect();
21357 }, [mounted, contentElement]);
21358 if (!hasListboxInside) {
21359 props = {
21360 role: "listbox",
21361 "aria-multiselectable": ariaMultiSelectable,
21362 ...props
21363 };
21364 }
21365 props = useWrapElement(
21366 props,
21367 (element) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
21368 [store, role]
21369 );
21370 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
21371 props = {
21372 id,
21373 hidden,
21374 ...props,
21375 ref: useMergeRefs(setContentElement, ref, props.ref),
21376 style
21377 };
21378 return removeUndefinedValues(props);
21379 }
21380 );
21381 var ComboboxList = forwardRef210(function ComboboxList2(props) {
21382 const htmlProps = useComboboxList(props);
21383 return createElement3(TagName13, htmlProps);
21384 });
21385
21386 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
21387 var import_react33 = __toESM(require_react(), 1);
21388 var TagValueContext = (0, import_react33.createContext)(null);
21389 var TagRemoveIdContext = (0, import_react33.createContext)(
21390 null
21391 );
21392 var ctx7 = createStoreContext(
21393 [CompositeContextProvider],
21394 [CompositeScopedContextProvider]
21395 );
21396 var useTagContext = ctx7.useContext;
21397 var useTagScopedContext = ctx7.useScopedContext;
21398 var useTagProviderContext = ctx7.useProviderContext;
21399 var TagContextProvider = ctx7.ContextProvider;
21400 var TagScopedContextProvider = ctx7.ScopedContextProvider;
21401
21402 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
21403 var isTouchSafari = isSafari2() && isTouchDevice();
21404 function createComboboxStore({
21405 tag,
21406 ...props
21407 } = {}) {
21408 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
21409 throwOnConflictingProps(props, store);
21410 const tagState = tag == null ? void 0 : tag.getState();
21411 const syncState = store == null ? void 0 : store.getState();
21412 const activeId = defaultValue(
21413 props.activeId,
21414 syncState == null ? void 0 : syncState.activeId,
21415 props.defaultActiveId,
21416 null
21417 );
21418 const composite = createCompositeStore({
21419 ...props,
21420 activeId,
21421 includesBaseElement: defaultValue(
21422 props.includesBaseElement,
21423 syncState == null ? void 0 : syncState.includesBaseElement,
21424 true
21425 ),
21426 orientation: defaultValue(
21427 props.orientation,
21428 syncState == null ? void 0 : syncState.orientation,
21429 "vertical"
21430 ),
21431 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
21432 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
21433 virtualFocus: defaultValue(
21434 props.virtualFocus,
21435 syncState == null ? void 0 : syncState.virtualFocus,
21436 true
21437 )
21438 });
21439 const popover = createPopoverStore({
21440 ...props,
21441 placement: defaultValue(
21442 props.placement,
21443 syncState == null ? void 0 : syncState.placement,
21444 "bottom-start"
21445 )
21446 });
21447 const value = defaultValue(
21448 props.value,
21449 syncState == null ? void 0 : syncState.value,
21450 props.defaultValue,
21451 ""
21452 );
21453 const selectedValue = defaultValue(
21454 props.selectedValue,
21455 syncState == null ? void 0 : syncState.selectedValue,
21456 tagState == null ? void 0 : tagState.values,
21457 props.defaultSelectedValue,
21458 ""
21459 );
21460 const multiSelectable = Array.isArray(selectedValue);
21461 const initialState = {
21462 ...composite.getState(),
21463 ...popover.getState(),
21464 value,
21465 selectedValue,
21466 resetValueOnSelect: defaultValue(
21467 props.resetValueOnSelect,
21468 syncState == null ? void 0 : syncState.resetValueOnSelect,
21469 multiSelectable
21470 ),
21471 resetValueOnHide: defaultValue(
21472 props.resetValueOnHide,
21473 syncState == null ? void 0 : syncState.resetValueOnHide,
21474 multiSelectable && !tag
21475 ),
21476 activeValue: syncState == null ? void 0 : syncState.activeValue
21477 };
21478 const combobox = createStore(initialState, composite, popover, store);
21479 if (isTouchSafari) {
21480 setup(
21481 combobox,
21482 () => sync(combobox, ["virtualFocus"], () => {
21483 combobox.setState("virtualFocus", false);
21484 })
21485 );
21486 }
21487 setup(combobox, () => {
21488 if (!tag) return;
21489 return chain(
21490 sync(combobox, ["selectedValue"], (state) => {
21491 if (!Array.isArray(state.selectedValue)) return;
21492 tag.setValues(state.selectedValue);
21493 }),
21494 sync(tag, ["values"], (state) => {
21495 combobox.setState("selectedValue", state.values);
21496 })
21497 );
21498 });
21499 setup(
21500 combobox,
21501 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
21502 if (!state.resetValueOnHide) return;
21503 if (state.mounted) return;
21504 combobox.setState("value", value);
21505 })
21506 );
21507 setup(
21508 combobox,
21509 () => sync(combobox, ["open"], (state) => {
21510 if (state.open) return;
21511 combobox.setState("activeId", activeId);
21512 combobox.setState("moves", 0);
21513 })
21514 );
21515 setup(
21516 combobox,
21517 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
21518 if (state.moves === prevState.moves) {
21519 combobox.setState("activeValue", void 0);
21520 }
21521 })
21522 );
21523 setup(
21524 combobox,
21525 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
21526 if (state.moves === prev.moves) return;
21527 const { activeId: activeId2 } = combobox.getState();
21528 const activeItem = composite.item(activeId2);
21529 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
21530 })
21531 );
21532 return {
21533 ...popover,
21534 ...composite,
21535 ...combobox,
21536 tag,
21537 setValue: (value2) => combobox.setState("value", value2),
21538 resetValue: () => combobox.setState("value", initialState.value),
21539 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
21540 };
21541 }
21542
21543 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
21544 function useComboboxStoreOptions(props) {
21545 const tag = useTagContext();
21546 props = {
21547 ...props,
21548 tag: props.tag !== void 0 ? props.tag : tag
21549 };
21550 return useCompositeStoreOptions(props);
21551 }
21552 function useComboboxStoreProps(store, update2, props) {
21553 useUpdateEffect(update2, [props.tag]);
21554 useStoreProps(store, props, "value", "setValue");
21555 useStoreProps(store, props, "selectedValue", "setSelectedValue");
21556 useStoreProps(store, props, "resetValueOnHide");
21557 useStoreProps(store, props, "resetValueOnSelect");
21558 return Object.assign(
21559 useCompositeStoreProps(
21560 usePopoverStoreProps(store, update2, props),
21561 update2,
21562 props
21563 ),
21564 { tag: props.tag }
21565 );
21566 }
21567 function useComboboxStore(props = {}) {
21568 props = useComboboxStoreOptions(props);
21569 const [store, update2] = useStore2(createComboboxStore, props);
21570 return useComboboxStoreProps(store, update2, props);
21571 }
21572
21573 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
21574 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
21575 function ComboboxProvider(props = {}) {
21576 const store = useComboboxStore(props);
21577 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(ComboboxContextProvider, { value: store, children: props.children });
21578 }
21579
21580 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
21581 var import_remove_accents = __toESM(require_remove_accents(), 1);
21582 var import_compose8 = __toESM(require_compose(), 1);
21583 var import_i18n25 = __toESM(require_i18n(), 1);
21584 var import_element67 = __toESM(require_element(), 1);
21585 var import_components19 = __toESM(require_components(), 1);
21586
21587 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
21588 var EMPTY_ARRAY3 = [];
21589 var getCurrentValue = (filterDefinition, currentFilter) => {
21590 if (filterDefinition.singleSelection) {
21591 return currentFilter?.value;
21592 }
21593 if (Array.isArray(currentFilter?.value)) {
21594 return currentFilter.value;
21595 }
21596 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
21597 return [currentFilter.value];
21598 }
21599 return EMPTY_ARRAY3;
21600 };
21601
21602 // packages/dataviews/build-module/hooks/use-elements.mjs
21603 var import_element66 = __toESM(require_element(), 1);
21604 var EMPTY_ARRAY4 = [];
21605 function useElements({
21606 elements,
21607 getElements
21608 }) {
21609 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
21610 const [records, setRecords] = (0, import_element66.useState)(staticElements);
21611 const [isLoading, setIsLoading] = (0, import_element66.useState)(false);
21612 (0, import_element66.useEffect)(() => {
21613 if (!getElements) {
21614 setRecords(staticElements);
21615 return;
21616 }
21617 let cancelled = false;
21618 setIsLoading(true);
21619 getElements().then((fetchedElements) => {
21620 if (!cancelled) {
21621 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
21622 setRecords(dynamicElements);
21623 }
21624 }).catch(() => {
21625 if (!cancelled) {
21626 setRecords(staticElements);
21627 }
21628 }).finally(() => {
21629 if (!cancelled) {
21630 setIsLoading(false);
21631 }
21632 });
21633 return () => {
21634 cancelled = true;
21635 };
21636 }, [getElements, staticElements]);
21637 return {
21638 elements: records,
21639 isLoading
21640 };
21641 }
21642
21643 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
21644 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
21645 function normalizeSearchInput(input = "") {
21646 return (0, import_remove_accents.default)(input.trim().toLowerCase());
21647 }
21648 var getNewValue = (filterDefinition, currentFilter, value) => {
21649 if (filterDefinition.singleSelection) {
21650 return value;
21651 }
21652 if (Array.isArray(currentFilter?.value)) {
21653 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
21654 }
21655 return [value];
21656 };
21657 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
21658 return `${prefix}-${filterElementValue}`;
21659 }
21660 var MultiSelectionOption = ({ selected }) => {
21661 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21662 "span",
21663 {
21664 className: clsx_default(
21665 "dataviews-filters__search-widget-listitem-multi-selection",
21666 { "is-selected": selected }
21667 ),
21668 children: selected && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Icon, { icon: check_default })
21669 }
21670 );
21671 };
21672 var SingleSelectionOption = ({ selected }) => {
21673 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21674 "span",
21675 {
21676 className: clsx_default(
21677 "dataviews-filters__search-widget-listitem-single-selection",
21678 { "is-selected": selected }
21679 )
21680 }
21681 );
21682 };
21683 function ListBox({ view, filter, onChangeView }) {
21684 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
21685 const [activeCompositeId, setActiveCompositeId] = (0, import_element67.useState)(
21686 // When there are one or less operators, the first item is set as active
21687 // (by setting the initial `activeId` to `undefined`).
21688 // With 2 or more operators, the focus is moved on the operators control
21689 // (by setting the initial `activeId` to `null`), meaning that there won't
21690 // be an active item initially. Focus is then managed via the
21691 // `onFocusVisible` callback.
21692 filter.operators?.length === 1 ? void 0 : null
21693 );
21694 const currentFilter = view.filters?.find(
21695 (f2) => f2.field === filter.field
21696 );
21697 const currentValue = getCurrentValue(filter, currentFilter);
21698 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21699 import_components19.Composite,
21700 {
21701 virtualFocus: true,
21702 focusLoop: true,
21703 activeId: activeCompositeId,
21704 setActiveId: setActiveCompositeId,
21705 role: "listbox",
21706 className: "dataviews-filters__search-widget-listbox",
21707 "aria-label": (0, import_i18n25.sprintf)(
21708 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
21709 (0, import_i18n25.__)("List of: %1$s"),
21710 filter.name
21711 ),
21712 onFocusVisible: () => {
21713 if (!activeCompositeId && filter.elements.length) {
21714 setActiveCompositeId(
21715 generateFilterElementCompositeItemId(
21716 baseId,
21717 filter.elements[0].value
21718 )
21719 );
21720 }
21721 },
21722 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Composite.Typeahead, {}),
21723 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21724 import_components19.Composite.Hover,
21725 {
21726 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21727 import_components19.Composite.Item,
21728 {
21729 id: generateFilterElementCompositeItemId(
21730 baseId,
21731 element.value
21732 ),
21733 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21734 "div",
21735 {
21736 "aria-label": element.label,
21737 role: "option",
21738 className: "dataviews-filters__search-widget-listitem"
21739 }
21740 ),
21741 onClick: () => {
21742 const newFilters = currentFilter ? [
21743 ...(view.filters ?? []).map(
21744 (_filter) => {
21745 if (_filter.field === filter.field) {
21746 return {
21747 ..._filter,
21748 operator: currentFilter.operator || filter.operators[0],
21749 value: getNewValue(
21750 filter,
21751 currentFilter,
21752 element.value
21753 )
21754 };
21755 }
21756 return _filter;
21757 }
21758 )
21759 ] : [
21760 ...view.filters ?? [],
21761 {
21762 field: filter.field,
21763 operator: filter.operators[0],
21764 value: getNewValue(
21765 filter,
21766 currentFilter,
21767 element.value
21768 )
21769 }
21770 ];
21771 onChangeView({
21772 ...view,
21773 page: 1,
21774 filters: newFilters
21775 });
21776 }
21777 }
21778 ),
21779 children: [
21780 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21781 SingleSelectionOption,
21782 {
21783 selected: currentValue === element.value
21784 }
21785 ),
21786 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21787 MultiSelectionOption,
21788 {
21789 selected: currentValue.includes(element.value)
21790 }
21791 ),
21792 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21793 "span",
21794 {
21795 className: "dataviews-filters__search-widget-listitem-value",
21796 title: element.label,
21797 children: element.label
21798 }
21799 )
21800 ]
21801 },
21802 element.value
21803 ))
21804 }
21805 );
21806 }
21807 function ComboboxList22({ view, filter, onChangeView }) {
21808 const [searchValue, setSearchValue] = (0, import_element67.useState)("");
21809 const deferredSearchValue = (0, import_element67.useDeferredValue)(searchValue);
21810 const currentFilter = view.filters?.find(
21811 (_filter) => _filter.field === filter.field
21812 );
21813 const currentValue = getCurrentValue(filter, currentFilter);
21814 const matches = (0, import_element67.useMemo)(() => {
21815 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
21816 return filter.elements.filter(
21817 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
21818 );
21819 }, [filter.elements, deferredSearchValue]);
21820 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21821 ComboboxProvider,
21822 {
21823 selectedValue: currentValue,
21824 setSelectedValue: (value) => {
21825 const newFilters = currentFilter ? [
21826 ...(view.filters ?? []).map((_filter) => {
21827 if (_filter.field === filter.field) {
21828 return {
21829 ..._filter,
21830 operator: currentFilter.operator || filter.operators[0],
21831 value
21832 };
21833 }
21834 return _filter;
21835 })
21836 ] : [
21837 ...view.filters ?? [],
21838 {
21839 field: filter.field,
21840 operator: filter.operators[0],
21841 value
21842 }
21843 ];
21844 onChangeView({
21845 ...view,
21846 page: 1,
21847 filters: newFilters
21848 });
21849 },
21850 setValue: setSearchValue,
21851 children: [
21852 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
21853 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ComboboxLabel, {}), children: (0, import_i18n25.__)("Search items") }),
21854 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21855 Combobox,
21856 {
21857 autoSelect: "always",
21858 placeholder: (0, import_i18n25.__)("Search"),
21859 className: "dataviews-filters__search-widget-filter-combobox__input"
21860 }
21861 ),
21862 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Icon, { icon: search_default }) })
21863 ] }),
21864 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21865 ComboboxList,
21866 {
21867 className: "dataviews-filters__search-widget-filter-combobox-list",
21868 alwaysVisible: true,
21869 children: [
21870 matches.map((element) => {
21871 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21872 ComboboxItem,
21873 {
21874 resetValueOnSelect: false,
21875 value: element.value,
21876 className: "dataviews-filters__search-widget-listitem",
21877 hideOnClick: false,
21878 setValueOnClick: false,
21879 focusOnHover: true,
21880 children: [
21881 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21882 SingleSelectionOption,
21883 {
21884 selected: currentValue === element.value
21885 }
21886 ),
21887 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21888 MultiSelectionOption,
21889 {
21890 selected: currentValue.includes(
21891 element.value
21892 )
21893 }
21894 ),
21895 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21896 "span",
21897 {
21898 className: "dataviews-filters__search-widget-listitem-value",
21899 title: element.label,
21900 children: [
21901 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21902 ComboboxItemValue,
21903 {
21904 className: "dataviews-filters__search-widget-filter-combobox-item-value",
21905 value: element.label
21906 }
21907 ),
21908 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
21909 ]
21910 }
21911 )
21912 ]
21913 },
21914 element.value
21915 );
21916 }),
21917 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("p", { children: (0, import_i18n25.__)("No results found") })
21918 ]
21919 }
21920 )
21921 ]
21922 }
21923 );
21924 }
21925 function SearchWidget(props) {
21926 const { elements, isLoading } = useElements({
21927 elements: props.filter.elements,
21928 getElements: props.filter.getElements
21929 });
21930 if (isLoading) {
21931 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Spinner, {}) });
21932 }
21933 if (elements.length === 0) {
21934 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n25.__)("No elements found") });
21935 }
21936 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
21937 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
21938 }
21939
21940 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
21941 var import_es6 = __toESM(require_es6(), 1);
21942 var import_compose9 = __toESM(require_compose(), 1);
21943 var import_element68 = __toESM(require_element(), 1);
21944 var import_components20 = __toESM(require_components(), 1);
21945 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
21946 function InputWidget({
21947 filter,
21948 view,
21949 onChangeView,
21950 fields
21951 }) {
21952 const currentFilter = view.filters?.find(
21953 (f2) => f2.field === filter.field
21954 );
21955 const currentValue = getCurrentValue(filter, currentFilter);
21956 const field = (0, import_element68.useMemo)(() => {
21957 const currentField = fields.find((f2) => f2.id === filter.field);
21958 if (currentField) {
21959 return {
21960 ...currentField,
21961 // Deactivate validation for filters.
21962 isValid: {},
21963 // Filter controls are always enabled.
21964 isDisabled: () => false,
21965 // Filter controls are always visible.
21966 isVisible: () => true,
21967 // Configure getValue/setValue as if Item was a plain object.
21968 getValue: ({ item }) => item[currentField.id],
21969 setValue: ({ value }) => ({
21970 [currentField.id]: value
21971 })
21972 };
21973 }
21974 return currentField;
21975 }, [fields, filter.field]);
21976 const data = (0, import_element68.useMemo)(() => {
21977 return (view.filters ?? []).reduce(
21978 (acc, activeFilter) => {
21979 acc[activeFilter.field] = activeFilter.value;
21980 return acc;
21981 },
21982 {}
21983 );
21984 }, [view.filters]);
21985 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
21986 if (!field || !currentFilter) {
21987 return;
21988 }
21989 const nextValue = field.getValue({ item: updatedData });
21990 if ((0, import_es6.default)(nextValue, currentValue)) {
21991 return;
21992 }
21993 onChangeView({
21994 ...view,
21995 filters: (view.filters ?? []).map(
21996 (_filter) => _filter.field === filter.field ? {
21997 ..._filter,
21998 operator: currentFilter.operator || filter.operators[0],
21999 // Consider empty strings as undefined:
22000 //
22001 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
22002 // - empty string as value means "search empty string": returns only the records that have an empty string as value
22003 //
22004 // In practice, this means the filter will not be able to find an empty string as the value.
22005 value: nextValue === "" ? void 0 : nextValue
22006 } : _filter
22007 )
22008 });
22009 });
22010 if (!field || !field.Edit || !currentFilter) {
22011 return null;
22012 }
22013 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
22014 import_components20.Flex,
22015 {
22016 className: "dataviews-filters__user-input-widget",
22017 gap: 2.5,
22018 direction: "column",
22019 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
22020 field.Edit,
22021 {
22022 hideLabelFromVision: true,
22023 data,
22024 field,
22025 operator: currentFilter.operator,
22026 onChange: handleChange
22027 }
22028 )
22029 }
22030 );
22031 }
22032
22033 // node_modules/date-fns/constants.js
22034 var daysInYear = 365.2425;
22035 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
22036 var minTime = -maxTime;
22037 var millisecondsInWeek = 6048e5;
22038 var millisecondsInDay = 864e5;
22039 var secondsInHour = 3600;
22040 var secondsInDay = secondsInHour * 24;
22041 var secondsInWeek = secondsInDay * 7;
22042 var secondsInYear = secondsInDay * daysInYear;
22043 var secondsInMonth = secondsInYear / 12;
22044 var secondsInQuarter = secondsInMonth * 3;
22045 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
22046
22047 // node_modules/date-fns/constructFrom.js
22048 function constructFrom(date, value) {
22049 if (typeof date === "function") return date(value);
22050 if (date && typeof date === "object" && constructFromSymbol in date)
22051 return date[constructFromSymbol](value);
22052 if (date instanceof Date) return new date.constructor(value);
22053 return new Date(value);
22054 }
22055
22056 // node_modules/date-fns/toDate.js
22057 function toDate(argument, context) {
22058 return constructFrom(context || argument, argument);
22059 }
22060
22061 // node_modules/date-fns/addDays.js
22062 function addDays(date, amount, options) {
22063 const _date = toDate(date, options?.in);
22064 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
22065 if (!amount) return _date;
22066 _date.setDate(_date.getDate() + amount);
22067 return _date;
22068 }
22069
22070 // node_modules/date-fns/addMonths.js
22071 function addMonths(date, amount, options) {
22072 const _date = toDate(date, options?.in);
22073 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
22074 if (!amount) {
22075 return _date;
22076 }
22077 const dayOfMonth = _date.getDate();
22078 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
22079 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
22080 const daysInMonth = endOfDesiredMonth.getDate();
22081 if (dayOfMonth >= daysInMonth) {
22082 return endOfDesiredMonth;
22083 } else {
22084 _date.setFullYear(
22085 endOfDesiredMonth.getFullYear(),
22086 endOfDesiredMonth.getMonth(),
22087 dayOfMonth
22088 );
22089 return _date;
22090 }
22091 }
22092
22093 // node_modules/date-fns/_lib/defaultOptions.js
22094 var defaultOptions = {};
22095 function getDefaultOptions() {
22096 return defaultOptions;
22097 }
22098
22099 // node_modules/date-fns/startOfWeek.js
22100 function startOfWeek(date, options) {
22101 const defaultOptions2 = getDefaultOptions();
22102 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
22103 const _date = toDate(date, options?.in);
22104 const day = _date.getDay();
22105 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
22106 _date.setDate(_date.getDate() - diff);
22107 _date.setHours(0, 0, 0, 0);
22108 return _date;
22109 }
22110
22111 // node_modules/date-fns/startOfISOWeek.js
22112 function startOfISOWeek(date, options) {
22113 return startOfWeek(date, { ...options, weekStartsOn: 1 });
22114 }
22115
22116 // node_modules/date-fns/getISOWeekYear.js
22117 function getISOWeekYear(date, options) {
22118 const _date = toDate(date, options?.in);
22119 const year = _date.getFullYear();
22120 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
22121 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
22122 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
22123 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
22124 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
22125 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
22126 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
22127 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
22128 if (_date.getTime() >= startOfNextYear.getTime()) {
22129 return year + 1;
22130 } else if (_date.getTime() >= startOfThisYear.getTime()) {
22131 return year;
22132 } else {
22133 return year - 1;
22134 }
22135 }
22136
22137 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
22138 function getTimezoneOffsetInMilliseconds(date) {
22139 const _date = toDate(date);
22140 const utcDate = new Date(
22141 Date.UTC(
22142 _date.getFullYear(),
22143 _date.getMonth(),
22144 _date.getDate(),
22145 _date.getHours(),
22146 _date.getMinutes(),
22147 _date.getSeconds(),
22148 _date.getMilliseconds()
22149 )
22150 );
22151 utcDate.setUTCFullYear(_date.getFullYear());
22152 return +date - +utcDate;
22153 }
22154
22155 // node_modules/date-fns/_lib/normalizeDates.js
22156 function normalizeDates(context, ...dates) {
22157 const normalize = constructFrom.bind(
22158 null,
22159 context || dates.find((date) => typeof date === "object")
22160 );
22161 return dates.map(normalize);
22162 }
22163
22164 // node_modules/date-fns/startOfDay.js
22165 function startOfDay(date, options) {
22166 const _date = toDate(date, options?.in);
22167 _date.setHours(0, 0, 0, 0);
22168 return _date;
22169 }
22170
22171 // node_modules/date-fns/differenceInCalendarDays.js
22172 function differenceInCalendarDays(laterDate, earlierDate, options) {
22173 const [laterDate_, earlierDate_] = normalizeDates(
22174 options?.in,
22175 laterDate,
22176 earlierDate
22177 );
22178 const laterStartOfDay = startOfDay(laterDate_);
22179 const earlierStartOfDay = startOfDay(earlierDate_);
22180 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
22181 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
22182 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
22183 }
22184
22185 // node_modules/date-fns/startOfISOWeekYear.js
22186 function startOfISOWeekYear(date, options) {
22187 const year = getISOWeekYear(date, options);
22188 const fourthOfJanuary = constructFrom(options?.in || date, 0);
22189 fourthOfJanuary.setFullYear(year, 0, 4);
22190 fourthOfJanuary.setHours(0, 0, 0, 0);
22191 return startOfISOWeek(fourthOfJanuary);
22192 }
22193
22194 // node_modules/date-fns/addWeeks.js
22195 function addWeeks(date, amount, options) {
22196 return addDays(date, amount * 7, options);
22197 }
22198
22199 // node_modules/date-fns/addYears.js
22200 function addYears(date, amount, options) {
22201 return addMonths(date, amount * 12, options);
22202 }
22203
22204 // node_modules/date-fns/isDate.js
22205 function isDate(value) {
22206 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
22207 }
22208
22209 // node_modules/date-fns/isValid.js
22210 function isValid(date) {
22211 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
22212 }
22213
22214 // node_modules/date-fns/startOfMonth.js
22215 function startOfMonth(date, options) {
22216 const _date = toDate(date, options?.in);
22217 _date.setDate(1);
22218 _date.setHours(0, 0, 0, 0);
22219 return _date;
22220 }
22221
22222 // node_modules/date-fns/startOfYear.js
22223 function startOfYear(date, options) {
22224 const date_ = toDate(date, options?.in);
22225 date_.setFullYear(date_.getFullYear(), 0, 1);
22226 date_.setHours(0, 0, 0, 0);
22227 return date_;
22228 }
22229
22230 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
22231 var formatDistanceLocale = {
22232 lessThanXSeconds: {
22233 one: "less than a second",
22234 other: "less than {{count}} seconds"
22235 },
22236 xSeconds: {
22237 one: "1 second",
22238 other: "{{count}} seconds"
22239 },
22240 halfAMinute: "half a minute",
22241 lessThanXMinutes: {
22242 one: "less than a minute",
22243 other: "less than {{count}} minutes"
22244 },
22245 xMinutes: {
22246 one: "1 minute",
22247 other: "{{count}} minutes"
22248 },
22249 aboutXHours: {
22250 one: "about 1 hour",
22251 other: "about {{count}} hours"
22252 },
22253 xHours: {
22254 one: "1 hour",
22255 other: "{{count}} hours"
22256 },
22257 xDays: {
22258 one: "1 day",
22259 other: "{{count}} days"
22260 },
22261 aboutXWeeks: {
22262 one: "about 1 week",
22263 other: "about {{count}} weeks"
22264 },
22265 xWeeks: {
22266 one: "1 week",
22267 other: "{{count}} weeks"
22268 },
22269 aboutXMonths: {
22270 one: "about 1 month",
22271 other: "about {{count}} months"
22272 },
22273 xMonths: {
22274 one: "1 month",
22275 other: "{{count}} months"
22276 },
22277 aboutXYears: {
22278 one: "about 1 year",
22279 other: "about {{count}} years"
22280 },
22281 xYears: {
22282 one: "1 year",
22283 other: "{{count}} years"
22284 },
22285 overXYears: {
22286 one: "over 1 year",
22287 other: "over {{count}} years"
22288 },
22289 almostXYears: {
22290 one: "almost 1 year",
22291 other: "almost {{count}} years"
22292 }
22293 };
22294 var formatDistance = (token, count, options) => {
22295 let result;
22296 const tokenValue = formatDistanceLocale[token];
22297 if (typeof tokenValue === "string") {
22298 result = tokenValue;
22299 } else if (count === 1) {
22300 result = tokenValue.one;
22301 } else {
22302 result = tokenValue.other.replace("{{count}}", count.toString());
22303 }
22304 if (options?.addSuffix) {
22305 if (options.comparison && options.comparison > 0) {
22306 return "in " + result;
22307 } else {
22308 return result + " ago";
22309 }
22310 }
22311 return result;
22312 };
22313
22314 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
22315 function buildFormatLongFn(args) {
22316 return (options = {}) => {
22317 const width = options.width ? String(options.width) : args.defaultWidth;
22318 const format6 = args.formats[width] || args.formats[args.defaultWidth];
22319 return format6;
22320 };
22321 }
22322
22323 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
22324 var dateFormats = {
22325 full: "EEEE, MMMM do, y",
22326 long: "MMMM do, y",
22327 medium: "MMM d, y",
22328 short: "MM/dd/yyyy"
22329 };
22330 var timeFormats = {
22331 full: "h:mm:ss a zzzz",
22332 long: "h:mm:ss a z",
22333 medium: "h:mm:ss a",
22334 short: "h:mm a"
22335 };
22336 var dateTimeFormats = {
22337 full: "{{date}} 'at' {{time}}",
22338 long: "{{date}} 'at' {{time}}",
22339 medium: "{{date}}, {{time}}",
22340 short: "{{date}}, {{time}}"
22341 };
22342 var formatLong = {
22343 date: buildFormatLongFn({
22344 formats: dateFormats,
22345 defaultWidth: "full"
22346 }),
22347 time: buildFormatLongFn({
22348 formats: timeFormats,
22349 defaultWidth: "full"
22350 }),
22351 dateTime: buildFormatLongFn({
22352 formats: dateTimeFormats,
22353 defaultWidth: "full"
22354 })
22355 };
22356
22357 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
22358 var formatRelativeLocale = {
22359 lastWeek: "'last' eeee 'at' p",
22360 yesterday: "'yesterday at' p",
22361 today: "'today at' p",
22362 tomorrow: "'tomorrow at' p",
22363 nextWeek: "eeee 'at' p",
22364 other: "P"
22365 };
22366 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
22367
22368 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
22369 function buildLocalizeFn(args) {
22370 return (value, options) => {
22371 const context = options?.context ? String(options.context) : "standalone";
22372 let valuesArray;
22373 if (context === "formatting" && args.formattingValues) {
22374 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
22375 const width = options?.width ? String(options.width) : defaultWidth;
22376 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
22377 } else {
22378 const defaultWidth = args.defaultWidth;
22379 const width = options?.width ? String(options.width) : args.defaultWidth;
22380 valuesArray = args.values[width] || args.values[defaultWidth];
22381 }
22382 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
22383 return valuesArray[index2];
22384 };
22385 }
22386
22387 // node_modules/date-fns/locale/en-US/_lib/localize.js
22388 var eraValues = {
22389 narrow: ["B", "A"],
22390 abbreviated: ["BC", "AD"],
22391 wide: ["Before Christ", "Anno Domini"]
22392 };
22393 var quarterValues = {
22394 narrow: ["1", "2", "3", "4"],
22395 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
22396 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
22397 };
22398 var monthValues = {
22399 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
22400 abbreviated: [
22401 "Jan",
22402 "Feb",
22403 "Mar",
22404 "Apr",
22405 "May",
22406 "Jun",
22407 "Jul",
22408 "Aug",
22409 "Sep",
22410 "Oct",
22411 "Nov",
22412 "Dec"
22413 ],
22414 wide: [
22415 "January",
22416 "February",
22417 "March",
22418 "April",
22419 "May",
22420 "June",
22421 "July",
22422 "August",
22423 "September",
22424 "October",
22425 "November",
22426 "December"
22427 ]
22428 };
22429 var dayValues = {
22430 narrow: ["S", "M", "T", "W", "T", "F", "S"],
22431 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
22432 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
22433 wide: [
22434 "Sunday",
22435 "Monday",
22436 "Tuesday",
22437 "Wednesday",
22438 "Thursday",
22439 "Friday",
22440 "Saturday"
22441 ]
22442 };
22443 var dayPeriodValues = {
22444 narrow: {
22445 am: "a",
22446 pm: "p",
22447 midnight: "mi",
22448 noon: "n",
22449 morning: "morning",
22450 afternoon: "afternoon",
22451 evening: "evening",
22452 night: "night"
22453 },
22454 abbreviated: {
22455 am: "AM",
22456 pm: "PM",
22457 midnight: "midnight",
22458 noon: "noon",
22459 morning: "morning",
22460 afternoon: "afternoon",
22461 evening: "evening",
22462 night: "night"
22463 },
22464 wide: {
22465 am: "a.m.",
22466 pm: "p.m.",
22467 midnight: "midnight",
22468 noon: "noon",
22469 morning: "morning",
22470 afternoon: "afternoon",
22471 evening: "evening",
22472 night: "night"
22473 }
22474 };
22475 var formattingDayPeriodValues = {
22476 narrow: {
22477 am: "a",
22478 pm: "p",
22479 midnight: "mi",
22480 noon: "n",
22481 morning: "in the morning",
22482 afternoon: "in the afternoon",
22483 evening: "in the evening",
22484 night: "at night"
22485 },
22486 abbreviated: {
22487 am: "AM",
22488 pm: "PM",
22489 midnight: "midnight",
22490 noon: "noon",
22491 morning: "in the morning",
22492 afternoon: "in the afternoon",
22493 evening: "in the evening",
22494 night: "at night"
22495 },
22496 wide: {
22497 am: "a.m.",
22498 pm: "p.m.",
22499 midnight: "midnight",
22500 noon: "noon",
22501 morning: "in the morning",
22502 afternoon: "in the afternoon",
22503 evening: "in the evening",
22504 night: "at night"
22505 }
22506 };
22507 var ordinalNumber = (dirtyNumber, _options) => {
22508 const number = Number(dirtyNumber);
22509 const rem100 = number % 100;
22510 if (rem100 > 20 || rem100 < 10) {
22511 switch (rem100 % 10) {
22512 case 1:
22513 return number + "st";
22514 case 2:
22515 return number + "nd";
22516 case 3:
22517 return number + "rd";
22518 }
22519 }
22520 return number + "th";
22521 };
22522 var localize = {
22523 ordinalNumber,
22524 era: buildLocalizeFn({
22525 values: eraValues,
22526 defaultWidth: "wide"
22527 }),
22528 quarter: buildLocalizeFn({
22529 values: quarterValues,
22530 defaultWidth: "wide",
22531 argumentCallback: (quarter) => quarter - 1
22532 }),
22533 month: buildLocalizeFn({
22534 values: monthValues,
22535 defaultWidth: "wide"
22536 }),
22537 day: buildLocalizeFn({
22538 values: dayValues,
22539 defaultWidth: "wide"
22540 }),
22541 dayPeriod: buildLocalizeFn({
22542 values: dayPeriodValues,
22543 defaultWidth: "wide",
22544 formattingValues: formattingDayPeriodValues,
22545 defaultFormattingWidth: "wide"
22546 })
22547 };
22548
22549 // node_modules/date-fns/locale/_lib/buildMatchFn.js
22550 function buildMatchFn(args) {
22551 return (string, options = {}) => {
22552 const width = options.width;
22553 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
22554 const matchResult = string.match(matchPattern);
22555 if (!matchResult) {
22556 return null;
22557 }
22558 const matchedString = matchResult[0];
22559 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
22560 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
22561 // [TODO] -- I challenge you to fix the type
22562 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
22563 );
22564 let value;
22565 value = args.valueCallback ? args.valueCallback(key) : key;
22566 value = options.valueCallback ? (
22567 // [TODO] -- I challenge you to fix the type
22568 options.valueCallback(value)
22569 ) : value;
22570 const rest = string.slice(matchedString.length);
22571 return { value, rest };
22572 };
22573 }
22574 function findKey(object, predicate) {
22575 for (const key in object) {
22576 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
22577 return key;
22578 }
22579 }
22580 return void 0;
22581 }
22582 function findIndex(array, predicate) {
22583 for (let key = 0; key < array.length; key++) {
22584 if (predicate(array[key])) {
22585 return key;
22586 }
22587 }
22588 return void 0;
22589 }
22590
22591 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
22592 function buildMatchPatternFn(args) {
22593 return (string, options = {}) => {
22594 const matchResult = string.match(args.matchPattern);
22595 if (!matchResult) return null;
22596 const matchedString = matchResult[0];
22597 const parseResult = string.match(args.parsePattern);
22598 if (!parseResult) return null;
22599 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
22600 value = options.valueCallback ? options.valueCallback(value) : value;
22601 const rest = string.slice(matchedString.length);
22602 return { value, rest };
22603 };
22604 }
22605
22606 // node_modules/date-fns/locale/en-US/_lib/match.js
22607 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
22608 var parseOrdinalNumberPattern = /\d+/i;
22609 var matchEraPatterns = {
22610 narrow: /^(b|a)/i,
22611 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
22612 wide: /^(before christ|before common era|anno domini|common era)/i
22613 };
22614 var parseEraPatterns = {
22615 any: [/^b/i, /^(a|c)/i]
22616 };
22617 var matchQuarterPatterns = {
22618 narrow: /^[1234]/i,
22619 abbreviated: /^q[1234]/i,
22620 wide: /^[1234](th|st|nd|rd)? quarter/i
22621 };
22622 var parseQuarterPatterns = {
22623 any: [/1/i, /2/i, /3/i, /4/i]
22624 };
22625 var matchMonthPatterns = {
22626 narrow: /^[jfmasond]/i,
22627 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
22628 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
22629 };
22630 var parseMonthPatterns = {
22631 narrow: [
22632 /^j/i,
22633 /^f/i,
22634 /^m/i,
22635 /^a/i,
22636 /^m/i,
22637 /^j/i,
22638 /^j/i,
22639 /^a/i,
22640 /^s/i,
22641 /^o/i,
22642 /^n/i,
22643 /^d/i
22644 ],
22645 any: [
22646 /^ja/i,
22647 /^f/i,
22648 /^mar/i,
22649 /^ap/i,
22650 /^may/i,
22651 /^jun/i,
22652 /^jul/i,
22653 /^au/i,
22654 /^s/i,
22655 /^o/i,
22656 /^n/i,
22657 /^d/i
22658 ]
22659 };
22660 var matchDayPatterns = {
22661 narrow: /^[smtwf]/i,
22662 short: /^(su|mo|tu|we|th|fr|sa)/i,
22663 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
22664 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
22665 };
22666 var parseDayPatterns = {
22667 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
22668 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
22669 };
22670 var matchDayPeriodPatterns = {
22671 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
22672 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
22673 };
22674 var parseDayPeriodPatterns = {
22675 any: {
22676 am: /^a/i,
22677 pm: /^p/i,
22678 midnight: /^mi/i,
22679 noon: /^no/i,
22680 morning: /morning/i,
22681 afternoon: /afternoon/i,
22682 evening: /evening/i,
22683 night: /night/i
22684 }
22685 };
22686 var match = {
22687 ordinalNumber: buildMatchPatternFn({
22688 matchPattern: matchOrdinalNumberPattern,
22689 parsePattern: parseOrdinalNumberPattern,
22690 valueCallback: (value) => parseInt(value, 10)
22691 }),
22692 era: buildMatchFn({
22693 matchPatterns: matchEraPatterns,
22694 defaultMatchWidth: "wide",
22695 parsePatterns: parseEraPatterns,
22696 defaultParseWidth: "any"
22697 }),
22698 quarter: buildMatchFn({
22699 matchPatterns: matchQuarterPatterns,
22700 defaultMatchWidth: "wide",
22701 parsePatterns: parseQuarterPatterns,
22702 defaultParseWidth: "any",
22703 valueCallback: (index2) => index2 + 1
22704 }),
22705 month: buildMatchFn({
22706 matchPatterns: matchMonthPatterns,
22707 defaultMatchWidth: "wide",
22708 parsePatterns: parseMonthPatterns,
22709 defaultParseWidth: "any"
22710 }),
22711 day: buildMatchFn({
22712 matchPatterns: matchDayPatterns,
22713 defaultMatchWidth: "wide",
22714 parsePatterns: parseDayPatterns,
22715 defaultParseWidth: "any"
22716 }),
22717 dayPeriod: buildMatchFn({
22718 matchPatterns: matchDayPeriodPatterns,
22719 defaultMatchWidth: "any",
22720 parsePatterns: parseDayPeriodPatterns,
22721 defaultParseWidth: "any"
22722 })
22723 };
22724
22725 // node_modules/date-fns/locale/en-US.js
22726 var enUS = {
22727 code: "en-US",
22728 formatDistance,
22729 formatLong,
22730 formatRelative,
22731 localize,
22732 match,
22733 options: {
22734 weekStartsOn: 0,
22735 firstWeekContainsDate: 1
22736 }
22737 };
22738
22739 // node_modules/date-fns/getDayOfYear.js
22740 function getDayOfYear(date, options) {
22741 const _date = toDate(date, options?.in);
22742 const diff = differenceInCalendarDays(_date, startOfYear(_date));
22743 const dayOfYear = diff + 1;
22744 return dayOfYear;
22745 }
22746
22747 // node_modules/date-fns/getISOWeek.js
22748 function getISOWeek(date, options) {
22749 const _date = toDate(date, options?.in);
22750 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
22751 return Math.round(diff / millisecondsInWeek) + 1;
22752 }
22753
22754 // node_modules/date-fns/getWeekYear.js
22755 function getWeekYear(date, options) {
22756 const _date = toDate(date, options?.in);
22757 const year = _date.getFullYear();
22758 const defaultOptions2 = getDefaultOptions();
22759 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22760 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
22761 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
22762 firstWeekOfNextYear.setHours(0, 0, 0, 0);
22763 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
22764 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
22765 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
22766 firstWeekOfThisYear.setHours(0, 0, 0, 0);
22767 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
22768 if (+_date >= +startOfNextYear) {
22769 return year + 1;
22770 } else if (+_date >= +startOfThisYear) {
22771 return year;
22772 } else {
22773 return year - 1;
22774 }
22775 }
22776
22777 // node_modules/date-fns/startOfWeekYear.js
22778 function startOfWeekYear(date, options) {
22779 const defaultOptions2 = getDefaultOptions();
22780 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22781 const year = getWeekYear(date, options);
22782 const firstWeek = constructFrom(options?.in || date, 0);
22783 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
22784 firstWeek.setHours(0, 0, 0, 0);
22785 const _date = startOfWeek(firstWeek, options);
22786 return _date;
22787 }
22788
22789 // node_modules/date-fns/getWeek.js
22790 function getWeek(date, options) {
22791 const _date = toDate(date, options?.in);
22792 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
22793 return Math.round(diff / millisecondsInWeek) + 1;
22794 }
22795
22796 // node_modules/date-fns/_lib/addLeadingZeros.js
22797 function addLeadingZeros(number, targetLength) {
22798 const sign = number < 0 ? "-" : "";
22799 const output = Math.abs(number).toString().padStart(targetLength, "0");
22800 return sign + output;
22801 }
22802
22803 // node_modules/date-fns/_lib/format/lightFormatters.js
22804 var lightFormatters = {
22805 // Year
22806 y(date, token) {
22807 const signedYear = date.getFullYear();
22808 const year = signedYear > 0 ? signedYear : 1 - signedYear;
22809 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
22810 },
22811 // Month
22812 M(date, token) {
22813 const month = date.getMonth();
22814 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
22815 },
22816 // Day of the month
22817 d(date, token) {
22818 return addLeadingZeros(date.getDate(), token.length);
22819 },
22820 // AM or PM
22821 a(date, token) {
22822 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
22823 switch (token) {
22824 case "a":
22825 case "aa":
22826 return dayPeriodEnumValue.toUpperCase();
22827 case "aaa":
22828 return dayPeriodEnumValue;
22829 case "aaaaa":
22830 return dayPeriodEnumValue[0];
22831 case "aaaa":
22832 default:
22833 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
22834 }
22835 },
22836 // Hour [1-12]
22837 h(date, token) {
22838 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
22839 },
22840 // Hour [0-23]
22841 H(date, token) {
22842 return addLeadingZeros(date.getHours(), token.length);
22843 },
22844 // Minute
22845 m(date, token) {
22846 return addLeadingZeros(date.getMinutes(), token.length);
22847 },
22848 // Second
22849 s(date, token) {
22850 return addLeadingZeros(date.getSeconds(), token.length);
22851 },
22852 // Fraction of second
22853 S(date, token) {
22854 const numberOfDigits = token.length;
22855 const milliseconds = date.getMilliseconds();
22856 const fractionalSeconds = Math.trunc(
22857 milliseconds * Math.pow(10, numberOfDigits - 3)
22858 );
22859 return addLeadingZeros(fractionalSeconds, token.length);
22860 }
22861 };
22862
22863 // node_modules/date-fns/_lib/format/formatters.js
22864 var dayPeriodEnum = {
22865 am: "am",
22866 pm: "pm",
22867 midnight: "midnight",
22868 noon: "noon",
22869 morning: "morning",
22870 afternoon: "afternoon",
22871 evening: "evening",
22872 night: "night"
22873 };
22874 var formatters = {
22875 // Era
22876 G: function(date, token, localize2) {
22877 const era = date.getFullYear() > 0 ? 1 : 0;
22878 switch (token) {
22879 // AD, BC
22880 case "G":
22881 case "GG":
22882 case "GGG":
22883 return localize2.era(era, { width: "abbreviated" });
22884 // A, B
22885 case "GGGGG":
22886 return localize2.era(era, { width: "narrow" });
22887 // Anno Domini, Before Christ
22888 case "GGGG":
22889 default:
22890 return localize2.era(era, { width: "wide" });
22891 }
22892 },
22893 // Year
22894 y: function(date, token, localize2) {
22895 if (token === "yo") {
22896 const signedYear = date.getFullYear();
22897 const year = signedYear > 0 ? signedYear : 1 - signedYear;
22898 return localize2.ordinalNumber(year, { unit: "year" });
22899 }
22900 return lightFormatters.y(date, token);
22901 },
22902 // Local week-numbering year
22903 Y: function(date, token, localize2, options) {
22904 const signedWeekYear = getWeekYear(date, options);
22905 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
22906 if (token === "YY") {
22907 const twoDigitYear = weekYear % 100;
22908 return addLeadingZeros(twoDigitYear, 2);
22909 }
22910 if (token === "Yo") {
22911 return localize2.ordinalNumber(weekYear, { unit: "year" });
22912 }
22913 return addLeadingZeros(weekYear, token.length);
22914 },
22915 // ISO week-numbering year
22916 R: function(date, token) {
22917 const isoWeekYear = getISOWeekYear(date);
22918 return addLeadingZeros(isoWeekYear, token.length);
22919 },
22920 // Extended year. This is a single number designating the year of this calendar system.
22921 // The main difference between `y` and `u` localizers are B.C. years:
22922 // | Year | `y` | `u` |
22923 // |------|-----|-----|
22924 // | AC 1 | 1 | 1 |
22925 // | BC 1 | 1 | 0 |
22926 // | BC 2 | 2 | -1 |
22927 // Also `yy` always returns the last two digits of a year,
22928 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
22929 u: function(date, token) {
22930 const year = date.getFullYear();
22931 return addLeadingZeros(year, token.length);
22932 },
22933 // Quarter
22934 Q: function(date, token, localize2) {
22935 const quarter = Math.ceil((date.getMonth() + 1) / 3);
22936 switch (token) {
22937 // 1, 2, 3, 4
22938 case "Q":
22939 return String(quarter);
22940 // 01, 02, 03, 04
22941 case "QQ":
22942 return addLeadingZeros(quarter, 2);
22943 // 1st, 2nd, 3rd, 4th
22944 case "Qo":
22945 return localize2.ordinalNumber(quarter, { unit: "quarter" });
22946 // Q1, Q2, Q3, Q4
22947 case "QQQ":
22948 return localize2.quarter(quarter, {
22949 width: "abbreviated",
22950 context: "formatting"
22951 });
22952 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
22953 case "QQQQQ":
22954 return localize2.quarter(quarter, {
22955 width: "narrow",
22956 context: "formatting"
22957 });
22958 // 1st quarter, 2nd quarter, ...
22959 case "QQQQ":
22960 default:
22961 return localize2.quarter(quarter, {
22962 width: "wide",
22963 context: "formatting"
22964 });
22965 }
22966 },
22967 // Stand-alone quarter
22968 q: function(date, token, localize2) {
22969 const quarter = Math.ceil((date.getMonth() + 1) / 3);
22970 switch (token) {
22971 // 1, 2, 3, 4
22972 case "q":
22973 return String(quarter);
22974 // 01, 02, 03, 04
22975 case "qq":
22976 return addLeadingZeros(quarter, 2);
22977 // 1st, 2nd, 3rd, 4th
22978 case "qo":
22979 return localize2.ordinalNumber(quarter, { unit: "quarter" });
22980 // Q1, Q2, Q3, Q4
22981 case "qqq":
22982 return localize2.quarter(quarter, {
22983 width: "abbreviated",
22984 context: "standalone"
22985 });
22986 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
22987 case "qqqqq":
22988 return localize2.quarter(quarter, {
22989 width: "narrow",
22990 context: "standalone"
22991 });
22992 // 1st quarter, 2nd quarter, ...
22993 case "qqqq":
22994 default:
22995 return localize2.quarter(quarter, {
22996 width: "wide",
22997 context: "standalone"
22998 });
22999 }
23000 },
23001 // Month
23002 M: function(date, token, localize2) {
23003 const month = date.getMonth();
23004 switch (token) {
23005 case "M":
23006 case "MM":
23007 return lightFormatters.M(date, token);
23008 // 1st, 2nd, ..., 12th
23009 case "Mo":
23010 return localize2.ordinalNumber(month + 1, { unit: "month" });
23011 // Jan, Feb, ..., Dec
23012 case "MMM":
23013 return localize2.month(month, {
23014 width: "abbreviated",
23015 context: "formatting"
23016 });
23017 // J, F, ..., D
23018 case "MMMMM":
23019 return localize2.month(month, {
23020 width: "narrow",
23021 context: "formatting"
23022 });
23023 // January, February, ..., December
23024 case "MMMM":
23025 default:
23026 return localize2.month(month, { width: "wide", context: "formatting" });
23027 }
23028 },
23029 // Stand-alone month
23030 L: function(date, token, localize2) {
23031 const month = date.getMonth();
23032 switch (token) {
23033 // 1, 2, ..., 12
23034 case "L":
23035 return String(month + 1);
23036 // 01, 02, ..., 12
23037 case "LL":
23038 return addLeadingZeros(month + 1, 2);
23039 // 1st, 2nd, ..., 12th
23040 case "Lo":
23041 return localize2.ordinalNumber(month + 1, { unit: "month" });
23042 // Jan, Feb, ..., Dec
23043 case "LLL":
23044 return localize2.month(month, {
23045 width: "abbreviated",
23046 context: "standalone"
23047 });
23048 // J, F, ..., D
23049 case "LLLLL":
23050 return localize2.month(month, {
23051 width: "narrow",
23052 context: "standalone"
23053 });
23054 // January, February, ..., December
23055 case "LLLL":
23056 default:
23057 return localize2.month(month, { width: "wide", context: "standalone" });
23058 }
23059 },
23060 // Local week of year
23061 w: function(date, token, localize2, options) {
23062 const week = getWeek(date, options);
23063 if (token === "wo") {
23064 return localize2.ordinalNumber(week, { unit: "week" });
23065 }
23066 return addLeadingZeros(week, token.length);
23067 },
23068 // ISO week of year
23069 I: function(date, token, localize2) {
23070 const isoWeek = getISOWeek(date);
23071 if (token === "Io") {
23072 return localize2.ordinalNumber(isoWeek, { unit: "week" });
23073 }
23074 return addLeadingZeros(isoWeek, token.length);
23075 },
23076 // Day of the month
23077 d: function(date, token, localize2) {
23078 if (token === "do") {
23079 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
23080 }
23081 return lightFormatters.d(date, token);
23082 },
23083 // Day of year
23084 D: function(date, token, localize2) {
23085 const dayOfYear = getDayOfYear(date);
23086 if (token === "Do") {
23087 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
23088 }
23089 return addLeadingZeros(dayOfYear, token.length);
23090 },
23091 // Day of week
23092 E: function(date, token, localize2) {
23093 const dayOfWeek = date.getDay();
23094 switch (token) {
23095 // Tue
23096 case "E":
23097 case "EE":
23098 case "EEE":
23099 return localize2.day(dayOfWeek, {
23100 width: "abbreviated",
23101 context: "formatting"
23102 });
23103 // T
23104 case "EEEEE":
23105 return localize2.day(dayOfWeek, {
23106 width: "narrow",
23107 context: "formatting"
23108 });
23109 // Tu
23110 case "EEEEEE":
23111 return localize2.day(dayOfWeek, {
23112 width: "short",
23113 context: "formatting"
23114 });
23115 // Tuesday
23116 case "EEEE":
23117 default:
23118 return localize2.day(dayOfWeek, {
23119 width: "wide",
23120 context: "formatting"
23121 });
23122 }
23123 },
23124 // Local day of week
23125 e: function(date, token, localize2, options) {
23126 const dayOfWeek = date.getDay();
23127 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
23128 switch (token) {
23129 // Numerical value (Nth day of week with current locale or weekStartsOn)
23130 case "e":
23131 return String(localDayOfWeek);
23132 // Padded numerical value
23133 case "ee":
23134 return addLeadingZeros(localDayOfWeek, 2);
23135 // 1st, 2nd, ..., 7th
23136 case "eo":
23137 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
23138 case "eee":
23139 return localize2.day(dayOfWeek, {
23140 width: "abbreviated",
23141 context: "formatting"
23142 });
23143 // T
23144 case "eeeee":
23145 return localize2.day(dayOfWeek, {
23146 width: "narrow",
23147 context: "formatting"
23148 });
23149 // Tu
23150 case "eeeeee":
23151 return localize2.day(dayOfWeek, {
23152 width: "short",
23153 context: "formatting"
23154 });
23155 // Tuesday
23156 case "eeee":
23157 default:
23158 return localize2.day(dayOfWeek, {
23159 width: "wide",
23160 context: "formatting"
23161 });
23162 }
23163 },
23164 // Stand-alone local day of week
23165 c: function(date, token, localize2, options) {
23166 const dayOfWeek = date.getDay();
23167 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
23168 switch (token) {
23169 // Numerical value (same as in `e`)
23170 case "c":
23171 return String(localDayOfWeek);
23172 // Padded numerical value
23173 case "cc":
23174 return addLeadingZeros(localDayOfWeek, token.length);
23175 // 1st, 2nd, ..., 7th
23176 case "co":
23177 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
23178 case "ccc":
23179 return localize2.day(dayOfWeek, {
23180 width: "abbreviated",
23181 context: "standalone"
23182 });
23183 // T
23184 case "ccccc":
23185 return localize2.day(dayOfWeek, {
23186 width: "narrow",
23187 context: "standalone"
23188 });
23189 // Tu
23190 case "cccccc":
23191 return localize2.day(dayOfWeek, {
23192 width: "short",
23193 context: "standalone"
23194 });
23195 // Tuesday
23196 case "cccc":
23197 default:
23198 return localize2.day(dayOfWeek, {
23199 width: "wide",
23200 context: "standalone"
23201 });
23202 }
23203 },
23204 // ISO day of week
23205 i: function(date, token, localize2) {
23206 const dayOfWeek = date.getDay();
23207 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
23208 switch (token) {
23209 // 2
23210 case "i":
23211 return String(isoDayOfWeek);
23212 // 02
23213 case "ii":
23214 return addLeadingZeros(isoDayOfWeek, token.length);
23215 // 2nd
23216 case "io":
23217 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
23218 // Tue
23219 case "iii":
23220 return localize2.day(dayOfWeek, {
23221 width: "abbreviated",
23222 context: "formatting"
23223 });
23224 // T
23225 case "iiiii":
23226 return localize2.day(dayOfWeek, {
23227 width: "narrow",
23228 context: "formatting"
23229 });
23230 // Tu
23231 case "iiiiii":
23232 return localize2.day(dayOfWeek, {
23233 width: "short",
23234 context: "formatting"
23235 });
23236 // Tuesday
23237 case "iiii":
23238 default:
23239 return localize2.day(dayOfWeek, {
23240 width: "wide",
23241 context: "formatting"
23242 });
23243 }
23244 },
23245 // AM or PM
23246 a: function(date, token, localize2) {
23247 const hours = date.getHours();
23248 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
23249 switch (token) {
23250 case "a":
23251 case "aa":
23252 return localize2.dayPeriod(dayPeriodEnumValue, {
23253 width: "abbreviated",
23254 context: "formatting"
23255 });
23256 case "aaa":
23257 return localize2.dayPeriod(dayPeriodEnumValue, {
23258 width: "abbreviated",
23259 context: "formatting"
23260 }).toLowerCase();
23261 case "aaaaa":
23262 return localize2.dayPeriod(dayPeriodEnumValue, {
23263 width: "narrow",
23264 context: "formatting"
23265 });
23266 case "aaaa":
23267 default:
23268 return localize2.dayPeriod(dayPeriodEnumValue, {
23269 width: "wide",
23270 context: "formatting"
23271 });
23272 }
23273 },
23274 // AM, PM, midnight, noon
23275 b: function(date, token, localize2) {
23276 const hours = date.getHours();
23277 let dayPeriodEnumValue;
23278 if (hours === 12) {
23279 dayPeriodEnumValue = dayPeriodEnum.noon;
23280 } else if (hours === 0) {
23281 dayPeriodEnumValue = dayPeriodEnum.midnight;
23282 } else {
23283 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
23284 }
23285 switch (token) {
23286 case "b":
23287 case "bb":
23288 return localize2.dayPeriod(dayPeriodEnumValue, {
23289 width: "abbreviated",
23290 context: "formatting"
23291 });
23292 case "bbb":
23293 return localize2.dayPeriod(dayPeriodEnumValue, {
23294 width: "abbreviated",
23295 context: "formatting"
23296 }).toLowerCase();
23297 case "bbbbb":
23298 return localize2.dayPeriod(dayPeriodEnumValue, {
23299 width: "narrow",
23300 context: "formatting"
23301 });
23302 case "bbbb":
23303 default:
23304 return localize2.dayPeriod(dayPeriodEnumValue, {
23305 width: "wide",
23306 context: "formatting"
23307 });
23308 }
23309 },
23310 // in the morning, in the afternoon, in the evening, at night
23311 B: function(date, token, localize2) {
23312 const hours = date.getHours();
23313 let dayPeriodEnumValue;
23314 if (hours >= 17) {
23315 dayPeriodEnumValue = dayPeriodEnum.evening;
23316 } else if (hours >= 12) {
23317 dayPeriodEnumValue = dayPeriodEnum.afternoon;
23318 } else if (hours >= 4) {
23319 dayPeriodEnumValue = dayPeriodEnum.morning;
23320 } else {
23321 dayPeriodEnumValue = dayPeriodEnum.night;
23322 }
23323 switch (token) {
23324 case "B":
23325 case "BB":
23326 case "BBB":
23327 return localize2.dayPeriod(dayPeriodEnumValue, {
23328 width: "abbreviated",
23329 context: "formatting"
23330 });
23331 case "BBBBB":
23332 return localize2.dayPeriod(dayPeriodEnumValue, {
23333 width: "narrow",
23334 context: "formatting"
23335 });
23336 case "BBBB":
23337 default:
23338 return localize2.dayPeriod(dayPeriodEnumValue, {
23339 width: "wide",
23340 context: "formatting"
23341 });
23342 }
23343 },
23344 // Hour [1-12]
23345 h: function(date, token, localize2) {
23346 if (token === "ho") {
23347 let hours = date.getHours() % 12;
23348 if (hours === 0) hours = 12;
23349 return localize2.ordinalNumber(hours, { unit: "hour" });
23350 }
23351 return lightFormatters.h(date, token);
23352 },
23353 // Hour [0-23]
23354 H: function(date, token, localize2) {
23355 if (token === "Ho") {
23356 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
23357 }
23358 return lightFormatters.H(date, token);
23359 },
23360 // Hour [0-11]
23361 K: function(date, token, localize2) {
23362 const hours = date.getHours() % 12;
23363 if (token === "Ko") {
23364 return localize2.ordinalNumber(hours, { unit: "hour" });
23365 }
23366 return addLeadingZeros(hours, token.length);
23367 },
23368 // Hour [1-24]
23369 k: function(date, token, localize2) {
23370 let hours = date.getHours();
23371 if (hours === 0) hours = 24;
23372 if (token === "ko") {
23373 return localize2.ordinalNumber(hours, { unit: "hour" });
23374 }
23375 return addLeadingZeros(hours, token.length);
23376 },
23377 // Minute
23378 m: function(date, token, localize2) {
23379 if (token === "mo") {
23380 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
23381 }
23382 return lightFormatters.m(date, token);
23383 },
23384 // Second
23385 s: function(date, token, localize2) {
23386 if (token === "so") {
23387 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
23388 }
23389 return lightFormatters.s(date, token);
23390 },
23391 // Fraction of second
23392 S: function(date, token) {
23393 return lightFormatters.S(date, token);
23394 },
23395 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
23396 X: function(date, token, _localize) {
23397 const timezoneOffset = date.getTimezoneOffset();
23398 if (timezoneOffset === 0) {
23399 return "Z";
23400 }
23401 switch (token) {
23402 // Hours and optional minutes
23403 case "X":
23404 return formatTimezoneWithOptionalMinutes(timezoneOffset);
23405 // Hours, minutes and optional seconds without `:` delimiter
23406 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
23407 // so this token always has the same output as `XX`
23408 case "XXXX":
23409 case "XX":
23410 return formatTimezone(timezoneOffset);
23411 // Hours, minutes and optional seconds with `:` delimiter
23412 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
23413 // so this token always has the same output as `XXX`
23414 case "XXXXX":
23415 case "XXX":
23416 // Hours and minutes with `:` delimiter
23417 default:
23418 return formatTimezone(timezoneOffset, ":");
23419 }
23420 },
23421 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
23422 x: function(date, token, _localize) {
23423 const timezoneOffset = date.getTimezoneOffset();
23424 switch (token) {
23425 // Hours and optional minutes
23426 case "x":
23427 return formatTimezoneWithOptionalMinutes(timezoneOffset);
23428 // Hours, minutes and optional seconds without `:` delimiter
23429 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
23430 // so this token always has the same output as `xx`
23431 case "xxxx":
23432 case "xx":
23433 return formatTimezone(timezoneOffset);
23434 // Hours, minutes and optional seconds with `:` delimiter
23435 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
23436 // so this token always has the same output as `xxx`
23437 case "xxxxx":
23438 case "xxx":
23439 // Hours and minutes with `:` delimiter
23440 default:
23441 return formatTimezone(timezoneOffset, ":");
23442 }
23443 },
23444 // Timezone (GMT)
23445 O: function(date, token, _localize) {
23446 const timezoneOffset = date.getTimezoneOffset();
23447 switch (token) {
23448 // Short
23449 case "O":
23450 case "OO":
23451 case "OOO":
23452 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
23453 // Long
23454 case "OOOO":
23455 default:
23456 return "GMT" + formatTimezone(timezoneOffset, ":");
23457 }
23458 },
23459 // Timezone (specific non-location)
23460 z: function(date, token, _localize) {
23461 const timezoneOffset = date.getTimezoneOffset();
23462 switch (token) {
23463 // Short
23464 case "z":
23465 case "zz":
23466 case "zzz":
23467 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
23468 // Long
23469 case "zzzz":
23470 default:
23471 return "GMT" + formatTimezone(timezoneOffset, ":");
23472 }
23473 },
23474 // Seconds timestamp
23475 t: function(date, token, _localize) {
23476 const timestamp = Math.trunc(+date / 1e3);
23477 return addLeadingZeros(timestamp, token.length);
23478 },
23479 // Milliseconds timestamp
23480 T: function(date, token, _localize) {
23481 return addLeadingZeros(+date, token.length);
23482 }
23483 };
23484 function formatTimezoneShort(offset4, delimiter = "") {
23485 const sign = offset4 > 0 ? "-" : "+";
23486 const absOffset = Math.abs(offset4);
23487 const hours = Math.trunc(absOffset / 60);
23488 const minutes = absOffset % 60;
23489 if (minutes === 0) {
23490 return sign + String(hours);
23491 }
23492 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
23493 }
23494 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
23495 if (offset4 % 60 === 0) {
23496 const sign = offset4 > 0 ? "-" : "+";
23497 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
23498 }
23499 return formatTimezone(offset4, delimiter);
23500 }
23501 function formatTimezone(offset4, delimiter = "") {
23502 const sign = offset4 > 0 ? "-" : "+";
23503 const absOffset = Math.abs(offset4);
23504 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
23505 const minutes = addLeadingZeros(absOffset % 60, 2);
23506 return sign + hours + delimiter + minutes;
23507 }
23508
23509 // node_modules/date-fns/_lib/format/longFormatters.js
23510 var dateLongFormatter = (pattern, formatLong2) => {
23511 switch (pattern) {
23512 case "P":
23513 return formatLong2.date({ width: "short" });
23514 case "PP":
23515 return formatLong2.date({ width: "medium" });
23516 case "PPP":
23517 return formatLong2.date({ width: "long" });
23518 case "PPPP":
23519 default:
23520 return formatLong2.date({ width: "full" });
23521 }
23522 };
23523 var timeLongFormatter = (pattern, formatLong2) => {
23524 switch (pattern) {
23525 case "p":
23526 return formatLong2.time({ width: "short" });
23527 case "pp":
23528 return formatLong2.time({ width: "medium" });
23529 case "ppp":
23530 return formatLong2.time({ width: "long" });
23531 case "pppp":
23532 default:
23533 return formatLong2.time({ width: "full" });
23534 }
23535 };
23536 var dateTimeLongFormatter = (pattern, formatLong2) => {
23537 const matchResult = pattern.match(/(P+)(p+)?/) || [];
23538 const datePattern = matchResult[1];
23539 const timePattern = matchResult[2];
23540 if (!timePattern) {
23541 return dateLongFormatter(pattern, formatLong2);
23542 }
23543 let dateTimeFormat;
23544 switch (datePattern) {
23545 case "P":
23546 dateTimeFormat = formatLong2.dateTime({ width: "short" });
23547 break;
23548 case "PP":
23549 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
23550 break;
23551 case "PPP":
23552 dateTimeFormat = formatLong2.dateTime({ width: "long" });
23553 break;
23554 case "PPPP":
23555 default:
23556 dateTimeFormat = formatLong2.dateTime({ width: "full" });
23557 break;
23558 }
23559 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
23560 };
23561 var longFormatters = {
23562 p: timeLongFormatter,
23563 P: dateTimeLongFormatter
23564 };
23565
23566 // node_modules/date-fns/_lib/protectedTokens.js
23567 var dayOfYearTokenRE = /^D+$/;
23568 var weekYearTokenRE = /^Y+$/;
23569 var throwTokens = ["D", "DD", "YY", "YYYY"];
23570 function isProtectedDayOfYearToken(token) {
23571 return dayOfYearTokenRE.test(token);
23572 }
23573 function isProtectedWeekYearToken(token) {
23574 return weekYearTokenRE.test(token);
23575 }
23576 function warnOrThrowProtectedError(token, format6, input) {
23577 const _message = message(token, format6, input);
23578 console.warn(_message);
23579 if (throwTokens.includes(token)) throw new RangeError(_message);
23580 }
23581 function message(token, format6, input) {
23582 const subject = token[0] === "Y" ? "years" : "days of the month";
23583 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`;
23584 }
23585
23586 // node_modules/date-fns/format.js
23587 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
23588 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
23589 var escapedStringRegExp = /^'([^]*?)'?$/;
23590 var doubleQuoteRegExp = /''/g;
23591 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
23592 function format(date, formatStr, options) {
23593 const defaultOptions2 = getDefaultOptions();
23594 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
23595 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
23596 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
23597 const originalDate = toDate(date, options?.in);
23598 if (!isValid(originalDate)) {
23599 throw new RangeError("Invalid time value");
23600 }
23601 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
23602 const firstCharacter = substring[0];
23603 if (firstCharacter === "p" || firstCharacter === "P") {
23604 const longFormatter = longFormatters[firstCharacter];
23605 return longFormatter(substring, locale.formatLong);
23606 }
23607 return substring;
23608 }).join("").match(formattingTokensRegExp).map((substring) => {
23609 if (substring === "''") {
23610 return { isToken: false, value: "'" };
23611 }
23612 const firstCharacter = substring[0];
23613 if (firstCharacter === "'") {
23614 return { isToken: false, value: cleanEscapedString(substring) };
23615 }
23616 if (formatters[firstCharacter]) {
23617 return { isToken: true, value: substring };
23618 }
23619 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
23620 throw new RangeError(
23621 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
23622 );
23623 }
23624 return { isToken: false, value: substring };
23625 });
23626 if (locale.localize.preprocessor) {
23627 parts = locale.localize.preprocessor(originalDate, parts);
23628 }
23629 const formatterOptions = {
23630 firstWeekContainsDate,
23631 weekStartsOn,
23632 locale
23633 };
23634 return parts.map((part) => {
23635 if (!part.isToken) return part.value;
23636 const token = part.value;
23637 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
23638 warnOrThrowProtectedError(token, formatStr, String(date));
23639 }
23640 const formatter = formatters[token[0]];
23641 return formatter(originalDate, token, locale.localize, formatterOptions);
23642 }).join("");
23643 }
23644 function cleanEscapedString(input) {
23645 const matched = input.match(escapedStringRegExp);
23646 if (!matched) {
23647 return input;
23648 }
23649 return matched[1].replace(doubleQuoteRegExp, "'");
23650 }
23651
23652 // node_modules/date-fns/subDays.js
23653 function subDays(date, amount, options) {
23654 return addDays(date, -amount, options);
23655 }
23656
23657 // node_modules/date-fns/subMonths.js
23658 function subMonths(date, amount, options) {
23659 return addMonths(date, -amount, options);
23660 }
23661
23662 // node_modules/date-fns/subWeeks.js
23663 function subWeeks(date, amount, options) {
23664 return addWeeks(date, -amount, options);
23665 }
23666
23667 // node_modules/date-fns/subYears.js
23668 function subYears(date, amount, options) {
23669 return addYears(date, -amount, options);
23670 }
23671
23672 // packages/dataviews/build-module/utils/operators.mjs
23673 var import_i18n26 = __toESM(require_i18n(), 1);
23674 var import_element69 = __toESM(require_element(), 1);
23675 var import_date = __toESM(require_date(), 1);
23676 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23677 var filterTextWrappers = {
23678 Name: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
23679 Value: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
23680 };
23681 function getRelativeDate(value, unit) {
23682 switch (unit) {
23683 case "days":
23684 return subDays(/* @__PURE__ */ new Date(), value);
23685 case "weeks":
23686 return subWeeks(/* @__PURE__ */ new Date(), value);
23687 case "months":
23688 return subMonths(/* @__PURE__ */ new Date(), value);
23689 case "years":
23690 return subYears(/* @__PURE__ */ new Date(), value);
23691 default:
23692 return /* @__PURE__ */ new Date();
23693 }
23694 }
23695 var isNoneOperatorDefinition = {
23696 /* translators: DataViews operator name */
23697 label: (0, import_i18n26.__)("Is none of"),
23698 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23699 (0, import_i18n26.sprintf)(
23700 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
23701 (0, import_i18n26.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
23702 filter.name,
23703 activeElements.map((element) => element.label).join(", ")
23704 ),
23705 filterTextWrappers
23706 ),
23707 filter: ((item, field, filterValue) => {
23708 if (!filterValue?.length) {
23709 return true;
23710 }
23711 const fieldValue = field.getValue({ item });
23712 if (Array.isArray(fieldValue)) {
23713 return !filterValue.some(
23714 (fv) => fieldValue.includes(fv)
23715 );
23716 } else if (typeof fieldValue === "string") {
23717 return !filterValue.includes(fieldValue);
23718 }
23719 return false;
23720 }),
23721 selection: "multi"
23722 };
23723 var OPERATORS = [
23724 {
23725 name: OPERATOR_IS_ANY,
23726 /* translators: DataViews operator name */
23727 label: (0, import_i18n26.__)("Includes"),
23728 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23729 (0, import_i18n26.sprintf)(
23730 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
23731 (0, import_i18n26.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
23732 filter.name,
23733 activeElements.map((element) => element.label).join(", ")
23734 ),
23735 filterTextWrappers
23736 ),
23737 filter(item, field, filterValue) {
23738 if (!filterValue?.length) {
23739 return true;
23740 }
23741 const fieldValue = field.getValue({ item });
23742 if (Array.isArray(fieldValue)) {
23743 return filterValue.some(
23744 (fv) => fieldValue.includes(fv)
23745 );
23746 } else if (typeof fieldValue === "string") {
23747 return filterValue.includes(fieldValue);
23748 }
23749 return false;
23750 },
23751 selection: "multi"
23752 },
23753 {
23754 name: OPERATOR_IS_NONE,
23755 ...isNoneOperatorDefinition
23756 },
23757 {
23758 name: OPERATOR_IS_ALL,
23759 /* translators: DataViews operator name */
23760 label: (0, import_i18n26.__)("Includes all"),
23761 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23762 (0, import_i18n26.sprintf)(
23763 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
23764 (0, import_i18n26.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
23765 filter.name,
23766 activeElements.map((element) => element.label).join(", ")
23767 ),
23768 filterTextWrappers
23769 ),
23770 filter(item, field, filterValue) {
23771 if (!filterValue?.length) {
23772 return true;
23773 }
23774 return filterValue.every((value) => {
23775 return field.getValue({ item })?.includes(value);
23776 });
23777 },
23778 selection: "multi"
23779 },
23780 {
23781 name: OPERATOR_IS_NOT_ALL,
23782 ...isNoneOperatorDefinition
23783 },
23784 {
23785 name: OPERATOR_BETWEEN,
23786 /* translators: DataViews operator name */
23787 label: (0, import_i18n26.__)("Between (inc)"),
23788 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23789 (0, import_i18n26.sprintf)(
23790 /* 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". */
23791 (0, import_i18n26.__)(
23792 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
23793 ),
23794 filter.name,
23795 activeElements[0].label[0],
23796 activeElements[0].label[1]
23797 ),
23798 filterTextWrappers
23799 ),
23800 filter(item, field, filterValue) {
23801 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
23802 return true;
23803 }
23804 const fieldValue = field.getValue({ item });
23805 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
23806 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
23807 }
23808 return false;
23809 },
23810 selection: "custom"
23811 },
23812 {
23813 name: OPERATOR_IN_THE_PAST,
23814 /* translators: DataViews operator name */
23815 label: (0, import_i18n26.__)("In the past"),
23816 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23817 (0, import_i18n26.sprintf)(
23818 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
23819 (0, import_i18n26.__)(
23820 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
23821 ),
23822 filter.name,
23823 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
23824 ),
23825 filterTextWrappers
23826 ),
23827 filter(item, field, filterValue) {
23828 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
23829 return true;
23830 }
23831 const targetDate = getRelativeDate(
23832 filterValue.value,
23833 filterValue.unit
23834 );
23835 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
23836 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
23837 },
23838 selection: "custom"
23839 },
23840 {
23841 name: OPERATOR_OVER,
23842 /* translators: DataViews operator name */
23843 label: (0, import_i18n26.__)("Over"),
23844 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23845 (0, import_i18n26.sprintf)(
23846 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
23847 (0, import_i18n26.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
23848 filter.name,
23849 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
23850 ),
23851 filterTextWrappers
23852 ),
23853 filter(item, field, filterValue) {
23854 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
23855 return true;
23856 }
23857 const targetDate = getRelativeDate(
23858 filterValue.value,
23859 filterValue.unit
23860 );
23861 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
23862 return fieldValue < targetDate;
23863 },
23864 selection: "custom"
23865 },
23866 {
23867 name: OPERATOR_IS,
23868 /* translators: DataViews operator name */
23869 label: (0, import_i18n26.__)("Is"),
23870 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23871 (0, import_i18n26.sprintf)(
23872 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
23873 (0, import_i18n26.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
23874 filter.name,
23875 activeElements[0].label
23876 ),
23877 filterTextWrappers
23878 ),
23879 filter(item, field, filterValue) {
23880 return filterValue === field.getValue({ item }) || filterValue === void 0;
23881 },
23882 selection: "single"
23883 },
23884 {
23885 name: OPERATOR_IS_NOT,
23886 /* translators: DataViews operator name */
23887 label: (0, import_i18n26.__)("Is not"),
23888 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23889 (0, import_i18n26.sprintf)(
23890 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
23891 (0, import_i18n26.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
23892 filter.name,
23893 activeElements[0].label
23894 ),
23895 filterTextWrappers
23896 ),
23897 filter(item, field, filterValue) {
23898 return filterValue !== field.getValue({ item });
23899 },
23900 selection: "single"
23901 },
23902 {
23903 name: OPERATOR_LESS_THAN,
23904 /* translators: DataViews operator name */
23905 label: (0, import_i18n26.__)("Less than"),
23906 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23907 (0, import_i18n26.sprintf)(
23908 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
23909 (0, import_i18n26.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
23910 filter.name,
23911 activeElements[0].label
23912 ),
23913 filterTextWrappers
23914 ),
23915 filter(item, field, filterValue) {
23916 if (filterValue === void 0) {
23917 return true;
23918 }
23919 const fieldValue = field.getValue({ item });
23920 return fieldValue < filterValue;
23921 },
23922 selection: "single"
23923 },
23924 {
23925 name: OPERATOR_GREATER_THAN,
23926 /* translators: DataViews operator name */
23927 label: (0, import_i18n26.__)("Greater than"),
23928 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23929 (0, import_i18n26.sprintf)(
23930 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
23931 (0, import_i18n26.__)(
23932 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
23933 ),
23934 filter.name,
23935 activeElements[0].label
23936 ),
23937 filterTextWrappers
23938 ),
23939 filter(item, field, filterValue) {
23940 if (filterValue === void 0) {
23941 return true;
23942 }
23943 const fieldValue = field.getValue({ item });
23944 return fieldValue > filterValue;
23945 },
23946 selection: "single"
23947 },
23948 {
23949 name: OPERATOR_LESS_THAN_OR_EQUAL,
23950 /* translators: DataViews operator name */
23951 label: (0, import_i18n26.__)("Less than or equal"),
23952 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23953 (0, import_i18n26.sprintf)(
23954 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
23955 (0, import_i18n26.__)(
23956 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
23957 ),
23958 filter.name,
23959 activeElements[0].label
23960 ),
23961 filterTextWrappers
23962 ),
23963 filter(item, field, filterValue) {
23964 if (filterValue === void 0) {
23965 return true;
23966 }
23967 const fieldValue = field.getValue({ item });
23968 return fieldValue <= filterValue;
23969 },
23970 selection: "single"
23971 },
23972 {
23973 name: OPERATOR_GREATER_THAN_OR_EQUAL,
23974 /* translators: DataViews operator name */
23975 label: (0, import_i18n26.__)("Greater than or equal"),
23976 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23977 (0, import_i18n26.sprintf)(
23978 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
23979 (0, import_i18n26.__)(
23980 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
23981 ),
23982 filter.name,
23983 activeElements[0].label
23984 ),
23985 filterTextWrappers
23986 ),
23987 filter(item, field, filterValue) {
23988 if (filterValue === void 0) {
23989 return true;
23990 }
23991 const fieldValue = field.getValue({ item });
23992 return fieldValue >= filterValue;
23993 },
23994 selection: "single"
23995 },
23996 {
23997 name: OPERATOR_BEFORE,
23998 /* translators: DataViews operator name */
23999 label: (0, import_i18n26.__)("Before"),
24000 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24001 (0, import_i18n26.sprintf)(
24002 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
24003 (0, import_i18n26.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
24004 filter.name,
24005 activeElements[0].label
24006 ),
24007 filterTextWrappers
24008 ),
24009 filter(item, field, filterValue) {
24010 if (filterValue === void 0) {
24011 return true;
24012 }
24013 const filterDate = (0, import_date.getDate)(filterValue);
24014 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24015 return fieldDate < filterDate;
24016 },
24017 selection: "single"
24018 },
24019 {
24020 name: OPERATOR_AFTER,
24021 /* translators: DataViews operator name */
24022 label: (0, import_i18n26.__)("After"),
24023 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24024 (0, import_i18n26.sprintf)(
24025 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
24026 (0, import_i18n26.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
24027 filter.name,
24028 activeElements[0].label
24029 ),
24030 filterTextWrappers
24031 ),
24032 filter(item, field, filterValue) {
24033 if (filterValue === void 0) {
24034 return true;
24035 }
24036 const filterDate = (0, import_date.getDate)(filterValue);
24037 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24038 return fieldDate > filterDate;
24039 },
24040 selection: "single"
24041 },
24042 {
24043 name: OPERATOR_BEFORE_INC,
24044 /* translators: DataViews operator name */
24045 label: (0, import_i18n26.__)("Before (inc)"),
24046 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24047 (0, import_i18n26.sprintf)(
24048 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
24049 (0, import_i18n26.__)(
24050 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
24051 ),
24052 filter.name,
24053 activeElements[0].label
24054 ),
24055 filterTextWrappers
24056 ),
24057 filter(item, field, filterValue) {
24058 if (filterValue === void 0) {
24059 return true;
24060 }
24061 const filterDate = (0, import_date.getDate)(filterValue);
24062 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24063 return fieldDate <= filterDate;
24064 },
24065 selection: "single"
24066 },
24067 {
24068 name: OPERATOR_AFTER_INC,
24069 /* translators: DataViews operator name */
24070 label: (0, import_i18n26.__)("After (inc)"),
24071 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24072 (0, import_i18n26.sprintf)(
24073 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
24074 (0, import_i18n26.__)(
24075 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
24076 ),
24077 filter.name,
24078 activeElements[0].label
24079 ),
24080 filterTextWrappers
24081 ),
24082 filter(item, field, filterValue) {
24083 if (filterValue === void 0) {
24084 return true;
24085 }
24086 const filterDate = (0, import_date.getDate)(filterValue);
24087 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24088 return fieldDate >= filterDate;
24089 },
24090 selection: "single"
24091 },
24092 {
24093 name: OPERATOR_CONTAINS,
24094 /* translators: DataViews operator name */
24095 label: (0, import_i18n26.__)("Contains"),
24096 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24097 (0, import_i18n26.sprintf)(
24098 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
24099 (0, import_i18n26.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
24100 filter.name,
24101 activeElements[0].label
24102 ),
24103 filterTextWrappers
24104 ),
24105 filter(item, field, filterValue) {
24106 if (filterValue === void 0) {
24107 return true;
24108 }
24109 const fieldValue = field.getValue({ item });
24110 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
24111 },
24112 selection: "single"
24113 },
24114 {
24115 name: OPERATOR_NOT_CONTAINS,
24116 /* translators: DataViews operator name */
24117 label: (0, import_i18n26.__)("Doesn't contain"),
24118 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24119 (0, import_i18n26.sprintf)(
24120 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
24121 (0, import_i18n26.__)(
24122 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
24123 ),
24124 filter.name,
24125 activeElements[0].label
24126 ),
24127 filterTextWrappers
24128 ),
24129 filter(item, field, filterValue) {
24130 if (filterValue === void 0) {
24131 return true;
24132 }
24133 const fieldValue = field.getValue({ item });
24134 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
24135 },
24136 selection: "single"
24137 },
24138 {
24139 name: OPERATOR_STARTS_WITH,
24140 /* translators: DataViews operator name */
24141 label: (0, import_i18n26.__)("Starts with"),
24142 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24143 (0, import_i18n26.sprintf)(
24144 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
24145 (0, import_i18n26.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
24146 filter.name,
24147 activeElements[0].label
24148 ),
24149 filterTextWrappers
24150 ),
24151 filter(item, field, filterValue) {
24152 if (filterValue === void 0) {
24153 return true;
24154 }
24155 const fieldValue = field.getValue({ item });
24156 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
24157 },
24158 selection: "single"
24159 },
24160 {
24161 name: OPERATOR_ON,
24162 /* translators: DataViews operator name */
24163 label: (0, import_i18n26.__)("On"),
24164 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24165 (0, import_i18n26.sprintf)(
24166 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
24167 (0, import_i18n26.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
24168 filter.name,
24169 activeElements[0].label
24170 ),
24171 filterTextWrappers
24172 ),
24173 filter(item, field, filterValue) {
24174 if (filterValue === void 0) {
24175 return true;
24176 }
24177 const filterDate = (0, import_date.getDate)(filterValue);
24178 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24179 return filterDate.getTime() === fieldDate.getTime();
24180 },
24181 selection: "single"
24182 },
24183 {
24184 name: OPERATOR_NOT_ON,
24185 /* translators: DataViews operator name */
24186 label: (0, import_i18n26.__)("Not on"),
24187 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
24188 (0, import_i18n26.sprintf)(
24189 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
24190 (0, import_i18n26.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
24191 filter.name,
24192 activeElements[0].label
24193 ),
24194 filterTextWrappers
24195 ),
24196 filter(item, field, filterValue) {
24197 if (filterValue === void 0) {
24198 return true;
24199 }
24200 const filterDate = (0, import_date.getDate)(filterValue);
24201 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24202 return filterDate.getTime() !== fieldDate.getTime();
24203 },
24204 selection: "single"
24205 }
24206 ];
24207 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
24208 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
24209 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
24210 (op) => op.name === name
24211 );
24212 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
24213
24214 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
24215 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24216 var ENTER = "Enter";
24217 var SPACE = " ";
24218 var FilterText = ({
24219 activeElements,
24220 filterInView,
24221 filter
24222 }) => {
24223 if (activeElements === void 0 || activeElements.length === 0) {
24224 return filter.name;
24225 }
24226 const operator = getOperatorByName(filterInView?.operator);
24227 if (operator !== void 0) {
24228 return operator.filterText(filter, activeElements);
24229 }
24230 return (0, import_i18n27.sprintf)(
24231 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
24232 (0, import_i18n27.__)("Unknown status for %1$s"),
24233 filter.name
24234 );
24235 };
24236 function OperatorSelector({
24237 filter,
24238 view,
24239 onChangeView
24240 }) {
24241 const operatorOptions = filter.operators?.map((operator) => ({
24242 value: operator,
24243 label: getOperatorByName(operator)?.label || operator
24244 }));
24245 const currentFilter = view.filters?.find(
24246 (_filter) => _filter.field === filter.field
24247 );
24248 const value = currentFilter?.operator || filter.operators[0];
24249 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
24250 Stack,
24251 {
24252 direction: "row",
24253 gap: "sm",
24254 justify: "flex-start",
24255 className: "dataviews-filters__summary-operators-container",
24256 align: "center",
24257 children: [
24258 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
24259 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24260 import_components21.SelectControl,
24261 {
24262 className: "dataviews-filters__summary-operators-filter-select",
24263 label: (0, import_i18n27.__)("Conditions"),
24264 value,
24265 options: operatorOptions,
24266 onChange: (newValue) => {
24267 const newOperator = newValue;
24268 const currentOperator = currentFilter?.operator;
24269 const newFilters = currentFilter ? [
24270 ...(view.filters ?? []).map(
24271 (_filter) => {
24272 if (_filter.field === filter.field) {
24273 const currentOpSelectionModel = getOperatorByName(
24274 currentOperator
24275 )?.selection;
24276 const newOpSelectionModel = getOperatorByName(
24277 newOperator
24278 )?.selection;
24279 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
24280 currentOpSelectionModel,
24281 newOpSelectionModel
24282 ].includes("custom");
24283 return {
24284 ..._filter,
24285 value: shouldResetValue ? void 0 : _filter.value,
24286 operator: newOperator
24287 };
24288 }
24289 return _filter;
24290 }
24291 )
24292 ] : [
24293 ...view.filters ?? [],
24294 {
24295 field: filter.field,
24296 operator: newOperator,
24297 value: void 0
24298 }
24299 ];
24300 onChangeView({
24301 ...view,
24302 page: 1,
24303 filters: newFilters
24304 });
24305 },
24306 size: "small",
24307 variant: "minimal",
24308 hideLabelFromVision: true
24309 }
24310 )
24311 ]
24312 }
24313 );
24314 }
24315 function Filter({
24316 addFilterRef,
24317 openedFilter,
24318 fields,
24319 ...commonProps
24320 }) {
24321 const toggleRef = (0, import_element70.useRef)(null);
24322 const { filter, view, onChangeView } = commonProps;
24323 const filterInView = view.filters?.find(
24324 (f2) => f2.field === filter.field
24325 );
24326 let activeElements = [];
24327 const field = (0, import_element70.useMemo)(() => {
24328 const currentField = fields.find((f2) => f2.id === filter.field);
24329 if (currentField) {
24330 return {
24331 ...currentField,
24332 // Configure getValue as if Item was a plain object.
24333 // See related input-widget.tsx
24334 getValue: ({ item }) => item[currentField.id]
24335 };
24336 }
24337 return currentField;
24338 }, [fields, filter.field]);
24339 const { elements } = useElements({
24340 elements: filter.elements,
24341 getElements: filter.getElements
24342 });
24343 if (elements.length > 0) {
24344 activeElements = elements.filter((element) => {
24345 if (filter.singleSelection) {
24346 return element.value === filterInView?.value;
24347 }
24348 return filterInView?.value?.includes(element.value);
24349 });
24350 } else if (Array.isArray(filterInView?.value)) {
24351 const label = filterInView.value.map((v2) => {
24352 const formattedValue = field?.getValueFormatted({
24353 item: { [field.id]: v2 },
24354 field
24355 });
24356 return formattedValue || String(v2);
24357 });
24358 activeElements = [
24359 {
24360 value: filterInView.value,
24361 // @ts-ignore
24362 label
24363 }
24364 ];
24365 } else if (typeof filterInView?.value === "object") {
24366 activeElements = [
24367 { value: filterInView.value, label: filterInView.value }
24368 ];
24369 } else if (filterInView?.value !== void 0) {
24370 const label = field !== void 0 ? field.getValueFormatted({
24371 item: { [field.id]: filterInView.value },
24372 field
24373 }) : String(filterInView.value);
24374 activeElements = [
24375 {
24376 value: filterInView.value,
24377 label
24378 }
24379 ];
24380 }
24381 const isPrimary = filter.isPrimary;
24382 const isLocked = filterInView?.isLocked;
24383 const hasValues = !isLocked && filterInView?.value !== void 0;
24384 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
24385 const resetOrRemoveLabel = isPrimary ? (0, import_i18n27.__)("Reset") : (0, import_i18n27.__)("Remove");
24386 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24387 import_components21.Dropdown,
24388 {
24389 defaultOpen: openedFilter === filter.field,
24390 contentClassName: "dataviews-filters__summary-popover",
24391 popoverProps: { placement: "bottom-start", role: "dialog" },
24392 onClose: () => {
24393 toggleRef.current?.focus();
24394 },
24395 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
24396 /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(tooltip_exports.Root, { children: [
24397 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24398 tooltip_exports.Trigger,
24399 {
24400 render: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24401 "div",
24402 {
24403 className: clsx_default(
24404 "dataviews-filters__summary-chip",
24405 {
24406 "has-reset": canResetOrRemove,
24407 "has-values": hasValues,
24408 "is-not-clickable": isLocked
24409 }
24410 ),
24411 role: "button",
24412 tabIndex: isLocked ? -1 : 0,
24413 onClick: () => {
24414 if (!isLocked) {
24415 onToggle();
24416 }
24417 },
24418 onKeyDown: (event) => {
24419 if (!isLocked && [ENTER, SPACE].includes(
24420 event.key
24421 )) {
24422 onToggle();
24423 event.preventDefault();
24424 }
24425 },
24426 "aria-disabled": isLocked,
24427 "aria-pressed": isOpen,
24428 "aria-expanded": isOpen,
24429 ref: toggleRef,
24430 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24431 FilterText,
24432 {
24433 activeElements,
24434 filterInView,
24435 filter
24436 }
24437 )
24438 }
24439 )
24440 }
24441 ),
24442 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(tooltip_exports.Popup, { children: (0, import_i18n27.sprintf)(
24443 /* translators: 1: Filter name. */
24444 (0, import_i18n27.__)("Filter by: %1$s"),
24445 filter.name.toLowerCase()
24446 ) })
24447 ] }),
24448 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(tooltip_exports.Root, { children: [
24449 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24450 tooltip_exports.Trigger,
24451 {
24452 render: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24453 "button",
24454 {
24455 className: clsx_default(
24456 "dataviews-filters__summary-chip-remove",
24457 { "has-values": hasValues }
24458 ),
24459 "aria-label": resetOrRemoveLabel,
24460 onClick: () => {
24461 onChangeView({
24462 ...view,
24463 page: 1,
24464 filters: view.filters?.filter(
24465 (_filter) => _filter.field !== filter.field
24466 )
24467 });
24468 if (!isPrimary) {
24469 addFilterRef.current?.focus();
24470 } else {
24471 toggleRef.current?.focus();
24472 }
24473 },
24474 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components21.Icon, { icon: close_small_default })
24475 }
24476 )
24477 }
24478 ),
24479 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
24480 ] })
24481 ] }),
24482 renderContent: () => {
24483 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
24484 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(OperatorSelector, { ...commonProps }),
24485 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24486 SearchWidget,
24487 {
24488 ...commonProps,
24489 filter: {
24490 ...commonProps.filter,
24491 elements
24492 }
24493 }
24494 ) : /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(InputWidget, { ...commonProps, fields })
24495 ] });
24496 }
24497 }
24498 );
24499 }
24500
24501 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
24502 var import_components22 = __toESM(require_components(), 1);
24503 var import_i18n28 = __toESM(require_i18n(), 1);
24504 var import_element71 = __toESM(require_element(), 1);
24505 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24506 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
24507 function AddFilterMenu({
24508 filters,
24509 view,
24510 onChangeView,
24511 setOpenedFilter,
24512 triggerProps
24513 }) {
24514 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
24515 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Menu4, { children: [
24516 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.TriggerButton, { ...triggerProps }),
24517 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
24518 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24519 Menu4.Item,
24520 {
24521 onClick: () => {
24522 setOpenedFilter(filter.field);
24523 onChangeView({
24524 ...view,
24525 page: 1,
24526 filters: [
24527 ...view.filters || [],
24528 {
24529 field: filter.field,
24530 value: void 0,
24531 operator: filter.operators[0]
24532 }
24533 ]
24534 });
24535 },
24536 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.ItemLabel, { children: filter.name })
24537 },
24538 filter.field
24539 );
24540 }) })
24541 ] });
24542 }
24543 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
24544 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
24545 return null;
24546 }
24547 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
24548 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24549 AddFilterMenu,
24550 {
24551 triggerProps: {
24552 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24553 import_components22.Button,
24554 {
24555 accessibleWhenDisabled: true,
24556 size: "compact",
24557 className: "dataviews-filters-button",
24558 variant: "tertiary",
24559 disabled: !inactiveFilters.length,
24560 ref
24561 }
24562 ),
24563 children: (0, import_i18n28.__)("Add filter")
24564 },
24565 ...{ filters, view, onChangeView, setOpenedFilter }
24566 }
24567 );
24568 }
24569 var add_filter_default = (0, import_element71.forwardRef)(AddFilter);
24570
24571 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
24572 var import_components23 = __toESM(require_components(), 1);
24573 var import_i18n29 = __toESM(require_i18n(), 1);
24574 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24575 function ResetFilter({
24576 filters,
24577 view,
24578 onChangeView
24579 }) {
24580 const isPrimary = (field) => filters.some(
24581 (_filter) => _filter.field === field && _filter.isPrimary
24582 );
24583 const isDisabled = !view.search && !view.filters?.some(
24584 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
24585 );
24586 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24587 import_components23.Button,
24588 {
24589 disabled: isDisabled,
24590 accessibleWhenDisabled: true,
24591 size: "compact",
24592 variant: "tertiary",
24593 className: "dataviews-filters__reset-button",
24594 onClick: () => {
24595 onChangeView({
24596 ...view,
24597 page: 1,
24598 search: "",
24599 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
24600 });
24601 },
24602 children: (0, import_i18n29.__)("Reset")
24603 }
24604 );
24605 }
24606
24607 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
24608 var import_element72 = __toESM(require_element(), 1);
24609 function useFilters(fields, view) {
24610 return (0, import_element72.useMemo)(() => {
24611 const filters = [];
24612 fields.forEach((field) => {
24613 if (field.filterBy === false || !field.hasElements && !field.Edit) {
24614 return;
24615 }
24616 const operators = field.filterBy.operators;
24617 const isPrimary = !!field.filterBy?.isPrimary;
24618 const isLocked = view.filters?.some(
24619 (f2) => f2.field === field.id && !!f2.isLocked
24620 ) ?? false;
24621 filters.push({
24622 field: field.id,
24623 name: field.label,
24624 elements: field.elements,
24625 getElements: field.getElements,
24626 hasElements: field.hasElements,
24627 singleSelection: operators.some(
24628 (op) => isSingleSelectionOperator(op)
24629 ),
24630 operators,
24631 isVisible: isLocked || isPrimary || !!view.filters?.some(
24632 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
24633 ),
24634 isPrimary,
24635 isLocked
24636 });
24637 });
24638 filters.sort((a2, b2) => {
24639 if (a2.isLocked && !b2.isLocked) {
24640 return -1;
24641 }
24642 if (!a2.isLocked && b2.isLocked) {
24643 return 1;
24644 }
24645 if (a2.isPrimary && !b2.isPrimary) {
24646 return -1;
24647 }
24648 if (!a2.isPrimary && b2.isPrimary) {
24649 return 1;
24650 }
24651 return a2.name.localeCompare(b2.name);
24652 });
24653 return filters;
24654 }, [fields, view]);
24655 }
24656 var use_filters_default = useFilters;
24657
24658 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
24659 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24660 function Filters({ className }) {
24661 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element73.useContext)(dataviews_context_default);
24662 const addFilterRef = (0, import_element73.useRef)(null);
24663 const filters = use_filters_default(fields, view);
24664 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24665 add_filter_default,
24666 {
24667 filters,
24668 view,
24669 onChangeView,
24670 ref: addFilterRef,
24671 setOpenedFilter
24672 },
24673 "add-filter"
24674 );
24675 const visibleFilters = filters.filter((filter) => filter.isVisible);
24676 if (visibleFilters.length === 0) {
24677 return null;
24678 }
24679 const filterComponents = [
24680 ...visibleFilters.map((filter) => {
24681 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24682 Filter,
24683 {
24684 filter,
24685 view,
24686 fields,
24687 onChangeView,
24688 addFilterRef,
24689 openedFilter
24690 },
24691 filter.field
24692 );
24693 }),
24694 addFilter
24695 ];
24696 filterComponents.push(
24697 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24698 ResetFilter,
24699 {
24700 filters,
24701 view,
24702 onChangeView
24703 },
24704 "reset-filters"
24705 )
24706 );
24707 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24708 Stack,
24709 {
24710 direction: "row",
24711 justify: "flex-start",
24712 gap: "sm",
24713 style: { width: "fit-content" },
24714 wrap: "wrap",
24715 className,
24716 children: filterComponents
24717 }
24718 );
24719 }
24720 var filters_default = (0, import_element73.memo)(Filters);
24721
24722 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
24723 var import_element74 = __toESM(require_element(), 1);
24724 var import_components24 = __toESM(require_components(), 1);
24725 var import_i18n30 = __toESM(require_i18n(), 1);
24726 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24727 function FiltersToggle() {
24728 const {
24729 filters,
24730 view,
24731 onChangeView,
24732 setOpenedFilter,
24733 isShowingFilter,
24734 setIsShowingFilter
24735 } = (0, import_element74.useContext)(dataviews_context_default);
24736 const buttonRef = (0, import_element74.useRef)(null);
24737 const onChangeViewWithFilterVisibility = (0, import_element74.useCallback)(
24738 (_view) => {
24739 onChangeView(_view);
24740 setIsShowingFilter(true);
24741 },
24742 [onChangeView, setIsShowingFilter]
24743 );
24744 if (filters.length === 0) {
24745 return null;
24746 }
24747 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
24748 const addFilterButtonProps = {
24749 label: (0, import_i18n30.__)("Add filter"),
24750 "aria-expanded": false,
24751 isPressed: false
24752 };
24753 const toggleFiltersButtonProps = {
24754 label: (0, import_i18n30._x)("Filter", "verb"),
24755 "aria-expanded": isShowingFilter,
24756 isPressed: isShowingFilter,
24757 onClick: () => {
24758 if (!isShowingFilter) {
24759 setOpenedFilter(null);
24760 }
24761 setIsShowingFilter(!isShowingFilter);
24762 }
24763 };
24764 const hasPrimaryOrLockedFilters = filters.some(
24765 (filter) => filter.isPrimary || filter.isLocked
24766 );
24767 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24768 import_components24.Button,
24769 {
24770 ref: buttonRef,
24771 className: "dataviews-filters__visibility-toggle",
24772 size: "compact",
24773 icon: funnel_default,
24774 disabled: hasPrimaryOrLockedFilters,
24775 accessibleWhenDisabled: true,
24776 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
24777 }
24778 );
24779 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24780 AddFilterMenu,
24781 {
24782 filters,
24783 view,
24784 onChangeView: onChangeViewWithFilterVisibility,
24785 setOpenedFilter,
24786 triggerProps: { render: buttonComponent }
24787 }
24788 ) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24789 FilterVisibilityToggle,
24790 {
24791 buttonRef,
24792 filtersCount: view.filters?.length,
24793 children: buttonComponent
24794 }
24795 ) });
24796 }
24797 function FilterVisibilityToggle({
24798 buttonRef,
24799 filtersCount,
24800 children
24801 }) {
24802 (0, import_element74.useEffect)(
24803 () => () => {
24804 buttonRef.current?.focus();
24805 },
24806 [buttonRef]
24807 );
24808 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_jsx_runtime104.Fragment, { children: [
24809 children,
24810 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
24811 ] });
24812 }
24813 var toggle_default = FiltersToggle;
24814
24815 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
24816 var import_element75 = __toESM(require_element(), 1);
24817 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24818 function FiltersToggled(props) {
24819 const { isShowingFilter } = (0, import_element75.useContext)(dataviews_context_default);
24820 if (!isShowingFilter) {
24821 return null;
24822 }
24823 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(filters_default, { ...props });
24824 }
24825 var filters_toggled_default = FiltersToggled;
24826
24827 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
24828 var import_element76 = __toESM(require_element(), 1);
24829 var import_components25 = __toESM(require_components(), 1);
24830 var import_i18n31 = __toESM(require_i18n(), 1);
24831 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24832 function DataViewsLayout({ className }) {
24833 const {
24834 actions = [],
24835 data,
24836 fields,
24837 getItemId,
24838 getItemLevel,
24839 hasInitiallyLoaded,
24840 isLoading,
24841 view,
24842 onChangeView,
24843 selection,
24844 onChangeSelection,
24845 setOpenedFilter,
24846 onClickItem,
24847 isItemClickable,
24848 renderItemLink,
24849 defaultLayouts,
24850 containerRef,
24851 empty = /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { children: (0, import_i18n31.__)("No results") })
24852 } = (0, import_element76.useContext)(dataviews_context_default);
24853 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
24854 delay: 200
24855 });
24856 if (!hasInitiallyLoaded) {
24857 if (!isDelayedInitialLoading) {
24858 return null;
24859 }
24860 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components25.Spinner, {}) }) });
24861 }
24862 const ViewComponent = VIEW_LAYOUTS.find(
24863 (v2) => v2.type === view.type && defaultLayouts[v2.type]
24864 )?.component;
24865 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24866 ViewComponent,
24867 {
24868 className,
24869 actions,
24870 data,
24871 fields,
24872 getItemId,
24873 getItemLevel,
24874 isLoading,
24875 onChangeView,
24876 onChangeSelection,
24877 selection,
24878 setOpenedFilter,
24879 onClickItem,
24880 renderItemLink,
24881 isItemClickable,
24882 view,
24883 empty
24884 }
24885 ) });
24886 }
24887
24888 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
24889 var import_element77 = __toESM(require_element(), 1);
24890 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24891 var EMPTY_ARRAY5 = [];
24892 function DataViewsFooter() {
24893 const {
24894 view,
24895 paginationInfo: { totalItems = 0, totalPages },
24896 data,
24897 actions = EMPTY_ARRAY5,
24898 isLoading,
24899 hasInitiallyLoaded
24900 } = (0, import_element77.useContext)(dataviews_context_default);
24901 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
24902 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
24903 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
24904 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
24905 return null;
24906 }
24907 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24908 "div",
24909 {
24910 className: "dataviews-footer",
24911 inert: isRefreshing ? "true" : void 0,
24912 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
24913 Stack,
24914 {
24915 direction: "row",
24916 justify: "end",
24917 align: "center",
24918 className: clsx_default("dataviews-footer__content", {
24919 "is-refreshing": isDelayedRefreshing
24920 }),
24921 gap: "sm",
24922 children: [
24923 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(BulkActionsFooter, {}),
24924 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(dataviews_pagination_default, {})
24925 ]
24926 }
24927 )
24928 }
24929 );
24930 }
24931
24932 // packages/dataviews/build-module/components/dataviews-search/index.mjs
24933 var import_i18n32 = __toESM(require_i18n(), 1);
24934 var import_element78 = __toESM(require_element(), 1);
24935 var import_components26 = __toESM(require_components(), 1);
24936 var import_compose10 = __toESM(require_compose(), 1);
24937 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24938 var DataViewsSearch = (0, import_element78.memo)(function Search({ label }) {
24939 const { view, onChangeView } = (0, import_element78.useContext)(dataviews_context_default);
24940 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
24941 view.search
24942 );
24943 (0, import_element78.useEffect)(() => {
24944 if (view.search !== debouncedSearch) {
24945 setSearch(view.search ?? "");
24946 }
24947 }, [view.search, setSearch]);
24948 const onChangeViewRef = (0, import_element78.useRef)(onChangeView);
24949 const viewRef = (0, import_element78.useRef)(view);
24950 (0, import_element78.useEffect)(() => {
24951 onChangeViewRef.current = onChangeView;
24952 viewRef.current = view;
24953 }, [onChangeView, view]);
24954 (0, import_element78.useEffect)(() => {
24955 if (debouncedSearch !== viewRef.current?.search) {
24956 onChangeViewRef.current({
24957 ...viewRef.current,
24958 page: view.page ? 1 : void 0,
24959 startPosition: view.startPosition ? 1 : void 0,
24960 search: debouncedSearch
24961 });
24962 }
24963 }, [debouncedSearch]);
24964 const searchLabel = label || (0, import_i18n32.__)("Search");
24965 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24966 import_components26.SearchControl,
24967 {
24968 className: "dataviews-search",
24969 onChange: setSearch,
24970 value: search,
24971 label: searchLabel,
24972 placeholder: searchLabel,
24973 size: "compact"
24974 }
24975 );
24976 });
24977 var dataviews_search_default = DataViewsSearch;
24978
24979 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
24980 var import_components27 = __toESM(require_components(), 1);
24981 var import_i18n33 = __toESM(require_i18n(), 1);
24982 var import_element79 = __toESM(require_element(), 1);
24983 var import_warning = __toESM(require_warning(), 1);
24984 var import_compose11 = __toESM(require_compose(), 1);
24985 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24986 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
24987 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
24988 className: "dataviews-config__popover",
24989 placement: "bottom-end",
24990 offset: 9
24991 };
24992 function ViewTypeMenu() {
24993 const { view, onChangeView, defaultLayouts } = (0, import_element79.useContext)(dataviews_context_default);
24994 const availableLayouts = Object.keys(defaultLayouts);
24995 if (availableLayouts.length <= 1) {
24996 return null;
24997 }
24998 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
24999 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Menu5, { children: [
25000 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25001 Menu5.TriggerButton,
25002 {
25003 render: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25004 import_components27.Button,
25005 {
25006 size: "compact",
25007 icon: activeView?.icon,
25008 label: (0, import_i18n33.__)("Layout")
25009 }
25010 )
25011 }
25012 ),
25013 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
25014 const config = VIEW_LAYOUTS.find(
25015 (v2) => v2.type === layout
25016 );
25017 if (!config) {
25018 return null;
25019 }
25020 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25021 Menu5.RadioItem,
25022 {
25023 value: layout,
25024 name: "view-actions-available-view",
25025 checked: layout === view.type,
25026 hideOnClick: true,
25027 onChange: (e2) => {
25028 switch (e2.target.value) {
25029 case "list":
25030 case "grid":
25031 case "table":
25032 case "pickerGrid":
25033 case "pickerTable":
25034 case "pickerActivity":
25035 case "activity":
25036 const viewWithoutLayout = { ...view };
25037 if ("layout" in viewWithoutLayout) {
25038 delete viewWithoutLayout.layout;
25039 }
25040 return onChangeView({
25041 ...viewWithoutLayout,
25042 type: e2.target.value,
25043 ...defaultLayouts[e2.target.value]
25044 });
25045 }
25046 (0, import_warning.default)("Invalid dataview");
25047 },
25048 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Menu5.ItemLabel, { children: config.label })
25049 },
25050 layout
25051 );
25052 }) })
25053 ] });
25054 }
25055 function SortFieldControl() {
25056 const { view, fields, onChangeView } = (0, import_element79.useContext)(dataviews_context_default);
25057 const orderOptions = (0, import_element79.useMemo)(() => {
25058 const sortableFields = fields.filter(
25059 (field) => field.enableSorting !== false
25060 );
25061 return sortableFields.map((field) => {
25062 return {
25063 label: field.label,
25064 value: field.id
25065 };
25066 });
25067 }, [fields]);
25068 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25069 import_components27.SelectControl,
25070 {
25071 __next40pxDefaultSize: true,
25072 label: (0, import_i18n33.__)("Sort by"),
25073 value: view.sort?.field,
25074 options: orderOptions,
25075 onChange: (value) => {
25076 onChangeView({
25077 ...view,
25078 sort: {
25079 direction: view?.sort?.direction || "desc",
25080 field: value
25081 },
25082 showLevels: false
25083 });
25084 }
25085 }
25086 );
25087 }
25088 function SortDirectionControl() {
25089 const { view, fields, onChangeView } = (0, import_element79.useContext)(dataviews_context_default);
25090 const sortableFields = fields.filter(
25091 (field) => field.enableSorting !== false
25092 );
25093 if (sortableFields.length === 0) {
25094 return null;
25095 }
25096 let value = view.sort?.direction;
25097 if (!value && view.sort?.field) {
25098 value = "desc";
25099 }
25100 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25101 import_components27.__experimentalToggleGroupControl,
25102 {
25103 className: "dataviews-view-config__sort-direction",
25104 __next40pxDefaultSize: true,
25105 isBlock: true,
25106 label: (0, import_i18n33.__)("Order"),
25107 value,
25108 onChange: (newDirection) => {
25109 if (newDirection === "asc" || newDirection === "desc") {
25110 onChangeView({
25111 ...view,
25112 sort: {
25113 direction: newDirection,
25114 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
25115 fields.find(
25116 (field) => field.enableSorting !== false
25117 )?.id || ""
25118 },
25119 showLevels: false
25120 });
25121 return;
25122 }
25123 (0, import_warning.default)("Invalid direction");
25124 },
25125 children: SORTING_DIRECTIONS.map((direction) => {
25126 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25127 import_components27.__experimentalToggleGroupControlOptionIcon,
25128 {
25129 value: direction,
25130 icon: sortIcons[direction],
25131 label: sortLabels[direction]
25132 },
25133 direction
25134 );
25135 })
25136 }
25137 );
25138 }
25139 function ItemsPerPageControl() {
25140 const { view, config, onChangeView } = (0, import_element79.useContext)(dataviews_context_default);
25141 const { infiniteScrollEnabled } = view;
25142 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
25143 return null;
25144 }
25145 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25146 import_components27.__experimentalToggleGroupControl,
25147 {
25148 __next40pxDefaultSize: true,
25149 isBlock: true,
25150 label: (0, import_i18n33.__)("Items per page"),
25151 value: view.perPage || 10,
25152 disabled: !view?.sort?.field,
25153 onChange: (newItemsPerPage) => {
25154 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
25155 onChangeView({
25156 ...view,
25157 perPage: newItemsPerPageNumber,
25158 page: 1
25159 });
25160 },
25161 children: config.perPageSizes.map((value) => {
25162 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25163 import_components27.__experimentalToggleGroupControlOption,
25164 {
25165 value,
25166 label: value.toString()
25167 },
25168 value
25169 );
25170 })
25171 }
25172 );
25173 }
25174 function ResetViewButton() {
25175 const { onReset } = (0, import_element79.useContext)(dataviews_context_default);
25176 if (onReset === void 0) {
25177 return null;
25178 }
25179 const isDisabled = onReset === false;
25180 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25181 import_components27.Button,
25182 {
25183 variant: "tertiary",
25184 size: "compact",
25185 disabled: isDisabled,
25186 accessibleWhenDisabled: true,
25187 className: "dataviews-view-config__reset-button",
25188 onClick: () => {
25189 if (typeof onReset === "function") {
25190 onReset();
25191 }
25192 },
25193 children: (0, import_i18n33.__)("Reset view")
25194 }
25195 );
25196 }
25197 function DataviewsViewConfigDropdown() {
25198 const { view, onReset } = (0, import_element79.useContext)(dataviews_context_default);
25199 const popoverId = (0, import_compose11.useInstanceId)(
25200 _DataViewsViewConfig,
25201 "dataviews-view-config-dropdown"
25202 );
25203 const activeLayout = VIEW_LAYOUTS.find(
25204 (layout) => layout.type === view.type
25205 );
25206 const isModified = typeof onReset === "function";
25207 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25208 import_components27.Dropdown,
25209 {
25210 expandOnMobile: true,
25211 popoverProps: {
25212 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
25213 id: popoverId
25214 },
25215 renderToggle: ({ onToggle, isOpen }) => {
25216 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
25217 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25218 import_components27.Button,
25219 {
25220 size: "compact",
25221 icon: cog_default,
25222 label: (0, import_i18n33._x)(
25223 "View options",
25224 "View is used as a noun"
25225 ),
25226 onClick: onToggle,
25227 "aria-expanded": isOpen ? "true" : "false",
25228 "aria-controls": popoverId
25229 }
25230 ),
25231 isModified && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
25232 ] });
25233 },
25234 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25235 import_components27.__experimentalDropdownContentWrapper,
25236 {
25237 paddingSize: "medium",
25238 className: "dataviews-config__popover-content-wrapper",
25239 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25240 Stack,
25241 {
25242 direction: "column",
25243 className: "dataviews-view-config",
25244 gap: "xl",
25245 children: [
25246 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25247 Stack,
25248 {
25249 direction: "row",
25250 justify: "space-between",
25251 align: "center",
25252 className: "dataviews-view-config__header",
25253 children: [
25254 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25255 import_components27.__experimentalHeading,
25256 {
25257 level: 2,
25258 className: "dataviews-settings-section__title",
25259 children: (0, import_i18n33.__)("Appearance")
25260 }
25261 ),
25262 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ResetViewButton, {})
25263 ]
25264 }
25265 ),
25266 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25267 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25268 Stack,
25269 {
25270 direction: "row",
25271 gap: "sm",
25272 className: "dataviews-view-config__sort-controls",
25273 children: [
25274 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SortFieldControl, {}),
25275 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SortDirectionControl, {})
25276 ]
25277 }
25278 ),
25279 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(activeLayout.viewConfigOptions, {}),
25280 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ItemsPerPageControl, {}),
25281 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PropertiesSection, {})
25282 ] })
25283 ]
25284 }
25285 )
25286 }
25287 )
25288 }
25289 );
25290 }
25291 function _DataViewsViewConfig() {
25292 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
25293 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ViewTypeMenu, {}),
25294 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(DataviewsViewConfigDropdown, {})
25295 ] });
25296 }
25297 var DataViewsViewConfig = (0, import_element79.memo)(_DataViewsViewConfig);
25298 var dataviews_view_config_default = DataViewsViewConfig;
25299
25300 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
25301 var import_components28 = __toESM(require_components(), 1);
25302 var import_element80 = __toESM(require_element(), 1);
25303
25304 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
25305 function getCustomValidity(isValid2, validity) {
25306 let customValidity;
25307 if (isValid2?.required && validity?.required) {
25308 customValidity = validity?.required?.message ? validity.required : void 0;
25309 } else if (isValid2?.pattern && validity?.pattern) {
25310 customValidity = validity.pattern;
25311 } else if (isValid2?.min && validity?.min) {
25312 customValidity = validity.min;
25313 } else if (isValid2?.max && validity?.max) {
25314 customValidity = validity.max;
25315 } else if (isValid2?.minLength && validity?.minLength) {
25316 customValidity = validity.minLength;
25317 } else if (isValid2?.maxLength && validity?.maxLength) {
25318 customValidity = validity.maxLength;
25319 } else if (isValid2?.elements && validity?.elements) {
25320 customValidity = validity.elements;
25321 } else if (validity?.custom) {
25322 customValidity = validity.custom;
25323 }
25324 return customValidity;
25325 }
25326
25327 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
25328 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25329 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
25330 function Checkbox({
25331 field,
25332 onChange,
25333 data,
25334 hideLabelFromVision,
25335 markWhenOptional,
25336 validity
25337 }) {
25338 const { getValue, setValue, label, description, isValid: isValid2 } = field;
25339 const disabled2 = field.isDisabled({ item: data, field });
25340 const onChangeControl = (0, import_element80.useCallback)(() => {
25341 onChange(
25342 setValue({ item: data, value: !getValue({ item: data }) })
25343 );
25344 }, [data, getValue, onChange, setValue]);
25345 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
25346 ValidatedCheckboxControl,
25347 {
25348 required: !!field.isValid?.required,
25349 markWhenOptional,
25350 customValidity: getCustomValidity(isValid2, validity),
25351 hidden: hideLabelFromVision,
25352 label,
25353 help: description,
25354 checked: getValue({ item: data }),
25355 onChange: onChangeControl,
25356 disabled: disabled2
25357 }
25358 );
25359 }
25360
25361 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
25362 var import_components29 = __toESM(require_components(), 1);
25363 var import_element81 = __toESM(require_element(), 1);
25364 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
25365 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
25366 function Combobox3({
25367 data,
25368 field,
25369 onChange,
25370 hideLabelFromVision,
25371 validity
25372 }) {
25373 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
25374 const value = getValue({ item: data }) ?? "";
25375 const onChangeControl = (0, import_element81.useCallback)(
25376 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
25377 [data, onChange, setValue]
25378 );
25379 const { elements, isLoading } = useElements({
25380 elements: field.elements,
25381 getElements: field.getElements
25382 });
25383 if (isLoading) {
25384 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components29.Spinner, {});
25385 }
25386 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
25387 ValidatedComboboxControl,
25388 {
25389 required: !!field.isValid?.required,
25390 customValidity: getCustomValidity(isValid2, validity),
25391 label,
25392 value,
25393 help: description,
25394 placeholder,
25395 options: elements,
25396 onChange: onChangeControl,
25397 hideLabelFromVision,
25398 allowReset: true,
25399 expandOnFocus: true
25400 }
25401 );
25402 }
25403
25404 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
25405 var import_components31 = __toESM(require_components(), 1);
25406 var import_element84 = __toESM(require_element(), 1);
25407 var import_i18n35 = __toESM(require_i18n(), 1);
25408 var import_date3 = __toESM(require_date(), 1);
25409
25410 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
25411 var import_components30 = __toESM(require_components(), 1);
25412 var import_element82 = __toESM(require_element(), 1);
25413 var import_i18n34 = __toESM(require_i18n(), 1);
25414 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
25415 var TIME_UNITS_OPTIONS = {
25416 [OPERATOR_IN_THE_PAST]: [
25417 { value: "days", label: (0, import_i18n34.__)("Days") },
25418 { value: "weeks", label: (0, import_i18n34.__)("Weeks") },
25419 { value: "months", label: (0, import_i18n34.__)("Months") },
25420 { value: "years", label: (0, import_i18n34.__)("Years") }
25421 ],
25422 [OPERATOR_OVER]: [
25423 { value: "days", label: (0, import_i18n34.__)("Days ago") },
25424 { value: "weeks", label: (0, import_i18n34.__)("Weeks ago") },
25425 { value: "months", label: (0, import_i18n34.__)("Months ago") },
25426 { value: "years", label: (0, import_i18n34.__)("Years ago") }
25427 ]
25428 };
25429 function RelativeDateControl({
25430 className,
25431 data,
25432 field,
25433 onChange,
25434 hideLabelFromVision,
25435 operator
25436 }) {
25437 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
25438 const { id, label, description, getValue, setValue } = field;
25439 const disabled2 = field.isDisabled({ item: data, field });
25440 const fieldValue = getValue({ item: data });
25441 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
25442 const onChangeValue = (0, import_element82.useCallback)(
25443 (newValue) => onChange(
25444 setValue({
25445 item: data,
25446 value: { value: Number(newValue), unit }
25447 })
25448 ),
25449 [onChange, setValue, data, unit]
25450 );
25451 const onChangeUnit = (0, import_element82.useCallback)(
25452 (newUnit) => onChange(
25453 setValue({
25454 item: data,
25455 value: { value: relValue, unit: newUnit }
25456 })
25457 ),
25458 [onChange, setValue, data, relValue]
25459 );
25460 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25461 import_components30.BaseControl,
25462 {
25463 id,
25464 className: clsx_default(className, "dataviews-controls__relative-date"),
25465 label,
25466 hideLabelFromVision,
25467 help: description,
25468 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "row", gap: "sm", children: [
25469 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25470 import_components30.__experimentalNumberControl,
25471 {
25472 __next40pxDefaultSize: true,
25473 className: "dataviews-controls__relative-date-number",
25474 spinControls: "none",
25475 min: 1,
25476 step: 1,
25477 value: relValue,
25478 onChange: onChangeValue,
25479 disabled: disabled2
25480 }
25481 ),
25482 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25483 import_components30.SelectControl,
25484 {
25485 className: "dataviews-controls__relative-date-unit",
25486 __next40pxDefaultSize: true,
25487 label: (0, import_i18n34.__)("Unit"),
25488 value: unit,
25489 options,
25490 onChange: onChangeUnit,
25491 hideLabelFromVision: true,
25492 disabled: disabled2
25493 }
25494 )
25495 ] })
25496 }
25497 );
25498 }
25499
25500 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
25501 var import_element83 = __toESM(require_element(), 1);
25502 function useDisabledDateMatchers(isValid2, parseDateFn) {
25503 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
25504 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
25505 const disabledMatchers = (0, import_element83.useMemo)(() => {
25506 const matchers = [];
25507 if (minConstraint) {
25508 const minDate = parseDateFn(minConstraint);
25509 if (minDate) {
25510 matchers.push({ before: minDate });
25511 }
25512 }
25513 if (maxConstraint) {
25514 const maxDate = parseDateFn(maxConstraint);
25515 if (maxDate) {
25516 matchers.push({ after: maxDate });
25517 }
25518 }
25519 return matchers.length > 0 ? matchers : void 0;
25520 }, [minConstraint, maxConstraint, parseDateFn]);
25521 return { minConstraint, maxConstraint, disabledMatchers };
25522 }
25523
25524 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
25525 var import_date2 = __toESM(require_date(), 1);
25526 function parseDateTime(dateTimeString) {
25527 if (!dateTimeString) {
25528 return null;
25529 }
25530 const parsed = (0, import_date2.getDate)(dateTimeString);
25531 return parsed && isValid(parsed) ? parsed : null;
25532 }
25533
25534 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
25535 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
25536 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
25537 var formatDateTime = (value) => {
25538 if (!value) {
25539 return "";
25540 }
25541 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
25542 };
25543 function CalendarDateTimeControl({
25544 data,
25545 field,
25546 onChange,
25547 hideLabelFromVision,
25548 markWhenOptional,
25549 validity,
25550 config
25551 }) {
25552 const { compact } = config || {};
25553 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
25554 const disabled2 = field.isDisabled({ item: data, field });
25555 const fieldValue = getValue({ item: data });
25556 const value = typeof fieldValue === "string" ? fieldValue : void 0;
25557 const [calendarMonth, setCalendarMonth] = (0, import_element84.useState)(() => {
25558 const parsedDate = parseDateTime(value);
25559 return parsedDate || /* @__PURE__ */ new Date();
25560 });
25561 const inputControlRef = (0, import_element84.useRef)(null);
25562 const validationTimeoutRef = (0, import_element84.useRef)(void 0);
25563 const previousFocusRef = (0, import_element84.useRef)(null);
25564 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
25565 const onChangeCallback = (0, import_element84.useCallback)(
25566 (newValue) => onChange(setValue({ item: data, value: newValue })),
25567 [data, onChange, setValue]
25568 );
25569 (0, import_element84.useEffect)(() => {
25570 return () => {
25571 if (validationTimeoutRef.current) {
25572 clearTimeout(validationTimeoutRef.current);
25573 }
25574 };
25575 }, []);
25576 const onSelectDate = (0, import_element84.useCallback)(
25577 (newDate) => {
25578 let dateTimeValue;
25579 if (newDate) {
25580 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
25581 let wpTime;
25582 if (value) {
25583 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
25584 } else {
25585 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
25586 }
25587 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
25588 dateTimeValue = finalDateTime.toISOString();
25589 onChangeCallback(dateTimeValue);
25590 if (validationTimeoutRef.current) {
25591 clearTimeout(validationTimeoutRef.current);
25592 }
25593 } else {
25594 onChangeCallback(void 0);
25595 }
25596 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
25597 validationTimeoutRef.current = setTimeout(() => {
25598 if (inputControlRef.current) {
25599 inputControlRef.current.focus();
25600 inputControlRef.current.blur();
25601 onChangeCallback(dateTimeValue);
25602 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
25603 previousFocusRef.current.focus();
25604 }
25605 }
25606 }, 0);
25607 },
25608 [onChangeCallback, value]
25609 );
25610 const handleManualDateTimeChange = (0, import_element84.useCallback)(
25611 (newValue) => {
25612 if (newValue) {
25613 const dateTime = (0, import_date3.getDate)(newValue);
25614 onChangeCallback(dateTime.toISOString());
25615 const parsedDate = parseDateTime(dateTime.toISOString());
25616 if (parsedDate) {
25617 setCalendarMonth(parsedDate);
25618 }
25619 } else {
25620 onChangeCallback(void 0);
25621 }
25622 },
25623 [onChangeCallback]
25624 );
25625 const { format: fieldFormat } = field;
25626 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
25627 const {
25628 timezone: { string: timezoneString }
25629 } = (0, import_date3.getSettings)();
25630 let displayLabel = label;
25631 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
25632 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
25633 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
25634 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
25635 }
25636 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25637 import_components31.BaseControl,
25638 {
25639 id,
25640 label: displayLabel,
25641 help: description,
25642 hideLabelFromVision,
25643 children: /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25644 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25645 ValidatedInputControl,
25646 {
25647 ref: inputControlRef,
25648 __next40pxDefaultSize: true,
25649 required: !!isValid2?.required,
25650 customValidity: getCustomValidity(isValid2, validity),
25651 type: "datetime-local",
25652 label: (0, import_i18n35.__)("Date time"),
25653 hideLabelFromVision: true,
25654 value: formatDateTime(value),
25655 onChange: handleManualDateTimeChange,
25656 disabled: disabled2,
25657 min: minConstraint ? formatDateTime(minConstraint) : void 0,
25658 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
25659 }
25660 ),
25661 !compact && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25662 DateCalendar,
25663 {
25664 style: { width: "100%" },
25665 selected: value ? parseDateTime(value) || void 0 : void 0,
25666 onSelect: onSelectDate,
25667 month: calendarMonth,
25668 onMonthChange: setCalendarMonth,
25669 timeZone: timezoneString || void 0,
25670 weekStartsOn,
25671 disabled: disabled2 || disabledMatchers
25672 }
25673 )
25674 ] })
25675 }
25676 );
25677 }
25678 function DateTime({
25679 data,
25680 field,
25681 onChange,
25682 hideLabelFromVision,
25683 markWhenOptional,
25684 operator,
25685 validity,
25686 config
25687 }) {
25688 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
25689 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25690 RelativeDateControl,
25691 {
25692 className: "dataviews-controls__datetime",
25693 data,
25694 field,
25695 onChange,
25696 hideLabelFromVision,
25697 operator
25698 }
25699 );
25700 }
25701 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25702 CalendarDateTimeControl,
25703 {
25704 data,
25705 field,
25706 onChange,
25707 hideLabelFromVision,
25708 markWhenOptional,
25709 validity,
25710 config
25711 }
25712 );
25713 }
25714
25715 // packages/dataviews/build-module/components/dataform-controls/date.mjs
25716 var import_components32 = __toESM(require_components(), 1);
25717 var import_element85 = __toESM(require_element(), 1);
25718 var import_i18n36 = __toESM(require_i18n(), 1);
25719 var import_date4 = __toESM(require_date(), 1);
25720 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25721 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
25722 var DATE_PRESETS = [
25723 {
25724 id: "today",
25725 label: (0, import_i18n36.__)("Today"),
25726 getValue: () => (0, import_date4.getDate)(null)
25727 },
25728 {
25729 id: "yesterday",
25730 label: (0, import_i18n36.__)("Yesterday"),
25731 getValue: () => {
25732 const today = (0, import_date4.getDate)(null);
25733 return subDays(today, 1);
25734 }
25735 },
25736 {
25737 id: "past-week",
25738 label: (0, import_i18n36.__)("Past week"),
25739 getValue: () => {
25740 const today = (0, import_date4.getDate)(null);
25741 return subDays(today, 7);
25742 }
25743 },
25744 {
25745 id: "past-month",
25746 label: (0, import_i18n36.__)("Past month"),
25747 getValue: () => {
25748 const today = (0, import_date4.getDate)(null);
25749 return subMonths(today, 1);
25750 }
25751 }
25752 ];
25753 var DATE_RANGE_PRESETS = [
25754 {
25755 id: "last-7-days",
25756 label: (0, import_i18n36.__)("Last 7 days"),
25757 getValue: () => {
25758 const today = (0, import_date4.getDate)(null);
25759 return [subDays(today, 7), today];
25760 }
25761 },
25762 {
25763 id: "last-30-days",
25764 label: (0, import_i18n36.__)("Last 30 days"),
25765 getValue: () => {
25766 const today = (0, import_date4.getDate)(null);
25767 return [subDays(today, 30), today];
25768 }
25769 },
25770 {
25771 id: "month-to-date",
25772 label: (0, import_i18n36.__)("Month to date"),
25773 getValue: () => {
25774 const today = (0, import_date4.getDate)(null);
25775 return [startOfMonth(today), today];
25776 }
25777 },
25778 {
25779 id: "last-year",
25780 label: (0, import_i18n36.__)("Last year"),
25781 getValue: () => {
25782 const today = (0, import_date4.getDate)(null);
25783 return [subYears(today, 1), today];
25784 }
25785 },
25786 {
25787 id: "year-to-date",
25788 label: (0, import_i18n36.__)("Year to date"),
25789 getValue: () => {
25790 const today = (0, import_date4.getDate)(null);
25791 return [startOfYear(today), today];
25792 }
25793 }
25794 ];
25795 var parseDate = (dateString) => {
25796 if (!dateString) {
25797 return null;
25798 }
25799 const parsed = (0, import_date4.getDate)(dateString);
25800 return parsed && isValid(parsed) ? parsed : null;
25801 };
25802 var formatDate = (date) => {
25803 if (!date) {
25804 return "";
25805 }
25806 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
25807 };
25808 function ValidatedDateControl({
25809 field,
25810 validity,
25811 inputRefs,
25812 isTouched,
25813 setIsTouched,
25814 children
25815 }) {
25816 const { isValid: isValid2 } = field;
25817 const [customValidity, setCustomValidity] = (0, import_element85.useState)(void 0);
25818 const validateRefs = (0, import_element85.useCallback)(() => {
25819 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25820 for (const ref of refs) {
25821 const input = ref.current;
25822 if (input && !input.validity.valid) {
25823 setCustomValidity({
25824 type: "invalid",
25825 message: input.validationMessage
25826 });
25827 return;
25828 }
25829 }
25830 setCustomValidity(void 0);
25831 }, [inputRefs]);
25832 (0, import_element85.useEffect)(() => {
25833 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25834 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
25835 for (const ref of refs) {
25836 const input = ref.current;
25837 if (input) {
25838 input.setCustomValidity(
25839 result?.type === "invalid" && result.message ? result.message : ""
25840 );
25841 }
25842 }
25843 }, [inputRefs, isValid2, validity]);
25844 (0, import_element85.useEffect)(() => {
25845 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25846 const handleInvalid = (event) => {
25847 event.preventDefault();
25848 setIsTouched(true);
25849 };
25850 for (const ref of refs) {
25851 ref.current?.addEventListener("invalid", handleInvalid);
25852 }
25853 return () => {
25854 for (const ref of refs) {
25855 ref.current?.removeEventListener("invalid", handleInvalid);
25856 }
25857 };
25858 }, [inputRefs, setIsTouched]);
25859 (0, import_element85.useEffect)(() => {
25860 if (!isTouched) {
25861 return;
25862 }
25863 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
25864 if (result) {
25865 setCustomValidity(result);
25866 } else {
25867 validateRefs();
25868 }
25869 }, [isTouched, isValid2, validity, validateRefs]);
25870 const onBlur = (event) => {
25871 if (isTouched) {
25872 return;
25873 }
25874 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
25875 setIsTouched(true);
25876 }
25877 };
25878 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)("div", { onBlur, children: [
25879 children,
25880 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
25881 "p",
25882 {
25883 className: clsx_default(
25884 "components-validated-control__indicator",
25885 customValidity.type === "invalid" ? "is-invalid" : void 0
25886 ),
25887 children: [
25888 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25889 import_components32.Icon,
25890 {
25891 className: "components-validated-control__indicator-icon",
25892 icon: error_default,
25893 size: 16,
25894 fill: "currentColor"
25895 }
25896 ),
25897 customValidity.message
25898 ]
25899 }
25900 ) })
25901 ] });
25902 }
25903 function CalendarDateControl({
25904 data,
25905 field,
25906 onChange,
25907 hideLabelFromVision,
25908 markWhenOptional,
25909 validity
25910 }) {
25911 const {
25912 id,
25913 label,
25914 description,
25915 setValue,
25916 getValue,
25917 isValid: isValid2,
25918 format: fieldFormat
25919 } = field;
25920 const disabled2 = field.isDisabled({ item: data, field });
25921 const [selectedPresetId, setSelectedPresetId] = (0, import_element85.useState)(
25922 null
25923 );
25924 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
25925 const fieldValue = getValue({ item: data });
25926 const value = typeof fieldValue === "string" ? fieldValue : void 0;
25927 const [calendarMonth, setCalendarMonth] = (0, import_element85.useState)(() => {
25928 const parsedDate = parseDate(value);
25929 return parsedDate || /* @__PURE__ */ new Date();
25930 });
25931 const [isTouched, setIsTouched] = (0, import_element85.useState)(false);
25932 const validityTargetRef = (0, import_element85.useRef)(null);
25933 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
25934 const onChangeCallback = (0, import_element85.useCallback)(
25935 (newValue) => onChange(setValue({ item: data, value: newValue })),
25936 [data, onChange, setValue]
25937 );
25938 const onSelectDate = (0, import_element85.useCallback)(
25939 (newDate) => {
25940 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
25941 onChangeCallback(dateValue);
25942 setSelectedPresetId(null);
25943 setIsTouched(true);
25944 },
25945 [onChangeCallback]
25946 );
25947 const handlePresetClick = (0, import_element85.useCallback)(
25948 (preset) => {
25949 const presetDate = preset.getValue();
25950 const dateValue = formatDate(presetDate);
25951 setCalendarMonth(presetDate);
25952 onChangeCallback(dateValue);
25953 setSelectedPresetId(preset.id);
25954 setIsTouched(true);
25955 },
25956 [onChangeCallback]
25957 );
25958 const handleManualDateChange = (0, import_element85.useCallback)(
25959 (newValue) => {
25960 onChangeCallback(newValue);
25961 if (newValue) {
25962 const parsedDate = parseDate(newValue);
25963 if (parsedDate) {
25964 setCalendarMonth(parsedDate);
25965 }
25966 }
25967 setSelectedPresetId(null);
25968 setIsTouched(true);
25969 },
25970 [onChangeCallback]
25971 );
25972 const {
25973 timezone: { string: timezoneString }
25974 } = (0, import_date4.getSettings)();
25975 let displayLabel = label;
25976 if (isValid2?.required && !markWhenOptional) {
25977 displayLabel = `${label} (${(0, import_i18n36.__)("Required")})`;
25978 } else if (!isValid2?.required && markWhenOptional) {
25979 displayLabel = `${label} (${(0, import_i18n36.__)("Optional")})`;
25980 }
25981 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25982 ValidatedDateControl,
25983 {
25984 field,
25985 validity,
25986 inputRefs: validityTargetRef,
25987 isTouched,
25988 setIsTouched,
25989 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25990 import_components32.BaseControl,
25991 {
25992 id,
25993 className: "dataviews-controls__date",
25994 label: displayLabel,
25995 help: description,
25996 hideLabelFromVision,
25997 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25998 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
25999 Stack,
26000 {
26001 direction: "row",
26002 gap: "sm",
26003 wrap: "wrap",
26004 justify: "flex-start",
26005 children: [
26006 DATE_PRESETS.map((preset) => {
26007 const isSelected2 = selectedPresetId === preset.id;
26008 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26009 import_components32.Button,
26010 {
26011 className: "dataviews-controls__date-preset",
26012 variant: "tertiary",
26013 isPressed: isSelected2,
26014 size: "small",
26015 disabled: disabled2,
26016 accessibleWhenDisabled: true,
26017 onClick: () => handlePresetClick(preset),
26018 children: preset.label
26019 },
26020 preset.id
26021 );
26022 }),
26023 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26024 import_components32.Button,
26025 {
26026 className: "dataviews-controls__date-preset",
26027 variant: "tertiary",
26028 isPressed: !selectedPresetId,
26029 size: "small",
26030 disabled: !!selectedPresetId || disabled2,
26031 accessibleWhenDisabled: true,
26032 children: (0, import_i18n36.__)("Custom")
26033 }
26034 )
26035 ]
26036 }
26037 ),
26038 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26039 import_components32.__experimentalInputControl,
26040 {
26041 __next40pxDefaultSize: true,
26042 ref: validityTargetRef,
26043 type: "date",
26044 label: (0, import_i18n36.__)("Date"),
26045 hideLabelFromVision: true,
26046 value,
26047 onChange: handleManualDateChange,
26048 required: !!field.isValid?.required,
26049 disabled: disabled2,
26050 min: minConstraint,
26051 max: maxConstraint
26052 }
26053 ),
26054 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26055 DateCalendar2,
26056 {
26057 style: { width: "100%" },
26058 selected: value ? parseDate(value) || void 0 : void 0,
26059 onSelect: onSelectDate,
26060 month: calendarMonth,
26061 onMonthChange: setCalendarMonth,
26062 timeZone: timezoneString || void 0,
26063 weekStartsOn,
26064 disabled: disabled2 || disabledMatchers,
26065 disableNavigation: disabled2
26066 }
26067 )
26068 ] })
26069 }
26070 )
26071 }
26072 );
26073 }
26074 function CalendarDateRangeControl({
26075 data,
26076 field,
26077 onChange,
26078 hideLabelFromVision,
26079 markWhenOptional,
26080 validity
26081 }) {
26082 const {
26083 id,
26084 label,
26085 description,
26086 getValue,
26087 setValue,
26088 isValid: isValid2,
26089 format: fieldFormat
26090 } = field;
26091 const disabled2 = field.isDisabled({ item: data, field });
26092 let value;
26093 const fieldValue = getValue({ item: data });
26094 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
26095 value = fieldValue;
26096 }
26097 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
26098 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
26099 const onChangeCallback = (0, import_element85.useCallback)(
26100 (newValue) => {
26101 onChange(
26102 setValue({
26103 item: data,
26104 value: newValue
26105 })
26106 );
26107 },
26108 [data, onChange, setValue]
26109 );
26110 const [selectedPresetId, setSelectedPresetId] = (0, import_element85.useState)(
26111 null
26112 );
26113 const selectedRange = (0, import_element85.useMemo)(() => {
26114 if (!value) {
26115 return { from: void 0, to: void 0 };
26116 }
26117 const [from, to] = value;
26118 return {
26119 from: parseDate(from) || void 0,
26120 to: parseDate(to) || void 0
26121 };
26122 }, [value]);
26123 const [calendarMonth, setCalendarMonth] = (0, import_element85.useState)(() => {
26124 return selectedRange.from || /* @__PURE__ */ new Date();
26125 });
26126 const [isTouched, setIsTouched] = (0, import_element85.useState)(false);
26127 const fromInputRef = (0, import_element85.useRef)(null);
26128 const toInputRef = (0, import_element85.useRef)(null);
26129 const updateDateRange = (0, import_element85.useCallback)(
26130 (fromDate, toDate2) => {
26131 if (fromDate && toDate2) {
26132 onChangeCallback([
26133 formatDate(fromDate),
26134 formatDate(toDate2)
26135 ]);
26136 } else if (!fromDate && !toDate2) {
26137 onChangeCallback(void 0);
26138 }
26139 },
26140 [onChangeCallback]
26141 );
26142 const onSelectCalendarRange = (0, import_element85.useCallback)(
26143 (newRange) => {
26144 updateDateRange(newRange?.from, newRange?.to);
26145 setSelectedPresetId(null);
26146 setIsTouched(true);
26147 },
26148 [updateDateRange]
26149 );
26150 const handlePresetClick = (0, import_element85.useCallback)(
26151 (preset) => {
26152 const [startDate, endDate] = preset.getValue();
26153 setCalendarMonth(startDate);
26154 updateDateRange(startDate, endDate);
26155 setSelectedPresetId(preset.id);
26156 setIsTouched(true);
26157 },
26158 [updateDateRange]
26159 );
26160 const handleManualDateChange = (0, import_element85.useCallback)(
26161 (fromOrTo, newValue) => {
26162 const [currentFrom, currentTo] = value || [
26163 void 0,
26164 void 0
26165 ];
26166 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
26167 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
26168 updateDateRange(updatedFrom, updatedTo);
26169 if (newValue) {
26170 const parsedDate = parseDate(newValue);
26171 if (parsedDate) {
26172 setCalendarMonth(parsedDate);
26173 }
26174 }
26175 setSelectedPresetId(null);
26176 setIsTouched(true);
26177 },
26178 [value, updateDateRange]
26179 );
26180 const { timezone } = (0, import_date4.getSettings)();
26181 let displayLabel = label;
26182 if (field.isValid?.required && !markWhenOptional) {
26183 displayLabel = `${label} (${(0, import_i18n36.__)("Required")})`;
26184 } else if (!field.isValid?.required && markWhenOptional) {
26185 displayLabel = `${label} (${(0, import_i18n36.__)("Optional")})`;
26186 }
26187 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26188 ValidatedDateControl,
26189 {
26190 field,
26191 validity,
26192 inputRefs: [fromInputRef, toInputRef],
26193 isTouched,
26194 setIsTouched,
26195 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26196 import_components32.BaseControl,
26197 {
26198 id,
26199 className: "dataviews-controls__date",
26200 label: displayLabel,
26201 help: description,
26202 hideLabelFromVision,
26203 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Stack, { direction: "column", gap: "lg", children: [
26204 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
26205 Stack,
26206 {
26207 direction: "row",
26208 gap: "sm",
26209 wrap: "wrap",
26210 justify: "flex-start",
26211 children: [
26212 DATE_RANGE_PRESETS.map((preset) => {
26213 const isSelected2 = selectedPresetId === preset.id;
26214 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26215 import_components32.Button,
26216 {
26217 className: "dataviews-controls__date-preset",
26218 variant: "tertiary",
26219 isPressed: isSelected2,
26220 size: "small",
26221 disabled: disabled2,
26222 accessibleWhenDisabled: true,
26223 onClick: () => handlePresetClick(preset),
26224 children: preset.label
26225 },
26226 preset.id
26227 );
26228 }),
26229 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26230 import_components32.Button,
26231 {
26232 className: "dataviews-controls__date-preset",
26233 variant: "tertiary",
26234 isPressed: !selectedPresetId,
26235 size: "small",
26236 accessibleWhenDisabled: true,
26237 disabled: !!selectedPresetId || disabled2,
26238 children: (0, import_i18n36.__)("Custom")
26239 }
26240 )
26241 ]
26242 }
26243 ),
26244 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
26245 Stack,
26246 {
26247 direction: "row",
26248 gap: "sm",
26249 justify: "space-between",
26250 className: "dataviews-controls__date-range-inputs",
26251 children: [
26252 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26253 import_components32.__experimentalInputControl,
26254 {
26255 __next40pxDefaultSize: true,
26256 ref: fromInputRef,
26257 type: "date",
26258 label: (0, import_i18n36.__)("From"),
26259 hideLabelFromVision: true,
26260 value: value?.[0],
26261 onChange: (newValue) => handleManualDateChange("from", newValue),
26262 required: !!field.isValid?.required,
26263 disabled: disabled2,
26264 min: minConstraint,
26265 max: maxConstraint
26266 }
26267 ),
26268 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26269 import_components32.__experimentalInputControl,
26270 {
26271 __next40pxDefaultSize: true,
26272 ref: toInputRef,
26273 type: "date",
26274 label: (0, import_i18n36.__)("To"),
26275 hideLabelFromVision: true,
26276 value: value?.[1],
26277 onChange: (newValue) => handleManualDateChange("to", newValue),
26278 required: !!field.isValid?.required,
26279 disabled: disabled2,
26280 min: minConstraint,
26281 max: maxConstraint
26282 }
26283 )
26284 ]
26285 }
26286 ),
26287 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26288 DateRangeCalendar,
26289 {
26290 style: { width: "100%" },
26291 selected: selectedRange,
26292 onSelect: onSelectCalendarRange,
26293 month: calendarMonth,
26294 onMonthChange: setCalendarMonth,
26295 timeZone: timezone.string || void 0,
26296 weekStartsOn,
26297 disabled: disabled2 || disabledMatchers
26298 }
26299 )
26300 ] })
26301 }
26302 )
26303 }
26304 );
26305 }
26306 function DateControl({
26307 data,
26308 field,
26309 onChange,
26310 hideLabelFromVision,
26311 markWhenOptional,
26312 operator,
26313 validity
26314 }) {
26315 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
26316 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26317 RelativeDateControl,
26318 {
26319 className: "dataviews-controls__date",
26320 data,
26321 field,
26322 onChange,
26323 hideLabelFromVision,
26324 operator
26325 }
26326 );
26327 }
26328 if (operator === OPERATOR_BETWEEN) {
26329 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26330 CalendarDateRangeControl,
26331 {
26332 data,
26333 field,
26334 onChange,
26335 hideLabelFromVision,
26336 markWhenOptional,
26337 validity
26338 }
26339 );
26340 }
26341 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26342 CalendarDateControl,
26343 {
26344 data,
26345 field,
26346 onChange,
26347 hideLabelFromVision,
26348 markWhenOptional,
26349 validity
26350 }
26351 );
26352 }
26353
26354 // packages/dataviews/build-module/components/dataform-controls/select.mjs
26355 var import_components33 = __toESM(require_components(), 1);
26356 var import_element86 = __toESM(require_element(), 1);
26357 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
26358 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
26359 function Select({
26360 data,
26361 field,
26362 onChange,
26363 hideLabelFromVision,
26364 markWhenOptional,
26365 validity
26366 }) {
26367 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
26368 const disabled2 = field.isDisabled({ item: data, field });
26369 const isMultiple = type === "array";
26370 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
26371 const onChangeControl = (0, import_element86.useCallback)(
26372 (newValue) => onChange(setValue({ item: data, value: newValue })),
26373 [data, onChange, setValue]
26374 );
26375 const { elements, isLoading } = useElements({
26376 elements: field.elements,
26377 getElements: field.getElements
26378 });
26379 if (isLoading) {
26380 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components33.Spinner, {});
26381 }
26382 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26383 ValidatedSelectControl,
26384 {
26385 required: !!field.isValid?.required,
26386 markWhenOptional,
26387 customValidity: getCustomValidity(isValid2, validity),
26388 label,
26389 value,
26390 help: description,
26391 options: elements,
26392 onChange: onChangeControl,
26393 __next40pxDefaultSize: true,
26394 hideLabelFromVision,
26395 multiple: isMultiple,
26396 disabled: disabled2
26397 }
26398 );
26399 }
26400
26401 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
26402 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
26403 var ELEMENTS_THRESHOLD = 10;
26404 function AdaptiveSelect(props) {
26405 const { field } = props;
26406 const { elements } = useElements({
26407 elements: field.elements,
26408 getElements: field.getElements
26409 });
26410 if (elements.length >= ELEMENTS_THRESHOLD) {
26411 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(Combobox3, { ...props });
26412 }
26413 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(Select, { ...props });
26414 }
26415
26416 // packages/dataviews/build-module/components/dataform-controls/email.mjs
26417 var import_components35 = __toESM(require_components(), 1);
26418
26419 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
26420 var import_components34 = __toESM(require_components(), 1);
26421 var import_element87 = __toESM(require_element(), 1);
26422 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
26423 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
26424 function ValidatedText({
26425 data,
26426 field,
26427 onChange,
26428 hideLabelFromVision,
26429 markWhenOptional,
26430 type,
26431 prefix,
26432 suffix,
26433 validity
26434 }) {
26435 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
26436 const value = getValue({ item: data });
26437 const disabled2 = field.isDisabled({ item: data, field });
26438 const onChangeControl = (0, import_element87.useCallback)(
26439 (newValue) => onChange(
26440 setValue({
26441 item: data,
26442 value: newValue
26443 })
26444 ),
26445 [data, setValue, onChange]
26446 );
26447 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26448 ValidatedInputControl2,
26449 {
26450 required: !!isValid2.required,
26451 markWhenOptional,
26452 customValidity: getCustomValidity(isValid2, validity),
26453 label,
26454 placeholder,
26455 value: value ?? "",
26456 help: description,
26457 onChange: onChangeControl,
26458 hideLabelFromVision,
26459 type,
26460 prefix,
26461 suffix,
26462 disabled: disabled2,
26463 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
26464 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
26465 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
26466 __next40pxDefaultSize: true
26467 }
26468 );
26469 }
26470
26471 // packages/dataviews/build-module/components/dataform-controls/email.mjs
26472 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
26473 function Email({
26474 data,
26475 field,
26476 onChange,
26477 hideLabelFromVision,
26478 markWhenOptional,
26479 validity
26480 }) {
26481 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26482 ValidatedText,
26483 {
26484 ...{
26485 data,
26486 field,
26487 onChange,
26488 hideLabelFromVision,
26489 markWhenOptional,
26490 validity,
26491 type: "email",
26492 prefix: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components35.Icon, { icon: envelope_default }) })
26493 }
26494 }
26495 );
26496 }
26497
26498 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
26499 var import_components36 = __toESM(require_components(), 1);
26500 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
26501 function Telephone({
26502 data,
26503 field,
26504 onChange,
26505 hideLabelFromVision,
26506 markWhenOptional,
26507 validity
26508 }) {
26509 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26510 ValidatedText,
26511 {
26512 ...{
26513 data,
26514 field,
26515 onChange,
26516 hideLabelFromVision,
26517 markWhenOptional,
26518 validity,
26519 type: "tel",
26520 prefix: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_components36.Icon, { icon: mobile_default }) })
26521 }
26522 }
26523 );
26524 }
26525
26526 // packages/dataviews/build-module/components/dataform-controls/url.mjs
26527 var import_components37 = __toESM(require_components(), 1);
26528 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26529 function Url({
26530 data,
26531 field,
26532 onChange,
26533 hideLabelFromVision,
26534 markWhenOptional,
26535 validity
26536 }) {
26537 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
26538 ValidatedText,
26539 {
26540 ...{
26541 data,
26542 field,
26543 onChange,
26544 hideLabelFromVision,
26545 markWhenOptional,
26546 validity,
26547 type: "url",
26548 prefix: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.Icon, { icon: link_default }) })
26549 }
26550 }
26551 );
26552 }
26553
26554 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
26555 var import_components38 = __toESM(require_components(), 1);
26556 var import_element88 = __toESM(require_element(), 1);
26557 var import_i18n37 = __toESM(require_i18n(), 1);
26558 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
26559 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
26560 function toNumberOrEmpty(value) {
26561 if (value === "" || value === void 0) {
26562 return "";
26563 }
26564 const number = Number(value);
26565 return Number.isFinite(number) ? number : "";
26566 }
26567 function BetweenControls({
26568 value,
26569 onChange,
26570 hideLabelFromVision,
26571 step
26572 }) {
26573 const [min2 = "", max2 = ""] = value;
26574 const onChangeMin = (0, import_element88.useCallback)(
26575 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
26576 [onChange, max2]
26577 );
26578 const onChangeMax = (0, import_element88.useCallback)(
26579 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
26580 [onChange, min2]
26581 );
26582 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26583 import_components38.BaseControl,
26584 {
26585 help: (0, import_i18n37.__)("The max. value must be greater than the min. value."),
26586 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
26587 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26588 import_components38.__experimentalNumberControl,
26589 {
26590 label: (0, import_i18n37.__)("Min."),
26591 value: min2,
26592 max: max2 ? Number(max2) - step : void 0,
26593 onChange: onChangeMin,
26594 __next40pxDefaultSize: true,
26595 hideLabelFromVision,
26596 step
26597 }
26598 ),
26599 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26600 import_components38.__experimentalNumberControl,
26601 {
26602 label: (0, import_i18n37.__)("Max."),
26603 value: max2,
26604 min: min2 ? Number(min2) + step : void 0,
26605 onChange: onChangeMax,
26606 __next40pxDefaultSize: true,
26607 hideLabelFromVision,
26608 step
26609 }
26610 )
26611 ] })
26612 }
26613 );
26614 }
26615 function ValidatedNumber({
26616 data,
26617 field,
26618 onChange,
26619 hideLabelFromVision,
26620 markWhenOptional,
26621 operator,
26622 validity
26623 }) {
26624 const decimals = field.format?.decimals ?? 0;
26625 const step = Math.pow(10, Math.abs(decimals) * -1);
26626 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26627 const value = getValue({ item: data }) ?? "";
26628 const disabled2 = field.isDisabled({ item: data, field });
26629 const onChangeControl = (0, import_element88.useCallback)(
26630 (newValue) => {
26631 onChange(
26632 setValue({
26633 item: data,
26634 // Do not convert an empty string or undefined to a number,
26635 // otherwise there's a mismatch between the UI control (empty)
26636 // and the data relied by onChange (0).
26637 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
26638 })
26639 );
26640 },
26641 [data, onChange, setValue]
26642 );
26643 const onChangeBetweenControls = (0, import_element88.useCallback)(
26644 (newValue) => {
26645 onChange(
26646 setValue({
26647 item: data,
26648 value: newValue
26649 })
26650 );
26651 },
26652 [data, onChange, setValue]
26653 );
26654 if (operator === OPERATOR_BETWEEN) {
26655 let valueBetween = ["", ""];
26656 if (Array.isArray(value) && value.length === 2 && value.every(
26657 (element) => typeof element === "number" || element === ""
26658 )) {
26659 valueBetween = value;
26660 }
26661 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26662 BetweenControls,
26663 {
26664 value: valueBetween,
26665 onChange: onChangeBetweenControls,
26666 hideLabelFromVision,
26667 step
26668 }
26669 );
26670 }
26671 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26672 ValidatedNumberControl,
26673 {
26674 required: !!isValid2.required,
26675 markWhenOptional,
26676 customValidity: getCustomValidity(isValid2, validity),
26677 label,
26678 help: description,
26679 value,
26680 onChange: onChangeControl,
26681 __next40pxDefaultSize: true,
26682 hideLabelFromVision,
26683 step,
26684 min: isValid2.min ? isValid2.min.constraint : void 0,
26685 max: isValid2.max ? isValid2.max.constraint : void 0,
26686 disabled: disabled2
26687 }
26688 );
26689 }
26690
26691 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
26692 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
26693 function Integer(props) {
26694 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(ValidatedNumber, { ...props });
26695 }
26696
26697 // packages/dataviews/build-module/components/dataform-controls/number.mjs
26698 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
26699 function Number2(props) {
26700 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ValidatedNumber, { ...props });
26701 }
26702
26703 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
26704 var import_components39 = __toESM(require_components(), 1);
26705 var import_element89 = __toESM(require_element(), 1);
26706 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
26707 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
26708 function Radio({
26709 data,
26710 field,
26711 onChange,
26712 hideLabelFromVision,
26713 markWhenOptional,
26714 validity
26715 }) {
26716 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26717 const disabled2 = field.isDisabled({ item: data, field });
26718 const { elements, isLoading } = useElements({
26719 elements: field.elements,
26720 getElements: field.getElements
26721 });
26722 const value = getValue({ item: data });
26723 const onChangeControl = (0, import_element89.useCallback)(
26724 (newValue) => onChange(setValue({ item: data, value: newValue })),
26725 [data, onChange, setValue]
26726 );
26727 if (isLoading) {
26728 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components39.Spinner, {});
26729 }
26730 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
26731 ValidatedRadioControl,
26732 {
26733 required: !!field.isValid?.required,
26734 markWhenOptional,
26735 customValidity: getCustomValidity(isValid2, validity),
26736 label,
26737 help: description,
26738 onChange: onChangeControl,
26739 options: elements,
26740 selected: value,
26741 hideLabelFromVision,
26742 disabled: disabled2
26743 }
26744 );
26745 }
26746
26747 // packages/dataviews/build-module/components/dataform-controls/text.mjs
26748 var import_element90 = __toESM(require_element(), 1);
26749 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
26750 function Text3({
26751 data,
26752 field,
26753 onChange,
26754 hideLabelFromVision,
26755 markWhenOptional,
26756 config,
26757 validity
26758 }) {
26759 const { prefix, suffix } = config || {};
26760 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
26761 ValidatedText,
26762 {
26763 ...{
26764 data,
26765 field,
26766 onChange,
26767 hideLabelFromVision,
26768 markWhenOptional,
26769 validity,
26770 prefix: prefix ? (0, import_element90.createElement)(prefix) : void 0,
26771 suffix: suffix ? (0, import_element90.createElement)(suffix) : void 0
26772 }
26773 }
26774 );
26775 }
26776
26777 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
26778 var import_components40 = __toESM(require_components(), 1);
26779 var import_element91 = __toESM(require_element(), 1);
26780 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
26781 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
26782 function Toggle({
26783 field,
26784 onChange,
26785 data,
26786 hideLabelFromVision,
26787 markWhenOptional,
26788 validity
26789 }) {
26790 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26791 const disabled2 = field.isDisabled({ item: data, field });
26792 const onChangeControl = (0, import_element91.useCallback)(() => {
26793 onChange(
26794 setValue({ item: data, value: !getValue({ item: data }) })
26795 );
26796 }, [onChange, setValue, data, getValue]);
26797 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
26798 ValidatedToggleControl,
26799 {
26800 required: !!isValid2.required,
26801 markWhenOptional,
26802 customValidity: getCustomValidity(isValid2, validity),
26803 hidden: hideLabelFromVision,
26804 label,
26805 help: description,
26806 checked: getValue({ item: data }),
26807 onChange: onChangeControl,
26808 disabled: disabled2
26809 }
26810 );
26811 }
26812
26813 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
26814 var import_components41 = __toESM(require_components(), 1);
26815 var import_element92 = __toESM(require_element(), 1);
26816 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
26817 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
26818 function Textarea({
26819 data,
26820 field,
26821 onChange,
26822 hideLabelFromVision,
26823 markWhenOptional,
26824 config,
26825 validity
26826 }) {
26827 const { rows = 4 } = config || {};
26828 const disabled2 = field.isDisabled({ item: data, field });
26829 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
26830 const value = field.getValue({ item: data });
26831 const onChangeControl = (0, import_element92.useCallback)(
26832 (newValue) => onChange(setValue({ item: data, value: newValue })),
26833 [data, onChange, setValue]
26834 );
26835 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
26836 ValidatedTextareaControl,
26837 {
26838 required: !!isValid2.required,
26839 markWhenOptional,
26840 customValidity: getCustomValidity(isValid2, validity),
26841 label,
26842 placeholder,
26843 value: value ?? "",
26844 help: description,
26845 onChange: onChangeControl,
26846 rows,
26847 disabled: disabled2,
26848 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
26849 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
26850 __next40pxDefaultSize: true,
26851 hideLabelFromVision
26852 }
26853 );
26854 }
26855
26856 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
26857 var import_components42 = __toESM(require_components(), 1);
26858 var import_element93 = __toESM(require_element(), 1);
26859 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
26860 var { ValidatedToggleGroupControl } = unlock2(import_components42.privateApis);
26861 function ToggleGroup({
26862 data,
26863 field,
26864 onChange,
26865 hideLabelFromVision,
26866 markWhenOptional,
26867 validity
26868 }) {
26869 const { getValue, setValue, isValid: isValid2 } = field;
26870 const disabled2 = field.isDisabled({ item: data, field });
26871 const value = getValue({ item: data });
26872 const onChangeControl = (0, import_element93.useCallback)(
26873 (newValue) => onChange(setValue({ item: data, value: newValue })),
26874 [data, onChange, setValue]
26875 );
26876 const { elements, isLoading } = useElements({
26877 elements: field.elements,
26878 getElements: field.getElements
26879 });
26880 if (isLoading) {
26881 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_components42.Spinner, {});
26882 }
26883 if (elements.length === 0) {
26884 return null;
26885 }
26886 const selectedOption = elements.find((el) => el.value === value);
26887 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
26888 ValidatedToggleGroupControl,
26889 {
26890 required: !!field.isValid?.required,
26891 markWhenOptional,
26892 customValidity: getCustomValidity(isValid2, validity),
26893 __next40pxDefaultSize: true,
26894 isBlock: true,
26895 label: field.label,
26896 help: selectedOption?.description || field.description,
26897 onChange: onChangeControl,
26898 value,
26899 hideLabelFromVision,
26900 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
26901 import_components42.__experimentalToggleGroupControlOption,
26902 {
26903 label: el.label,
26904 value: el.value,
26905 disabled: disabled2
26906 },
26907 el.value
26908 ))
26909 }
26910 );
26911 }
26912
26913 // packages/dataviews/build-module/components/dataform-controls/array.mjs
26914 var import_components43 = __toESM(require_components(), 1);
26915 var import_element94 = __toESM(require_element(), 1);
26916 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
26917 var { ValidatedFormTokenField } = unlock2(import_components43.privateApis);
26918 function ArrayControl({
26919 data,
26920 field,
26921 onChange,
26922 hideLabelFromVision,
26923 markWhenOptional,
26924 validity
26925 }) {
26926 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
26927 const value = getValue({ item: data });
26928 const disabled2 = field.isDisabled({ item: data, field });
26929 const { elements, isLoading } = useElements({
26930 elements: field.elements,
26931 getElements: field.getElements
26932 });
26933 const arrayValueAsElements = (0, import_element94.useMemo)(
26934 () => Array.isArray(value) ? value.map((token) => {
26935 const element = elements?.find(
26936 (suggestion) => suggestion.value === token
26937 );
26938 return element || { value: token, label: token };
26939 }) : [],
26940 [value, elements]
26941 );
26942 const onChangeControl = (0, import_element94.useCallback)(
26943 (tokens) => {
26944 const valueTokens = tokens.map((token) => {
26945 if (typeof token === "object" && "value" in token) {
26946 return token.value;
26947 }
26948 return token;
26949 });
26950 onChange(setValue({ item: data, value: valueTokens }));
26951 },
26952 [onChange, setValue, data]
26953 );
26954 if (isLoading) {
26955 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components43.Spinner, {});
26956 }
26957 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
26958 ValidatedFormTokenField,
26959 {
26960 required: !!isValid2?.required,
26961 markWhenOptional,
26962 customValidity: getCustomValidity(isValid2, validity),
26963 label: hideLabelFromVision ? void 0 : label,
26964 value: arrayValueAsElements,
26965 onChange: onChangeControl,
26966 placeholder,
26967 suggestions: elements?.map((element) => element.value),
26968 disabled: disabled2,
26969 __experimentalValidateInput: (token) => {
26970 if (field.isValid?.elements && elements) {
26971 return elements.some(
26972 (element) => element.value === token || element.label === token
26973 );
26974 }
26975 return true;
26976 },
26977 __experimentalExpandOnFocus: elements && elements.length > 0,
26978 help: description ?? (field.isValid?.elements ? "" : void 0),
26979 displayTransform: (token) => {
26980 if (typeof token === "object" && "label" in token) {
26981 return token.label;
26982 }
26983 if (typeof token === "string" && elements) {
26984 const element = elements.find(
26985 (el) => el.value === token
26986 );
26987 return element?.label || token;
26988 }
26989 return token;
26990 },
26991 __experimentalRenderItem: ({ item }) => {
26992 if (typeof item === "string" && elements) {
26993 const element = elements.find(
26994 (el) => el.value === item
26995 );
26996 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { children: element?.label || item });
26997 }
26998 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { children: item });
26999 }
27000 }
27001 );
27002 }
27003
27004 // node_modules/colord/index.mjs
27005 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
27006 var t = function(r3) {
27007 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
27008 };
27009 var n = function(r3, t2, n2) {
27010 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
27011 };
27012 var e = function(r3, t2, n2) {
27013 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
27014 };
27015 var u = function(r3) {
27016 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
27017 };
27018 var a = function(r3) {
27019 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
27020 };
27021 var o = function(r3) {
27022 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
27023 };
27024 var i = /^#([0-9a-f]{3,8})$/i;
27025 var s = function(r3) {
27026 var t2 = r3.toString(16);
27027 return t2.length < 2 ? "0" + t2 : t2;
27028 };
27029 var h = function(r3) {
27030 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;
27031 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
27032 };
27033 var b = function(r3) {
27034 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
27035 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
27036 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;
27037 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 };
27038 };
27039 var g = function(r3) {
27040 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
27041 };
27042 var d = function(r3) {
27043 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
27044 };
27045 var f = function(r3) {
27046 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 }));
27047 var t2, n2, e2;
27048 };
27049 var c = function(r3) {
27050 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 };
27051 var t2, n2, e2, u2;
27052 };
27053 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
27054 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
27055 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
27056 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
27057 var y = { string: [[function(r3) {
27058 var t2 = i.exec(r3);
27059 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;
27060 }, "hex"], [function(r3) {
27061 var t2 = v.exec(r3) || m.exec(r3);
27062 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;
27063 }, "rgb"], [function(t2) {
27064 var n2 = l.exec(t2) || p.exec(t2);
27065 if (!n2) return null;
27066 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) });
27067 return f(a2);
27068 }, "hsl"]], object: [[function(r3) {
27069 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
27070 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
27071 }, "rgb"], [function(r3) {
27072 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
27073 if (!t(n2) || !t(e2) || !t(u2)) return null;
27074 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
27075 return f(i2);
27076 }, "hsl"], [function(r3) {
27077 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
27078 if (!t(n2) || !t(a2) || !t(o2)) return null;
27079 var h2 = (function(r4) {
27080 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
27081 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
27082 return b(h2);
27083 }, "hsv"]] };
27084 var N = function(r3, t2) {
27085 for (var n2 = 0; n2 < t2.length; n2++) {
27086 var e2 = t2[n2][0](r3);
27087 if (e2) return [e2, t2[n2][1]];
27088 }
27089 return [null, void 0];
27090 };
27091 var x = function(r3) {
27092 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
27093 };
27094 var M = function(r3, t2) {
27095 var n2 = c(r3);
27096 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
27097 };
27098 var H = function(r3) {
27099 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
27100 };
27101 var $ = function(r3, t2) {
27102 var n2 = c(r3);
27103 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
27104 };
27105 var j = (function() {
27106 function r3(r4) {
27107 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
27108 }
27109 return r3.prototype.isValid = function() {
27110 return null !== this.parsed;
27111 }, r3.prototype.brightness = function() {
27112 return n(H(this.rgba), 2);
27113 }, r3.prototype.isDark = function() {
27114 return H(this.rgba) < 0.5;
27115 }, r3.prototype.isLight = function() {
27116 return H(this.rgba) >= 0.5;
27117 }, r3.prototype.toHex = function() {
27118 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;
27119 var r4, t2, e2, u2, a2, i2;
27120 }, r3.prototype.toRgb = function() {
27121 return o(this.rgba);
27122 }, r3.prototype.toRgbString = function() {
27123 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 + ")";
27124 var r4, t2, n2, e2, u2;
27125 }, r3.prototype.toHsl = function() {
27126 return d(c(this.rgba));
27127 }, r3.prototype.toHslString = function() {
27128 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 + "%)";
27129 var r4, t2, n2, e2, u2;
27130 }, r3.prototype.toHsv = function() {
27131 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
27132 var r4;
27133 }, r3.prototype.invert = function() {
27134 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
27135 var r4;
27136 }, r3.prototype.saturate = function(r4) {
27137 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
27138 }, r3.prototype.desaturate = function(r4) {
27139 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
27140 }, r3.prototype.grayscale = function() {
27141 return w(M(this.rgba, -1));
27142 }, r3.prototype.lighten = function(r4) {
27143 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
27144 }, r3.prototype.darken = function(r4) {
27145 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
27146 }, r3.prototype.rotate = function(r4) {
27147 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
27148 }, r3.prototype.alpha = function(r4) {
27149 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
27150 var t2;
27151 }, r3.prototype.hue = function(r4) {
27152 var t2 = c(this.rgba);
27153 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
27154 }, r3.prototype.isEqual = function(r4) {
27155 return this.toHex() === w(r4).toHex();
27156 }, r3;
27157 })();
27158 var w = function(r3) {
27159 return r3 instanceof j ? r3 : new j(r3);
27160 };
27161
27162 // packages/dataviews/build-module/components/dataform-controls/color.mjs
27163 var import_components44 = __toESM(require_components(), 1);
27164 var import_element95 = __toESM(require_element(), 1);
27165 var import_i18n38 = __toESM(require_i18n(), 1);
27166 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
27167 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components44.privateApis);
27168 var ColorPickerDropdown = ({
27169 color,
27170 onColorChange,
27171 disabled: disabled2
27172 }) => {
27173 const validColor = color && w(color).isValid() ? color : "#ffffff";
27174 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
27175 import_components44.Dropdown,
27176 {
27177 className: "dataviews-controls__color-picker-dropdown",
27178 popoverProps: { resize: false },
27179 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
27180 import_components44.Button,
27181 {
27182 onClick: onToggle,
27183 "aria-label": (0, import_i18n38.__)("Open color picker"),
27184 size: "small",
27185 disabled: disabled2,
27186 accessibleWhenDisabled: true,
27187 icon: () => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
27188 }
27189 ),
27190 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
27191 import_components44.ColorPicker,
27192 {
27193 color: validColor,
27194 onChange: onColorChange,
27195 enableAlpha: true
27196 }
27197 ) })
27198 }
27199 );
27200 };
27201 function Color({
27202 data,
27203 field,
27204 onChange,
27205 hideLabelFromVision,
27206 markWhenOptional,
27207 validity
27208 }) {
27209 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
27210 const disabled2 = field.isDisabled({ item: data, field });
27211 const value = field.getValue({ item: data }) || "";
27212 const handleColorChange = (0, import_element95.useCallback)(
27213 (newColor) => {
27214 onChange(setValue({ item: data, value: newColor }));
27215 },
27216 [data, onChange, setValue]
27217 );
27218 const handleInputChange = (0, import_element95.useCallback)(
27219 (newValue) => {
27220 onChange(setValue({ item: data, value: newValue || "" }));
27221 },
27222 [data, onChange, setValue]
27223 );
27224 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
27225 ValidatedInputControl3,
27226 {
27227 required: !!field.isValid?.required,
27228 markWhenOptional,
27229 customValidity: getCustomValidity(isValid2, validity),
27230 label,
27231 placeholder,
27232 value,
27233 help: description,
27234 onChange: handleInputChange,
27235 hideLabelFromVision,
27236 type: "text",
27237 disabled: disabled2,
27238 prefix: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
27239 ColorPickerDropdown,
27240 {
27241 color: value,
27242 onColorChange: handleColorChange,
27243 disabled: disabled2
27244 }
27245 ) })
27246 }
27247 );
27248 }
27249
27250 // packages/dataviews/build-module/components/dataform-controls/password.mjs
27251 var import_components45 = __toESM(require_components(), 1);
27252 var import_element96 = __toESM(require_element(), 1);
27253 var import_i18n39 = __toESM(require_i18n(), 1);
27254 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
27255 function Password({
27256 data,
27257 field,
27258 onChange,
27259 hideLabelFromVision,
27260 markWhenOptional,
27261 validity
27262 }) {
27263 const [isVisible2, setIsVisible] = (0, import_element96.useState)(false);
27264 const disabled2 = field.isDisabled({ item: data, field });
27265 const toggleVisibility = (0, import_element96.useCallback)(() => {
27266 setIsVisible((prev) => !prev);
27267 }, []);
27268 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
27269 ValidatedText,
27270 {
27271 ...{
27272 data,
27273 field,
27274 onChange,
27275 hideLabelFromVision,
27276 markWhenOptional,
27277 validity,
27278 type: isVisible2 ? "text" : "password",
27279 suffix: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
27280 import_components45.Button,
27281 {
27282 icon: isVisible2 ? unseen_default : seen_default,
27283 onClick: toggleVisibility,
27284 size: "small",
27285 label: isVisible2 ? (0, import_i18n39.__)("Hide password") : (0, import_i18n39.__)("Show password"),
27286 disabled: disabled2,
27287 accessibleWhenDisabled: true
27288 }
27289 ) })
27290 }
27291 }
27292 );
27293 }
27294
27295 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
27296 function hasElements(field) {
27297 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
27298 }
27299
27300 // packages/dataviews/build-module/components/dataform-controls/index.mjs
27301 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
27302 var FORM_CONTROLS = {
27303 adaptiveSelect: AdaptiveSelect,
27304 array: ArrayControl,
27305 checkbox: Checkbox,
27306 color: Color,
27307 combobox: Combobox3,
27308 datetime: DateTime,
27309 date: DateControl,
27310 email: Email,
27311 telephone: Telephone,
27312 url: Url,
27313 integer: Integer,
27314 number: Number2,
27315 password: Password,
27316 radio: Radio,
27317 select: Select,
27318 text: Text3,
27319 toggle: Toggle,
27320 textarea: Textarea,
27321 toggleGroup: ToggleGroup
27322 };
27323 function isEditConfig(value) {
27324 return value && typeof value === "object" && typeof value.control === "string";
27325 }
27326 function createConfiguredControl(config) {
27327 const { control, ...controlConfig } = config;
27328 const BaseControlType = getControlByType(control);
27329 if (BaseControlType === null) {
27330 return null;
27331 }
27332 return function ConfiguredControl(props) {
27333 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(BaseControlType, { ...props, config: controlConfig });
27334 };
27335 }
27336 function getControl(field, fallback) {
27337 if (typeof field.Edit === "function") {
27338 return field.Edit;
27339 }
27340 if (typeof field.Edit === "string") {
27341 return getControlByType(field.Edit);
27342 }
27343 if (isEditConfig(field.Edit)) {
27344 return createConfiguredControl(field.Edit);
27345 }
27346 if (hasElements(field) && field.type !== "array") {
27347 return getControlByType("adaptiveSelect");
27348 }
27349 if (fallback === null) {
27350 return null;
27351 }
27352 return getControlByType(fallback);
27353 }
27354 function getControlByType(type) {
27355 if (Object.keys(FORM_CONTROLS).includes(type)) {
27356 return FORM_CONTROLS[type];
27357 }
27358 return null;
27359 }
27360
27361 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
27362 function getFilterBy(field, defaultOperators, validOperators) {
27363 if (field.filterBy === false) {
27364 return false;
27365 }
27366 const operators = field.filterBy?.operators?.filter(
27367 (op) => validOperators.includes(op)
27368 ) ?? defaultOperators;
27369 if (operators.length === 0) {
27370 return false;
27371 }
27372 return {
27373 isPrimary: !!field.filterBy?.isPrimary,
27374 operators
27375 };
27376 }
27377 var get_filter_by_default = getFilterBy;
27378
27379 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
27380 var getValueFromId = (id) => ({ item }) => {
27381 const path = id.split(".");
27382 let value = item;
27383 for (const segment of path) {
27384 if (value.hasOwnProperty(segment)) {
27385 value = value[segment];
27386 } else {
27387 value = void 0;
27388 }
27389 }
27390 return value;
27391 };
27392 var get_value_from_id_default = getValueFromId;
27393
27394 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
27395 var setValueFromId = (id) => ({ value }) => {
27396 const path = id.split(".");
27397 const result = {};
27398 let current = result;
27399 for (const segment of path.slice(0, -1)) {
27400 current[segment] = {};
27401 current = current[segment];
27402 }
27403 current[path.at(-1)] = value;
27404 return result;
27405 };
27406 var set_value_from_id_default = setValueFromId;
27407
27408 // packages/dataviews/build-module/field-types/email.mjs
27409 var import_i18n40 = __toESM(require_i18n(), 1);
27410
27411 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
27412 function RenderFromElements({
27413 item,
27414 field
27415 }) {
27416 const { elements, isLoading } = useElements({
27417 elements: field.elements,
27418 getElements: field.getElements
27419 });
27420 const value = field.getValue({ item });
27421 if (isLoading) {
27422 return value;
27423 }
27424 if (elements.length === 0) {
27425 return value;
27426 }
27427 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
27428 }
27429
27430 // packages/dataviews/build-module/field-types/utils/render-default.mjs
27431 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
27432 function render({
27433 item,
27434 field
27435 }) {
27436 if (field.hasElements) {
27437 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(RenderFromElements, { item, field });
27438 }
27439 return field.getValueFormatted({ item, field });
27440 }
27441
27442 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
27443 var sort_text_default = (a2, b2, direction) => {
27444 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
27445 };
27446
27447 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
27448 function isValidRequired(item, field) {
27449 const value = field.getValue({ item });
27450 return ![void 0, "", null].includes(value);
27451 }
27452
27453 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
27454 function isValidMinLength(item, field) {
27455 if (typeof field.isValid.minLength?.constraint !== "number") {
27456 return false;
27457 }
27458 const value = field.getValue({ item });
27459 if ([void 0, "", null].includes(value)) {
27460 return true;
27461 }
27462 return String(value).length >= field.isValid.minLength.constraint;
27463 }
27464
27465 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
27466 function isValidMaxLength(item, field) {
27467 if (typeof field.isValid.maxLength?.constraint !== "number") {
27468 return false;
27469 }
27470 const value = field.getValue({ item });
27471 if ([void 0, "", null].includes(value)) {
27472 return true;
27473 }
27474 return String(value).length <= field.isValid.maxLength.constraint;
27475 }
27476
27477 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
27478 function isValidPattern(item, field) {
27479 if (field.isValid.pattern?.constraint === void 0) {
27480 return true;
27481 }
27482 try {
27483 const regexp = new RegExp(field.isValid.pattern.constraint);
27484 const value = field.getValue({ item });
27485 if ([void 0, "", null].includes(value)) {
27486 return true;
27487 }
27488 return regexp.test(String(value));
27489 } catch {
27490 return false;
27491 }
27492 }
27493
27494 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
27495 function isValidElements(item, field) {
27496 const elements = field.elements ?? [];
27497 const validValues = elements.map((el) => el.value);
27498 if (validValues.length === 0) {
27499 return true;
27500 }
27501 const value = field.getValue({ item });
27502 return [].concat(value).every((v2) => validValues.includes(v2));
27503 }
27504
27505 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
27506 function getValueFormatted({
27507 item,
27508 field
27509 }) {
27510 return field.getValue({ item });
27511 }
27512 var get_value_formatted_default_default = getValueFormatted;
27513
27514 // packages/dataviews/build-module/field-types/email.mjs
27515 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])?)*$/;
27516 function isValidCustom(item, field) {
27517 const value = field.getValue({ item });
27518 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
27519 return (0, import_i18n40.__)("Value must be a valid email address.");
27520 }
27521 return null;
27522 }
27523 var email_default = {
27524 type: "email",
27525 render,
27526 Edit: "email",
27527 sort: sort_text_default,
27528 enableSorting: true,
27529 enableGlobalSearch: false,
27530 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27531 validOperators: [
27532 OPERATOR_IS,
27533 OPERATOR_IS_NOT,
27534 OPERATOR_CONTAINS,
27535 OPERATOR_NOT_CONTAINS,
27536 OPERATOR_STARTS_WITH,
27537 // Multiple selection
27538 OPERATOR_IS_ANY,
27539 OPERATOR_IS_NONE,
27540 OPERATOR_IS_ALL,
27541 OPERATOR_IS_NOT_ALL
27542 ],
27543 format: {},
27544 getValueFormatted: get_value_formatted_default_default,
27545 validate: {
27546 required: isValidRequired,
27547 pattern: isValidPattern,
27548 minLength: isValidMinLength,
27549 maxLength: isValidMaxLength,
27550 elements: isValidElements,
27551 custom: isValidCustom
27552 }
27553 };
27554
27555 // packages/dataviews/build-module/field-types/integer.mjs
27556 var import_i18n41 = __toESM(require_i18n(), 1);
27557
27558 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
27559 var sort_number_default = (a2, b2, direction) => {
27560 return direction === "asc" ? a2 - b2 : b2 - a2;
27561 };
27562
27563 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
27564 function isValidMin(item, field) {
27565 if (typeof field.isValid.min?.constraint !== "number") {
27566 return false;
27567 }
27568 const value = field.getValue({ item });
27569 if ([void 0, "", null].includes(value)) {
27570 return true;
27571 }
27572 return Number(value) >= field.isValid.min.constraint;
27573 }
27574
27575 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
27576 function isValidMax(item, field) {
27577 if (typeof field.isValid.max?.constraint !== "number") {
27578 return false;
27579 }
27580 const value = field.getValue({ item });
27581 if ([void 0, "", null].includes(value)) {
27582 return true;
27583 }
27584 return Number(value) <= field.isValid.max.constraint;
27585 }
27586
27587 // packages/dataviews/build-module/field-types/integer.mjs
27588 var format2 = {
27589 separatorThousand: ","
27590 };
27591 function getValueFormatted2({
27592 item,
27593 field
27594 }) {
27595 let value = field.getValue({ item });
27596 if (value === null || value === void 0) {
27597 return "";
27598 }
27599 value = Number(value);
27600 if (!Number.isFinite(value)) {
27601 return String(value);
27602 }
27603 let formatInteger;
27604 if (field.type !== "integer") {
27605 formatInteger = format2;
27606 } else {
27607 formatInteger = field.format;
27608 }
27609 const { separatorThousand } = formatInteger;
27610 const integerValue = Math.trunc(value);
27611 if (!separatorThousand) {
27612 return String(integerValue);
27613 }
27614 return String(integerValue).replace(
27615 /\B(?=(\d{3})+(?!\d))/g,
27616 separatorThousand
27617 );
27618 }
27619 function isValidCustom2(item, field) {
27620 const value = field.getValue({ item });
27621 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
27622 return (0, import_i18n41.__)("Value must be an integer.");
27623 }
27624 return null;
27625 }
27626 var integer_default = {
27627 type: "integer",
27628 render,
27629 Edit: "integer",
27630 sort: sort_number_default,
27631 enableSorting: true,
27632 enableGlobalSearch: false,
27633 defaultOperators: [
27634 OPERATOR_IS,
27635 OPERATOR_IS_NOT,
27636 OPERATOR_LESS_THAN,
27637 OPERATOR_GREATER_THAN,
27638 OPERATOR_LESS_THAN_OR_EQUAL,
27639 OPERATOR_GREATER_THAN_OR_EQUAL,
27640 OPERATOR_BETWEEN
27641 ],
27642 validOperators: [
27643 // Single-selection
27644 OPERATOR_IS,
27645 OPERATOR_IS_NOT,
27646 OPERATOR_LESS_THAN,
27647 OPERATOR_GREATER_THAN,
27648 OPERATOR_LESS_THAN_OR_EQUAL,
27649 OPERATOR_GREATER_THAN_OR_EQUAL,
27650 OPERATOR_BETWEEN,
27651 // Multiple-selection
27652 OPERATOR_IS_ANY,
27653 OPERATOR_IS_NONE,
27654 OPERATOR_IS_ALL,
27655 OPERATOR_IS_NOT_ALL
27656 ],
27657 format: format2,
27658 getValueFormatted: getValueFormatted2,
27659 validate: {
27660 required: isValidRequired,
27661 min: isValidMin,
27662 max: isValidMax,
27663 elements: isValidElements,
27664 custom: isValidCustom2
27665 }
27666 };
27667
27668 // packages/dataviews/build-module/field-types/number.mjs
27669 var import_i18n42 = __toESM(require_i18n(), 1);
27670 var format3 = {
27671 separatorThousand: ",",
27672 separatorDecimal: ".",
27673 decimals: 2
27674 };
27675 function getValueFormatted3({
27676 item,
27677 field
27678 }) {
27679 let value = field.getValue({ item });
27680 if (value === null || value === void 0) {
27681 return "";
27682 }
27683 value = Number(value);
27684 if (!Number.isFinite(value)) {
27685 return String(value);
27686 }
27687 let formatNumber;
27688 if (field.type !== "number") {
27689 formatNumber = format3;
27690 } else {
27691 formatNumber = field.format;
27692 }
27693 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
27694 const fixedValue = value.toFixed(decimals);
27695 const [integerPart, decimalPart] = fixedValue.split(".");
27696 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
27697 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
27698 }
27699 function isEmpty2(value) {
27700 return value === "" || value === void 0 || value === null;
27701 }
27702 function isValidCustom3(item, field) {
27703 const value = field.getValue({ item });
27704 if (!isEmpty2(value) && !Number.isFinite(value)) {
27705 return (0, import_i18n42.__)("Value must be a number.");
27706 }
27707 return null;
27708 }
27709 var number_default = {
27710 type: "number",
27711 render,
27712 Edit: "number",
27713 sort: sort_number_default,
27714 enableSorting: true,
27715 enableGlobalSearch: false,
27716 defaultOperators: [
27717 OPERATOR_IS,
27718 OPERATOR_IS_NOT,
27719 OPERATOR_LESS_THAN,
27720 OPERATOR_GREATER_THAN,
27721 OPERATOR_LESS_THAN_OR_EQUAL,
27722 OPERATOR_GREATER_THAN_OR_EQUAL,
27723 OPERATOR_BETWEEN
27724 ],
27725 validOperators: [
27726 // Single-selection
27727 OPERATOR_IS,
27728 OPERATOR_IS_NOT,
27729 OPERATOR_LESS_THAN,
27730 OPERATOR_GREATER_THAN,
27731 OPERATOR_LESS_THAN_OR_EQUAL,
27732 OPERATOR_GREATER_THAN_OR_EQUAL,
27733 OPERATOR_BETWEEN,
27734 // Multiple-selection
27735 OPERATOR_IS_ANY,
27736 OPERATOR_IS_NONE,
27737 OPERATOR_IS_ALL,
27738 OPERATOR_IS_NOT_ALL
27739 ],
27740 format: format3,
27741 getValueFormatted: getValueFormatted3,
27742 validate: {
27743 required: isValidRequired,
27744 min: isValidMin,
27745 max: isValidMax,
27746 elements: isValidElements,
27747 custom: isValidCustom3
27748 }
27749 };
27750
27751 // packages/dataviews/build-module/field-types/text.mjs
27752 var text_default = {
27753 type: "text",
27754 render,
27755 Edit: "text",
27756 sort: sort_text_default,
27757 enableSorting: true,
27758 enableGlobalSearch: false,
27759 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27760 validOperators: [
27761 // Single selection
27762 OPERATOR_IS,
27763 OPERATOR_IS_NOT,
27764 OPERATOR_CONTAINS,
27765 OPERATOR_NOT_CONTAINS,
27766 OPERATOR_STARTS_WITH,
27767 // Multiple selection
27768 OPERATOR_IS_ANY,
27769 OPERATOR_IS_NONE,
27770 OPERATOR_IS_ALL,
27771 OPERATOR_IS_NOT_ALL
27772 ],
27773 format: {},
27774 getValueFormatted: get_value_formatted_default_default,
27775 validate: {
27776 required: isValidRequired,
27777 pattern: isValidPattern,
27778 minLength: isValidMinLength,
27779 maxLength: isValidMaxLength,
27780 elements: isValidElements
27781 }
27782 };
27783
27784 // packages/dataviews/build-module/field-types/datetime.mjs
27785 var import_date7 = __toESM(require_date(), 1);
27786
27787 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
27788 var import_date6 = __toESM(require_date(), 1);
27789 function parseDateLike(value) {
27790 if (!value) {
27791 return null;
27792 }
27793 if (!isValid(new Date(value))) {
27794 return null;
27795 }
27796 const parsed = (0, import_date6.getDate)(value);
27797 return parsed && isValid(parsed) ? parsed : null;
27798 }
27799 function validateDateLikeBoundary(item, field, boundary) {
27800 const constraint = field.isValid[boundary]?.constraint;
27801 if (typeof constraint !== "string") {
27802 return false;
27803 }
27804 const value = field.getValue({ item });
27805 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
27806 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
27807 return true;
27808 }
27809 const parsedConstraint = parseDateLike(constraint);
27810 const parsedValue = parseDateLike(String(boundaryValue));
27811 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
27812 }
27813 function isValidMinDate(item, field) {
27814 return validateDateLikeBoundary(item, field, "min");
27815 }
27816 function isValidMaxDate(item, field) {
27817 return validateDateLikeBoundary(item, field, "max");
27818 }
27819
27820 // packages/dataviews/build-module/field-types/datetime.mjs
27821 var format4 = {
27822 datetime: (0, import_date7.getSettings)().formats.datetime,
27823 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
27824 };
27825 function getValueFormatted4({
27826 item,
27827 field
27828 }) {
27829 const value = field.getValue({ item });
27830 if (["", void 0, null].includes(value)) {
27831 return "";
27832 }
27833 let formatDatetime;
27834 if (field.type !== "datetime") {
27835 formatDatetime = format4;
27836 } else {
27837 formatDatetime = field.format;
27838 }
27839 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
27840 }
27841 var sort = (a2, b2, direction) => {
27842 const timeA = new Date(a2).getTime();
27843 const timeB = new Date(b2).getTime();
27844 return direction === "asc" ? timeA - timeB : timeB - timeA;
27845 };
27846 var datetime_default = {
27847 type: "datetime",
27848 render,
27849 Edit: "datetime",
27850 sort,
27851 enableSorting: true,
27852 enableGlobalSearch: false,
27853 defaultOperators: [
27854 OPERATOR_ON,
27855 OPERATOR_NOT_ON,
27856 OPERATOR_BEFORE,
27857 OPERATOR_AFTER,
27858 OPERATOR_BEFORE_INC,
27859 OPERATOR_AFTER_INC,
27860 OPERATOR_IN_THE_PAST,
27861 OPERATOR_OVER
27862 ],
27863 validOperators: [
27864 OPERATOR_ON,
27865 OPERATOR_NOT_ON,
27866 OPERATOR_BEFORE,
27867 OPERATOR_AFTER,
27868 OPERATOR_BEFORE_INC,
27869 OPERATOR_AFTER_INC,
27870 OPERATOR_IN_THE_PAST,
27871 OPERATOR_OVER
27872 ],
27873 format: format4,
27874 getValueFormatted: getValueFormatted4,
27875 validate: {
27876 required: isValidRequired,
27877 elements: isValidElements,
27878 min: isValidMinDate,
27879 max: isValidMaxDate
27880 }
27881 };
27882
27883 // packages/dataviews/build-module/field-types/date.mjs
27884 var import_date8 = __toESM(require_date(), 1);
27885 var format5 = {
27886 date: (0, import_date8.getSettings)().formats.date,
27887 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
27888 };
27889 function getValueFormatted5({
27890 item,
27891 field
27892 }) {
27893 const value = field.getValue({ item });
27894 if (["", void 0, null].includes(value)) {
27895 return "";
27896 }
27897 let formatDate2;
27898 if (field.type !== "date") {
27899 formatDate2 = format5;
27900 } else {
27901 formatDate2 = field.format;
27902 }
27903 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
27904 }
27905 var sort2 = (a2, b2, direction) => {
27906 const timeA = new Date(a2).getTime();
27907 const timeB = new Date(b2).getTime();
27908 return direction === "asc" ? timeA - timeB : timeB - timeA;
27909 };
27910 var date_default = {
27911 type: "date",
27912 render,
27913 Edit: "date",
27914 sort: sort2,
27915 enableSorting: true,
27916 enableGlobalSearch: false,
27917 defaultOperators: [
27918 OPERATOR_ON,
27919 OPERATOR_NOT_ON,
27920 OPERATOR_BEFORE,
27921 OPERATOR_AFTER,
27922 OPERATOR_BEFORE_INC,
27923 OPERATOR_AFTER_INC,
27924 OPERATOR_IN_THE_PAST,
27925 OPERATOR_OVER,
27926 OPERATOR_BETWEEN
27927 ],
27928 validOperators: [
27929 OPERATOR_ON,
27930 OPERATOR_NOT_ON,
27931 OPERATOR_BEFORE,
27932 OPERATOR_AFTER,
27933 OPERATOR_BEFORE_INC,
27934 OPERATOR_AFTER_INC,
27935 OPERATOR_IN_THE_PAST,
27936 OPERATOR_OVER,
27937 OPERATOR_BETWEEN
27938 ],
27939 format: format5,
27940 getValueFormatted: getValueFormatted5,
27941 validate: {
27942 required: isValidRequired,
27943 elements: isValidElements,
27944 min: isValidMinDate,
27945 max: isValidMaxDate
27946 }
27947 };
27948
27949 // packages/dataviews/build-module/field-types/boolean.mjs
27950 var import_i18n43 = __toESM(require_i18n(), 1);
27951
27952 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
27953 function isValidRequiredForBool(item, field) {
27954 const value = field.getValue({ item });
27955 return value === true;
27956 }
27957
27958 // packages/dataviews/build-module/field-types/boolean.mjs
27959 function getValueFormatted6({
27960 item,
27961 field
27962 }) {
27963 const value = field.getValue({ item });
27964 if (value === true) {
27965 return (0, import_i18n43.__)("True");
27966 }
27967 if (value === false) {
27968 return (0, import_i18n43.__)("False");
27969 }
27970 return "";
27971 }
27972 function isValidCustom4(item, field) {
27973 const value = field.getValue({ item });
27974 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
27975 return (0, import_i18n43.__)("Value must be true, false, or undefined");
27976 }
27977 return null;
27978 }
27979 var sort3 = (a2, b2, direction) => {
27980 const boolA = Boolean(a2);
27981 const boolB = Boolean(b2);
27982 if (boolA === boolB) {
27983 return 0;
27984 }
27985 if (direction === "asc") {
27986 return boolA ? 1 : -1;
27987 }
27988 return boolA ? -1 : 1;
27989 };
27990 var boolean_default = {
27991 type: "boolean",
27992 render,
27993 Edit: "checkbox",
27994 sort: sort3,
27995 validate: {
27996 required: isValidRequiredForBool,
27997 elements: isValidElements,
27998 custom: isValidCustom4
27999 },
28000 enableSorting: true,
28001 enableGlobalSearch: false,
28002 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
28003 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
28004 format: {},
28005 getValueFormatted: getValueFormatted6
28006 };
28007
28008 // packages/dataviews/build-module/field-types/media.mjs
28009 var media_default = {
28010 type: "media",
28011 render: () => null,
28012 Edit: null,
28013 sort: () => 0,
28014 enableSorting: false,
28015 enableGlobalSearch: false,
28016 defaultOperators: [],
28017 validOperators: [],
28018 format: {},
28019 getValueFormatted: get_value_formatted_default_default,
28020 // cannot validate any constraint, so
28021 // the only available validation for the field author
28022 // would be providing a custom validator.
28023 validate: {}
28024 };
28025
28026 // packages/dataviews/build-module/field-types/array.mjs
28027 var import_i18n44 = __toESM(require_i18n(), 1);
28028
28029 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
28030 function isValidRequiredForArray(item, field) {
28031 const value = field.getValue({ item });
28032 return Array.isArray(value) && value.length > 0 && value.every(
28033 (element) => ![void 0, "", null].includes(element)
28034 );
28035 }
28036
28037 // packages/dataviews/build-module/field-types/array.mjs
28038 function getValueFormatted7({
28039 item,
28040 field
28041 }) {
28042 const value = field.getValue({ item });
28043 const arr = Array.isArray(value) ? value : [];
28044 return arr.join(", ");
28045 }
28046 function render2({ item, field }) {
28047 return getValueFormatted7({ item, field });
28048 }
28049 function isValidCustom5(item, field) {
28050 const value = field.getValue({ item });
28051 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
28052 return (0, import_i18n44.__)("Value must be an array.");
28053 }
28054 if (!value.every((v2) => typeof v2 === "string")) {
28055 return (0, import_i18n44.__)("Every value must be a string.");
28056 }
28057 return null;
28058 }
28059 var sort4 = (a2, b2, direction) => {
28060 const arrA = Array.isArray(a2) ? a2 : [];
28061 const arrB = Array.isArray(b2) ? b2 : [];
28062 if (arrA.length !== arrB.length) {
28063 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
28064 }
28065 const joinedA = arrA.join(",");
28066 const joinedB = arrB.join(",");
28067 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
28068 };
28069 var array_default = {
28070 type: "array",
28071 render: render2,
28072 Edit: "array",
28073 sort: sort4,
28074 enableSorting: true,
28075 enableGlobalSearch: false,
28076 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28077 validOperators: [
28078 OPERATOR_IS_ANY,
28079 OPERATOR_IS_NONE,
28080 OPERATOR_IS_ALL,
28081 OPERATOR_IS_NOT_ALL
28082 ],
28083 format: {},
28084 getValueFormatted: getValueFormatted7,
28085 validate: {
28086 required: isValidRequiredForArray,
28087 elements: isValidElements,
28088 custom: isValidCustom5
28089 }
28090 };
28091
28092 // packages/dataviews/build-module/field-types/password.mjs
28093 function getValueFormatted8({
28094 item,
28095 field
28096 }) {
28097 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
28098 }
28099 var password_default = {
28100 type: "password",
28101 render,
28102 Edit: "password",
28103 sort: () => 0,
28104 // Passwords should not be sortable for security reasons
28105 enableSorting: false,
28106 enableGlobalSearch: false,
28107 defaultOperators: [],
28108 validOperators: [],
28109 format: {},
28110 getValueFormatted: getValueFormatted8,
28111 validate: {
28112 required: isValidRequired,
28113 pattern: isValidPattern,
28114 minLength: isValidMinLength,
28115 maxLength: isValidMaxLength,
28116 elements: isValidElements
28117 }
28118 };
28119
28120 // packages/dataviews/build-module/field-types/telephone.mjs
28121 var telephone_default = {
28122 type: "telephone",
28123 render,
28124 Edit: "telephone",
28125 sort: sort_text_default,
28126 enableSorting: true,
28127 enableGlobalSearch: false,
28128 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28129 validOperators: [
28130 OPERATOR_IS,
28131 OPERATOR_IS_NOT,
28132 OPERATOR_CONTAINS,
28133 OPERATOR_NOT_CONTAINS,
28134 OPERATOR_STARTS_WITH,
28135 // Multiple selection
28136 OPERATOR_IS_ANY,
28137 OPERATOR_IS_NONE,
28138 OPERATOR_IS_ALL,
28139 OPERATOR_IS_NOT_ALL
28140 ],
28141 format: {},
28142 getValueFormatted: get_value_formatted_default_default,
28143 validate: {
28144 required: isValidRequired,
28145 pattern: isValidPattern,
28146 minLength: isValidMinLength,
28147 maxLength: isValidMaxLength,
28148 elements: isValidElements
28149 }
28150 };
28151
28152 // packages/dataviews/build-module/field-types/color.mjs
28153 var import_i18n45 = __toESM(require_i18n(), 1);
28154 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
28155 function render3({ item, field }) {
28156 if (field.hasElements) {
28157 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(RenderFromElements, { item, field });
28158 }
28159 const value = get_value_formatted_default_default({ item, field });
28160 if (!value || !w(value).isValid()) {
28161 return value;
28162 }
28163 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
28164 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28165 "div",
28166 {
28167 style: {
28168 width: "16px",
28169 height: "16px",
28170 borderRadius: "50%",
28171 backgroundColor: value,
28172 border: "1px solid #ddd",
28173 flexShrink: 0
28174 }
28175 }
28176 ),
28177 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("span", { children: value })
28178 ] });
28179 }
28180 function isValidCustom6(item, field) {
28181 const value = field.getValue({ item });
28182 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
28183 return (0, import_i18n45.__)("Value must be a valid color.");
28184 }
28185 return null;
28186 }
28187 var sort5 = (a2, b2, direction) => {
28188 const colorA = w(a2);
28189 const colorB = w(b2);
28190 if (!colorA.isValid() && !colorB.isValid()) {
28191 return 0;
28192 }
28193 if (!colorA.isValid()) {
28194 return direction === "asc" ? 1 : -1;
28195 }
28196 if (!colorB.isValid()) {
28197 return direction === "asc" ? -1 : 1;
28198 }
28199 const hslA = colorA.toHsl();
28200 const hslB = colorB.toHsl();
28201 if (hslA.h !== hslB.h) {
28202 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
28203 }
28204 if (hslA.s !== hslB.s) {
28205 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
28206 }
28207 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
28208 };
28209 var color_default = {
28210 type: "color",
28211 render: render3,
28212 Edit: "color",
28213 sort: sort5,
28214 enableSorting: true,
28215 enableGlobalSearch: false,
28216 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28217 validOperators: [
28218 OPERATOR_IS,
28219 OPERATOR_IS_NOT,
28220 OPERATOR_IS_ANY,
28221 OPERATOR_IS_NONE
28222 ],
28223 format: {},
28224 getValueFormatted: get_value_formatted_default_default,
28225 validate: {
28226 required: isValidRequired,
28227 elements: isValidElements,
28228 custom: isValidCustom6
28229 }
28230 };
28231
28232 // packages/dataviews/build-module/field-types/url.mjs
28233 var url_default = {
28234 type: "url",
28235 render,
28236 Edit: "url",
28237 sort: sort_text_default,
28238 enableSorting: true,
28239 enableGlobalSearch: false,
28240 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28241 validOperators: [
28242 OPERATOR_IS,
28243 OPERATOR_IS_NOT,
28244 OPERATOR_CONTAINS,
28245 OPERATOR_NOT_CONTAINS,
28246 OPERATOR_STARTS_WITH,
28247 // Multiple selection
28248 OPERATOR_IS_ANY,
28249 OPERATOR_IS_NONE,
28250 OPERATOR_IS_ALL,
28251 OPERATOR_IS_NOT_ALL
28252 ],
28253 format: {},
28254 getValueFormatted: get_value_formatted_default_default,
28255 validate: {
28256 required: isValidRequired,
28257 pattern: isValidPattern,
28258 minLength: isValidMinLength,
28259 maxLength: isValidMaxLength,
28260 elements: isValidElements
28261 }
28262 };
28263
28264 // packages/dataviews/build-module/field-types/no-type.mjs
28265 var sort6 = (a2, b2, direction) => {
28266 if (typeof a2 === "number" && typeof b2 === "number") {
28267 return sort_number_default(a2, b2, direction);
28268 }
28269 return sort_text_default(a2, b2, direction);
28270 };
28271 var no_type_default = {
28272 // type: no type for this one
28273 render,
28274 Edit: null,
28275 sort: sort6,
28276 enableSorting: true,
28277 enableGlobalSearch: false,
28278 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
28279 validOperators: getAllOperatorNames(),
28280 format: {},
28281 getValueFormatted: get_value_formatted_default_default,
28282 validate: {
28283 required: isValidRequired,
28284 elements: isValidElements
28285 }
28286 };
28287
28288 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
28289 function supportsNumericRangeConstraint(type) {
28290 return type === "integer" || type === "number";
28291 }
28292 function supportsDateRangeConstraint(type) {
28293 return type === "date" || type === "datetime";
28294 }
28295 function normalizeRangeRule(value, fieldType, key) {
28296 const validator = fieldType.validate[key];
28297 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
28298 return { constraint: value, validate: validator };
28299 }
28300 return void 0;
28301 }
28302 function getIsValid(field, fieldType) {
28303 const rules = field.isValid;
28304 let required;
28305 if (rules?.required === true && fieldType.validate.required !== void 0) {
28306 required = {
28307 constraint: true,
28308 validate: fieldType.validate.required
28309 };
28310 }
28311 let elements;
28312 if ((rules?.elements === true || // elements is enabled unless the field opts-out
28313 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
28314 elements = {
28315 constraint: true,
28316 validate: fieldType.validate.elements
28317 };
28318 }
28319 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
28320 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
28321 const minLengthValue = rules?.minLength;
28322 let minLength;
28323 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
28324 minLength = {
28325 constraint: minLengthValue,
28326 validate: fieldType.validate.minLength
28327 };
28328 }
28329 const maxLengthValue = rules?.maxLength;
28330 let maxLength;
28331 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
28332 maxLength = {
28333 constraint: maxLengthValue,
28334 validate: fieldType.validate.maxLength
28335 };
28336 }
28337 const patternValue = rules?.pattern;
28338 let pattern;
28339 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
28340 pattern = {
28341 constraint: patternValue,
28342 validate: fieldType.validate.pattern
28343 };
28344 }
28345 const custom = rules?.custom ?? fieldType.validate.custom;
28346 return {
28347 required,
28348 elements,
28349 min: min2,
28350 max: max2,
28351 minLength,
28352 maxLength,
28353 pattern,
28354 custom
28355 };
28356 }
28357
28358 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
28359 function getFilter(fieldType) {
28360 return fieldType.validOperators.reduce((accumulator, operator) => {
28361 const operatorObj = getOperatorByName(operator);
28362 if (operatorObj?.filter) {
28363 accumulator[operator] = operatorObj.filter;
28364 }
28365 return accumulator;
28366 }, {});
28367 }
28368
28369 // packages/dataviews/build-module/field-types/utils/get-format.mjs
28370 function getFormat(field, fieldType) {
28371 return {
28372 ...fieldType.format,
28373 ...field.format
28374 };
28375 }
28376 var get_format_default = getFormat;
28377
28378 // packages/dataviews/build-module/field-types/index.mjs
28379 function getFieldTypeByName(type) {
28380 const found = [
28381 email_default,
28382 integer_default,
28383 number_default,
28384 text_default,
28385 datetime_default,
28386 date_default,
28387 boolean_default,
28388 media_default,
28389 array_default,
28390 password_default,
28391 telephone_default,
28392 color_default,
28393 url_default
28394 ].find((fieldType) => fieldType?.type === type);
28395 if (!!found) {
28396 return found;
28397 }
28398 return no_type_default;
28399 }
28400 function normalizeFields(fields) {
28401 return fields.map((field) => {
28402 const fieldType = getFieldTypeByName(field.type);
28403 const getValue = field.getValue || get_value_from_id_default(field.id);
28404 const sort7 = function(a2, b2, direction) {
28405 const aValue = getValue({ item: a2 });
28406 const bValue = getValue({ item: b2 });
28407 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
28408 };
28409 return {
28410 id: field.id,
28411 label: field.label || field.id,
28412 header: field.header || field.label || field.id,
28413 description: field.description,
28414 placeholder: field.placeholder,
28415 getValue,
28416 setValue: field.setValue || set_value_from_id_default(field.id),
28417 elements: field.elements,
28418 getElements: field.getElements,
28419 hasElements: hasElements(field),
28420 isVisible: field.isVisible,
28421 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
28422 enableHiding: field.enableHiding ?? true,
28423 readOnly: field.readOnly ?? false,
28424 // The type provides defaults for the following props
28425 type: fieldType.type,
28426 render: field.render ?? fieldType.render,
28427 Edit: getControl(field, fieldType.Edit),
28428 sort: sort7,
28429 enableSorting: field.enableSorting ?? fieldType.enableSorting,
28430 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
28431 isValid: getIsValid(field, fieldType),
28432 filterBy: get_filter_by_default(
28433 field,
28434 fieldType.defaultOperators,
28435 fieldType.validOperators
28436 ),
28437 filter: getFilter(fieldType),
28438 format: get_format_default(field, fieldType),
28439 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
28440 };
28441 });
28442 }
28443
28444 // packages/dataviews/build-module/hooks/use-data.mjs
28445 var import_element97 = __toESM(require_element(), 1);
28446 function useData({
28447 view,
28448 data: shownData,
28449 getItemId,
28450 isLoading,
28451 paginationInfo,
28452 selection
28453 }) {
28454 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
28455 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element97.useState)(
28456 !isLoading
28457 );
28458 (0, import_element97.useEffect)(() => {
28459 if (!isLoading) {
28460 setHasInitiallyLoaded(true);
28461 }
28462 }, [isLoading]);
28463 const previousDataRef = (0, import_element97.useRef)(shownData);
28464 const previousPaginationInfoRef = (0, import_element97.useRef)(paginationInfo);
28465 (0, import_element97.useEffect)(() => {
28466 if (!isLoading) {
28467 previousDataRef.current = shownData;
28468 previousPaginationInfoRef.current = paginationInfo;
28469 }
28470 }, [shownData, isLoading, paginationInfo]);
28471 const [visibleEntries, setVisibleEntries] = (0, import_element97.useState)([]);
28472 const positionMapRef = (0, import_element97.useRef)(/* @__PURE__ */ new Map());
28473 const allLoadedRecordsRef = (0, import_element97.useRef)([]);
28474 const prevViewParamsRef = (0, import_element97.useRef)({
28475 search: void 0,
28476 filters: void 0,
28477 perPage: void 0
28478 });
28479 const scrollDirectionRef = (0, import_element97.useRef)(void 0);
28480 const prevStartPositionRef = (0, import_element97.useRef)(void 0);
28481 const hasInitializedRef = (0, import_element97.useRef)(false);
28482 const allLoadedRecords = (0, import_element97.useMemo)(() => {
28483 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
28484 if (view.startPosition < prevStartPositionRef.current) {
28485 scrollDirectionRef.current = "up";
28486 } else if (view.startPosition > prevStartPositionRef.current) {
28487 scrollDirectionRef.current = "down";
28488 }
28489 }
28490 prevStartPositionRef.current = view.startPosition;
28491 const currentFiltersKey = JSON.stringify(view.filters ?? []);
28492 const prevFiltersKey = prevViewParamsRef.current.filters;
28493 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
28494 hasInitializedRef.current = true;
28495 prevViewParamsRef.current = {
28496 search: view.search,
28497 filters: currentFiltersKey,
28498 perPage: view.perPage
28499 };
28500 if (shouldReset) {
28501 positionMapRef.current.clear();
28502 scrollDirectionRef.current = void 0;
28503 const startPosition = view.search ? 1 : view.startPosition ?? 1;
28504 const records = shownData.map((record, index2) => {
28505 const position = startPosition + index2;
28506 positionMapRef.current.set(getItemId(record), position);
28507 return {
28508 ...record,
28509 position
28510 };
28511 });
28512 allLoadedRecordsRef.current = records;
28513 return records;
28514 }
28515 const prev = allLoadedRecordsRef.current;
28516 const shownDataIds = new Set(shownData.map(getItemId));
28517 const scrollDirection = scrollDirectionRef.current;
28518 const basePosition = view.search ? 1 : view.startPosition ?? 1;
28519 const newRecords = shownData.map((record, index2) => {
28520 const itemId = getItemId(record);
28521 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
28522 if (position !== void 0) {
28523 positionMapRef.current.set(itemId, position);
28524 }
28525 return {
28526 ...record,
28527 position
28528 };
28529 });
28530 if (newRecords.length === 0) {
28531 return prev;
28532 }
28533 const prevWithoutDuplicates = prev.filter(
28534 (record) => !shownDataIds.has(getItemId(record))
28535 );
28536 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
28537 allRecords.sort((a2, b2) => {
28538 const posA = a2.position;
28539 const posB = b2.position;
28540 return posA - posB;
28541 });
28542 let result = allRecords;
28543 if (visibleEntries.length > 0) {
28544 const visibleMin = Math.min(...visibleEntries);
28545 const visibleMax = Math.max(...visibleEntries);
28546 const buffer = 20;
28547 const recordPositions = allRecords.map(
28548 (r3) => r3.position
28549 );
28550 const minRecordPos = Math.min(...recordPositions);
28551 const maxRecordPos = Math.max(...recordPositions);
28552 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
28553 if (hasOverlap) {
28554 result = allRecords.filter((record) => {
28555 const itemId = getItemId(record);
28556 const isSelected2 = selection?.includes(itemId);
28557 if (isSelected2) {
28558 return true;
28559 }
28560 const itemPosition = record.position;
28561 if (scrollDirection === "up") {
28562 return itemPosition <= visibleMax + buffer;
28563 } else if (scrollDirection === "down") {
28564 return itemPosition >= visibleMin - buffer;
28565 }
28566 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
28567 });
28568 }
28569 }
28570 allLoadedRecordsRef.current = result;
28571 return result;
28572 }, [
28573 shownData,
28574 view.search,
28575 view.filters,
28576 view.perPage,
28577 view.startPosition,
28578 view.infiniteScrollEnabled,
28579 visibleEntries,
28580 selection,
28581 getItemId
28582 ]);
28583 if (!isInfiniteScrollEnabled) {
28584 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
28585 return {
28586 data: dataToReturn.map((item) => ({
28587 ...item,
28588 position: void 0
28589 })),
28590 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
28591 hasInitiallyLoaded,
28592 setVisibleEntries: void 0
28593 };
28594 }
28595 return {
28596 data: allLoadedRecords,
28597 paginationInfo,
28598 hasInitiallyLoaded,
28599 setVisibleEntries
28600 };
28601 }
28602
28603 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
28604 var import_element98 = __toESM(require_element(), 1);
28605 var import_compose12 = __toESM(require_compose(), 1);
28606 function captureAnchorElement(container, anchorElementRef, direction) {
28607 const containerRect = container.getBoundingClientRect();
28608 const centerY = containerRect.top + containerRect.height / 2;
28609 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
28610 if (items.length === 0) {
28611 return false;
28612 }
28613 const bestAnchor = items.reduce((best, item) => {
28614 const itemRect = item.getBoundingClientRect();
28615 const itemCenterY = itemRect.top + itemRect.height / 2;
28616 const distance = Math.abs(itemCenterY - centerY);
28617 const bestRect = best.getBoundingClientRect();
28618 const bestCenterY = bestRect.top + bestRect.height / 2;
28619 const bestDistance = Math.abs(bestCenterY - centerY);
28620 return distance < bestDistance ? item : best;
28621 });
28622 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
28623 const anchorRect = bestAnchor.getBoundingClientRect();
28624 anchorElementRef.current = {
28625 posinset,
28626 viewportOffset: anchorRect.top - containerRect.top,
28627 direction
28628 };
28629 return true;
28630 }
28631 function useInfiniteScroll({
28632 view,
28633 onChangeView,
28634 isLoading,
28635 paginationInfo,
28636 containerRef,
28637 setVisibleEntries
28638 }) {
28639 const anchorElementRef = (0, import_element98.useRef)(null);
28640 const viewRef = (0, import_element98.useRef)(view);
28641 const isLoadingRef = (0, import_element98.useRef)(isLoading);
28642 const onChangeViewRef = (0, import_element98.useRef)(onChangeView);
28643 const totalItemsRef = (0, import_element98.useRef)(paginationInfo.totalItems);
28644 (0, import_element98.useLayoutEffect)(() => {
28645 viewRef.current = view;
28646 isLoadingRef.current = isLoading;
28647 onChangeViewRef.current = onChangeView;
28648 totalItemsRef.current = paginationInfo.totalItems;
28649 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
28650 const intersectionObserverCallback = (0, import_element98.useCallback)(
28651 (entries) => {
28652 if (!setVisibleEntries) {
28653 return;
28654 }
28655 setVisibleEntries((prev) => {
28656 const newVisibleEntries = new Set(prev);
28657 let hasChanged = false;
28658 entries.forEach((entry) => {
28659 const posInSet = Number(
28660 entry.target?.attributes?.getNamedItem(
28661 "aria-posinset"
28662 )?.value
28663 );
28664 if (isNaN(posInSet)) {
28665 return;
28666 }
28667 if (entry.isIntersecting) {
28668 if (!newVisibleEntries.has(posInSet)) {
28669 newVisibleEntries.add(posInSet);
28670 hasChanged = true;
28671 }
28672 } else if (newVisibleEntries.has(posInSet)) {
28673 newVisibleEntries.delete(posInSet);
28674 hasChanged = true;
28675 }
28676 });
28677 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
28678 });
28679 },
28680 [setVisibleEntries]
28681 );
28682 (0, import_element98.useLayoutEffect)(() => {
28683 const container = containerRef.current;
28684 const anchor = anchorElementRef.current;
28685 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
28686 return;
28687 }
28688 const anchorElement = container.querySelector(
28689 `[aria-posinset="${anchor.posinset}"]`
28690 );
28691 if (anchorElement) {
28692 const containerRect = container.getBoundingClientRect();
28693 const anchorRect = anchorElement.getBoundingClientRect();
28694 const currentOffset = anchorRect.top - containerRect.top;
28695 const scrollAdjustment = currentOffset - anchor.viewportOffset;
28696 if (Math.abs(scrollAdjustment) > 1) {
28697 container.scrollTop += scrollAdjustment;
28698 }
28699 }
28700 anchorElementRef.current = null;
28701 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
28702 const intersectionObserverRef = (0, import_element98.useRef)(
28703 null
28704 );
28705 (0, import_element98.useEffect)(() => {
28706 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
28707 if (intersectionObserverRef.current) {
28708 intersectionObserverRef.current.disconnect();
28709 intersectionObserverRef.current = null;
28710 }
28711 return;
28712 }
28713 intersectionObserverRef.current = new IntersectionObserver(
28714 intersectionObserverCallback,
28715 { root: null, rootMargin: "0px", threshold: 0.1 }
28716 );
28717 return () => {
28718 if (intersectionObserverRef.current) {
28719 intersectionObserverRef.current.disconnect();
28720 intersectionObserverRef.current = null;
28721 }
28722 };
28723 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
28724 (0, import_element98.useEffect)(() => {
28725 if (!view.infiniteScrollEnabled || !containerRef.current) {
28726 return;
28727 }
28728 let lastScrollTop = 0;
28729 const BOTTOM_THRESHOLD = 600;
28730 const TOP_THRESHOLD = 800;
28731 const handleScroll = (0, import_compose12.throttle)((event) => {
28732 const currentView = viewRef.current;
28733 const totalItems = totalItemsRef.current;
28734 const target = event.target;
28735 const scrollTop = target.scrollTop;
28736 const scrollHeight = target.scrollHeight;
28737 const clientHeight = target.clientHeight;
28738 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
28739 lastScrollTop = scrollTop;
28740 if (isLoadingRef.current) {
28741 return;
28742 }
28743 const currentStartPosition = currentView.startPosition || 1;
28744 const batchSize = currentView.perPage || 10;
28745 const currentEndPosition = Math.min(
28746 currentStartPosition + batchSize,
28747 totalItems
28748 );
28749 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
28750 if (currentEndPosition < totalItems) {
28751 const newStartPosition = currentEndPosition;
28752 captureAnchorElement(target, anchorElementRef, "down");
28753 onChangeViewRef.current({
28754 ...currentView,
28755 startPosition: newStartPosition
28756 });
28757 }
28758 }
28759 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
28760 if (currentStartPosition > 1) {
28761 const calculatedStartPosition = currentStartPosition - batchSize;
28762 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
28763 captureAnchorElement(target, anchorElementRef, "up");
28764 onChangeViewRef.current({
28765 ...currentView,
28766 startPosition: newStartPosition
28767 });
28768 }
28769 }
28770 }, 50);
28771 const container = containerRef.current;
28772 container.addEventListener("scroll", handleScroll);
28773 return () => {
28774 container.removeEventListener("scroll", handleScroll);
28775 handleScroll.cancel();
28776 };
28777 }, [containerRef, view.infiniteScrollEnabled]);
28778 return {
28779 intersectionObserver: intersectionObserverRef.current
28780 };
28781 }
28782
28783 // packages/dataviews/build-module/dataviews/index.mjs
28784 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
28785 var defaultGetItemId = (item) => item.id;
28786 var defaultIsItemClickable = () => true;
28787 var EMPTY_ARRAY6 = [];
28788 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
28789 var dataViewsLayouts = VIEW_LAYOUTS.filter(
28790 (viewLayout) => !viewLayout.isPicker
28791 );
28792 function DefaultUI({
28793 header,
28794 search = true,
28795 searchLabel = void 0
28796 }) {
28797 const { view } = (0, import_element99.useContext)(dataviews_context_default);
28798 const isInfiniteScroll = view.infiniteScrollEnabled;
28799 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [
28800 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
28801 Stack,
28802 {
28803 direction: "row",
28804 align: "top",
28805 justify: "space-between",
28806 className: clsx_default("dataviews__view-actions", {
28807 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
28808 }),
28809 gap: "xs",
28810 children: [
28811 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
28812 Stack,
28813 {
28814 direction: "row",
28815 justify: "start",
28816 gap: "sm",
28817 className: "dataviews__search",
28818 children: [
28819 search && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(dataviews_search_default, { label: searchLabel }),
28820 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(toggle_default, {})
28821 ]
28822 }
28823 ),
28824 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
28825 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(dataviews_view_config_default, {}),
28826 header
28827 ] })
28828 ]
28829 }
28830 ),
28831 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
28832 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(DataViewsLayout, {}),
28833 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(DataViewsFooter, {})
28834 ] });
28835 }
28836 function DataViews({
28837 view,
28838 onChangeView,
28839 fields,
28840 search = true,
28841 searchLabel = void 0,
28842 actions = EMPTY_ARRAY6,
28843 data,
28844 getItemId = defaultGetItemId,
28845 getItemLevel,
28846 isLoading = false,
28847 paginationInfo,
28848 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
28849 selection: selectionProperty,
28850 onChangeSelection,
28851 onClickItem,
28852 renderItemLink,
28853 isItemClickable = defaultIsItemClickable,
28854 header,
28855 children,
28856 config = { perPageSizes: [10, 20, 50, 100] },
28857 empty,
28858 onReset
28859 }) {
28860 const [selectionState, setSelectionState] = (0, import_element99.useState)([]);
28861 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
28862 const selection = isUncontrolled ? selectionState : selectionProperty;
28863 const {
28864 data: displayData,
28865 paginationInfo: displayPaginationInfo,
28866 hasInitiallyLoaded,
28867 setVisibleEntries
28868 } = useData({
28869 view,
28870 data,
28871 getItemId,
28872 isLoading,
28873 selection,
28874 paginationInfo
28875 });
28876 const containerRef = (0, import_element99.useRef)(null);
28877 const [containerWidth, setContainerWidth] = (0, import_element99.useState)(0);
28878 const resizeObserverRef = (0, import_compose13.useResizeObserver)(
28879 (resizeObserverEntries) => {
28880 setContainerWidth(
28881 resizeObserverEntries[0].borderBoxSize[0].inlineSize
28882 );
28883 },
28884 { box: "border-box" }
28885 );
28886 const [openedFilter, setOpenedFilter] = (0, import_element99.useState)(null);
28887 function setSelectionWithChange(value) {
28888 const newValue = typeof value === "function" ? value(selection) : value;
28889 if (isUncontrolled) {
28890 setSelectionState(newValue);
28891 }
28892 if (onChangeSelection) {
28893 onChangeSelection(newValue);
28894 }
28895 }
28896 const _fields = (0, import_element99.useMemo)(() => normalizeFields(fields), [fields]);
28897 const _selection = (0, import_element99.useMemo)(() => {
28898 if (view.infiniteScrollEnabled) {
28899 return selection;
28900 }
28901 return selection.filter(
28902 (id) => data.some((item) => getItemId(item) === id)
28903 );
28904 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
28905 const filters = use_filters_default(_fields, view);
28906 const hasPrimaryOrLockedFilters = (0, import_element99.useMemo)(
28907 () => (filters || []).some(
28908 (filter) => filter.isPrimary || filter.isLocked
28909 ),
28910 [filters]
28911 );
28912 const [isShowingFilter, setIsShowingFilter] = (0, import_element99.useState)(
28913 hasPrimaryOrLockedFilters
28914 );
28915 const { intersectionObserver } = useInfiniteScroll({
28916 view,
28917 onChangeView,
28918 isLoading,
28919 paginationInfo,
28920 containerRef,
28921 setVisibleEntries
28922 });
28923 (0, import_element99.useEffect)(() => {
28924 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
28925 setIsShowingFilter(true);
28926 }
28927 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
28928 const defaultLayouts = (0, import_element99.useMemo)(
28929 () => Object.fromEntries(
28930 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
28931 return dataViewsLayouts.some(
28932 (viewLayout) => viewLayout.type === layoutType
28933 );
28934 }).map(([key, value]) => [
28935 key,
28936 value === true ? {} : value
28937 ])
28938 ),
28939 [defaultLayoutsProperty]
28940 );
28941 if (!defaultLayouts[view.type]) {
28942 return null;
28943 }
28944 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28945 dataviews_context_default.Provider,
28946 {
28947 value: {
28948 view,
28949 onChangeView,
28950 fields: _fields,
28951 actions,
28952 data: displayData,
28953 isLoading,
28954 paginationInfo: displayPaginationInfo,
28955 selection: _selection,
28956 onChangeSelection: setSelectionWithChange,
28957 openedFilter,
28958 setOpenedFilter,
28959 getItemId,
28960 getItemLevel,
28961 isItemClickable,
28962 onClickItem,
28963 renderItemLink,
28964 containerWidth,
28965 containerRef,
28966 resizeObserverRef,
28967 defaultLayouts,
28968 filters,
28969 isShowingFilter,
28970 setIsShowingFilter,
28971 config,
28972 empty,
28973 hasInitiallyLoaded,
28974 onReset,
28975 intersectionObserver
28976 },
28977 children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28978 DefaultUI,
28979 {
28980 header,
28981 search,
28982 searchLabel
28983 }
28984 ) })
28985 }
28986 );
28987 }
28988 var DataViewsSubComponents = DataViews;
28989 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
28990 DataViewsSubComponents.Filters = filters_default;
28991 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
28992 DataViewsSubComponents.FiltersToggle = toggle_default;
28993 DataViewsSubComponents.Layout = DataViewsLayout;
28994 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
28995 DataViewsSubComponents.Pagination = DataViewsPagination;
28996 DataViewsSubComponents.Search = dataviews_search_default;
28997 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
28998 DataViewsSubComponents.Footer = DataViewsFooter;
28999 var dataviews_default = DataViewsSubComponents;
29000
29001 // packages/dataviews/build-module/dataform/index.mjs
29002 var import_element111 = __toESM(require_element(), 1);
29003
29004 // packages/dataviews/build-module/components/dataform-context/index.mjs
29005 var import_element100 = __toESM(require_element(), 1);
29006 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
29007 var DataFormContext = (0, import_element100.createContext)({
29008 fields: []
29009 });
29010 DataFormContext.displayName = "DataFormContext";
29011 function DataFormProvider({
29012 fields,
29013 children
29014 }) {
29015 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(DataFormContext.Provider, { value: { fields }, children });
29016 }
29017 var dataform_context_default = DataFormContext;
29018
29019 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
29020 var import_element110 = __toESM(require_element(), 1);
29021
29022 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
29023 var import_element101 = __toESM(require_element(), 1);
29024 var import_components46 = __toESM(require_components(), 1);
29025
29026 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
29027 var import_i18n46 = __toESM(require_i18n(), 1);
29028 var DEFAULT_LAYOUT = {
29029 type: "regular",
29030 labelPosition: "top"
29031 };
29032 var normalizeCardSummaryField = (sum) => {
29033 if (typeof sum === "string") {
29034 return [{ id: sum, visibility: "when-collapsed" }];
29035 }
29036 return sum.map((item) => {
29037 if (typeof item === "string") {
29038 return { id: item, visibility: "when-collapsed" };
29039 }
29040 return { id: item.id, visibility: item.visibility };
29041 });
29042 };
29043 function normalizeLayout(layout) {
29044 let normalizedLayout = DEFAULT_LAYOUT;
29045 if (layout?.type === "regular") {
29046 normalizedLayout = {
29047 type: "regular",
29048 labelPosition: layout?.labelPosition ?? "top"
29049 };
29050 } else if (layout?.type === "panel") {
29051 const summary = layout.summary ?? [];
29052 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
29053 const openAs = layout?.openAs;
29054 let normalizedOpenAs;
29055 if (typeof openAs === "object" && openAs.type === "modal") {
29056 normalizedOpenAs = {
29057 type: "modal",
29058 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n46.__)("Apply"),
29059 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n46.__)("Cancel")
29060 };
29061 } else if (openAs === "modal") {
29062 normalizedOpenAs = {
29063 type: "modal",
29064 applyLabel: (0, import_i18n46.__)("Apply"),
29065 cancelLabel: (0, import_i18n46.__)("Cancel")
29066 };
29067 } else {
29068 normalizedOpenAs = { type: "dropdown" };
29069 }
29070 normalizedLayout = {
29071 type: "panel",
29072 labelPosition: layout?.labelPosition ?? "side",
29073 openAs: normalizedOpenAs,
29074 summary: normalizedSummary,
29075 editVisibility: layout?.editVisibility ?? "on-hover"
29076 };
29077 } else if (layout?.type === "card") {
29078 if (layout.withHeader === false) {
29079 normalizedLayout = {
29080 type: "card",
29081 withHeader: false,
29082 isOpened: true,
29083 summary: [],
29084 isCollapsible: false
29085 };
29086 } else {
29087 const summary = layout.summary ?? [];
29088 normalizedLayout = {
29089 type: "card",
29090 withHeader: true,
29091 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
29092 summary: normalizeCardSummaryField(summary),
29093 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
29094 };
29095 }
29096 } else if (layout?.type === "row") {
29097 normalizedLayout = {
29098 type: "row",
29099 alignment: layout?.alignment ?? "center",
29100 styles: layout?.styles ?? {}
29101 };
29102 } else if (layout?.type === "details") {
29103 normalizedLayout = {
29104 type: "details",
29105 summary: layout?.summary ?? ""
29106 };
29107 }
29108 return normalizedLayout;
29109 }
29110 function normalizeForm(form) {
29111 const normalizedFormLayout = normalizeLayout(form?.layout);
29112 const normalizedFields = (form.fields ?? []).map(
29113 (field) => {
29114 if (typeof field === "string") {
29115 return {
29116 id: field,
29117 layout: normalizedFormLayout
29118 };
29119 }
29120 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
29121 return {
29122 id: field.id,
29123 layout: fieldLayout,
29124 ...!!field.label && { label: field.label },
29125 ...!!field.description && {
29126 description: field.description
29127 },
29128 ..."children" in field && Array.isArray(field.children) && {
29129 children: normalizeForm({
29130 fields: field.children,
29131 layout: DEFAULT_LAYOUT
29132 }).fields
29133 }
29134 };
29135 }
29136 );
29137 return {
29138 layout: normalizedFormLayout,
29139 fields: normalizedFields
29140 };
29141 }
29142 var normalize_form_default = normalizeForm;
29143
29144 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
29145 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
29146 function Header3({ title }) {
29147 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29148 Stack,
29149 {
29150 direction: "column",
29151 className: "dataforms-layouts-regular__header",
29152 gap: "lg",
29153 children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components46.__experimentalHeading, { level: 2, size: 13, children: title }) })
29154 }
29155 );
29156 }
29157 function FormRegularField({
29158 data,
29159 field,
29160 onChange,
29161 hideLabelFromVision,
29162 markWhenOptional,
29163 validity
29164 }) {
29165 const { fields } = (0, import_element101.useContext)(dataform_context_default);
29166 const layout = field.layout;
29167 const form = (0, import_element101.useMemo)(
29168 () => ({
29169 layout: DEFAULT_LAYOUT,
29170 fields: !!field.children ? field.children : []
29171 }),
29172 [field]
29173 );
29174 if (!!field.children) {
29175 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(import_jsx_runtime137.Fragment, { children: [
29176 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(Header3, { title: field.label }),
29177 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29178 DataFormLayout,
29179 {
29180 data,
29181 form,
29182 onChange,
29183 validity: validity?.children
29184 }
29185 )
29186 ] });
29187 }
29188 const labelPosition = layout.labelPosition;
29189 const fieldDefinition = fields.find(
29190 (fieldDef) => fieldDef.id === field.id
29191 );
29192 if (!fieldDefinition || !fieldDefinition.Edit) {
29193 return null;
29194 }
29195 if (labelPosition === "side") {
29196 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(
29197 Stack,
29198 {
29199 direction: "row",
29200 className: "dataforms-layouts-regular__field",
29201 gap: "sm",
29202 children: [
29203 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29204 "div",
29205 {
29206 className: clsx_default(
29207 "dataforms-layouts-regular__field-label",
29208 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
29209 ),
29210 children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components46.BaseControl.VisualLabel, { children: fieldDefinition.label })
29211 }
29212 ),
29213 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29214 fieldDefinition.render,
29215 {
29216 item: data,
29217 field: fieldDefinition
29218 }
29219 ) : /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29220 fieldDefinition.Edit,
29221 {
29222 data,
29223 field: fieldDefinition,
29224 onChange,
29225 hideLabelFromVision: true,
29226 markWhenOptional,
29227 validity
29228 },
29229 fieldDefinition.id
29230 ) })
29231 ]
29232 }
29233 );
29234 }
29235 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_jsx_runtime137.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(import_jsx_runtime137.Fragment, { children: [
29236 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components46.BaseControl.VisualLabel, { children: fieldDefinition.label }),
29237 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29238 fieldDefinition.render,
29239 {
29240 item: data,
29241 field: fieldDefinition
29242 }
29243 )
29244 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29245 fieldDefinition.Edit,
29246 {
29247 data,
29248 field: fieldDefinition,
29249 onChange,
29250 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
29251 markWhenOptional,
29252 validity
29253 }
29254 ) });
29255 }
29256
29257 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
29258 var import_deepmerge2 = __toESM(require_cjs(), 1);
29259 var import_components49 = __toESM(require_components(), 1);
29260 var import_element106 = __toESM(require_element(), 1);
29261 var import_compose15 = __toESM(require_compose(), 1);
29262
29263 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
29264 var import_components48 = __toESM(require_components(), 1);
29265 var import_i18n47 = __toESM(require_i18n(), 1);
29266 var import_compose14 = __toESM(require_compose(), 1);
29267 var import_element102 = __toESM(require_element(), 1);
29268
29269 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
29270 function getLabelClassName(labelPosition, showError) {
29271 return clsx_default(
29272 "dataforms-layouts-panel__field-label",
29273 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
29274 { "has-error": showError }
29275 );
29276 }
29277 var get_label_classname_default = getLabelClassName;
29278
29279 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
29280 var import_components47 = __toESM(require_components(), 1);
29281 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
29282 function getLabelContent(showError, errorMessage, fieldLabel) {
29283 return showError ? /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(tooltip_exports.Root, { children: [
29284 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29285 tooltip_exports.Trigger,
29286 {
29287 render: /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
29288 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_components47.Icon, { icon: error_default, size: 16 }),
29289 /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(VisuallyHidden, { children: [
29290 errorMessage,
29291 ": "
29292 ] }),
29293 fieldLabel
29294 ] })
29295 }
29296 ),
29297 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(tooltip_exports.Popup, { children: errorMessage })
29298 ] }) : fieldLabel;
29299 }
29300 var get_label_content_default = getLabelContent;
29301
29302 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
29303 function getFirstValidationError(validity) {
29304 if (!validity) {
29305 return void 0;
29306 }
29307 const validityRules = Object.keys(validity).filter(
29308 (key) => key !== "children"
29309 );
29310 for (const key of validityRules) {
29311 const rule = validity[key];
29312 if (rule === void 0) {
29313 continue;
29314 }
29315 if (rule.type === "invalid") {
29316 if (rule.message) {
29317 return rule.message;
29318 }
29319 if (key === "required") {
29320 return "A required field is empty";
29321 }
29322 return "Unidentified validation error";
29323 }
29324 }
29325 if (validity.children) {
29326 for (const childValidity of Object.values(validity.children)) {
29327 const childError = getFirstValidationError(childValidity);
29328 if (childError) {
29329 return childError;
29330 }
29331 }
29332 }
29333 return void 0;
29334 }
29335 var get_first_validation_error_default = getFirstValidationError;
29336
29337 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
29338 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
29339 function SummaryButton({
29340 data,
29341 field,
29342 fieldLabel,
29343 summaryFields,
29344 validity,
29345 touched,
29346 disabled: disabled2,
29347 onClick,
29348 "aria-expanded": ariaExpanded
29349 }) {
29350 const { labelPosition, editVisibility } = field.layout;
29351 const errorMessage = get_first_validation_error_default(validity);
29352 const showError = touched && !!errorMessage;
29353 const labelClassName = get_label_classname_default(labelPosition, showError);
29354 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
29355 const className = clsx_default(
29356 "dataforms-layouts-panel__field-trigger",
29357 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
29358 {
29359 "is-disabled": disabled2,
29360 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
29361 }
29362 );
29363 const controlId = (0, import_compose14.useInstanceId)(
29364 SummaryButton,
29365 "dataforms-layouts-panel__field-control"
29366 );
29367 const ariaLabel = showError ? (0, import_i18n47.sprintf)(
29368 // translators: %s: Field name.
29369 (0, import_i18n47._x)("Edit %s (has errors)", "field"),
29370 fieldLabel || ""
29371 ) : (0, import_i18n47.sprintf)(
29372 // translators: %s: Field name.
29373 (0, import_i18n47._x)("Edit %s", "field"),
29374 fieldLabel || ""
29375 );
29376 const rowRef = (0, import_element102.useRef)(null);
29377 const handleRowClick = () => {
29378 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection();
29379 if (selection && selection.toString().length > 0) {
29380 return;
29381 }
29382 onClick();
29383 };
29384 const handleKeyDown = (event) => {
29385 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
29386 event.preventDefault();
29387 onClick();
29388 }
29389 };
29390 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
29391 "div",
29392 {
29393 ref: rowRef,
29394 className,
29395 onClick: !disabled2 ? handleRowClick : void 0,
29396 onKeyDown: !disabled2 ? handleKeyDown : void 0,
29397 children: [
29398 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("span", { className: labelClassName, children: labelContent }),
29399 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(tooltip_exports.Root, { children: [
29400 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29401 tooltip_exports.Trigger,
29402 {
29403 render: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29404 "span",
29405 {
29406 className: "dataforms-layouts-panel__field-label-error-content",
29407 role: "img",
29408 "aria-label": errorMessage,
29409 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components48.Icon, { icon: error_default, size: 16 })
29410 }
29411 )
29412 }
29413 ),
29414 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(tooltip_exports.Popup, { children: errorMessage })
29415 ] }),
29416 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29417 "span",
29418 {
29419 id: `${controlId}`,
29420 className: "dataforms-layouts-panel__field-control",
29421 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29422 "span",
29423 {
29424 style: {
29425 display: "flex",
29426 flexDirection: "column",
29427 alignItems: "flex-start",
29428 width: "100%",
29429 gap: "2px"
29430 },
29431 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29432 "span",
29433 {
29434 style: { width: "100%" },
29435 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29436 summaryField.render,
29437 {
29438 item: data,
29439 field: summaryField
29440 }
29441 )
29442 },
29443 summaryField.id
29444 ))
29445 }
29446 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29447 summaryField.render,
29448 {
29449 item: data,
29450 field: summaryField
29451 },
29452 summaryField.id
29453 ))
29454 }
29455 ),
29456 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29457 import_components48.Button,
29458 {
29459 className: "dataforms-layouts-panel__field-trigger-icon",
29460 label: ariaLabel,
29461 icon: pencil_default,
29462 size: "small",
29463 "aria-expanded": ariaExpanded,
29464 "aria-haspopup": "dialog",
29465 "aria-describedby": `${controlId}`
29466 }
29467 )
29468 ]
29469 }
29470 );
29471 }
29472
29473 // packages/dataviews/build-module/hooks/use-form-validity.mjs
29474 var import_deepmerge = __toESM(require_cjs(), 1);
29475 var import_es62 = __toESM(require_es6(), 1);
29476 var import_element103 = __toESM(require_element(), 1);
29477 var import_i18n48 = __toESM(require_i18n(), 1);
29478 function isFormValid(formValidity) {
29479 if (!formValidity) {
29480 return true;
29481 }
29482 return Object.values(formValidity).every((fieldValidation) => {
29483 return Object.entries(fieldValidation).every(
29484 ([key, validation]) => {
29485 if (key === "children" && validation && typeof validation === "object") {
29486 return isFormValid(validation);
29487 }
29488 return validation.type !== "invalid" && validation.type !== "validating";
29489 }
29490 );
29491 });
29492 }
29493 function getFormFieldsToValidate(form, fields) {
29494 const normalizedForm = normalize_form_default(form);
29495 if (normalizedForm.fields.length === 0) {
29496 return [];
29497 }
29498 const fieldsMap = /* @__PURE__ */ new Map();
29499 fields.forEach((field) => {
29500 fieldsMap.set(field.id, field);
29501 });
29502 function processFormField(formField) {
29503 if ("children" in formField && Array.isArray(formField.children)) {
29504 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
29505 if (processedChildren.length === 0) {
29506 return null;
29507 }
29508 const fieldDef2 = fieldsMap.get(formField.id);
29509 if (fieldDef2) {
29510 const [normalizedField2] = normalizeFields([
29511 fieldDef2
29512 ]);
29513 return {
29514 id: formField.id,
29515 children: processedChildren,
29516 field: normalizedField2
29517 };
29518 }
29519 return {
29520 id: formField.id,
29521 children: processedChildren
29522 };
29523 }
29524 const fieldDef = fieldsMap.get(formField.id);
29525 if (!fieldDef) {
29526 return null;
29527 }
29528 const [normalizedField] = normalizeFields([fieldDef]);
29529 return {
29530 id: formField.id,
29531 children: [],
29532 field: normalizedField
29533 };
29534 }
29535 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
29536 return toValidate;
29537 }
29538 function setValidityAtPath(formValidity, fieldValidity, path) {
29539 if (!formValidity) {
29540 formValidity = {};
29541 }
29542 if (path.length === 0) {
29543 return formValidity;
29544 }
29545 const result = { ...formValidity };
29546 let current = result;
29547 for (let i2 = 0; i2 < path.length - 1; i2++) {
29548 const segment = path[i2];
29549 if (!current[segment]) {
29550 current[segment] = {};
29551 }
29552 current[segment] = { ...current[segment] };
29553 current = current[segment];
29554 }
29555 const finalKey = path[path.length - 1];
29556 current[finalKey] = {
29557 ...current[finalKey] || {},
29558 ...fieldValidity
29559 };
29560 return result;
29561 }
29562 function removeValidationProperty(formValidity, path, property) {
29563 if (!formValidity || path.length === 0) {
29564 return formValidity;
29565 }
29566 const result = { ...formValidity };
29567 let current = result;
29568 for (let i2 = 0; i2 < path.length - 1; i2++) {
29569 const segment = path[i2];
29570 if (!current[segment]) {
29571 return formValidity;
29572 }
29573 current[segment] = { ...current[segment] };
29574 current = current[segment];
29575 }
29576 const finalKey = path[path.length - 1];
29577 if (!current[finalKey]) {
29578 return formValidity;
29579 }
29580 const fieldValidity = { ...current[finalKey] };
29581 delete fieldValidity[property];
29582 if (Object.keys(fieldValidity).length === 0) {
29583 delete current[finalKey];
29584 } else {
29585 current[finalKey] = fieldValidity;
29586 }
29587 if (Object.keys(result).length === 0) {
29588 return void 0;
29589 }
29590 return result;
29591 }
29592 function handleElementsValidationAsync(promise, formField, promiseHandler) {
29593 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
29594 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
29595 elementsCounterRef.current[formField.id] = currentToken;
29596 promise.then((result) => {
29597 if (currentToken !== elementsCounterRef.current[formField.id]) {
29598 return;
29599 }
29600 if (!Array.isArray(result)) {
29601 setFormValidity((prev) => {
29602 const newFormValidity = setValidityAtPath(
29603 prev,
29604 {
29605 elements: {
29606 type: "invalid",
29607 message: (0, import_i18n48.__)("Could not validate elements.")
29608 }
29609 },
29610 [...path, formField.id]
29611 );
29612 return newFormValidity;
29613 });
29614 return;
29615 }
29616 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
29617 ...formField.field,
29618 elements: result
29619 })) {
29620 setFormValidity((prev) => {
29621 const newFormValidity = setValidityAtPath(
29622 prev,
29623 {
29624 elements: {
29625 type: "invalid",
29626 message: (0, import_i18n48.__)(
29627 "Value must be one of the elements."
29628 )
29629 }
29630 },
29631 [...path, formField.id]
29632 );
29633 return newFormValidity;
29634 });
29635 } else {
29636 setFormValidity((prev) => {
29637 return removeValidationProperty(
29638 prev,
29639 [...path, formField.id],
29640 "elements"
29641 );
29642 });
29643 }
29644 }).catch((error2) => {
29645 if (currentToken !== elementsCounterRef.current[formField.id]) {
29646 return;
29647 }
29648 let errorMessage;
29649 if (error2 instanceof Error) {
29650 errorMessage = error2.message;
29651 } else {
29652 errorMessage = String(error2) || (0, import_i18n48.__)(
29653 "Unknown error when running elements validation asynchronously."
29654 );
29655 }
29656 setFormValidity((prev) => {
29657 const newFormValidity = setValidityAtPath(
29658 prev,
29659 {
29660 elements: {
29661 type: "invalid",
29662 message: errorMessage
29663 }
29664 },
29665 [...path, formField.id]
29666 );
29667 return newFormValidity;
29668 });
29669 });
29670 }
29671 function handleCustomValidationAsync(promise, formField, promiseHandler) {
29672 const { customCounterRef, setFormValidity, path } = promiseHandler;
29673 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
29674 customCounterRef.current[formField.id] = currentToken;
29675 promise.then((result) => {
29676 if (currentToken !== customCounterRef.current[formField.id]) {
29677 return;
29678 }
29679 if (result === null) {
29680 setFormValidity((prev) => {
29681 return removeValidationProperty(
29682 prev,
29683 [...path, formField.id],
29684 "custom"
29685 );
29686 });
29687 return;
29688 }
29689 if (typeof result === "string") {
29690 setFormValidity((prev) => {
29691 const newFormValidity = setValidityAtPath(
29692 prev,
29693 {
29694 custom: {
29695 type: "invalid",
29696 message: result
29697 }
29698 },
29699 [...path, formField.id]
29700 );
29701 return newFormValidity;
29702 });
29703 return;
29704 }
29705 setFormValidity((prev) => {
29706 const newFormValidity = setValidityAtPath(
29707 prev,
29708 {
29709 custom: {
29710 type: "invalid",
29711 message: (0, import_i18n48.__)("Validation could not be processed.")
29712 }
29713 },
29714 [...path, formField.id]
29715 );
29716 return newFormValidity;
29717 });
29718 }).catch((error2) => {
29719 if (currentToken !== customCounterRef.current[formField.id]) {
29720 return;
29721 }
29722 let errorMessage;
29723 if (error2 instanceof Error) {
29724 errorMessage = error2.message;
29725 } else {
29726 errorMessage = String(error2) || (0, import_i18n48.__)(
29727 "Unknown error when running custom validation asynchronously."
29728 );
29729 }
29730 setFormValidity((prev) => {
29731 const newFormValidity = setValidityAtPath(
29732 prev,
29733 {
29734 custom: {
29735 type: "invalid",
29736 message: errorMessage
29737 }
29738 },
29739 [...path, formField.id]
29740 );
29741 return newFormValidity;
29742 });
29743 });
29744 }
29745 function validateFormField(item, formField, promiseHandler) {
29746 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
29747 return {
29748 required: { type: "invalid" }
29749 };
29750 }
29751 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
29752 return {
29753 pattern: {
29754 type: "invalid",
29755 message: (0, import_i18n48.__)("Value does not match the required pattern.")
29756 }
29757 };
29758 }
29759 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
29760 return {
29761 min: {
29762 type: "invalid",
29763 message: (0, import_i18n48.__)("Value is below the minimum.")
29764 }
29765 };
29766 }
29767 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
29768 return {
29769 max: {
29770 type: "invalid",
29771 message: (0, import_i18n48.__)("Value is above the maximum.")
29772 }
29773 };
29774 }
29775 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
29776 return {
29777 minLength: {
29778 type: "invalid",
29779 message: (0, import_i18n48.__)("Value is too short.")
29780 }
29781 };
29782 }
29783 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
29784 return {
29785 maxLength: {
29786 type: "invalid",
29787 message: (0, import_i18n48.__)("Value is too long.")
29788 }
29789 };
29790 }
29791 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
29792 return {
29793 elements: {
29794 type: "invalid",
29795 message: (0, import_i18n48.__)("Value must be one of the elements.")
29796 }
29797 };
29798 }
29799 let customError;
29800 if (!!formField.field && formField.field.isValid.custom) {
29801 try {
29802 const value = formField.field.getValue({ item });
29803 customError = formField.field.isValid.custom(
29804 (0, import_deepmerge.default)(
29805 item,
29806 formField.field.setValue({
29807 item,
29808 value
29809 })
29810 ),
29811 formField.field
29812 );
29813 } catch (error2) {
29814 let errorMessage;
29815 if (error2 instanceof Error) {
29816 errorMessage = error2.message;
29817 } else {
29818 errorMessage = String(error2) || (0, import_i18n48.__)("Unknown error when running custom validation.");
29819 }
29820 return {
29821 custom: {
29822 type: "invalid",
29823 message: errorMessage
29824 }
29825 };
29826 }
29827 }
29828 if (typeof customError === "string") {
29829 return {
29830 custom: {
29831 type: "invalid",
29832 message: customError
29833 }
29834 };
29835 }
29836 const fieldValidity = {};
29837 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
29838 handleElementsValidationAsync(
29839 formField.field.getElements(),
29840 formField,
29841 promiseHandler
29842 );
29843 fieldValidity.elements = {
29844 type: "validating",
29845 message: (0, import_i18n48.__)("Validating\u2026")
29846 };
29847 }
29848 if (customError instanceof Promise) {
29849 handleCustomValidationAsync(customError, formField, promiseHandler);
29850 fieldValidity.custom = {
29851 type: "validating",
29852 message: (0, import_i18n48.__)("Validating\u2026")
29853 };
29854 }
29855 if (Object.keys(fieldValidity).length > 0) {
29856 return fieldValidity;
29857 }
29858 if (formField.children.length > 0) {
29859 const result = {};
29860 formField.children.forEach((child) => {
29861 result[child.id] = validateFormField(item, child, {
29862 ...promiseHandler,
29863 path: [...promiseHandler.path, formField.id, "children"]
29864 });
29865 });
29866 const filteredResult = {};
29867 Object.entries(result).forEach(([key, value]) => {
29868 if (value !== void 0) {
29869 filteredResult[key] = value;
29870 }
29871 });
29872 if (Object.keys(filteredResult).length === 0) {
29873 return void 0;
29874 }
29875 return {
29876 children: filteredResult
29877 };
29878 }
29879 return void 0;
29880 }
29881 function getFormFieldValue(formField, item) {
29882 const fieldValue = formField?.field?.getValue({ item });
29883 if (formField.children.length === 0) {
29884 return fieldValue;
29885 }
29886 const childrenValues = formField.children.map(
29887 (child) => getFormFieldValue(child, item)
29888 );
29889 if (!childrenValues) {
29890 return fieldValue;
29891 }
29892 return {
29893 value: fieldValue,
29894 children: childrenValues
29895 };
29896 }
29897 function useFormValidity(item, fields, form) {
29898 const [formValidity, setFormValidity] = (0, import_element103.useState)();
29899 const customCounterRef = (0, import_element103.useRef)({});
29900 const elementsCounterRef = (0, import_element103.useRef)({});
29901 const previousValuesRef = (0, import_element103.useRef)({});
29902 const validate = (0, import_element103.useCallback)(() => {
29903 const promiseHandler = {
29904 customCounterRef,
29905 elementsCounterRef,
29906 setFormValidity,
29907 path: [],
29908 item
29909 };
29910 const formFieldsToValidate = getFormFieldsToValidate(form, fields);
29911 if (formFieldsToValidate.length === 0) {
29912 setFormValidity(void 0);
29913 return;
29914 }
29915 const newFormValidity = {};
29916 const untouchedFields = [];
29917 formFieldsToValidate.forEach((formField) => {
29918 const value = getFormFieldValue(formField, item);
29919 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
29920 previousValuesRef.current[formField.id],
29921 value
29922 )) {
29923 untouchedFields.push(formField.id);
29924 return;
29925 }
29926 previousValuesRef.current[formField.id] = value;
29927 const fieldValidity = validateFormField(
29928 item,
29929 formField,
29930 promiseHandler
29931 );
29932 if (fieldValidity !== void 0) {
29933 newFormValidity[formField.id] = fieldValidity;
29934 }
29935 });
29936 setFormValidity((existingFormValidity) => {
29937 let validity = {
29938 ...existingFormValidity,
29939 ...newFormValidity
29940 };
29941 const fieldsToKeep = [
29942 ...untouchedFields,
29943 ...Object.keys(newFormValidity)
29944 ];
29945 Object.keys(validity).forEach((key) => {
29946 if (validity && !fieldsToKeep.includes(key)) {
29947 delete validity[key];
29948 }
29949 });
29950 if (Object.keys(validity).length === 0) {
29951 validity = void 0;
29952 }
29953 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
29954 if (areEqual) {
29955 return existingFormValidity;
29956 }
29957 return validity;
29958 });
29959 }, [item, fields, form]);
29960 (0, import_element103.useEffect)(() => {
29961 validate();
29962 }, [validate]);
29963 return {
29964 validity: formValidity,
29965 isValid: isFormValid(formValidity)
29966 };
29967 }
29968 var use_form_validity_default = useFormValidity;
29969
29970 // packages/dataviews/build-module/hooks/use-report-validity.mjs
29971 var import_element104 = __toESM(require_element(), 1);
29972 function useReportValidity(ref, shouldReport) {
29973 (0, import_element104.useEffect)(() => {
29974 if (shouldReport && ref.current) {
29975 const inputs = ref.current.querySelectorAll(
29976 "input, textarea, select"
29977 );
29978 inputs.forEach((input) => {
29979 input.reportValidity();
29980 });
29981 }
29982 }, [shouldReport, ref]);
29983 }
29984
29985 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
29986 var import_element105 = __toESM(require_element(), 1);
29987
29988 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
29989 function extractSummaryIds(summary) {
29990 if (Array.isArray(summary)) {
29991 return summary.map(
29992 (item) => typeof item === "string" ? item : item.id
29993 );
29994 }
29995 return [];
29996 }
29997 var getSummaryFields = (summaryField, fields) => {
29998 if (Array.isArray(summaryField) && summaryField.length > 0) {
29999 const summaryIds = extractSummaryIds(summaryField);
30000 return summaryIds.map(
30001 (summaryId) => fields.find((_field) => _field.id === summaryId)
30002 ).filter((_field) => _field !== void 0);
30003 }
30004 return [];
30005 };
30006
30007 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
30008 var getFieldDefinition = (field, fields) => {
30009 const fieldDefinition = fields.find((_field) => _field.id === field.id);
30010 if (!fieldDefinition) {
30011 return fields.find((_field) => {
30012 if (!!field.children) {
30013 const simpleChildren = field.children.filter(
30014 (child) => !child.children
30015 );
30016 if (simpleChildren.length === 0) {
30017 return false;
30018 }
30019 return _field.id === simpleChildren[0].id;
30020 }
30021 return _field.id === field.id;
30022 });
30023 }
30024 return fieldDefinition;
30025 };
30026 function useFieldFromFormField(field) {
30027 const { fields } = (0, import_element105.useContext)(dataform_context_default);
30028 const layout = field.layout;
30029 const summaryFields = getSummaryFields(layout.summary, fields);
30030 const fieldDefinition = getFieldDefinition(field, fields);
30031 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
30032 if (summaryFields.length === 0) {
30033 return {
30034 summaryFields: fieldDefinition ? [fieldDefinition] : [],
30035 fieldDefinition,
30036 fieldLabel
30037 };
30038 }
30039 return {
30040 summaryFields,
30041 fieldDefinition,
30042 fieldLabel
30043 };
30044 }
30045 var use_field_from_form_field_default = useFieldFromFormField;
30046
30047 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
30048 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
30049 function ModalContent({
30050 data,
30051 field,
30052 onChange,
30053 fieldLabel,
30054 onClose,
30055 touched
30056 }) {
30057 const { openAs } = field.layout;
30058 const { applyLabel, cancelLabel } = openAs;
30059 const { fields } = (0, import_element106.useContext)(dataform_context_default);
30060 const [changes, setChanges] = (0, import_element106.useState)({});
30061 const modalData = (0, import_element106.useMemo)(() => {
30062 return (0, import_deepmerge2.default)(data, changes, {
30063 arrayMerge: (target, source) => source
30064 });
30065 }, [data, changes]);
30066 const form = (0, import_element106.useMemo)(
30067 () => ({
30068 layout: DEFAULT_LAYOUT,
30069 fields: !!field.children ? field.children : (
30070 // If not explicit children return the field id itself.
30071 [{ id: field.id, layout: DEFAULT_LAYOUT }]
30072 )
30073 }),
30074 [field]
30075 );
30076 const fieldsAsFieldType = fields.map((f2) => ({
30077 ...f2,
30078 Edit: f2.Edit === null ? void 0 : f2.Edit,
30079 isValid: {
30080 required: f2.isValid.required?.constraint,
30081 elements: f2.isValid.elements?.constraint,
30082 min: f2.isValid.min?.constraint,
30083 max: f2.isValid.max?.constraint,
30084 pattern: f2.isValid.pattern?.constraint,
30085 minLength: f2.isValid.minLength?.constraint,
30086 maxLength: f2.isValid.maxLength?.constraint
30087 }
30088 }));
30089 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
30090 const onApply = () => {
30091 onChange(changes);
30092 onClose();
30093 };
30094 const handleOnChange = (newValue) => {
30095 setChanges(
30096 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
30097 arrayMerge: (target, source) => source
30098 })
30099 );
30100 };
30101 const focusOnMountRef = (0, import_compose15.useFocusOnMount)("firstInputElement");
30102 const contentRef = (0, import_element106.useRef)(null);
30103 const mergedRef = (0, import_compose15.useMergeRefs)([focusOnMountRef, contentRef]);
30104 useReportValidity(contentRef, touched);
30105 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
30106 import_components49.Modal,
30107 {
30108 className: "dataforms-layouts-panel__modal",
30109 onRequestClose: onClose,
30110 isFullScreen: false,
30111 title: fieldLabel,
30112 size: "medium",
30113 children: [
30114 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30115 DataFormLayout,
30116 {
30117 data: modalData,
30118 form,
30119 onChange: handleOnChange,
30120 validity,
30121 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30122 FieldLayout,
30123 {
30124 data: modalData,
30125 field: childField,
30126 onChange: handleOnChange,
30127 hideLabelFromVision: form.fields.length < 2,
30128 markWhenOptional,
30129 validity: childFieldValidity
30130 },
30131 childField.id
30132 )
30133 }
30134 ) }),
30135 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
30136 Stack,
30137 {
30138 direction: "row",
30139 className: "dataforms-layouts-panel__modal-footer",
30140 gap: "md",
30141 children: [
30142 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components49.__experimentalSpacer, { style: { flex: 1 } }),
30143 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30144 import_components49.Button,
30145 {
30146 variant: "tertiary",
30147 onClick: onClose,
30148 __next40pxDefaultSize: true,
30149 children: cancelLabel
30150 }
30151 ),
30152 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30153 import_components49.Button,
30154 {
30155 variant: "primary",
30156 onClick: onApply,
30157 __next40pxDefaultSize: true,
30158 children: applyLabel
30159 }
30160 )
30161 ]
30162 }
30163 )
30164 ]
30165 }
30166 );
30167 }
30168 function PanelModal({
30169 data,
30170 field,
30171 onChange,
30172 validity
30173 }) {
30174 const [touched, setTouched] = (0, import_element106.useState)(false);
30175 const [isOpen, setIsOpen] = (0, import_element106.useState)(false);
30176 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
30177 if (!fieldDefinition) {
30178 return null;
30179 }
30180 const handleClose = () => {
30181 setIsOpen(false);
30182 setTouched(true);
30183 };
30184 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_jsx_runtime140.Fragment, { children: [
30185 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30186 SummaryButton,
30187 {
30188 data,
30189 field,
30190 fieldLabel,
30191 summaryFields,
30192 validity,
30193 touched,
30194 disabled: fieldDefinition.readOnly === true,
30195 onClick: () => setIsOpen(true),
30196 "aria-expanded": isOpen
30197 }
30198 ),
30199 isOpen && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30200 ModalContent,
30201 {
30202 data,
30203 field,
30204 onChange,
30205 fieldLabel: fieldLabel ?? "",
30206 onClose: handleClose,
30207 touched
30208 }
30209 )
30210 ] });
30211 }
30212 var modal_default = PanelModal;
30213
30214 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
30215 var import_components50 = __toESM(require_components(), 1);
30216 var import_i18n49 = __toESM(require_i18n(), 1);
30217 var import_element107 = __toESM(require_element(), 1);
30218 var import_compose16 = __toESM(require_compose(), 1);
30219 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
30220 function DropdownHeader({
30221 title,
30222 onClose
30223 }) {
30224 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30225 Stack,
30226 {
30227 direction: "column",
30228 className: "dataforms-layouts-panel__dropdown-header",
30229 gap: "lg",
30230 children: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
30231 title && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components50.__experimentalHeading, { level: 2, size: 13, children: title }),
30232 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components50.__experimentalSpacer, { style: { flex: 1 } }),
30233 onClose && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30234 import_components50.Button,
30235 {
30236 label: (0, import_i18n49.__)("Close"),
30237 icon: close_small_default,
30238 onClick: onClose,
30239 size: "small"
30240 }
30241 )
30242 ] })
30243 }
30244 );
30245 }
30246 function DropdownContentWithValidation({
30247 touched,
30248 children
30249 }) {
30250 const ref = (0, import_element107.useRef)(null);
30251 useReportValidity(ref, touched);
30252 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("div", { ref, children });
30253 }
30254 function PanelDropdown({
30255 data,
30256 field,
30257 onChange,
30258 validity
30259 }) {
30260 const [touched, setTouched] = (0, import_element107.useState)(false);
30261 const [popoverAnchor, setPopoverAnchor] = (0, import_element107.useState)(
30262 null
30263 );
30264 const popoverProps = (0, import_element107.useMemo)(
30265 () => ({
30266 // Anchor the popover to the middle of the entire row so that it doesn't
30267 // move around when the label changes.
30268 anchor: popoverAnchor,
30269 placement: "left-start",
30270 offset: 36,
30271 shift: true
30272 }),
30273 [popoverAnchor]
30274 );
30275 const [dialogRef, dialogProps] = (0, import_compose16.__experimentalUseDialog)({
30276 focusOnMount: "firstInputElement"
30277 });
30278 const form = (0, import_element107.useMemo)(
30279 () => ({
30280 layout: DEFAULT_LAYOUT,
30281 fields: !!field.children ? field.children : (
30282 // If not explicit children return the field id itself.
30283 [{ id: field.id, layout: DEFAULT_LAYOUT }]
30284 )
30285 }),
30286 [field]
30287 );
30288 const formValidity = (0, import_element107.useMemo)(() => {
30289 if (validity === void 0) {
30290 return void 0;
30291 }
30292 if (!!field.children) {
30293 return validity?.children;
30294 }
30295 return { [field.id]: validity };
30296 }, [validity, field]);
30297 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
30298 if (!fieldDefinition) {
30299 return null;
30300 }
30301 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30302 "div",
30303 {
30304 ref: setPopoverAnchor,
30305 className: "dataforms-layouts-panel__field-dropdown-anchor",
30306 children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30307 import_components50.Dropdown,
30308 {
30309 contentClassName: "dataforms-layouts-panel__field-dropdown",
30310 popoverProps,
30311 focusOnMount: false,
30312 onToggle: (willOpen) => {
30313 if (!willOpen) {
30314 setTouched(true);
30315 }
30316 },
30317 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30318 SummaryButton,
30319 {
30320 data,
30321 field,
30322 fieldLabel,
30323 summaryFields,
30324 validity,
30325 touched,
30326 disabled: fieldDefinition.readOnly === true,
30327 onClick: onToggle,
30328 "aria-expanded": isOpen
30329 }
30330 ),
30331 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
30332 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30333 DropdownHeader,
30334 {
30335 title: fieldLabel,
30336 onClose
30337 }
30338 ),
30339 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30340 DataFormLayout,
30341 {
30342 data,
30343 form,
30344 onChange,
30345 validity: formValidity,
30346 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30347 FieldLayout,
30348 {
30349 data,
30350 field: childField,
30351 onChange,
30352 hideLabelFromVision: (form?.fields ?? []).length < 2,
30353 markWhenOptional,
30354 validity: childFieldValidity
30355 },
30356 childField.id
30357 )
30358 }
30359 )
30360 ] }) })
30361 }
30362 )
30363 }
30364 );
30365 }
30366 var dropdown_default = PanelDropdown;
30367
30368 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
30369 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
30370 function FormPanelField({
30371 data,
30372 field,
30373 onChange,
30374 validity
30375 }) {
30376 const layout = field.layout;
30377 if (layout.openAs.type === "modal") {
30378 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
30379 modal_default,
30380 {
30381 data,
30382 field,
30383 onChange,
30384 validity
30385 }
30386 );
30387 }
30388 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
30389 dropdown_default,
30390 {
30391 data,
30392 field,
30393 onChange,
30394 validity
30395 }
30396 );
30397 }
30398
30399 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
30400 var import_element108 = __toESM(require_element(), 1);
30401
30402 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
30403 var import_i18n50 = __toESM(require_i18n(), 1);
30404 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
30405 function countInvalidFields(validity) {
30406 if (!validity) {
30407 return 0;
30408 }
30409 let count = 0;
30410 const validityRules = Object.keys(validity).filter(
30411 (key) => key !== "children"
30412 );
30413 for (const key of validityRules) {
30414 const rule = validity[key];
30415 if (rule?.type === "invalid") {
30416 count++;
30417 }
30418 }
30419 if (validity.children) {
30420 for (const childValidity of Object.values(validity.children)) {
30421 count += countInvalidFields(childValidity);
30422 }
30423 }
30424 return count;
30425 }
30426 function ValidationBadge({
30427 validity
30428 }) {
30429 const invalidCount = countInvalidFields(validity);
30430 if (invalidCount === 0) {
30431 return null;
30432 }
30433 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(Badge, { intent: "high", children: (0, import_i18n50.sprintf)(
30434 /* translators: %d: Number of fields that need attention */
30435 (0, import_i18n50._n)(
30436 "%d field needs attention",
30437 "%d fields need attention",
30438 invalidCount
30439 ),
30440 invalidCount
30441 ) });
30442 }
30443
30444 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
30445 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
30446 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
30447 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
30448 return false;
30449 }
30450 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
30451 const fieldConfig = summaryConfigArray.find((config) => {
30452 if (typeof config === "string") {
30453 return config === summaryField.id;
30454 }
30455 if (typeof config === "object" && "id" in config) {
30456 return config.id === summaryField.id;
30457 }
30458 return false;
30459 });
30460 if (!fieldConfig) {
30461 return false;
30462 }
30463 if (typeof fieldConfig === "string") {
30464 return true;
30465 }
30466 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
30467 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
30468 }
30469 return true;
30470 }
30471 function HeaderContent({
30472 data,
30473 fields,
30474 label,
30475 layout,
30476 isOpen,
30477 touched,
30478 validity
30479 }) {
30480 const summaryFields = getSummaryFields(layout.summary, fields);
30481 const visibleSummaryFields = summaryFields.filter(
30482 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
30483 );
30484 const hasBadge = touched && layout.isCollapsible;
30485 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
30486 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(
30487 Stack,
30488 {
30489 align: "center",
30490 justify: "space-between",
30491 className: "dataforms-layouts-card__field-header-content",
30492 children: [
30493 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(card_exports.Title, { children: label }),
30494 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
30495 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(ValidationBadge, { validity }),
30496 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30497 summaryField.render,
30498 {
30499 item: data,
30500 field: summaryField
30501 },
30502 summaryField.id
30503 )) })
30504 ] })
30505 ]
30506 }
30507 );
30508 }
30509 function BodyContent({
30510 data,
30511 field,
30512 form,
30513 onChange,
30514 hideLabelFromVision,
30515 markWhenOptional,
30516 validity,
30517 withHeader
30518 }) {
30519 if (field.children) {
30520 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_jsx_runtime144.Fragment, { children: [
30521 field.description && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
30522 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30523 DataFormLayout,
30524 {
30525 data,
30526 form,
30527 onChange,
30528 validity: validity?.children
30529 }
30530 )
30531 ] });
30532 }
30533 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
30534 if (!SingleFieldLayout) {
30535 return null;
30536 }
30537 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30538 SingleFieldLayout,
30539 {
30540 data,
30541 field,
30542 onChange,
30543 hideLabelFromVision: hideLabelFromVision || withHeader,
30544 markWhenOptional,
30545 validity
30546 }
30547 );
30548 }
30549 function FormCardField({
30550 data,
30551 field,
30552 onChange,
30553 hideLabelFromVision,
30554 markWhenOptional,
30555 validity
30556 }) {
30557 const { fields } = (0, import_element108.useContext)(dataform_context_default);
30558 const layout = field.layout;
30559 const contentRef = (0, import_element108.useRef)(null);
30560 const form = (0, import_element108.useMemo)(
30561 () => ({
30562 layout: DEFAULT_LAYOUT,
30563 fields: field.children ?? []
30564 }),
30565 [field]
30566 );
30567 const { isOpened, isCollapsible } = layout;
30568 const [isOpen, setIsOpen] = (0, import_element108.useState)(isOpened);
30569 const [touched, setTouched] = (0, import_element108.useState)(false);
30570 (0, import_element108.useEffect)(() => {
30571 setIsOpen(isOpened);
30572 }, [isOpened]);
30573 const handleOpenChange = (0, import_element108.useCallback)((open) => {
30574 if (!open) {
30575 setTouched(true);
30576 }
30577 setIsOpen(open);
30578 }, []);
30579 const handleBlur = (0, import_element108.useCallback)(() => {
30580 setTouched(true);
30581 }, []);
30582 useReportValidity(
30583 contentRef,
30584 (isCollapsible ? isOpen : true) && touched
30585 );
30586 let label = field.label;
30587 let withHeader;
30588 if (field.children) {
30589 withHeader = !!label && layout.withHeader;
30590 } else {
30591 const fieldDefinition = fields.find(
30592 (fieldDef) => fieldDef.id === field.id
30593 );
30594 if (!fieldDefinition || !fieldDefinition.Edit) {
30595 return null;
30596 }
30597 label = fieldDefinition.label;
30598 withHeader = !!label && layout.withHeader;
30599 }
30600 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30601 BodyContent,
30602 {
30603 data,
30604 field,
30605 form,
30606 onChange,
30607 hideLabelFromVision,
30608 markWhenOptional,
30609 validity,
30610 withHeader
30611 }
30612 );
30613 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30614 HeaderContent,
30615 {
30616 data,
30617 fields,
30618 label,
30619 layout,
30620 isOpen: isCollapsible ? !!isOpen : true,
30621 touched,
30622 validity
30623 }
30624 );
30625 if (withHeader && isCollapsible) {
30626 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(
30627 collapsible_card_exports.Root,
30628 {
30629 className: "dataforms-layouts-card__field",
30630 open: isOpen,
30631 onOpenChange: handleOpenChange,
30632 children: [
30633 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(collapsible_card_exports.Header, { children: headerContent }),
30634 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30635 collapsible_card_exports.Content,
30636 {
30637 ref: contentRef,
30638 onBlur: handleBlur,
30639 children: bodyContent
30640 }
30641 )
30642 ]
30643 }
30644 );
30645 }
30646 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
30647 withHeader && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(card_exports.Header, { children: headerContent }),
30648 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
30649 ] });
30650 }
30651
30652 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
30653 var import_components51 = __toESM(require_components(), 1);
30654 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
30655 function Header4({ title }) {
30656 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30657 Stack,
30658 {
30659 direction: "column",
30660 className: "dataforms-layouts-row__header",
30661 gap: "lg",
30662 children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components51.__experimentalHeading, { level: 2, size: 13, children: title }) })
30663 }
30664 );
30665 }
30666 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_jsx_runtime145.Fragment, { children });
30667 function FormRowField({
30668 data,
30669 field,
30670 onChange,
30671 hideLabelFromVision,
30672 markWhenOptional,
30673 validity
30674 }) {
30675 const layout = field.layout;
30676 if (!!field.children) {
30677 const form = {
30678 layout: DEFAULT_LAYOUT,
30679 fields: field.children
30680 };
30681 return /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
30682 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Header4, { title: field.label }),
30683 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30684 DataFormLayout,
30685 {
30686 data,
30687 form,
30688 onChange,
30689 validity: validity?.children,
30690 as: EMPTY_WRAPPER,
30691 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30692 "div",
30693 {
30694 className: "dataforms-layouts-row__field-control",
30695 style: layout.styles[childField.id],
30696 children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30697 FieldLayout,
30698 {
30699 data,
30700 field: childField,
30701 onChange,
30702 hideLabelFromVision,
30703 markWhenOptional,
30704 validity: childFieldValidity
30705 }
30706 )
30707 },
30708 childField.id
30709 )
30710 }
30711 ) })
30712 ] });
30713 }
30714 const RegularLayout = getFormFieldLayout("regular")?.component;
30715 if (!RegularLayout) {
30716 return null;
30717 }
30718 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_jsx_runtime145.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30719 RegularLayout,
30720 {
30721 data,
30722 field,
30723 onChange,
30724 markWhenOptional,
30725 validity
30726 }
30727 ) }) });
30728 }
30729
30730 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
30731 var import_element109 = __toESM(require_element(), 1);
30732 var import_i18n51 = __toESM(require_i18n(), 1);
30733 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
30734 function FormDetailsField({
30735 data,
30736 field,
30737 onChange,
30738 validity
30739 }) {
30740 const { fields } = (0, import_element109.useContext)(dataform_context_default);
30741 const detailsRef = (0, import_element109.useRef)(null);
30742 const contentRef = (0, import_element109.useRef)(null);
30743 const [touched, setTouched] = (0, import_element109.useState)(false);
30744 const [isOpen, setIsOpen] = (0, import_element109.useState)(false);
30745 const form = (0, import_element109.useMemo)(
30746 () => ({
30747 layout: DEFAULT_LAYOUT,
30748 fields: field.children ?? []
30749 }),
30750 [field]
30751 );
30752 (0, import_element109.useEffect)(() => {
30753 const details = detailsRef.current;
30754 if (!details) {
30755 return;
30756 }
30757 const handleToggle = () => {
30758 const nowOpen = details.open;
30759 if (!nowOpen) {
30760 setTouched(true);
30761 }
30762 setIsOpen(nowOpen);
30763 };
30764 details.addEventListener("toggle", handleToggle);
30765 return () => {
30766 details.removeEventListener("toggle", handleToggle);
30767 };
30768 }, []);
30769 useReportValidity(contentRef, isOpen && touched);
30770 const handleBlur = (0, import_element109.useCallback)(() => {
30771 setTouched(true);
30772 }, []);
30773 if (!field.children) {
30774 return null;
30775 }
30776 const summaryFieldId = field.layout.summary ?? "";
30777 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
30778 let summaryContent;
30779 if (summaryField && summaryField.render) {
30780 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(summaryField.render, { item: data, field: summaryField });
30781 } else {
30782 summaryContent = field.label || (0, import_i18n51.__)("More details");
30783 }
30784 return /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
30785 "details",
30786 {
30787 ref: detailsRef,
30788 className: "dataforms-layouts-details__details",
30789 children: [
30790 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
30791 Stack,
30792 {
30793 direction: "row",
30794 align: "center",
30795 gap: "md",
30796 className: "dataforms-layouts-details__summary-content",
30797 children: [
30798 summaryContent,
30799 touched && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(ValidationBadge, { validity })
30800 ]
30801 }
30802 ) }),
30803 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30804 "div",
30805 {
30806 ref: contentRef,
30807 className: "dataforms-layouts-details__content",
30808 onBlur: handleBlur,
30809 children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30810 DataFormLayout,
30811 {
30812 data,
30813 form,
30814 onChange,
30815 validity: validity?.children
30816 }
30817 )
30818 }
30819 )
30820 ]
30821 }
30822 );
30823 }
30824
30825 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
30826 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
30827 var FORM_FIELD_LAYOUTS = [
30828 {
30829 type: "regular",
30830 component: FormRegularField,
30831 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30832 Stack,
30833 {
30834 direction: "column",
30835 className: "dataforms-layouts__wrapper",
30836 gap: "lg",
30837 children
30838 }
30839 )
30840 },
30841 {
30842 type: "panel",
30843 component: FormPanelField,
30844 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30845 Stack,
30846 {
30847 direction: "column",
30848 className: "dataforms-layouts__wrapper",
30849 gap: "md",
30850 children
30851 }
30852 )
30853 },
30854 {
30855 type: "card",
30856 component: FormCardField,
30857 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30858 Stack,
30859 {
30860 direction: "column",
30861 className: "dataforms-layouts__wrapper",
30862 gap: "xl",
30863 children
30864 }
30865 )
30866 },
30867 {
30868 type: "row",
30869 component: FormRowField,
30870 wrapper: ({
30871 children,
30872 layout
30873 }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30874 Stack,
30875 {
30876 direction: "column",
30877 className: "dataforms-layouts__wrapper",
30878 gap: "lg",
30879 children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30880 Stack,
30881 {
30882 direction: "row",
30883 gap: "lg",
30884 align: layout.alignment,
30885 children
30886 }
30887 ) })
30888 }
30889 )
30890 },
30891 {
30892 type: "details",
30893 component: FormDetailsField
30894 }
30895 ];
30896 function getFormFieldLayout(type) {
30897 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
30898 }
30899
30900 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
30901 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
30902 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
30903 function DataFormLayout({
30904 data,
30905 form,
30906 onChange,
30907 validity,
30908 children,
30909 as
30910 }) {
30911 const { fields: fieldDefinitions } = (0, import_element110.useContext)(dataform_context_default);
30912 const markWhenOptional = (0, import_element110.useMemo)(() => {
30913 const requiredCount = fieldDefinitions.filter(
30914 (f2) => !!f2.isValid?.required
30915 ).length;
30916 const optionalCount = fieldDefinitions.length - requiredCount;
30917 return requiredCount > optionalCount;
30918 }, [fieldDefinitions]);
30919 function getFieldDefinition2(field) {
30920 return fieldDefinitions.find(
30921 (fieldDefinition) => fieldDefinition.id === field.id
30922 );
30923 }
30924 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
30925 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
30926 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
30927 if (!FieldLayout) {
30928 return null;
30929 }
30930 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
30931 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
30932 return null;
30933 }
30934 if (children) {
30935 return children(
30936 FieldLayout,
30937 formField,
30938 validity?.[formField.id],
30939 markWhenOptional
30940 );
30941 }
30942 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
30943 FieldLayout,
30944 {
30945 data,
30946 field: formField,
30947 onChange,
30948 markWhenOptional,
30949 validity: validity?.[formField.id]
30950 },
30951 formField.id
30952 );
30953 }) });
30954 }
30955
30956 // packages/dataviews/build-module/dataform/index.mjs
30957 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
30958 function DataForm({
30959 data,
30960 form,
30961 fields,
30962 onChange,
30963 validity
30964 }) {
30965 const normalizedForm = (0, import_element111.useMemo)(() => normalize_form_default(form), [form]);
30966 const normalizedFields = (0, import_element111.useMemo)(
30967 () => normalizeFields(fields),
30968 [fields]
30969 );
30970 if (!form.fields) {
30971 return null;
30972 }
30973 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
30974 DataFormLayout,
30975 {
30976 data,
30977 form: normalizedForm,
30978 onChange,
30979 validity
30980 }
30981 ) });
30982 }
30983
30984 // widgets/quick-draft/render.tsx
30985 var import_element116 = __toESM(require_element());
30986 var import_escape_html = __toESM(require_escape_html());
30987 var import_i18n54 = __toESM(require_i18n());
30988
30989 // widgets/quick-draft/components/drafts-list/drafts-list.tsx
30990 var import_core_data = __toESM(require_core_data());
30991 var import_data6 = __toESM(require_data());
30992 var import_date10 = __toESM(require_date());
30993 var import_element112 = __toESM(require_element());
30994 var import_html_entities = __toESM(require_html_entities());
30995 var import_i18n52 = __toESM(require_i18n());
30996 var import_url3 = __toESM(require_url());
30997
30998 // packages/style-runtime/src/index.ts
30999 var STYLE_HASH_ATTRIBUTE24 = "data-wp-hash";
31000 function getRuntime24() {
31001 const globalScope = globalThis;
31002 if (globalScope.__wpStyleRuntime) {
31003 return globalScope.__wpStyleRuntime;
31004 }
31005 globalScope.__wpStyleRuntime = {
31006 documents: /* @__PURE__ */ new Map(),
31007 styles: /* @__PURE__ */ new Map(),
31008 injectedStyles: /* @__PURE__ */ new WeakMap()
31009 };
31010 if (typeof document !== "undefined") {
31011 registerDocument24(document);
31012 }
31013 return globalScope.__wpStyleRuntime;
31014 }
31015 function documentContainsStyleHash24(targetDocument, hash) {
31016 if (!targetDocument.head) {
31017 return false;
31018 }
31019 for (const style of targetDocument.head.querySelectorAll(
31020 `style[${STYLE_HASH_ATTRIBUTE24}]`
31021 )) {
31022 if (style.getAttribute(STYLE_HASH_ATTRIBUTE24) === hash) {
31023 return true;
31024 }
31025 }
31026 return false;
31027 }
31028 function injectStyle24(targetDocument, hash, css) {
31029 if (!targetDocument.head) {
31030 return;
31031 }
31032 const runtime = getRuntime24();
31033 let injectedStyles = runtime.injectedStyles.get(targetDocument);
31034 if (!injectedStyles) {
31035 injectedStyles = /* @__PURE__ */ new Set();
31036 runtime.injectedStyles.set(targetDocument, injectedStyles);
31037 }
31038 if (injectedStyles.has(hash)) {
31039 return;
31040 }
31041 if (documentContainsStyleHash24(targetDocument, hash)) {
31042 injectedStyles.add(hash);
31043 return;
31044 }
31045 const style = targetDocument.createElement("style");
31046 style.setAttribute(STYLE_HASH_ATTRIBUTE24, hash);
31047 style.appendChild(targetDocument.createTextNode(css));
31048 targetDocument.head.appendChild(style);
31049 injectedStyles.add(hash);
31050 }
31051 function registerDocument24(targetDocument) {
31052 const runtime = getRuntime24();
31053 runtime.documents.set(
31054 targetDocument,
31055 (runtime.documents.get(targetDocument) ?? 0) + 1
31056 );
31057 for (const [hash, css] of runtime.styles) {
31058 injectStyle24(targetDocument, hash, css);
31059 }
31060 return () => {
31061 const count = runtime.documents.get(targetDocument);
31062 if (count === void 0) {
31063 return;
31064 }
31065 if (count <= 1) {
31066 runtime.documents.delete(targetDocument);
31067 return;
31068 }
31069 runtime.documents.set(targetDocument, count - 1);
31070 };
31071 }
31072 function registerStyle24(hash, css) {
31073 const runtime = getRuntime24();
31074 runtime.styles.set(hash, css);
31075 for (const targetDocument of runtime.documents.keys()) {
31076 injectStyle24(targetDocument, hash, css);
31077 }
31078 }
31079
31080 // widgets/quick-draft/components/drafts-list/drafts-list.module.css
31081 if (typeof process === "undefined" || true) {
31082 registerStyle24("f291e7cf7e", "._27c1e13d297c9c75__root{flex:1;min-height:0;min-width:0;overflow:auto}._54b9ae86534218ea__titleHeader{border-top:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);padding-block-end:var(--wpds-dimension-padding-md,12px);padding-block-start:var(--wpds-dimension-padding-md,12px);padding-inline-start:var(--wpds-dimension-padding-md,12px)}._2e31af77792038af__thumbImage{object-fit:cover}._2e31af77792038af__thumbImage,.c4458e85b75cb2ca__thumbPlaceholder{border-radius:var(--wpds-border-radius-md,4px);height:100%;width:100%}.c4458e85b75cb2ca__thumbPlaceholder{align-items:center;background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center}._30dc10ae55a67d24__titleRow{min-width:0;width:100%}.eb5556cdba7ae763__titleLink{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._41963413d9183e83__date{color:var(--wpds-color-fg-content-neutral-weak,#707070)}");
31083 }
31084 var drafts_list_default = { "root": "_27c1e13d297c9c75__root", "titleHeader": "_54b9ae86534218ea__titleHeader", "thumbImage": "_2e31af77792038af__thumbImage", "thumbPlaceholder": "c4458e85b75cb2ca__thumbPlaceholder", "titleRow": "_30dc10ae55a67d24__titleRow", "titleLink": "eb5556cdba7ae763__titleLink", "date": "_41963413d9183e83__date" };
31085
31086 // widgets/quick-draft/components/drafts-list/drafts-list.tsx
31087 var import_jsx_runtime150 = __toESM(require_jsx_runtime());
31088 var DRAFTS_QUERY = {
31089 status: "draft",
31090 orderby: "date",
31091 order: "desc",
31092 per_page: 20,
31093 _embed: "wp:featuredmedia"
31094 };
31095 var DEFAULT_LAYOUTS2 = { list: {} };
31096 var INITIAL_VIEW = {
31097 type: "list",
31098 page: 1,
31099 perPage: DRAFTS_QUERY.per_page,
31100 search: "",
31101 filters: [],
31102 fields: [],
31103 titleField: "title",
31104 descriptionField: "date",
31105 mediaField: "featured",
31106 showMedia: true,
31107 layout: { density: "compact" }
31108 };
31109 function getEditUrl(postId) {
31110 return (0, import_url3.addQueryArgs)("post.php", { post: postId, action: "edit" });
31111 }
31112 function getThumbnailUrl(post) {
31113 const media = post._embedded?.["wp:featuredmedia"]?.[0];
31114 const sizes = media?.media_details?.sizes;
31115 return sizes?.thumbnail?.source_url ?? sizes?.medium?.source_url ?? media?.source_url;
31116 }
31117 function DraftThumbnail({ post }) {
31118 const url = getThumbnailUrl(post);
31119 if (url) {
31120 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31121 "img",
31122 {
31123 className: drafts_list_default.thumbImage,
31124 src: url,
31125 alt: "",
31126 loading: "lazy"
31127 }
31128 );
31129 }
31130 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("div", { className: drafts_list_default.thumbPlaceholder, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Icon, { icon: post_featured_image_default }) });
31131 }
31132 function DraftTitle({
31133 post,
31134 onDelete
31135 }) {
31136 const title = (0, import_html_entities.decodeEntities)(post.title?.rendered ?? "") || (0, import_i18n52.__)("(no title)");
31137 return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
31138 Stack,
31139 {
31140 direction: "row",
31141 align: "center",
31142 justify: "space-between",
31143 gap: "sm",
31144 className: drafts_list_default.titleRow,
31145 children: [
31146 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31147 Link,
31148 {
31149 href: getEditUrl(post.id),
31150 openInNewTab: true,
31151 className: drafts_list_default.titleLink,
31152 children: title
31153 }
31154 ),
31155 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31156 IconButton,
31157 {
31158 icon: trash_default,
31159 label: (0, import_i18n52.__)("Delete draft"),
31160 variant: "minimal",
31161 size: "small",
31162 onClick: () => onDelete(post.id)
31163 }
31164 )
31165 ]
31166 }
31167 );
31168 }
31169 function DraftDate({ post }) {
31170 const fullDate = (0, import_date10.dateI18n)((0, import_date10.getSettings)().formats.datetime, post.date);
31171 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31172 Text,
31173 {
31174 variant: "body-sm",
31175 className: drafts_list_default.date,
31176 render: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { title: fullDate }),
31177 children: (0, import_date10.humanTimeDiff)(post.date)
31178 }
31179 );
31180 }
31181 function DraftsList() {
31182 const [view, setView] = (0, import_element112.useState)(INITIAL_VIEW);
31183 const { drafts, isLoading } = (0, import_data6.useSelect)((select) => {
31184 const { getEntityRecords, hasFinishedResolution } = select(import_core_data.store);
31185 const records = getEntityRecords("postType", "post", DRAFTS_QUERY);
31186 return {
31187 drafts: records ?? [],
31188 isLoading: !hasFinishedResolution("getEntityRecords", [
31189 "postType",
31190 "post",
31191 DRAFTS_QUERY
31192 ])
31193 };
31194 }, []);
31195 const { deleteEntityRecord } = (0, import_data6.useDispatch)(import_core_data.store);
31196 const deleteDraft = (0, import_element112.useCallback)(
31197 (id) => {
31198 void deleteEntityRecord("postType", "post", id, void 0);
31199 },
31200 [deleteEntityRecord]
31201 );
31202 const fields = (0, import_element112.useMemo)(
31203 () => [
31204 {
31205 id: "title",
31206 label: (0, import_i18n52.__)("Title"),
31207 enableSorting: false,
31208 enableHiding: false,
31209 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(DraftTitle, { post: item, onDelete: deleteDraft })
31210 },
31211 {
31212 id: "date",
31213 label: (0, import_i18n52.__)("Date"),
31214 enableSorting: false,
31215 enableHiding: false,
31216 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(DraftDate, { post: item })
31217 },
31218 {
31219 id: "featured",
31220 label: (0, import_i18n52.__)("Featured image"),
31221 enableSorting: false,
31222 enableHiding: false,
31223 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(DraftThumbnail, { post: item })
31224 }
31225 ],
31226 [deleteDraft]
31227 );
31228 return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(Stack, { direction: "column", className: drafts_list_default.root, children: [
31229 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Text, { variant: "heading-md", className: drafts_list_default.titleHeader, children: (0, import_i18n52.__)("Your recent drafts") }),
31230 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31231 dataviews_default,
31232 {
31233 data: drafts,
31234 fields,
31235 view,
31236 onChangeView: setView,
31237 getItemId: (item) => String(item.id),
31238 isLoading,
31239 paginationInfo: { totalItems: drafts.length, totalPages: 1 },
31240 defaultLayouts: DEFAULT_LAYOUTS2,
31241 empty: /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(empty_state_exports.Root, { children: [
31242 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(empty_state_exports.Icon, { icon: drafts_default }),
31243 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(empty_state_exports.Description, { children: (0, import_i18n52.__)("No drafts yet.") })
31244 ] }),
31245 children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(dataviews_default.Layout, {})
31246 }
31247 )
31248 ] });
31249 }
31250
31251 // widgets/quick-draft/components/saved-post/saved-post.tsx
31252 var import_element113 = __toESM(require_element());
31253 var import_i18n53 = __toESM(require_i18n());
31254 var import_url4 = __toESM(require_url());
31255
31256 // widgets/quick-draft/components/saved-post/saved-post.module.css
31257 if (typeof process === "undefined" || true) {
31258 registerStyle24("0548559a53", "._88880a636bc02513__body{height:100%}._20963e427e9696da__icon{background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);border-color:var(--wpds-color-stroke-surface-success,#94d29e);color:var(--wpds-color-fg-content-success,#002900)}.ff3d1c6f8ba60167__continueLink{color:var(--wpds-color-fg-interactive-brand-strong,#fff)}");
31259 }
31260 var saved_post_default = { "body": "_88880a636bc02513__body", "icon": "_20963e427e9696da__icon", "continueLink": "ff3d1c6f8ba60167__continueLink" };
31261
31262 // widgets/quick-draft/components/saved-post/saved-post.tsx
31263 var import_jsx_runtime151 = __toESM(require_jsx_runtime());
31264 function SavedPost({
31265 postId,
31266 postTitle,
31267 onWriteAnother
31268 }) {
31269 const editUrl = (0, import_url4.addQueryArgs)("post.php", {
31270 post: postId,
31271 action: "edit"
31272 });
31273 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
31274 Stack,
31275 {
31276 direction: "column",
31277 align: "center",
31278 justify: "center",
31279 className: saved_post_default.body,
31280 children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(empty_state_exports.Root, { children: [
31281 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(empty_state_exports.Icon, { icon: check_default, className: saved_post_default.icon }),
31282 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(empty_state_exports.Title, { children: (0, import_i18n53.__)("Draft saved") }),
31283 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(empty_state_exports.Description, { children: (0, import_element113.createInterpolateElement)(
31284 (0, import_i18n53.sprintf)(
31285 /* translators: %s: post title */
31286 (0, import_i18n53.__)(
31287 '<strong>"%s"</strong> is ready to keep editing.'
31288 ),
31289 postTitle
31290 ),
31291 {
31292 strong: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("strong", {})
31293 }
31294 ) }),
31295 /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(empty_state_exports.Actions, { children: [
31296 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
31297 Button4,
31298 {
31299 variant: "solid",
31300 size: "compact",
31301 nativeButton: false,
31302 render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
31303 Link,
31304 {
31305 href: editUrl,
31306 openInNewTab: true,
31307 className: saved_post_default.continueLink
31308 }
31309 ),
31310 children: (0, import_i18n53.__)("Continue editing")
31311 }
31312 ),
31313 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
31314 Button4,
31315 {
31316 variant: "minimal",
31317 size: "compact",
31318 onClick: onWriteAnother,
31319 children: (0, import_i18n53.__)("Write another")
31320 }
31321 )
31322 ] })
31323 ] })
31324 }
31325 );
31326 }
31327
31328 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.tsx
31329 var import_components52 = __toESM(require_components());
31330 var import_element114 = __toESM(require_element());
31331
31332 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.module.css
31333 if (typeof process === "undefined" || true) {
31334 registerStyle24("ca3754f0d9", ".d6b34c2200336d18__root{height:100%;min-height:0}.d6b34c2200336d18__root .components-base-control,.d6b34c2200336d18__root .components-base-control__field{display:flex;flex:1;flex-direction:column;min-height:0}.d6b34c2200336d18__root .components-textarea-control__input{flex:1;min-height:0;resize:none}.dataforms-layouts-regular__field:has(.d6b34c2200336d18__root){flex:1;min-height:0}");
31335 }
31336 var quick_draft_content_field_default = { "root": "d6b34c2200336d18__root" };
31337
31338 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.tsx
31339 var import_jsx_runtime152 = __toESM(require_jsx_runtime());
31340 function getErrorMessage(validity) {
31341 if (!validity) {
31342 return void 0;
31343 }
31344 const entries = [
31345 validity.required,
31346 validity.minLength,
31347 validity.maxLength,
31348 validity.pattern,
31349 validity.custom
31350 ];
31351 const invalid = entries.find((entry) => entry?.type === "invalid");
31352 return invalid?.message;
31353 }
31354 function QuickDraftContentField({
31355 data,
31356 field,
31357 onChange,
31358 hideLabelFromVision,
31359 validity
31360 }) {
31361 const value = field.getValue({ item: data });
31362 const disabled2 = field.isDisabled({ item: data, field });
31363 const onChangeValue = (0, import_element114.useCallback)(
31364 (newValue) => onChange(field.setValue({ item: data, value: newValue })),
31365 [data, field, onChange]
31366 );
31367 const errorMessage = getErrorMessage(validity);
31368 const help = errorMessage ?? field.description;
31369 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(Stack, { direction: "column", className: quick_draft_content_field_default.root, children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
31370 import_components52.TextareaControl,
31371 {
31372 label: field.label,
31373 hideLabelFromVision,
31374 value: value ?? "",
31375 placeholder: field.placeholder,
31376 help,
31377 onChange: onChangeValue,
31378 disabled: disabled2,
31379 rows: 4
31380 }
31381 ) });
31382 }
31383
31384 // widgets/quick-draft/hooks/use-widget-size/use-widget-size.ts
31385 var import_compose17 = __toESM(require_compose());
31386 var import_element115 = __toESM(require_element());
31387 var WIDE_MIN_WIDTH = 560;
31388 var TALL_MIN_HEIGHT = 420;
31389 var INITIAL_SIZE = { width: 0, height: 0 };
31390 function useWidgetSize() {
31391 const [size4, setSize] = (0, import_element115.useState)(INITIAL_SIZE);
31392 const ref = (0, import_compose17.useResizeObserver)(
31393 (entries) => {
31394 const entry = entries[0];
31395 if (!entry) {
31396 return;
31397 }
31398 const box = entry.borderBoxSize?.[0];
31399 const width = box ? box.inlineSize : entry.contentRect.width;
31400 const height = box ? box.blockSize : entry.contentRect.height;
31401 setSize(
31402 (prev) => prev.width === width && prev.height === height ? prev : { width, height }
31403 );
31404 },
31405 { box: "border-box" }
31406 );
31407 return (0, import_element115.useMemo)(
31408 () => ({
31409 ref,
31410 width: size4.width,
31411 height: size4.height,
31412 isWide: size4.width >= WIDE_MIN_WIDTH,
31413 isTall: size4.height >= TALL_MIN_HEIGHT
31414 }),
31415 [ref, size4.width, size4.height]
31416 );
31417 }
31418
31419 // widgets/quick-draft/style.module.css
31420 if (typeof process === "undefined" || true) {
31421 registerStyle24("eb2359b364", "._1ceea6985c028257__body,.e95823d50a99f185__fill{height:100%}._0325357a2c3b57a4__primaryPane{border-top:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);flex:1;min-height:0;min-width:0;padding:var(--wpds-dimension-padding-lg,16px)}._20004de4c12366b1__listPane{flex:1;min-height:0;min-width:0}._809476aa1889889d__backRow{border-top:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);padding:var(--wpds-dimension-padding-sm,8px)}._264d0da8d26b736f__row ._0325357a2c3b57a4__primaryPane{border-inline-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);margin:0 auto;max-width:calc(var(--wpds-dimension-base, 4px)*100)}._6b9679a01ecee959__formContainer,._6b9679a01ecee959__formContainer>.dataforms-layouts__wrapper{flex:1;min-height:0}");
31422 }
31423 var style_default23 = { "body": "_1ceea6985c028257__body", "fill": "e95823d50a99f185__fill", "primaryPane": "_0325357a2c3b57a4__primaryPane", "listPane": "_20004de4c12366b1__listPane", "backRow": "_809476aa1889889d__backRow", "row": "_264d0da8d26b736f__row", "formContainer": "_6b9679a01ecee959__formContainer" };
31424
31425 // widgets/quick-draft/render.tsx
31426 var import_jsx_runtime153 = __toESM(require_jsx_runtime());
31427 function textToParagraphBlocks(text) {
31428 if (!text.trim()) {
31429 return "";
31430 }
31431 return (0, import_autop.autop)((0, import_escape_html.escapeHTML)(text)).replace(
31432 /<p>([\s\S]*?)<\/p>/g,
31433 "<!-- wp:paragraph -->\n<p>$1</p>\n<!-- /wp:paragraph -->"
31434 );
31435 }
31436 var FORM = {
31437 layout: { type: "regular" },
31438 fields: ["title", "content"]
31439 };
31440 var INITIAL_DATA = {
31441 title: "",
31442 content: ""
31443 };
31444 function QuickDraft() {
31445 const [data, setData] = (0, import_element116.useState)(INITIAL_DATA);
31446 const [isSaving, setIsSaving] = (0, import_element116.useState)(false);
31447 const [createdPost, setCreatedPost] = (0, import_element116.useState)(null);
31448 const [isListOpenInCompact, setIsListOpenInCompact] = (0, import_element116.useState)(false);
31449 const { ref, isWide, isTall } = useWidgetSize();
31450 const showDraftsList = isWide || isTall;
31451 const listBeside = isWide;
31452 const { saveEntityRecord } = (0, import_data7.useDispatch)(import_core_data2.store);
31453 const { hasDrafts } = (0, import_data7.useSelect)(
31454 (select) => {
31455 if (showDraftsList) {
31456 return { hasDrafts: false };
31457 }
31458 const { getEntityRecords } = select(import_core_data2.store);
31459 const anyDrafts = getEntityRecords("postType", "post", {
31460 status: "draft",
31461 per_page: 1
31462 });
31463 return { hasDrafts: (anyDrafts?.length ?? 0) > 0 };
31464 },
31465 [showDraftsList]
31466 );
31467 const fields = (0, import_element116.useMemo)(
31468 () => [
31469 {
31470 id: "title",
31471 type: "text",
31472 label: (0, import_i18n54.__)("Title"),
31473 isValid: { required: true, minLength: 3 },
31474 hideLabelFromVision: true,
31475 help: (0, import_i18n54.__)("Enter a title for your post.")
31476 },
31477 {
31478 id: "content",
31479 type: "text",
31480 label: (0, import_i18n54.__)("Content"),
31481 isValid: { required: true, minLength: 10 },
31482 Edit: QuickDraftContentField,
31483 help: (0, import_i18n54.__)("Enter the content for your post.")
31484 }
31485 ],
31486 []
31487 );
31488 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, FORM);
31489 const canSave = isValid2 && !isSaving;
31490 const saveDraftPost = async () => {
31491 if (!canSave) {
31492 return;
31493 }
31494 setIsSaving(true);
31495 try {
31496 const saved = await saveEntityRecord("postType", "post", {
31497 title: data.title,
31498 content: textToParagraphBlocks(data.content),
31499 status: "draft"
31500 });
31501 const newId = saved?.id;
31502 if (typeof newId === "number") {
31503 setCreatedPost({ id: newId, title: data.title });
31504 }
31505 setData(INITIAL_DATA);
31506 } finally {
31507 setIsSaving(false);
31508 }
31509 };
31510 const writeAnother = () => {
31511 setCreatedPost(null);
31512 };
31513 let primary;
31514 if (createdPost !== null) {
31515 primary = /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31516 SavedPost,
31517 {
31518 postId: createdPost.id,
31519 postTitle: createdPost.title,
31520 onWriteAnother: writeAnother
31521 }
31522 );
31523 } else {
31524 primary = /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31525 Stack,
31526 {
31527 direction: "column",
31528 gap: "md",
31529 justify: "space-between",
31530 className: style_default23.fill,
31531 children: [
31532 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.formContainer, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31533 DataForm,
31534 {
31535 data,
31536 fields,
31537 form: FORM,
31538 validity,
31539 onChange: (edits) => setData((prev) => ({ ...prev, ...edits }))
31540 }
31541 ) }),
31542 /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(Stack, { direction: "row", gap: "md", justify: "flex-start", children: [
31543 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31544 Button4,
31545 {
31546 variant: "solid",
31547 onClick: saveDraftPost,
31548 loading: isSaving,
31549 disabled: !canSave,
31550 children: (0, import_i18n54.__)("Save as draft")
31551 }
31552 ),
31553 !showDraftsList && hasDrafts && /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31554 Button4,
31555 {
31556 variant: "minimal",
31557 onClick: () => setIsListOpenInCompact(true),
31558 children: [
31559 (0, import_i18n54.__)("Draft posts"),
31560 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Button4.Icon, { icon: chevron_right_default })
31561 ]
31562 }
31563 )
31564 ] })
31565 ]
31566 }
31567 );
31568 }
31569 if (!showDraftsList && isListOpenInCompact) {
31570 return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(Stack, { ref, direction: "column", className: style_default23.body, children: [
31571 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.listPane, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DraftsList, {}) }),
31572 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31573 Stack,
31574 {
31575 direction: "row",
31576 justify: "flex-start",
31577 className: style_default23.backRow,
31578 children: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31579 Button4,
31580 {
31581 variant: "minimal",
31582 tone: "neutral",
31583 size: "compact",
31584 onClick: () => setIsListOpenInCompact(false),
31585 children: [
31586 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Button4.Icon, { icon: chevron_left_default }),
31587 (0, import_i18n54.__)("Back")
31588 ]
31589 }
31590 )
31591 }
31592 )
31593 ] });
31594 }
31595 if (!showDraftsList) {
31596 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { ref, direction: "column", className: style_default23.body, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.primaryPane, children: primary }) });
31597 }
31598 return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31599 Stack,
31600 {
31601 ref,
31602 direction: listBeside ? "row" : "column",
31603 className: clsx_default(
31604 style_default23.body,
31605 listBeside ? style_default23.row : style_default23.column
31606 ),
31607 children: [
31608 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.primaryPane, children: primary }),
31609 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.listPane, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DraftsList, {}) })
31610 ]
31611 }
31612 );
31613 }
31614 export {
31615 QuickDraft as default
31616 };
31617 /*! Bundled license information:
31618
31619 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
31620 (**
31621 * @license React
31622 * use-sync-external-store-shim.development.js
31623 *
31624 * Copyright (c) Meta Platforms, Inc. and affiliates.
31625 *
31626 * This source code is licensed under the MIT license found in the
31627 * LICENSE file in the root directory of this source tree.
31628 *)
31629
31630 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
31631 (**
31632 * @license React
31633 * use-sync-external-store-shim/with-selector.development.js
31634 *
31635 * Copyright (c) Meta Platforms, Inc. and affiliates.
31636 *
31637 * This source code is licensed under the MIT license found in the
31638 * LICENSE file in the root directory of this source tree.
31639 *)
31640 */
31641