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

index.js in Gutenberg 23.5.1, at build/modules/content-types/index.js

38,532 lines 1.4 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/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/element
39 var require_element = __commonJS({
40 "package-external:@wordpress/element"(exports, module) {
41 module.exports = window.wp.element;
42 }
43 });
44
45 // vendor-external:react
46 var require_react = __commonJS({
47 "vendor-external:react"(exports, module) {
48 module.exports = window.React;
49 }
50 });
51
52 // vendor-external:react/jsx-runtime
53 var require_jsx_runtime = __commonJS({
54 "vendor-external:react/jsx-runtime"(exports, module) {
55 module.exports = window.ReactJSXRuntime;
56 }
57 });
58
59 // vendor-external:react-dom
60 var require_react_dom = __commonJS({
61 "vendor-external:react-dom"(exports, module) {
62 module.exports = window.ReactDOM;
63 }
64 });
65
66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
67 var require_use_sync_external_store_shim_development = __commonJS({
68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
69 "use strict";
70 (function() {
71 function is(x2, y2) {
72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
73 }
74 function useSyncExternalStore$2(subscribe2, getSnapshot) {
75 didWarnOld18Alpha || void 0 === React84.startTransition || (didWarnOld18Alpha = true, console.error(
76 "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."
77 ));
78 var value = getSnapshot();
79 if (!didWarnUncachedGetSnapshot) {
80 var cachedValue = getSnapshot();
81 objectIs(value, cachedValue) || (console.error(
82 "The result of getSnapshot should be cached to avoid an infinite loop"
83 ), didWarnUncachedGetSnapshot = true);
84 }
85 cachedValue = useState55({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect5(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot]
96 );
97 useEffect47(
98 function() {
99 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
100 return subscribe2(function() {
101 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102 });
103 },
104 [subscribe2]
105 );
106 useDebugValue2(value);
107 return value;
108 }
109 function checkIfSnapshotChanged(inst) {
110 var latestGetSnapshot = inst.getSnapshot;
111 inst = inst.value;
112 try {
113 var nextValue = latestGetSnapshot();
114 return !objectIs(inst, nextValue);
115 } catch (error2) {
116 return true;
117 }
118 }
119 function useSyncExternalStore$1(subscribe2, getSnapshot) {
120 return getSnapshot();
121 }
122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
123 var React84 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState55 = React84.useState, useEffect47 = React84.useEffect, useLayoutEffect5 = React84.useLayoutEffect, useDebugValue2 = React84.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
124 exports.useSyncExternalStore = void 0 !== React84.useSyncExternalStore ? React84.useSyncExternalStore : shim;
125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
126 })();
127 }
128 });
129
130 // node_modules/use-sync-external-store/shim/index.js
131 var require_shim = __commonJS({
132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
133 "use strict";
134 if (false) {
135 module.exports = null;
136 } else {
137 module.exports = require_use_sync_external_store_shim_development();
138 }
139 }
140 });
141
142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
143 var require_with_selector_development = __commonJS({
144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
145 "use strict";
146 (function() {
147 function is(x2, y2) {
148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React84 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef65 = React84.useRef, useEffect47 = React84.useEffect, useMemo70 = React84.useMemo, useDebugValue2 = React84.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef65(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo70(
159 function() {
160 function memoizedSelector(nextSnapshot) {
161 if (!hasMemo) {
162 hasMemo = true;
163 memoizedSnapshot = nextSnapshot;
164 nextSnapshot = selector2(nextSnapshot);
165 if (void 0 !== isEqual && inst.hasValue) {
166 var currentSelection = inst.value;
167 if (isEqual(currentSelection, nextSnapshot))
168 return memoizedSelection = currentSelection;
169 }
170 return memoizedSelection = nextSnapshot;
171 }
172 currentSelection = memoizedSelection;
173 if (objectIs(memoizedSnapshot, nextSnapshot))
174 return currentSelection;
175 var nextSelection = selector2(nextSnapshot);
176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
177 return memoizedSnapshot = nextSnapshot, currentSelection;
178 memoizedSnapshot = nextSnapshot;
179 return memoizedSelection = nextSelection;
180 }
181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
182 return [
183 function() {
184 return memoizedSelector(getSnapshot());
185 },
186 null === maybeGetServerSnapshot ? void 0 : function() {
187 return memoizedSelector(maybeGetServerSnapshot());
188 }
189 ];
190 },
191 [getSnapshot, getServerSnapshot, selector2, isEqual]
192 );
193 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
194 useEffect47(
195 function() {
196 inst.hasValue = true;
197 inst.value = value;
198 },
199 [value]
200 );
201 useDebugValue2(value);
202 return value;
203 };
204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
205 })();
206 }
207 });
208
209 // node_modules/use-sync-external-store/shim/with-selector.js
210 var require_with_selector = __commonJS({
211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
212 "use strict";
213 if (false) {
214 module.exports = null;
215 } else {
216 module.exports = require_with_selector_development();
217 }
218 }
219 });
220
221 // package-external:@wordpress/primitives
222 var require_primitives = __commonJS({
223 "package-external:@wordpress/primitives"(exports, module) {
224 module.exports = window.wp.primitives;
225 }
226 });
227
228 // package-external:@wordpress/compose
229 var require_compose = __commonJS({
230 "package-external:@wordpress/compose"(exports, module) {
231 module.exports = window.wp.compose;
232 }
233 });
234
235 // package-external:@wordpress/theme
236 var require_theme = __commonJS({
237 "package-external:@wordpress/theme"(exports, module) {
238 module.exports = window.wp.theme;
239 }
240 });
241
242 // package-external:@wordpress/private-apis
243 var require_private_apis = __commonJS({
244 "package-external:@wordpress/private-apis"(exports, module) {
245 module.exports = window.wp.privateApis;
246 }
247 });
248
249 // package-external:@wordpress/components
250 var require_components = __commonJS({
251 "package-external:@wordpress/components"(exports, module) {
252 module.exports = window.wp.components;
253 }
254 });
255
256 // package-external:@wordpress/keycodes
257 var require_keycodes = __commonJS({
258 "package-external:@wordpress/keycodes"(exports, module) {
259 module.exports = window.wp.keycodes;
260 }
261 });
262
263 // package-external:@wordpress/data
264 var require_data = __commonJS({
265 "package-external:@wordpress/data"(exports, module) {
266 module.exports = window.wp.data;
267 }
268 });
269
270 // node_modules/remove-accents/index.js
271 var require_remove_accents = __commonJS({
272 "node_modules/remove-accents/index.js"(exports, module) {
273 var characterMap = {
274 "À": "A",
275 "Á": "A",
276 "Â": "A",
277 "Ã": "A",
278 "Ä": "A",
279 "Å": "A",
280 "Ấ": "A",
281 "Ắ": "A",
282 "Ẳ": "A",
283 "Ẵ": "A",
284 "Ặ": "A",
285 "Æ": "AE",
286 "Ầ": "A",
287 "Ằ": "A",
288 "Ȃ": "A",
289 "Ả": "A",
290 "Ạ": "A",
291 "Ẩ": "A",
292 "Ẫ": "A",
293 "Ậ": "A",
294 "Ç": "C",
295 "Ḉ": "C",
296 "È": "E",
297 "É": "E",
298 "Ê": "E",
299 "Ë": "E",
300 "Ế": "E",
301 "Ḗ": "E",
302 "Ề": "E",
303 "Ḕ": "E",
304 "Ḝ": "E",
305 "Ȇ": "E",
306 "Ẻ": "E",
307 "Ẽ": "E",
308 "Ẹ": "E",
309 "Ể": "E",
310 "Ễ": "E",
311 "Ệ": "E",
312 "Ì": "I",
313 "Í": "I",
314 "Î": "I",
315 "Ï": "I",
316 "Ḯ": "I",
317 "Ȋ": "I",
318 "Ỉ": "I",
319 "Ị": "I",
320 "Ð": "D",
321 "Ñ": "N",
322 "Ò": "O",
323 "Ó": "O",
324 "Ô": "O",
325 "Õ": "O",
326 "Ö": "O",
327 "Ø": "O",
328 "Ố": "O",
329 "Ṍ": "O",
330 "Ṓ": "O",
331 "Ȏ": "O",
332 "Ỏ": "O",
333 "Ọ": "O",
334 "Ổ": "O",
335 "Ỗ": "O",
336 "Ộ": "O",
337 "Ờ": "O",
338 "Ở": "O",
339 "Ỡ": "O",
340 "Ớ": "O",
341 "Ợ": "O",
342 "Ù": "U",
343 "Ú": "U",
344 "Û": "U",
345 "Ü": "U",
346 "Ủ": "U",
347 "Ụ": "U",
348 "Ử": "U",
349 "Ữ": "U",
350 "Ự": "U",
351 "Ý": "Y",
352 "à": "a",
353 "á": "a",
354 "â": "a",
355 "ã": "a",
356 "ä": "a",
357 "å": "a",
358 "ấ": "a",
359 "ắ": "a",
360 "ẳ": "a",
361 "ẵ": "a",
362 "ặ": "a",
363 "æ": "ae",
364 "ầ": "a",
365 "ằ": "a",
366 "ȃ": "a",
367 "ả": "a",
368 "ạ": "a",
369 "ẩ": "a",
370 "ẫ": "a",
371 "ậ": "a",
372 "ç": "c",
373 "ḉ": "c",
374 "è": "e",
375 "é": "e",
376 "ê": "e",
377 "ë": "e",
378 "ế": "e",
379 "ḗ": "e",
380 "ề": "e",
381 "ḕ": "e",
382 "ḝ": "e",
383 "ȇ": "e",
384 "ẻ": "e",
385 "ẽ": "e",
386 "ẹ": "e",
387 "ể": "e",
388 "ễ": "e",
389 "ệ": "e",
390 "ì": "i",
391 "í": "i",
392 "î": "i",
393 "ï": "i",
394 "ḯ": "i",
395 "ȋ": "i",
396 "ỉ": "i",
397 "ị": "i",
398 "ð": "d",
399 "ñ": "n",
400 "ò": "o",
401 "ó": "o",
402 "ô": "o",
403 "õ": "o",
404 "ö": "o",
405 "ø": "o",
406 "ố": "o",
407 "ṍ": "o",
408 "ṓ": "o",
409 "ȏ": "o",
410 "ỏ": "o",
411 "ọ": "o",
412 "ổ": "o",
413 "ỗ": "o",
414 "ộ": "o",
415 "ờ": "o",
416 "ở": "o",
417 "ỡ": "o",
418 "ớ": "o",
419 "ợ": "o",
420 "ù": "u",
421 "ú": "u",
422 "û": "u",
423 "ü": "u",
424 "ủ": "u",
425 "ụ": "u",
426 "ử": "u",
427 "ữ": "u",
428 "ự": "u",
429 "ý": "y",
430 "ÿ": "y",
431 "Ā": "A",
432 "ā": "a",
433 "Ă": "A",
434 "ă": "a",
435 "Ą": "A",
436 "ą": "a",
437 "Ć": "C",
438 "ć": "c",
439 "Ĉ": "C",
440 "ĉ": "c",
441 "Ċ": "C",
442 "ċ": "c",
443 "Č": "C",
444 "č": "c",
445 "C̆": "C",
446 "c̆": "c",
447 "Ď": "D",
448 "ď": "d",
449 "Đ": "D",
450 "đ": "d",
451 "Ē": "E",
452 "ē": "e",
453 "Ĕ": "E",
454 "ĕ": "e",
455 "Ė": "E",
456 "ė": "e",
457 "Ę": "E",
458 "ę": "e",
459 "Ě": "E",
460 "ě": "e",
461 "Ĝ": "G",
462 "Ǵ": "G",
463 "ĝ": "g",
464 "ǵ": "g",
465 "Ğ": "G",
466 "ğ": "g",
467 "Ġ": "G",
468 "ġ": "g",
469 "Ģ": "G",
470 "ģ": "g",
471 "Ĥ": "H",
472 "ĥ": "h",
473 "Ħ": "H",
474 "ħ": "h",
475 "Ḫ": "H",
476 "ḫ": "h",
477 "Ĩ": "I",
478 "ĩ": "i",
479 "Ī": "I",
480 "ī": "i",
481 "Ĭ": "I",
482 "ĭ": "i",
483 "Į": "I",
484 "į": "i",
485 "İ": "I",
486 "ı": "i",
487 "IJ": "IJ",
488 "ij": "ij",
489 "Ĵ": "J",
490 "ĵ": "j",
491 "Ķ": "K",
492 "ķ": "k",
493 "Ḱ": "K",
494 "ḱ": "k",
495 "K̆": "K",
496 "k̆": "k",
497 "Ĺ": "L",
498 "ĺ": "l",
499 "Ļ": "L",
500 "ļ": "l",
501 "Ľ": "L",
502 "ľ": "l",
503 "Ŀ": "L",
504 "ŀ": "l",
505 "Ł": "l",
506 "ł": "l",
507 "Ḿ": "M",
508 "ḿ": "m",
509 "M̆": "M",
510 "m̆": "m",
511 "Ń": "N",
512 "ń": "n",
513 "Ņ": "N",
514 "ņ": "n",
515 "Ň": "N",
516 "ň": "n",
517 "ʼn": "n",
518 "N̆": "N",
519 "n̆": "n",
520 "Ō": "O",
521 "ō": "o",
522 "Ŏ": "O",
523 "ŏ": "o",
524 "Ő": "O",
525 "ő": "o",
526 "Œ": "OE",
527 "œ": "oe",
528 "P̆": "P",
529 "p̆": "p",
530 "Ŕ": "R",
531 "ŕ": "r",
532 "Ŗ": "R",
533 "ŗ": "r",
534 "Ř": "R",
535 "ř": "r",
536 "R̆": "R",
537 "r̆": "r",
538 "Ȓ": "R",
539 "ȓ": "r",
540 "Ś": "S",
541 "ś": "s",
542 "Ŝ": "S",
543 "ŝ": "s",
544 "Ş": "S",
545 "Ș": "S",
546 "ș": "s",
547 "ş": "s",
548 "Š": "S",
549 "š": "s",
550 "Ţ": "T",
551 "ţ": "t",
552 "ț": "t",
553 "Ț": "T",
554 "Ť": "T",
555 "ť": "t",
556 "Ŧ": "T",
557 "ŧ": "t",
558 "T̆": "T",
559 "t̆": "t",
560 "Ũ": "U",
561 "ũ": "u",
562 "Ū": "U",
563 "ū": "u",
564 "Ŭ": "U",
565 "ŭ": "u",
566 "Ů": "U",
567 "ů": "u",
568 "Ű": "U",
569 "ű": "u",
570 "Ų": "U",
571 "ų": "u",
572 "Ȗ": "U",
573 "ȗ": "u",
574 "V̆": "V",
575 "v̆": "v",
576 "Ŵ": "W",
577 "ŵ": "w",
578 "Ẃ": "W",
579 "ẃ": "w",
580 "X̆": "X",
581 "x̆": "x",
582 "Ŷ": "Y",
583 "ŷ": "y",
584 "Ÿ": "Y",
585 "Y̆": "Y",
586 "y̆": "y",
587 "Ź": "Z",
588 "ź": "z",
589 "Ż": "Z",
590 "ż": "z",
591 "Ž": "Z",
592 "ž": "z",
593 "ſ": "s",
594 "ƒ": "f",
595 "Ơ": "O",
596 "ơ": "o",
597 "Ư": "U",
598 "ư": "u",
599 "Ǎ": "A",
600 "ǎ": "a",
601 "Ǐ": "I",
602 "ǐ": "i",
603 "Ǒ": "O",
604 "ǒ": "o",
605 "Ǔ": "U",
606 "ǔ": "u",
607 "Ǖ": "U",
608 "ǖ": "u",
609 "Ǘ": "U",
610 "ǘ": "u",
611 "Ǚ": "U",
612 "ǚ": "u",
613 "Ǜ": "U",
614 "ǜ": "u",
615 "Ứ": "U",
616 "ứ": "u",
617 "Ṹ": "U",
618 "ṹ": "u",
619 "Ǻ": "A",
620 "ǻ": "a",
621 "Ǽ": "AE",
622 "ǽ": "ae",
623 "Ǿ": "O",
624 "ǿ": "o",
625 "Þ": "TH",
626 "þ": "th",
627 "Ṕ": "P",
628 "ṕ": "p",
629 "Ṥ": "S",
630 "ṥ": "s",
631 "X́": "X",
632 "x́": "x",
633 "Ѓ": "Г",
634 "ѓ": "г",
635 "Ќ": "К",
636 "ќ": "к",
637 "A̋": "A",
638 "a̋": "a",
639 "E̋": "E",
640 "e̋": "e",
641 "I̋": "I",
642 "i̋": "i",
643 "Ǹ": "N",
644 "ǹ": "n",
645 "Ồ": "O",
646 "ồ": "o",
647 "Ṑ": "O",
648 "ṑ": "o",
649 "Ừ": "U",
650 "ừ": "u",
651 "Ẁ": "W",
652 "ẁ": "w",
653 "Ỳ": "Y",
654 "ỳ": "y",
655 "Ȁ": "A",
656 "ȁ": "a",
657 "Ȅ": "E",
658 "ȅ": "e",
659 "Ȉ": "I",
660 "ȉ": "i",
661 "Ȍ": "O",
662 "ȍ": "o",
663 "Ȑ": "R",
664 "ȑ": "r",
665 "Ȕ": "U",
666 "ȕ": "u",
667 "B̌": "B",
668 "b̌": "b",
669 "Č̣": "C",
670 "č̣": "c",
671 "Ê̌": "E",
672 "ê̌": "e",
673 "F̌": "F",
674 "f̌": "f",
675 "Ǧ": "G",
676 "ǧ": "g",
677 "Ȟ": "H",
678 "ȟ": "h",
679 "J̌": "J",
680 "ǰ": "j",
681 "Ǩ": "K",
682 "ǩ": "k",
683 "M̌": "M",
684 "m̌": "m",
685 "P̌": "P",
686 "p̌": "p",
687 "Q̌": "Q",
688 "q̌": "q",
689 "Ř̩": "R",
690 "ř̩": "r",
691 "Ṧ": "S",
692 "ṧ": "s",
693 "V̌": "V",
694 "v̌": "v",
695 "W̌": "W",
696 "w̌": "w",
697 "X̌": "X",
698 "x̌": "x",
699 "Y̌": "Y",
700 "y̌": "y",
701 "A̧": "A",
702 "a̧": "a",
703 "B̧": "B",
704 "b̧": "b",
705 "Ḑ": "D",
706 "ḑ": "d",
707 "Ȩ": "E",
708 "ȩ": "e",
709 "Ɛ̧": "E",
710 "ɛ̧": "e",
711 "Ḩ": "H",
712 "ḩ": "h",
713 "I̧": "I",
714 "i̧": "i",
715 "Ɨ̧": "I",
716 "ɨ̧": "i",
717 "M̧": "M",
718 "m̧": "m",
719 "O̧": "O",
720 "o̧": "o",
721 "Q̧": "Q",
722 "q̧": "q",
723 "U̧": "U",
724 "u̧": "u",
725 "X̧": "X",
726 "x̧": "x",
727 "Z̧": "Z",
728 "z̧": "z",
729 "й": "и",
730 "Й": "И",
731 "ё": "е",
732 "Ё": "Е"
733 };
734 var chars = Object.keys(characterMap).join("|");
735 var allAccents = new RegExp(chars, "g");
736 var firstAccent = new RegExp(chars, "");
737 function matcher(match2) {
738 return characterMap[match2];
739 }
740 var removeAccents2 = function(string) {
741 return string.replace(allAccents, matcher);
742 };
743 var hasAccents = function(string) {
744 return !!string.match(firstAccent);
745 };
746 module.exports = removeAccents2;
747 module.exports.has = hasAccents;
748 module.exports.remove = removeAccents2;
749 }
750 });
751
752 // node_modules/fast-deep-equal/es6/index.js
753 var require_es6 = __commonJS({
754 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
755 "use strict";
756 module.exports = function equal(a2, b2) {
757 if (a2 === b2) return true;
758 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
759 if (a2.constructor !== b2.constructor) return false;
760 var length, i2, keys;
761 if (Array.isArray(a2)) {
762 length = a2.length;
763 if (length != b2.length) return false;
764 for (i2 = length; i2-- !== 0; )
765 if (!equal(a2[i2], b2[i2])) return false;
766 return true;
767 }
768 if (a2 instanceof Map && b2 instanceof Map) {
769 if (a2.size !== b2.size) return false;
770 for (i2 of a2.entries())
771 if (!b2.has(i2[0])) return false;
772 for (i2 of a2.entries())
773 if (!equal(i2[1], b2.get(i2[0]))) return false;
774 return true;
775 }
776 if (a2 instanceof Set && b2 instanceof Set) {
777 if (a2.size !== b2.size) return false;
778 for (i2 of a2.entries())
779 if (!b2.has(i2[0])) return false;
780 return true;
781 }
782 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (a2[i2] !== b2[i2]) return false;
787 return true;
788 }
789 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
790 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
791 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
792 keys = Object.keys(a2);
793 length = keys.length;
794 if (length !== Object.keys(b2).length) return false;
795 for (i2 = length; i2-- !== 0; )
796 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
797 for (i2 = length; i2-- !== 0; ) {
798 var key = keys[i2];
799 if (!equal(a2[key], b2[key])) return false;
800 }
801 return true;
802 }
803 return a2 !== a2 && b2 !== b2;
804 };
805 }
806 });
807
808 // package-external:@wordpress/date
809 var require_date = __commonJS({
810 "package-external:@wordpress/date"(exports, module) {
811 module.exports = window.wp.date;
812 }
813 });
814
815 // package-external:@wordpress/warning
816 var require_warning = __commonJS({
817 "package-external:@wordpress/warning"(exports, module) {
818 module.exports = window.wp.warning;
819 }
820 });
821
822 // node_modules/deepmerge/dist/cjs.js
823 var require_cjs = __commonJS({
824 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
825 "use strict";
826 var isMergeableObject = function isMergeableObject2(value) {
827 return isNonNullObject(value) && !isSpecial(value);
828 };
829 function isNonNullObject(value) {
830 return !!value && typeof value === "object";
831 }
832 function isSpecial(value) {
833 var stringValue = Object.prototype.toString.call(value);
834 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
835 }
836 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
837 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
838 function isReactElement(value) {
839 return value.$$typeof === REACT_ELEMENT_TYPE;
840 }
841 function emptyTarget(val) {
842 return Array.isArray(val) ? [] : {};
843 }
844 function cloneUnlessOtherwiseSpecified(value, options) {
845 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
846 }
847 function defaultArrayMerge(target, source, options) {
848 return target.concat(source).map(function(element) {
849 return cloneUnlessOtherwiseSpecified(element, options);
850 });
851 }
852 function getMergeFunction(key, options) {
853 if (!options.customMerge) {
854 return deepmerge;
855 }
856 var customMerge = options.customMerge(key);
857 return typeof customMerge === "function" ? customMerge : deepmerge;
858 }
859 function getEnumerableOwnPropertySymbols(target) {
860 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
861 return Object.propertyIsEnumerable.call(target, symbol3);
862 }) : [];
863 }
864 function getKeys2(target) {
865 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
866 }
867 function propertyIsOnObject(object, property) {
868 try {
869 return property in object;
870 } catch (_) {
871 return false;
872 }
873 }
874 function propertyIsUnsafe(target, key) {
875 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
876 }
877 function mergeObject(target, source, options) {
878 var destination = {};
879 if (options.isMergeableObject(target)) {
880 getKeys2(target).forEach(function(key) {
881 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
882 });
883 }
884 getKeys2(source).forEach(function(key) {
885 if (propertyIsUnsafe(target, key)) {
886 return;
887 }
888 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
889 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
890 } else {
891 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
892 }
893 });
894 return destination;
895 }
896 function deepmerge(target, source, options) {
897 options = options || {};
898 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
899 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
900 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
901 var sourceIsArray = Array.isArray(source);
902 var targetIsArray = Array.isArray(target);
903 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
904 if (!sourceAndTargetTypesMatch) {
905 return cloneUnlessOtherwiseSpecified(source, options);
906 } else if (sourceIsArray) {
907 return options.arrayMerge(target, source, options);
908 } else {
909 return mergeObject(target, source, options);
910 }
911 }
912 deepmerge.all = function deepmergeAll(array, options) {
913 if (!Array.isArray(array)) {
914 throw new Error("first argument should be an array");
915 }
916 return array.reduce(function(prev, next) {
917 return deepmerge(prev, next, options);
918 }, {});
919 };
920 var deepmerge_1 = deepmerge;
921 module.exports = deepmerge_1;
922 }
923 });
924
925 // package-external:@wordpress/core-data
926 var require_core_data = __commonJS({
927 "package-external:@wordpress/core-data"(exports, module) {
928 module.exports = window.wp.coreData;
929 }
930 });
931
932 // package-external:@wordpress/preferences
933 var require_preferences = __commonJS({
934 "package-external:@wordpress/preferences"(exports, module) {
935 module.exports = window.wp.preferences;
936 }
937 });
938
939 // package-external:@wordpress/notices
940 var require_notices = __commonJS({
941 "package-external:@wordpress/notices"(exports, module) {
942 module.exports = window.wp.notices;
943 }
944 });
945
946 // package-external:@wordpress/is-shallow-equal
947 var require_is_shallow_equal = __commonJS({
948 "package-external:@wordpress/is-shallow-equal"(exports, module) {
949 module.exports = window.wp.isShallowEqual;
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 // packages/admin-ui/build-module/breadcrumbs/index.mjs
961 var import_i18n4 = __toESM(require_i18n(), 1);
962 import { Link as RouterLink } from "@wordpress/route";
963
964 // node_modules/clsx/dist/clsx.mjs
965 function r(e2) {
966 var t2, f2, n2 = "";
967 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
968 else if ("object" == typeof e2) if (Array.isArray(e2)) {
969 var o2 = e2.length;
970 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
971 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
972 return n2;
973 }
974 function clsx() {
975 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
976 return n2;
977 }
978 var clsx_default = clsx;
979
980 // packages/ui/build-module/badge/badge.mjs
981 var import_element13 = __toESM(require_element(), 1);
982
983 // node_modules/@base-ui/utils/esm/useControlled.js
984 var React = __toESM(require_react(), 1);
985
986 // node_modules/@base-ui/utils/esm/error.js
987 var set;
988 if (true) {
989 set = /* @__PURE__ */ new Set();
990 }
991 function error(...messages) {
992 if (true) {
993 const messageKey = messages.join(" ");
994 if (!set.has(messageKey)) {
995 set.add(messageKey);
996 console.error(`Base UI: ${messageKey}`);
997 }
998 }
999 }
1000
1001 // node_modules/@base-ui/utils/esm/useControlled.js
1002 function useControlled({
1003 controlled,
1004 default: defaultProp,
1005 name,
1006 state = "value"
1007 }) {
1008 const {
1009 current: isControlled
1010 } = React.useRef(controlled !== void 0);
1011 const [valueState, setValue] = React.useState(defaultProp);
1012 const value = isControlled ? controlled : valueState;
1013 if (true) {
1014 React.useEffect(() => {
1015 if (isControlled !== (controlled !== void 0)) {
1016 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"));
1017 }
1018 }, [state, name, controlled]);
1019 const {
1020 current: defaultValue2
1021 } = React.useRef(defaultProp);
1022 React.useEffect(() => {
1023 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
1024 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"));
1025 }
1026 }, [defaultProp]);
1027 }
1028 const setValueIfUncontrolled = React.useCallback((newValue) => {
1029 if (!isControlled) {
1030 setValue(newValue);
1031 }
1032 }, []);
1033 return [value, setValueIfUncontrolled];
1034 }
1035 function serializeToDevModeString(input) {
1036 let nextId = 0;
1037 const seen = /* @__PURE__ */ new WeakMap();
1038 try {
1039 const result = JSON.stringify(input, function replacer(key, value) {
1040 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
1041 return void 0;
1042 }
1043 if (typeof value === "bigint") {
1044 return `__bigint__:${value}`;
1045 }
1046 if (value !== null && typeof value === "object") {
1047 const id = seen.get(value);
1048 if (id !== void 0) {
1049 return `__object__:${id}`;
1050 }
1051 seen.set(value, nextId);
1052 nextId += 1;
1053 }
1054 return value;
1055 });
1056 return result ?? `__top__:${typeof input}`;
1057 } catch {
1058 return "__unserializable__";
1059 }
1060 }
1061
1062 // node_modules/@base-ui/utils/esm/safeReact.js
1063 var React2 = __toESM(require_react(), 1);
1064 var SafeReact = {
1065 ...React2
1066 };
1067
1068 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1069 var React3 = __toESM(require_react(), 1);
1070 var UNINITIALIZED = {};
1071 function useRefWithInit(init2, initArg) {
1072 const ref = React3.useRef(UNINITIALIZED);
1073 if (ref.current === UNINITIALIZED) {
1074 ref.current = init2(initArg);
1075 }
1076 return ref;
1077 }
1078
1079 // node_modules/@base-ui/utils/esm/useStableCallback.js
1080 var useInsertionEffect = SafeReact.useInsertionEffect;
1081 var useSafeInsertionEffect = (
1082 // React 17 doesn't have useInsertionEffect.
1083 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1084 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1085 );
1086 function useStableCallback(callback) {
1087 const stable = useRefWithInit(createStableCallback).current;
1088 stable.next = callback;
1089 useSafeInsertionEffect(stable.effect);
1090 return stable.trampoline;
1091 }
1092 function createStableCallback() {
1093 const stable = {
1094 next: void 0,
1095 callback: assertNotCalled,
1096 trampoline: (...args) => stable.callback?.(...args),
1097 effect: () => {
1098 stable.callback = stable.next;
1099 }
1100 };
1101 return stable;
1102 }
1103 function assertNotCalled() {
1104 if (true) {
1105 throw (
1106 /* minify-error-disabled */
1107 new Error("Base UI: Cannot call an event handler while rendering.")
1108 );
1109 }
1110 }
1111
1112 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1113 var React4 = __toESM(require_react(), 1);
1114 var noop = () => {
1115 };
1116 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1117
1118 // node_modules/@base-ui/utils/esm/warn.js
1119 var set2;
1120 if (true) {
1121 set2 = /* @__PURE__ */ new Set();
1122 }
1123 function warn(...messages) {
1124 if (true) {
1125 const messageKey = messages.join(" ");
1126 if (!set2.has(messageKey)) {
1127 set2.add(messageKey);
1128 console.warn(`Base UI: ${messageKey}`);
1129 }
1130 }
1131 }
1132
1133 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1134 var React5 = __toESM(require_react(), 1);
1135 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1136 if (true) DirectionContext.displayName = "DirectionContext";
1137 function useDirection() {
1138 const context = React5.useContext(DirectionContext);
1139 return context?.direction ?? "ltr";
1140 }
1141
1142 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1143 var React8 = __toESM(require_react(), 1);
1144
1145 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1146 function useMergedRefs(a2, b2, c2, d2) {
1147 const forkRef = useRefWithInit(createForkRef).current;
1148 if (didChange(forkRef, a2, b2, c2, d2)) {
1149 update(forkRef, [a2, b2, c2, d2]);
1150 }
1151 return forkRef.callback;
1152 }
1153 function useMergedRefsN(refs) {
1154 const forkRef = useRefWithInit(createForkRef).current;
1155 if (didChangeN(forkRef, refs)) {
1156 update(forkRef, refs);
1157 }
1158 return forkRef.callback;
1159 }
1160 function createForkRef() {
1161 return {
1162 callback: null,
1163 cleanup: null,
1164 refs: []
1165 };
1166 }
1167 function didChange(forkRef, a2, b2, c2, d2) {
1168 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1169 }
1170 function didChangeN(forkRef, newRefs) {
1171 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1172 }
1173 function update(forkRef, refs) {
1174 forkRef.refs = refs;
1175 if (refs.every((ref) => ref == null)) {
1176 forkRef.callback = null;
1177 return;
1178 }
1179 forkRef.callback = (instance) => {
1180 if (forkRef.cleanup) {
1181 forkRef.cleanup();
1182 forkRef.cleanup = null;
1183 }
1184 if (instance != null) {
1185 const cleanupCallbacks = Array(refs.length).fill(null);
1186 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1187 const ref = refs[i2];
1188 if (ref == null) {
1189 continue;
1190 }
1191 switch (typeof ref) {
1192 case "function": {
1193 const refCleanup = ref(instance);
1194 if (typeof refCleanup === "function") {
1195 cleanupCallbacks[i2] = refCleanup;
1196 }
1197 break;
1198 }
1199 case "object": {
1200 ref.current = instance;
1201 break;
1202 }
1203 default:
1204 }
1205 }
1206 forkRef.cleanup = () => {
1207 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1208 const ref = refs[i2];
1209 if (ref == null) {
1210 continue;
1211 }
1212 switch (typeof ref) {
1213 case "function": {
1214 const cleanupCallback = cleanupCallbacks[i2];
1215 if (typeof cleanupCallback === "function") {
1216 cleanupCallback();
1217 } else {
1218 ref(null);
1219 }
1220 break;
1221 }
1222 case "object": {
1223 ref.current = null;
1224 break;
1225 }
1226 default:
1227 }
1228 }
1229 };
1230 }
1231 };
1232 }
1233
1234 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1235 var React7 = __toESM(require_react(), 1);
1236
1237 // node_modules/@base-ui/utils/esm/reactVersion.js
1238 var React6 = __toESM(require_react(), 1);
1239 var majorVersion = parseInt(React6.version, 10);
1240 function isReactVersionAtLeast(reactVersionToCheck) {
1241 return majorVersion >= reactVersionToCheck;
1242 }
1243
1244 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1245 function getReactElementRef(element) {
1246 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1247 return null;
1248 }
1249 const reactElement = element;
1250 const propsWithRef = reactElement.props;
1251 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1252 }
1253
1254 // node_modules/@base-ui/utils/esm/mergeObjects.js
1255 function mergeObjects(a2, b2) {
1256 if (a2 && !b2) {
1257 return a2;
1258 }
1259 if (!a2 && b2) {
1260 return b2;
1261 }
1262 if (a2 || b2) {
1263 return {
1264 ...a2,
1265 ...b2
1266 };
1267 }
1268 return void 0;
1269 }
1270
1271 // node_modules/@base-ui/utils/esm/empty.js
1272 function NOOP() {
1273 }
1274 var EMPTY_ARRAY = Object.freeze([]);
1275 var EMPTY_OBJECT = Object.freeze({});
1276
1277 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1278 function getStateAttributesProps(state, customMapping) {
1279 const props = {};
1280 for (const key in state) {
1281 const value = state[key];
1282 if (customMapping?.hasOwnProperty(key)) {
1283 const customProps = customMapping[key](value);
1284 if (customProps != null) {
1285 Object.assign(props, customProps);
1286 }
1287 continue;
1288 }
1289 if (value === true) {
1290 props[`data-${key.toLowerCase()}`] = "";
1291 } else if (value) {
1292 props[`data-${key.toLowerCase()}`] = value.toString();
1293 }
1294 }
1295 return props;
1296 }
1297
1298 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1299 function resolveClassName(className, state) {
1300 return typeof className === "function" ? className(state) : className;
1301 }
1302
1303 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1304 function resolveStyle(style, state) {
1305 return typeof style === "function" ? style(state) : style;
1306 }
1307
1308 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1309 var EMPTY_PROPS = {};
1310 function mergeProps(a2, b2, c2, d2, e2) {
1311 if (!c2 && !d2 && !e2 && !a2) {
1312 return createInitialMergedProps(b2);
1313 }
1314 let merged = createInitialMergedProps(a2);
1315 if (b2) {
1316 merged = mergeInto(merged, b2);
1317 }
1318 if (c2) {
1319 merged = mergeInto(merged, c2);
1320 }
1321 if (d2) {
1322 merged = mergeInto(merged, d2);
1323 }
1324 if (e2) {
1325 merged = mergeInto(merged, e2);
1326 }
1327 return merged;
1328 }
1329 function mergePropsN(props) {
1330 if (props.length === 0) {
1331 return EMPTY_PROPS;
1332 }
1333 if (props.length === 1) {
1334 return createInitialMergedProps(props[0]);
1335 }
1336 let merged = createInitialMergedProps(props[0]);
1337 for (let i2 = 1; i2 < props.length; i2 += 1) {
1338 merged = mergeInto(merged, props[i2]);
1339 }
1340 return merged;
1341 }
1342 function createInitialMergedProps(inputProps) {
1343 if (isPropsGetter(inputProps)) {
1344 return {
1345 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1346 };
1347 }
1348 return copyInitialProps(inputProps);
1349 }
1350 function mergeInto(merged, inputProps) {
1351 if (isPropsGetter(inputProps)) {
1352 return resolvePropsGetter(inputProps, merged);
1353 }
1354 return mutablyMergeInto(merged, inputProps);
1355 }
1356 function copyInitialProps(inputProps) {
1357 const copiedProps = {
1358 ...inputProps
1359 };
1360 for (const propName in copiedProps) {
1361 const propValue = copiedProps[propName];
1362 if (isEventHandler(propName, propValue)) {
1363 copiedProps[propName] = wrapEventHandler(propValue);
1364 }
1365 }
1366 return copiedProps;
1367 }
1368 function mutablyMergeInto(mergedProps, externalProps) {
1369 if (!externalProps) {
1370 return mergedProps;
1371 }
1372 for (const propName in externalProps) {
1373 const externalPropValue = externalProps[propName];
1374 switch (propName) {
1375 case "style": {
1376 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1377 break;
1378 }
1379 case "className": {
1380 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1381 break;
1382 }
1383 default: {
1384 if (isEventHandler(propName, externalPropValue)) {
1385 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1386 } else {
1387 mergedProps[propName] = externalPropValue;
1388 }
1389 }
1390 }
1391 }
1392 return mergedProps;
1393 }
1394 function isEventHandler(key, value) {
1395 const code0 = key.charCodeAt(0);
1396 const code1 = key.charCodeAt(1);
1397 const code2 = key.charCodeAt(2);
1398 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1399 }
1400 function isPropsGetter(inputProps) {
1401 return typeof inputProps === "function";
1402 }
1403 function resolvePropsGetter(inputProps, previousProps) {
1404 if (isPropsGetter(inputProps)) {
1405 return inputProps(previousProps);
1406 }
1407 return inputProps ?? EMPTY_PROPS;
1408 }
1409 function mergeEventHandlers(ourHandler, theirHandler) {
1410 if (!theirHandler) {
1411 return ourHandler;
1412 }
1413 if (!ourHandler) {
1414 return wrapEventHandler(theirHandler);
1415 }
1416 return (...args) => {
1417 const event = args[0];
1418 if (isSyntheticEvent(event)) {
1419 const baseUIEvent = event;
1420 makeEventPreventable(baseUIEvent);
1421 const result2 = theirHandler(...args);
1422 if (!baseUIEvent.baseUIHandlerPrevented) {
1423 ourHandler?.(...args);
1424 }
1425 return result2;
1426 }
1427 const result = theirHandler(...args);
1428 ourHandler?.(...args);
1429 return result;
1430 };
1431 }
1432 function wrapEventHandler(handler) {
1433 if (!handler) {
1434 return handler;
1435 }
1436 return (...args) => {
1437 const event = args[0];
1438 if (isSyntheticEvent(event)) {
1439 makeEventPreventable(event);
1440 }
1441 return handler(...args);
1442 };
1443 }
1444 function makeEventPreventable(event) {
1445 event.preventBaseUIHandler = () => {
1446 event.baseUIHandlerPrevented = true;
1447 };
1448 return event;
1449 }
1450 function mergeClassNames(ourClassName, theirClassName) {
1451 if (theirClassName) {
1452 if (ourClassName) {
1453 return theirClassName + " " + ourClassName;
1454 }
1455 return theirClassName;
1456 }
1457 return ourClassName;
1458 }
1459 function isSyntheticEvent(event) {
1460 return event != null && typeof event === "object" && "nativeEvent" in event;
1461 }
1462
1463 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1464 var import_react = __toESM(require_react(), 1);
1465 function useRenderElement(element, componentProps, params = {}) {
1466 const renderProp = componentProps.render;
1467 const outProps = useRenderElementProps(componentProps, params);
1468 if (params.enabled === false) {
1469 return null;
1470 }
1471 const state = params.state ?? EMPTY_OBJECT;
1472 return evaluateRenderProp(element, renderProp, outProps, state);
1473 }
1474 function useRenderElementProps(componentProps, params = {}) {
1475 const {
1476 className: classNameProp,
1477 style: styleProp,
1478 render: renderProp
1479 } = componentProps;
1480 const {
1481 state = EMPTY_OBJECT,
1482 ref,
1483 props,
1484 stateAttributesMapping: stateAttributesMapping7,
1485 enabled = true
1486 } = params;
1487 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1488 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1489 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping7) : EMPTY_OBJECT;
1490 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1491 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1492 if (typeof document !== "undefined") {
1493 if (!enabled) {
1494 useMergedRefs(null, null);
1495 } else if (Array.isArray(ref)) {
1496 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1497 } else {
1498 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1499 }
1500 }
1501 if (!enabled) {
1502 return EMPTY_OBJECT;
1503 }
1504 if (className !== void 0) {
1505 outProps.className = mergeClassNames(outProps.className, className);
1506 }
1507 if (style !== void 0) {
1508 outProps.style = mergeObjects(outProps.style, style);
1509 }
1510 return outProps;
1511 }
1512 function resolveRenderFunctionProps(props) {
1513 if (Array.isArray(props)) {
1514 return mergePropsN(props);
1515 }
1516 return mergeProps(void 0, props);
1517 }
1518 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1519 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1520 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1521 function evaluateRenderProp(element, render4, props, state) {
1522 if (render4) {
1523 if (typeof render4 === "function") {
1524 if (true) {
1525 warnIfRenderPropLooksLikeComponent(render4);
1526 }
1527 return render4(props, state);
1528 }
1529 const mergedProps = mergeProps(props, render4.props);
1530 mergedProps.ref = props.ref;
1531 let newElement = render4;
1532 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1533 const children = React8.Children.toArray(render4);
1534 newElement = children[0];
1535 }
1536 if (true) {
1537 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1538 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"));
1539 }
1540 }
1541 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1542 }
1543 if (element) {
1544 if (typeof element === "string") {
1545 return renderTag(element, props);
1546 }
1547 }
1548 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1549 }
1550 function warnIfRenderPropLooksLikeComponent(renderFn) {
1551 const functionName = renderFn.name;
1552 if (functionName.length === 0) {
1553 return;
1554 }
1555 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1556 return;
1557 }
1558 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1559 return;
1560 }
1561 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");
1562 }
1563 function renderTag(Tag, props) {
1564 if (Tag === "button") {
1565 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1566 type: "button",
1567 ...props,
1568 key: props.key
1569 });
1570 }
1571 if (Tag === "img") {
1572 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1573 alt: "",
1574 ...props,
1575 key: props.key
1576 });
1577 }
1578 return /* @__PURE__ */ React8.createElement(Tag, props);
1579 }
1580
1581 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1582 var reason_parts_exports = {};
1583 __export(reason_parts_exports, {
1584 cancelOpen: () => cancelOpen,
1585 chipRemovePress: () => chipRemovePress,
1586 clearPress: () => clearPress,
1587 closePress: () => closePress,
1588 closeWatcher: () => closeWatcher,
1589 decrementPress: () => decrementPress,
1590 disabled: () => disabled,
1591 drag: () => drag,
1592 escapeKey: () => escapeKey,
1593 focusOut: () => focusOut,
1594 imperativeAction: () => imperativeAction,
1595 incrementPress: () => incrementPress,
1596 initial: () => initial,
1597 inputBlur: () => inputBlur,
1598 inputChange: () => inputChange,
1599 inputClear: () => inputClear,
1600 inputPaste: () => inputPaste,
1601 inputPress: () => inputPress,
1602 itemPress: () => itemPress,
1603 keyboard: () => keyboard,
1604 linkPress: () => linkPress,
1605 listNavigation: () => listNavigation,
1606 missing: () => missing,
1607 none: () => none,
1608 outsidePress: () => outsidePress,
1609 pointer: () => pointer,
1610 scrub: () => scrub,
1611 siblingOpen: () => siblingOpen,
1612 swipe: () => swipe,
1613 trackPress: () => trackPress,
1614 triggerFocus: () => triggerFocus,
1615 triggerHover: () => triggerHover,
1616 triggerPress: () => triggerPress,
1617 wheel: () => wheel,
1618 windowResize: () => windowResize
1619 });
1620 var none = "none";
1621 var triggerPress = "trigger-press";
1622 var triggerHover = "trigger-hover";
1623 var triggerFocus = "trigger-focus";
1624 var outsidePress = "outside-press";
1625 var itemPress = "item-press";
1626 var closePress = "close-press";
1627 var linkPress = "link-press";
1628 var clearPress = "clear-press";
1629 var chipRemovePress = "chip-remove-press";
1630 var trackPress = "track-press";
1631 var incrementPress = "increment-press";
1632 var decrementPress = "decrement-press";
1633 var inputChange = "input-change";
1634 var inputClear = "input-clear";
1635 var inputBlur = "input-blur";
1636 var inputPaste = "input-paste";
1637 var inputPress = "input-press";
1638 var focusOut = "focus-out";
1639 var escapeKey = "escape-key";
1640 var closeWatcher = "close-watcher";
1641 var listNavigation = "list-navigation";
1642 var keyboard = "keyboard";
1643 var pointer = "pointer";
1644 var drag = "drag";
1645 var wheel = "wheel";
1646 var scrub = "scrub";
1647 var cancelOpen = "cancel-open";
1648 var siblingOpen = "sibling-open";
1649 var disabled = "disabled";
1650 var missing = "missing";
1651 var initial = "initial";
1652 var imperativeAction = "imperative-action";
1653 var swipe = "swipe";
1654 var windowResize = "window-resize";
1655
1656 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1657 function createChangeEventDetails(reason, event, trigger, customProperties) {
1658 let canceled = false;
1659 let allowPropagation = false;
1660 const custom = customProperties ?? EMPTY_OBJECT;
1661 const details = {
1662 reason,
1663 event: event ?? new Event("base-ui"),
1664 cancel() {
1665 canceled = true;
1666 },
1667 allowPropagation() {
1668 allowPropagation = true;
1669 },
1670 get isCanceled() {
1671 return canceled;
1672 },
1673 get isPropagationAllowed() {
1674 return allowPropagation;
1675 },
1676 trigger,
1677 ...custom
1678 };
1679 return details;
1680 }
1681
1682 // node_modules/@base-ui/utils/esm/useId.js
1683 var React9 = __toESM(require_react(), 1);
1684 var globalId = 0;
1685 function useGlobalId(idOverride, prefix = "mui") {
1686 const [defaultId, setDefaultId] = React9.useState(idOverride);
1687 const id = idOverride || defaultId;
1688 React9.useEffect(() => {
1689 if (defaultId == null) {
1690 globalId += 1;
1691 setDefaultId(`${prefix}-${globalId}`);
1692 }
1693 }, [defaultId, prefix]);
1694 return id;
1695 }
1696 var maybeReactUseId = SafeReact.useId;
1697 function useId(idOverride, prefix) {
1698 if (maybeReactUseId !== void 0) {
1699 const reactId = maybeReactUseId();
1700 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1701 }
1702 return useGlobalId(idOverride, prefix);
1703 }
1704
1705 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1706 function useBaseUiId(idOverride) {
1707 return useId(idOverride, "base-ui");
1708 }
1709
1710 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1711 var React12 = __toESM(require_react(), 1);
1712
1713 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1714 var React11 = __toESM(require_react(), 1);
1715
1716 // node_modules/@base-ui/utils/esm/useOnMount.js
1717 var React10 = __toESM(require_react(), 1);
1718 var EMPTY = [];
1719 function useOnMount(fn) {
1720 React10.useEffect(fn, EMPTY);
1721 }
1722
1723 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1724 var EMPTY2 = null;
1725 var LAST_RAF = globalThis.requestAnimationFrame;
1726 var Scheduler = class {
1727 /* This implementation uses an array as a backing data-structure for frame callbacks.
1728 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1729 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1730 * be much more efficient if there is a call pattern that alterns as
1731 * "request-cancel-request-cancel-…".
1732 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1733 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1734 callbacks = [];
1735 callbacksCount = 0;
1736 nextId = 1;
1737 startId = 1;
1738 isScheduled = false;
1739 tick = (timestamp) => {
1740 this.isScheduled = false;
1741 const currentCallbacks = this.callbacks;
1742 const currentCallbacksCount = this.callbacksCount;
1743 this.callbacks = [];
1744 this.callbacksCount = 0;
1745 this.startId = this.nextId;
1746 if (currentCallbacksCount > 0) {
1747 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1748 currentCallbacks[i2]?.(timestamp);
1749 }
1750 }
1751 };
1752 request(fn) {
1753 const id = this.nextId;
1754 this.nextId += 1;
1755 this.callbacks.push(fn);
1756 this.callbacksCount += 1;
1757 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1758 if (!this.isScheduled || didRAFChange) {
1759 requestAnimationFrame(this.tick);
1760 this.isScheduled = true;
1761 }
1762 return id;
1763 }
1764 cancel(id) {
1765 const index2 = id - this.startId;
1766 if (index2 < 0 || index2 >= this.callbacks.length) {
1767 return;
1768 }
1769 this.callbacks[index2] = null;
1770 this.callbacksCount -= 1;
1771 }
1772 };
1773 var scheduler = new Scheduler();
1774 var AnimationFrame = class _AnimationFrame {
1775 static create() {
1776 return new _AnimationFrame();
1777 }
1778 static request(fn) {
1779 return scheduler.request(fn);
1780 }
1781 static cancel(id) {
1782 return scheduler.cancel(id);
1783 }
1784 currentId = EMPTY2;
1785 /**
1786 * Executes `fn` after `delay`, clearing any previously scheduled call.
1787 */
1788 request(fn) {
1789 this.cancel();
1790 this.currentId = scheduler.request(() => {
1791 this.currentId = EMPTY2;
1792 fn();
1793 });
1794 }
1795 cancel = () => {
1796 if (this.currentId !== EMPTY2) {
1797 scheduler.cancel(this.currentId);
1798 this.currentId = EMPTY2;
1799 }
1800 };
1801 disposeEffect = () => {
1802 return this.cancel;
1803 };
1804 };
1805 function useAnimationFrame() {
1806 const timeout = useRefWithInit(AnimationFrame.create).current;
1807 useOnMount(timeout.disposeEffect);
1808 return timeout;
1809 }
1810
1811 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1812 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1813 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1814 const [mounted, setMounted] = React11.useState(open);
1815 if (open && !mounted) {
1816 setMounted(true);
1817 setTransitionStatus("starting");
1818 }
1819 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1820 setTransitionStatus("ending");
1821 }
1822 if (!open && !mounted && transitionStatus === "ending") {
1823 setTransitionStatus(void 0);
1824 }
1825 useIsoLayoutEffect(() => {
1826 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1827 const frame = AnimationFrame.request(() => {
1828 setTransitionStatus("ending");
1829 });
1830 return () => {
1831 AnimationFrame.cancel(frame);
1832 };
1833 }
1834 return void 0;
1835 }, [open, mounted, transitionStatus, deferEndingState]);
1836 useIsoLayoutEffect(() => {
1837 if (!open || enableIdleState) {
1838 return void 0;
1839 }
1840 const frame = AnimationFrame.request(() => {
1841 setTransitionStatus(void 0);
1842 });
1843 return () => {
1844 AnimationFrame.cancel(frame);
1845 };
1846 }, [enableIdleState, open]);
1847 useIsoLayoutEffect(() => {
1848 if (!open || !enableIdleState) {
1849 return void 0;
1850 }
1851 if (open && mounted && transitionStatus !== "idle") {
1852 setTransitionStatus("starting");
1853 }
1854 const frame = AnimationFrame.request(() => {
1855 setTransitionStatus("idle");
1856 });
1857 return () => {
1858 AnimationFrame.cancel(frame);
1859 };
1860 }, [enableIdleState, open, mounted, transitionStatus]);
1861 return {
1862 mounted,
1863 setMounted,
1864 transitionStatus
1865 };
1866 }
1867
1868 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1869 function useCollapsibleRoot(parameters) {
1870 const {
1871 open: openParam,
1872 defaultOpen,
1873 onOpenChange,
1874 disabled: disabled2
1875 } = parameters;
1876 const [open, setOpen] = useControlled({
1877 controlled: openParam,
1878 default: defaultOpen,
1879 name: "Collapsible",
1880 state: "open"
1881 });
1882 const {
1883 mounted,
1884 setMounted,
1885 transitionStatus
1886 } = useTransitionStatus(open, true, true);
1887 const defaultPanelId = useBaseUiId();
1888 const [panelIdState, setPanelIdState] = React12.useState();
1889 const panelId = panelIdState ?? defaultPanelId;
1890 const handleTrigger = useStableCallback((event) => {
1891 const nextOpen = !open;
1892 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
1893 onOpenChange(nextOpen, eventDetails);
1894 if (eventDetails.isCanceled) {
1895 return;
1896 }
1897 setOpen(nextOpen);
1898 });
1899 return React12.useMemo(() => ({
1900 disabled: disabled2,
1901 handleTrigger,
1902 mounted,
1903 open,
1904 panelId,
1905 setMounted,
1906 setOpen,
1907 setPanelIdState,
1908 transitionStatus
1909 }), [disabled2, handleTrigger, mounted, open, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]);
1910 }
1911
1912 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js
1913 var React13 = __toESM(require_react(), 1);
1914 var CollapsibleRootContext = /* @__PURE__ */ React13.createContext(void 0);
1915 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
1916 function useCollapsibleRootContext() {
1917 const context = React13.useContext(CollapsibleRootContext);
1918 if (context === void 0) {
1919 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
1920 }
1921 return context;
1922 }
1923
1924 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1925 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1926 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1927 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1928 return TransitionStatusDataAttributes2;
1929 })({});
1930 var STARTING_HOOK = {
1931 [TransitionStatusDataAttributes.startingStyle]: ""
1932 };
1933 var ENDING_HOOK = {
1934 [TransitionStatusDataAttributes.endingStyle]: ""
1935 };
1936 var transitionStatusMapping = {
1937 transitionStatus(value) {
1938 if (value === "starting") {
1939 return STARTING_HOOK;
1940 }
1941 if (value === "ending") {
1942 return ENDING_HOOK;
1943 }
1944 return null;
1945 }
1946 };
1947
1948 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js
1949 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
1950 CollapsiblePanelDataAttributes2["open"] = "data-open";
1951 CollapsiblePanelDataAttributes2["closed"] = "data-closed";
1952 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
1953 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
1954 return CollapsiblePanelDataAttributes2;
1955 })({});
1956
1957 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js
1958 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
1959 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
1960 return CollapsibleTriggerDataAttributes2;
1961 })({});
1962
1963 // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js
1964 var PANEL_OPEN_HOOK = {
1965 [CollapsiblePanelDataAttributes.open]: ""
1966 };
1967 var PANEL_CLOSED_HOOK = {
1968 [CollapsiblePanelDataAttributes.closed]: ""
1969 };
1970 var triggerOpenStateMapping = {
1971 open(value) {
1972 if (value) {
1973 return {
1974 [CollapsibleTriggerDataAttributes.panelOpen]: ""
1975 };
1976 }
1977 return null;
1978 }
1979 };
1980 var collapsibleOpenStateMapping = {
1981 open(value) {
1982 if (value) {
1983 return PANEL_OPEN_HOOK;
1984 }
1985 return PANEL_CLOSED_HOOK;
1986 }
1987 };
1988
1989 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
1990 var React16 = __toESM(require_react(), 1);
1991
1992 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1993 function hasWindow() {
1994 return typeof window !== "undefined";
1995 }
1996 function getNodeName(node) {
1997 if (isNode(node)) {
1998 return (node.nodeName || "").toLowerCase();
1999 }
2000 return "#document";
2001 }
2002 function getWindow(node) {
2003 var _node$ownerDocument;
2004 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2005 }
2006 function getDocumentElement(node) {
2007 var _ref;
2008 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2009 }
2010 function isNode(value) {
2011 if (!hasWindow()) {
2012 return false;
2013 }
2014 return value instanceof Node || value instanceof getWindow(value).Node;
2015 }
2016 function isElement(value) {
2017 if (!hasWindow()) {
2018 return false;
2019 }
2020 return value instanceof Element || value instanceof getWindow(value).Element;
2021 }
2022 function isHTMLElement(value) {
2023 if (!hasWindow()) {
2024 return false;
2025 }
2026 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2027 }
2028 function isShadowRoot(value) {
2029 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2030 return false;
2031 }
2032 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2033 }
2034 function isOverflowElement(element) {
2035 const {
2036 overflow,
2037 overflowX,
2038 overflowY,
2039 display
2040 } = getComputedStyle2(element);
2041 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2042 }
2043 function isTableElement(element) {
2044 return /^(table|td|th)$/.test(getNodeName(element));
2045 }
2046 function isTopLayer(element) {
2047 try {
2048 if (element.matches(":popover-open")) {
2049 return true;
2050 }
2051 } catch (_e) {
2052 }
2053 try {
2054 return element.matches(":modal");
2055 } catch (_e) {
2056 return false;
2057 }
2058 }
2059 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2060 var containRe = /paint|layout|strict|content/;
2061 var isNotNone = (value) => !!value && value !== "none";
2062 var isWebKitValue;
2063 function isContainingBlock(elementOrCss) {
2064 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2065 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 || "");
2066 }
2067 function getContainingBlock(element) {
2068 let currentNode = getParentNode(element);
2069 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2070 if (isContainingBlock(currentNode)) {
2071 return currentNode;
2072 } else if (isTopLayer(currentNode)) {
2073 return null;
2074 }
2075 currentNode = getParentNode(currentNode);
2076 }
2077 return null;
2078 }
2079 function isWebKit() {
2080 if (isWebKitValue == null) {
2081 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2082 }
2083 return isWebKitValue;
2084 }
2085 function isLastTraversableNode(node) {
2086 return /^(html|body|#document)$/.test(getNodeName(node));
2087 }
2088 function getComputedStyle2(element) {
2089 return getWindow(element).getComputedStyle(element);
2090 }
2091 function getNodeScroll(element) {
2092 if (isElement(element)) {
2093 return {
2094 scrollLeft: element.scrollLeft,
2095 scrollTop: element.scrollTop
2096 };
2097 }
2098 return {
2099 scrollLeft: element.scrollX,
2100 scrollTop: element.scrollY
2101 };
2102 }
2103 function getParentNode(node) {
2104 if (getNodeName(node) === "html") {
2105 return node;
2106 }
2107 const result = (
2108 // Step into the shadow DOM of the parent of a slotted node.
2109 node.assignedSlot || // DOM Element detected.
2110 node.parentNode || // ShadowRoot detected.
2111 isShadowRoot(node) && node.host || // Fallback.
2112 getDocumentElement(node)
2113 );
2114 return isShadowRoot(result) ? result.host : result;
2115 }
2116 function getNearestOverflowAncestor(node) {
2117 const parentNode = getParentNode(node);
2118 if (isLastTraversableNode(parentNode)) {
2119 return node.ownerDocument ? node.ownerDocument.body : node.body;
2120 }
2121 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2122 return parentNode;
2123 }
2124 return getNearestOverflowAncestor(parentNode);
2125 }
2126 function getOverflowAncestors(node, list, traverseIframes) {
2127 var _node$ownerDocument2;
2128 if (list === void 0) {
2129 list = [];
2130 }
2131 if (traverseIframes === void 0) {
2132 traverseIframes = true;
2133 }
2134 const scrollableAncestor = getNearestOverflowAncestor(node);
2135 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2136 const win = getWindow(scrollableAncestor);
2137 if (isBody) {
2138 const frameElement = getFrameElement(win);
2139 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2140 } else {
2141 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2142 }
2143 }
2144 function getFrameElement(win) {
2145 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2146 }
2147
2148 // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js
2149 var React14 = __toESM(require_react(), 1);
2150 var CompositeRootContext = /* @__PURE__ */ React14.createContext(void 0);
2151 if (true) CompositeRootContext.displayName = "CompositeRootContext";
2152 function useCompositeRootContext(optional = false) {
2153 const context = React14.useContext(CompositeRootContext);
2154 if (context === void 0 && !optional) {
2155 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
2156 }
2157 return context;
2158 }
2159
2160 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js
2161 var React15 = __toESM(require_react(), 1);
2162 function useFocusableWhenDisabled(parameters) {
2163 const {
2164 focusableWhenDisabled,
2165 disabled: disabled2,
2166 composite = false,
2167 tabIndex: tabIndexProp = 0,
2168 isNativeButton
2169 } = parameters;
2170 const isFocusableComposite = composite && focusableWhenDisabled !== false;
2171 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
2172 const props = React15.useMemo(() => {
2173 const additionalProps = {
2174 // allow Tabbing away from focusableWhenDisabled elements
2175 onKeyDown(event) {
2176 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
2177 event.preventDefault();
2178 }
2179 }
2180 };
2181 if (!composite) {
2182 additionalProps.tabIndex = tabIndexProp;
2183 if (!isNativeButton && disabled2) {
2184 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
2185 }
2186 }
2187 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
2188 additionalProps["aria-disabled"] = disabled2;
2189 }
2190 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
2191 additionalProps.disabled = disabled2;
2192 }
2193 return additionalProps;
2194 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
2195 return {
2196 props
2197 };
2198 }
2199
2200 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
2201 function useButton(parameters = {}) {
2202 const {
2203 disabled: disabled2 = false,
2204 focusableWhenDisabled,
2205 tabIndex = 0,
2206 native: isNativeButton = true,
2207 composite: compositeProp
2208 } = parameters;
2209 const elementRef = React16.useRef(null);
2210 const compositeRootContext = useCompositeRootContext(true);
2211 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2212 const {
2213 props: focusableWhenDisabledProps
2214 } = useFocusableWhenDisabled({
2215 focusableWhenDisabled,
2216 disabled: disabled2,
2217 composite: isCompositeItem,
2218 tabIndex,
2219 isNativeButton
2220 });
2221 if (true) {
2222 React16.useEffect(() => {
2223 if (!elementRef.current) {
2224 return;
2225 }
2226 const isButtonTag = isButtonElement(elementRef.current);
2227 if (isNativeButton) {
2228 if (!isButtonTag) {
2229 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2230 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`.";
2231 error(`${message2}${ownerStackMessage}`);
2232 }
2233 } else if (isButtonTag) {
2234 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2235 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`.";
2236 error(`${message2}${ownerStackMessage}`);
2237 }
2238 }, [isNativeButton]);
2239 }
2240 const updateDisabled = React16.useCallback(() => {
2241 const element = elementRef.current;
2242 if (!isButtonElement(element)) {
2243 return;
2244 }
2245 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2246 element.disabled = false;
2247 }
2248 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2249 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2250 const getButtonProps = React16.useCallback((externalProps = {}) => {
2251 const {
2252 onClick: externalOnClick,
2253 onMouseDown: externalOnMouseDown,
2254 onKeyUp: externalOnKeyUp,
2255 onKeyDown: externalOnKeyDown,
2256 onPointerDown: externalOnPointerDown,
2257 ...otherExternalProps
2258 } = externalProps;
2259 return mergeProps({
2260 onClick(event) {
2261 if (disabled2) {
2262 event.preventDefault();
2263 return;
2264 }
2265 externalOnClick?.(event);
2266 },
2267 onMouseDown(event) {
2268 if (!disabled2) {
2269 externalOnMouseDown?.(event);
2270 }
2271 },
2272 onKeyDown(event) {
2273 if (disabled2) {
2274 return;
2275 }
2276 makeEventPreventable(event);
2277 externalOnKeyDown?.(event);
2278 if (event.baseUIHandlerPrevented) {
2279 return;
2280 }
2281 const isCurrentTarget = event.target === event.currentTarget;
2282 const currentTarget = event.currentTarget;
2283 const isButton2 = isButtonElement(currentTarget);
2284 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2285 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2286 const isEnterKey = event.key === "Enter";
2287 const isSpaceKey = event.key === " ";
2288 const role = currentTarget.getAttribute("role");
2289 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2290 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2291 if (event.defaultPrevented && isTextNavigationRole) {
2292 return;
2293 }
2294 event.preventDefault();
2295 if (isLink || isNativeButton && isButton2) {
2296 currentTarget.click();
2297 event.preventBaseUIHandler();
2298 } else if (shouldClick) {
2299 externalOnClick?.(event);
2300 event.preventBaseUIHandler();
2301 }
2302 return;
2303 }
2304 if (shouldClick) {
2305 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2306 event.preventDefault();
2307 }
2308 if (!isNativeButton && isEnterKey) {
2309 externalOnClick?.(event);
2310 }
2311 }
2312 },
2313 onKeyUp(event) {
2314 if (disabled2) {
2315 return;
2316 }
2317 makeEventPreventable(event);
2318 externalOnKeyUp?.(event);
2319 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2320 event.preventDefault();
2321 return;
2322 }
2323 if (event.baseUIHandlerPrevented) {
2324 return;
2325 }
2326 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2327 externalOnClick?.(event);
2328 }
2329 },
2330 onPointerDown(event) {
2331 if (disabled2) {
2332 event.preventDefault();
2333 return;
2334 }
2335 externalOnPointerDown?.(event);
2336 }
2337 }, isNativeButton ? {
2338 type: "button"
2339 } : {
2340 role: "button"
2341 }, focusableWhenDisabledProps, otherExternalProps);
2342 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2343 const buttonRef = useStableCallback((element) => {
2344 elementRef.current = element;
2345 updateDisabled();
2346 });
2347 return {
2348 getButtonProps,
2349 buttonRef
2350 };
2351 }
2352 function isButtonElement(elem) {
2353 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2354 }
2355 function isValidLinkElement(elem) {
2356 return Boolean(elem?.tagName === "A" && elem?.href);
2357 }
2358
2359 // node_modules/@base-ui/utils/esm/detectBrowser.js
2360 var hasNavigator = typeof navigator !== "undefined";
2361 var nav = getNavigatorData();
2362 var platform = getPlatform();
2363 var userAgent = getUserAgent();
2364 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2365 var isIOS = (
2366 // iPads can claim to be MacIntel
2367 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2368 );
2369 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2370 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2371 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2372 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2373 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2374 var isJSDOM = userAgent.includes("jsdom/");
2375 function getNavigatorData() {
2376 if (!hasNavigator) {
2377 return {
2378 platform: "",
2379 maxTouchPoints: -1
2380 };
2381 }
2382 const uaData = navigator.userAgentData;
2383 if (uaData?.platform) {
2384 return {
2385 platform: uaData.platform,
2386 maxTouchPoints: navigator.maxTouchPoints
2387 };
2388 }
2389 return {
2390 platform: navigator.platform ?? "",
2391 maxTouchPoints: navigator.maxTouchPoints ?? -1
2392 };
2393 }
2394 function getUserAgent() {
2395 if (!hasNavigator) {
2396 return "";
2397 }
2398 const uaData = navigator.userAgentData;
2399 if (uaData && Array.isArray(uaData.brands)) {
2400 return uaData.brands.map(({
2401 brand,
2402 version: version2
2403 }) => `${brand}/${version2}`).join(" ");
2404 }
2405 return navigator.userAgent;
2406 }
2407 function getPlatform() {
2408 if (!hasNavigator) {
2409 return "";
2410 }
2411 const uaData = navigator.userAgentData;
2412 if (uaData?.platform) {
2413 return uaData.platform;
2414 }
2415 return navigator.platform ?? "";
2416 }
2417
2418 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2419 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2420 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2421
2422 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2423 function activeElement(doc) {
2424 let element = doc.activeElement;
2425 while (element?.shadowRoot?.activeElement != null) {
2426 element = element.shadowRoot.activeElement;
2427 }
2428 return element;
2429 }
2430 function contains(parent, child) {
2431 if (!parent || !child) {
2432 return false;
2433 }
2434 const rootNode = child.getRootNode?.();
2435 if (parent.contains(child)) {
2436 return true;
2437 }
2438 if (rootNode && isShadowRoot(rootNode)) {
2439 let next = child;
2440 while (next) {
2441 if (parent === next) {
2442 return true;
2443 }
2444 next = next.parentNode || next.host;
2445 }
2446 }
2447 return false;
2448 }
2449 function getTarget(event) {
2450 if ("composedPath" in event) {
2451 return event.composedPath()[0];
2452 }
2453 return event.target;
2454 }
2455
2456 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2457 function isTargetInsideEnabledTrigger(target, triggerElements) {
2458 if (!isElement(target)) {
2459 return false;
2460 }
2461 const targetElement = target;
2462 if (triggerElements.hasElement(targetElement)) {
2463 return !targetElement.hasAttribute("data-trigger-disabled");
2464 }
2465 for (const [, trigger] of triggerElements.entries()) {
2466 if (contains(trigger, targetElement)) {
2467 return !trigger.hasAttribute("data-trigger-disabled");
2468 }
2469 }
2470 return false;
2471 }
2472 function isEventTargetWithin(event, node) {
2473 if (node == null) {
2474 return false;
2475 }
2476 if ("composedPath" in event) {
2477 return event.composedPath().includes(node);
2478 }
2479 const eventAgain = event;
2480 return eventAgain.target != null && node.contains(eventAgain.target);
2481 }
2482 function isRootElement(element) {
2483 return element.matches("html,body");
2484 }
2485 function isTypeableElement(element) {
2486 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2487 }
2488 function isInteractiveElement(element) {
2489 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2490 }
2491 function isTypeableCombobox(element) {
2492 if (!element) {
2493 return false;
2494 }
2495 return element.getAttribute("role") === "combobox" && isTypeableElement(element);
2496 }
2497 function matchesFocusVisible(element) {
2498 if (!element || isJSDOM) {
2499 return true;
2500 }
2501 try {
2502 return element.matches(":focus-visible");
2503 } catch (_e) {
2504 return true;
2505 }
2506 }
2507 function getFloatingFocusElement(floatingElement) {
2508 if (!floatingElement) {
2509 return null;
2510 }
2511 return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE) ? floatingElement : floatingElement.querySelector(`[${FOCUSABLE_ATTRIBUTE}]`) || floatingElement;
2512 }
2513
2514 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2515 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2516 const directChildren = nodes.filter((node) => node.parentId === id);
2517 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2518 }
2519 function getNodeAncestors(nodes, id) {
2520 let allAncestors = [];
2521 let currentParentId = nodes.find((node) => node.id === id)?.parentId;
2522 while (currentParentId) {
2523 const currentNode = nodes.find((node) => node.id === currentParentId);
2524 currentParentId = currentNode?.parentId;
2525 if (currentNode) {
2526 allAncestors = allAncestors.concat(currentNode);
2527 }
2528 }
2529 return allAncestors;
2530 }
2531
2532 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2533 function stopEvent(event) {
2534 event.preventDefault();
2535 event.stopPropagation();
2536 }
2537 function isReactEvent(event) {
2538 return "nativeEvent" in event;
2539 }
2540 function isVirtualClick(event) {
2541 if (event.pointerType === "" && event.isTrusted) {
2542 return true;
2543 }
2544 if (isAndroid && event.pointerType) {
2545 return event.type === "click" && event.buttons === 1;
2546 }
2547 return event.detail === 0 && !event.pointerType;
2548 }
2549 function isVirtualPointerEvent(event) {
2550 if (isJSDOM) {
2551 return false;
2552 }
2553 return !isAndroid && event.width === 0 && event.height === 0 || isAndroid && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
2554 event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
2555 }
2556 function isMouseLikePointerType(pointerType, strict) {
2557 const values = ["mouse", "pen"];
2558 if (!strict) {
2559 values.push("", void 0);
2560 }
2561 return values.includes(pointerType);
2562 }
2563 function isClickLikeEvent(event) {
2564 const type = event.type;
2565 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2566 }
2567
2568 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2569 var sides = ["top", "right", "bottom", "left"];
2570 var min = Math.min;
2571 var max = Math.max;
2572 var round = Math.round;
2573 var floor = Math.floor;
2574 var createCoords = (v2) => ({
2575 x: v2,
2576 y: v2
2577 });
2578 var oppositeSideMap = {
2579 left: "right",
2580 right: "left",
2581 bottom: "top",
2582 top: "bottom"
2583 };
2584 function clamp(start, value, end) {
2585 return max(start, min(value, end));
2586 }
2587 function evaluate(value, param) {
2588 return typeof value === "function" ? value(param) : value;
2589 }
2590 function getSide(placement) {
2591 return placement.split("-")[0];
2592 }
2593 function getAlignment(placement) {
2594 return placement.split("-")[1];
2595 }
2596 function getOppositeAxis(axis) {
2597 return axis === "x" ? "y" : "x";
2598 }
2599 function getAxisLength(axis) {
2600 return axis === "y" ? "height" : "width";
2601 }
2602 function getSideAxis(placement) {
2603 const firstChar = placement[0];
2604 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2605 }
2606 function getAlignmentAxis(placement) {
2607 return getOppositeAxis(getSideAxis(placement));
2608 }
2609 function getAlignmentSides(placement, rects, rtl) {
2610 if (rtl === void 0) {
2611 rtl = false;
2612 }
2613 const alignment = getAlignment(placement);
2614 const alignmentAxis = getAlignmentAxis(placement);
2615 const length = getAxisLength(alignmentAxis);
2616 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2617 if (rects.reference[length] > rects.floating[length]) {
2618 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2619 }
2620 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2621 }
2622 function getExpandedPlacements(placement) {
2623 const oppositePlacement = getOppositePlacement(placement);
2624 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2625 }
2626 function getOppositeAlignmentPlacement(placement) {
2627 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2628 }
2629 var lrPlacement = ["left", "right"];
2630 var rlPlacement = ["right", "left"];
2631 var tbPlacement = ["top", "bottom"];
2632 var btPlacement = ["bottom", "top"];
2633 function getSideList(side, isStart, rtl) {
2634 switch (side) {
2635 case "top":
2636 case "bottom":
2637 if (rtl) return isStart ? rlPlacement : lrPlacement;
2638 return isStart ? lrPlacement : rlPlacement;
2639 case "left":
2640 case "right":
2641 return isStart ? tbPlacement : btPlacement;
2642 default:
2643 return [];
2644 }
2645 }
2646 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2647 const alignment = getAlignment(placement);
2648 let list = getSideList(getSide(placement), direction === "start", rtl);
2649 if (alignment) {
2650 list = list.map((side) => side + "-" + alignment);
2651 if (flipAlignment) {
2652 list = list.concat(list.map(getOppositeAlignmentPlacement));
2653 }
2654 }
2655 return list;
2656 }
2657 function getOppositePlacement(placement) {
2658 const side = getSide(placement);
2659 return oppositeSideMap[side] + placement.slice(side.length);
2660 }
2661 function expandPaddingObject(padding) {
2662 return {
2663 top: 0,
2664 right: 0,
2665 bottom: 0,
2666 left: 0,
2667 ...padding
2668 };
2669 }
2670 function getPaddingObject(padding) {
2671 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2672 top: padding,
2673 right: padding,
2674 bottom: padding,
2675 left: padding
2676 };
2677 }
2678 function rectToClientRect(rect) {
2679 const {
2680 x: x2,
2681 y: y2,
2682 width,
2683 height
2684 } = rect;
2685 return {
2686 width,
2687 height,
2688 top: y2,
2689 left: x2,
2690 right: x2 + width,
2691 bottom: y2 + height,
2692 x: x2,
2693 y: y2
2694 };
2695 }
2696
2697 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2698 function isHiddenByStyles(styles) {
2699 return styles.visibility === "hidden" || styles.visibility === "collapse";
2700 }
2701 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2702 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2703 return false;
2704 }
2705 if (typeof element.checkVisibility === "function") {
2706 return element.checkVisibility();
2707 }
2708 return styles.display !== "none" && styles.display !== "contents";
2709 }
2710
2711 // node_modules/@base-ui/utils/esm/owner.js
2712 function ownerDocument(node) {
2713 return node?.ownerDocument || document;
2714 }
2715
2716 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2717 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2718 function getParentElement(element) {
2719 const assignedSlot = element.assignedSlot;
2720 if (assignedSlot) {
2721 return assignedSlot;
2722 }
2723 if (element.parentElement) {
2724 return element.parentElement;
2725 }
2726 const rootNode = element.getRootNode();
2727 return isShadowRoot(rootNode) ? rootNode.host : null;
2728 }
2729 function getDetailsSummary(details) {
2730 for (const child of Array.from(details.children)) {
2731 if (getNodeName(child) === "summary") {
2732 return child;
2733 }
2734 }
2735 return null;
2736 }
2737 function isWithinOpenDetailsSummary(element, details) {
2738 const summary = getDetailsSummary(details);
2739 return !!summary && (element === summary || contains(summary, element));
2740 }
2741 function isFocusableCandidate(element) {
2742 const nodeName = element ? getNodeName(element) : "";
2743 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");
2744 }
2745 function isFocusableElement(element) {
2746 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2747 return false;
2748 }
2749 for (let current = element; current; current = getParentElement(current)) {
2750 const isAncestor = current !== element;
2751 const isSlot = getNodeName(current) === "slot";
2752 if (current.hasAttribute("inert")) {
2753 return false;
2754 }
2755 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2756 return false;
2757 }
2758 }
2759 return true;
2760 }
2761 function isVisibleInTabbableTree(element, isAncestor) {
2762 const styles = getComputedStyle2(element);
2763 if (!isAncestor) {
2764 return isElementVisible(element, styles);
2765 }
2766 return styles.display !== "none";
2767 }
2768 function getTabIndex(element) {
2769 const tabIndex = element.tabIndex;
2770 if (tabIndex < 0) {
2771 const nodeName = getNodeName(element);
2772 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2773 return 0;
2774 }
2775 }
2776 return tabIndex;
2777 }
2778 function getNamedRadioInput(element) {
2779 if (getNodeName(element) !== "input") {
2780 return null;
2781 }
2782 const input = element;
2783 return input.type === "radio" && input.name !== "" ? input : null;
2784 }
2785 function isTabbableRadio(element, candidates) {
2786 const input = getNamedRadioInput(element);
2787 if (!input) {
2788 return true;
2789 }
2790 const checkedRadio = candidates.find((candidate) => {
2791 const radio = getNamedRadioInput(candidate);
2792 return radio?.name === input.name && radio.form === input.form && radio.checked;
2793 });
2794 if (checkedRadio) {
2795 return checkedRadio === input;
2796 }
2797 return candidates.find((candidate) => {
2798 const radio = getNamedRadioInput(candidate);
2799 return radio?.name === input.name && radio.form === input.form;
2800 }) === input;
2801 }
2802 function getComposedChildren(container) {
2803 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2804 const assignedElements = container.assignedElements({
2805 flatten: true
2806 });
2807 if (assignedElements.length > 0) {
2808 return assignedElements;
2809 }
2810 }
2811 if (isHTMLElement(container) && container.shadowRoot) {
2812 return Array.from(container.shadowRoot.children);
2813 }
2814 return Array.from(container.children);
2815 }
2816 function appendCandidates(container, list) {
2817 getComposedChildren(container).forEach((child) => {
2818 if (isFocusableCandidate(child)) {
2819 list.push(child);
2820 }
2821 appendCandidates(child, list);
2822 });
2823 }
2824 function appendMatchingElements(container, selector2, list) {
2825 getComposedChildren(container).forEach((child) => {
2826 if (isHTMLElement(child) && child.matches(selector2)) {
2827 list.push(child);
2828 }
2829 appendMatchingElements(child, selector2, list);
2830 });
2831 }
2832 function isTabbable(element) {
2833 return isFocusableElement(element) && getTabIndex(element) >= 0;
2834 }
2835 function focusable(container) {
2836 const candidates = [];
2837 appendCandidates(container, candidates);
2838 return candidates.filter(isFocusableElement);
2839 }
2840 function tabbable(container) {
2841 const candidates = focusable(container);
2842 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2843 }
2844 function getTabbableIn(container, dir) {
2845 const list = tabbable(container);
2846 const len = list.length;
2847 if (len === 0) {
2848 return void 0;
2849 }
2850 const active = activeElement(ownerDocument(container));
2851 const index2 = list.indexOf(active);
2852 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2853 return list[nextIndex];
2854 }
2855 function getNextTabbable(referenceElement) {
2856 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2857 }
2858 function getPreviousTabbable(referenceElement) {
2859 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2860 }
2861 function getTabbableNearElement(referenceElement, dir) {
2862 if (!referenceElement) {
2863 return null;
2864 }
2865 const list = tabbable(ownerDocument(referenceElement).body);
2866 const elementCount = list.length;
2867 if (elementCount === 0) {
2868 return null;
2869 }
2870 const index2 = list.indexOf(referenceElement);
2871 if (index2 === -1) {
2872 return null;
2873 }
2874 const nextIndex = (index2 + dir + elementCount) % elementCount;
2875 return list[nextIndex];
2876 }
2877 function getTabbableAfterElement(referenceElement) {
2878 return getTabbableNearElement(referenceElement, 1);
2879 }
2880 function getTabbableBeforeElement(referenceElement) {
2881 return getTabbableNearElement(referenceElement, -1);
2882 }
2883 function isOutsideEvent(event, container) {
2884 const containerElement = container || event.currentTarget;
2885 const relatedTarget = event.relatedTarget;
2886 return !relatedTarget || !contains(containerElement, relatedTarget);
2887 }
2888 function disableFocusInside(container) {
2889 const tabbableElements = tabbable(container);
2890 tabbableElements.forEach((element) => {
2891 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2892 element.setAttribute("tabindex", "-1");
2893 });
2894 }
2895 function enableFocusInside(container) {
2896 const elements = [];
2897 appendMatchingElements(container, "[data-tabindex]", elements);
2898 elements.forEach((element) => {
2899 const tabindex = element.dataset.tabindex;
2900 delete element.dataset.tabindex;
2901 if (tabindex) {
2902 element.setAttribute("tabindex", tabindex);
2903 } else {
2904 element.removeAttribute("tabindex");
2905 }
2906 });
2907 }
2908
2909 // node_modules/@base-ui/react/esm/internals/composite/composite.js
2910 var ARROW_UP = "ArrowUp";
2911 var ARROW_DOWN = "ArrowDown";
2912 var ARROW_LEFT = "ArrowLeft";
2913 var ARROW_RIGHT = "ArrowRight";
2914 var HOME = "Home";
2915 var END = "End";
2916 var HORIZONTAL_KEYS = /* @__PURE__ */ new Set([ARROW_LEFT, ARROW_RIGHT]);
2917 var VERTICAL_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN]);
2918 var ARROW_KEYS = /* @__PURE__ */ new Set([...HORIZONTAL_KEYS, ...VERTICAL_KEYS]);
2919 var COMPOSITE_KEYS = /* @__PURE__ */ new Set([...ARROW_KEYS, HOME, END]);
2920
2921 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2922 var React18 = __toESM(require_react(), 1);
2923
2924 // node_modules/@base-ui/utils/esm/addEventListener.js
2925 function addEventListener(target, type, listener, options) {
2926 target.addEventListener(type, listener, options);
2927 return () => {
2928 target.removeEventListener(type, listener, options);
2929 };
2930 }
2931
2932 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2933 function useValueAsRef(value) {
2934 const latest = useRefWithInit(createLatestRef, value).current;
2935 latest.next = value;
2936 useIsoLayoutEffect(latest.effect);
2937 return latest;
2938 }
2939 function createLatestRef(value) {
2940 const latest = {
2941 current: value,
2942 next: value,
2943 effect: () => {
2944 latest.current = latest.next;
2945 }
2946 };
2947 return latest;
2948 }
2949
2950 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2951 var React17 = __toESM(require_react(), 1);
2952
2953 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2954 var ReactDOM = __toESM(require_react_dom(), 1);
2955
2956 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2957 function resolveRef(maybeRef) {
2958 if (maybeRef == null) {
2959 return maybeRef;
2960 }
2961 return "current" in maybeRef ? maybeRef.current : maybeRef;
2962 }
2963
2964 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2965 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2966 const frame = useAnimationFrame();
2967 return useStableCallback((fnToExecute, signal = null) => {
2968 frame.cancel();
2969 const element = resolveRef(elementOrRef);
2970 if (element == null) {
2971 return;
2972 }
2973 const resolvedElement = element;
2974 const done = () => {
2975 ReactDOM.flushSync(fnToExecute);
2976 };
2977 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2978 fnToExecute();
2979 return;
2980 }
2981 function exec() {
2982 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2983 if (!signal?.aborted) {
2984 done();
2985 }
2986 }).catch(() => {
2987 if (treatAbortedAsFinished) {
2988 if (!signal?.aborted) {
2989 done();
2990 }
2991 return;
2992 }
2993 const currentAnimations = resolvedElement.getAnimations();
2994 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2995 exec();
2996 }
2997 });
2998 }
2999 if (waitForStartingStyleRemoved) {
3000 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
3001 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
3002 frame.request(exec);
3003 return;
3004 }
3005 const attributeObserver = new MutationObserver(() => {
3006 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
3007 attributeObserver.disconnect();
3008 exec();
3009 }
3010 });
3011 attributeObserver.observe(resolvedElement, {
3012 attributes: true,
3013 attributeFilter: [startingStyleAttribute]
3014 });
3015 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
3016 once: true
3017 });
3018 return;
3019 }
3020 frame.request(exec);
3021 });
3022 }
3023
3024 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
3025 function useOpenChangeComplete(parameters) {
3026 const {
3027 enabled = true,
3028 open,
3029 ref,
3030 onComplete: onCompleteParam
3031 } = parameters;
3032 const onComplete = useStableCallback(onCompleteParam);
3033 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
3034 React17.useEffect(() => {
3035 if (!enabled) {
3036 return void 0;
3037 }
3038 const abortController = new AbortController();
3039 runOnceAnimationsFinish(onComplete, abortController.signal);
3040 return () => {
3041 abortController.abort();
3042 };
3043 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
3044 }
3045
3046 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
3047 var EMPTY_DIMENSIONS = {
3048 height: void 0,
3049 width: void 0
3050 };
3051 function useCollapsiblePanel(parameters) {
3052 const {
3053 externalRef,
3054 hiddenUntilFound,
3055 id: idParam,
3056 keepMounted,
3057 mounted,
3058 onOpenChange,
3059 open,
3060 setMounted,
3061 setOpen,
3062 transitionStatus
3063 } = parameters;
3064 const panelRef = React18.useRef(null);
3065 const animationTypeRef = React18.useRef(null);
3066 const [dimensions, setDimensionsUnwrapped] = React18.useState(EMPTY_DIMENSIONS);
3067 const lastMeasuredDimensionsRef = React18.useRef(EMPTY_DIMENSIONS);
3068 const shouldSkipNextOpenRef = React18.useRef(false);
3069 const shouldPreventMountAnimationRef = React18.useRef(open);
3070 const shouldPreventActivityResumeAnimationRef = React18.useRef(false);
3071 const [forcePanelIdle, setForcePanelIdle] = React18.useState(false);
3072 const pendingTemporaryStyleRestoreRef = React18.useRef(null);
3073 const mergedPanelRef = useMergedRefs(externalRef, panelRef);
3074 const latestStateRef = useValueAsRef({
3075 mounted,
3076 open
3077 });
3078 const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef, false, false);
3079 const hidden = !open && !mounted;
3080 const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus;
3081 const shouldPreventOpenAnimation = open && // These 2 refs are safe to read in render, they are only written from committed
3082 // layout/effect paths and gate one-shot motion suppression for the next open
3083 // lifecycle. They intentionally expose the last committed motion snapshot.
3084 (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current);
3085 const renderedDimensions = !open && mounted && // These 2 refs are also safe to read in render, both hold the last committed
3086 // animation mode and measurement. This fallback only restores a previously
3087 // measured pixel size after the live dimensions state has been reset back to `auto`.
3088 animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions;
3089 const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation";
3090 const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => {
3091 if (shouldCacheMeasurement) {
3092 lastMeasuredDimensionsRef.current = nextDimensions;
3093 }
3094 setDimensionsUnwrapped(nextDimensions);
3095 });
3096 const restorePendingTemporaryStyle = useStableCallback(() => {
3097 pendingTemporaryStyleRestoreRef.current?.();
3098 pendingTemporaryStyleRestoreRef.current = null;
3099 });
3100 const setPendingTemporaryStyleRestore = useStableCallback((restore) => {
3101 restorePendingTemporaryStyle();
3102 pendingTemporaryStyleRestoreRef.current = () => {
3103 pendingTemporaryStyleRestoreRef.current = null;
3104 restore();
3105 };
3106 });
3107 const markActivityResumeAnimationSuppressed = useStableCallback(() => {
3108 if (open && mounted && animationTypeRef.current === "css-animation") {
3109 shouldPreventActivityResumeAnimationRef.current = true;
3110 }
3111 });
3112 useIsoLayoutEffect(() => {
3113 if (!forcePanelIdle || transitionStatus === "starting") {
3114 return;
3115 }
3116 setForcePanelIdle(false);
3117 }, [forcePanelIdle, transitionStatus]);
3118 React18.useEffect(() => {
3119 return () => {
3120 markActivityResumeAnimationSuppressed();
3121 restorePendingTemporaryStyle();
3122 };
3123 }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]);
3124 useIsoLayoutEffect(() => {
3125 const panel = panelRef.current;
3126 if (!panel) {
3127 return void 0;
3128 }
3129 if (!open && pendingTemporaryStyleRestoreRef.current) {
3130 restorePendingTemporaryStyle();
3131 }
3132 const animationType = getAnimationType(panel, shouldPreventOpenAnimation);
3133 animationTypeRef.current = animationType;
3134 if (open && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") {
3135 lastMeasuredDimensionsRef.current = getDimensions(panel);
3136 return void 0;
3137 }
3138 if (open && transitionStatus === "starting") {
3139 const skipNextOpen = shouldSkipNextOpenRef.current;
3140 shouldSkipNextOpenRef.current = false;
3141 if (animationType === "none") {
3142 setDimensions(getDimensions(panel));
3143 setForcePanelIdle(true);
3144 return void 0;
3145 }
3146 if (animationType === "css-transition") {
3147 const restoreLayoutStyles = resetLayoutStyles(panel);
3148 setDimensions(getDimensions(panel));
3149 if (!skipNextOpen) {
3150 return restoreLayoutStyles;
3151 }
3152 const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s");
3153 setPendingTemporaryStyleRestore(restoreTransitionDuration);
3154 setForcePanelIdle(true);
3155 return restoreLayoutStyles;
3156 }
3157 if (animationType === "css-animation") {
3158 setDimensions(getDimensions(panel));
3159 if (!skipNextOpen) {
3160 const restoreAnimationName2 = setTemporaryStyle(panel, "animation-name", "none");
3161 restoreAnimationName2();
3162 return void 0;
3163 }
3164 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
3165 const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s");
3166 restoreAnimationName();
3167 setPendingTemporaryStyleRestore(restoreAnimationDuration);
3168 setForcePanelIdle(true);
3169 return void 0;
3170 }
3171 }
3172 if (!open && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) {
3173 if (animationType === "none") {
3174 setDimensions(EMPTY_DIMENSIONS, false);
3175 setMounted(false);
3176 return void 0;
3177 }
3178 if (animationType === "css-animation") {
3179 shouldPreventMountAnimationRef.current = false;
3180 shouldPreventActivityResumeAnimationRef.current = false;
3181 }
3182 setDimensions(getDimensions(panel));
3183 return void 0;
3184 }
3185 if (transitionStatus !== "ending") {
3186 return void 0;
3187 }
3188 if (animationType === "none") {
3189 setMounted(false);
3190 return void 0;
3191 }
3192 const nextDimensions = getDimensions(panel);
3193 const hasMeasuredSize = (nextDimensions.height ?? 0) > 0 || (nextDimensions.width ?? 0) > 0;
3194 if (!hasMeasuredSize) {
3195 setMounted(false);
3196 return void 0;
3197 }
3198 setDimensions(nextDimensions);
3199 if (animationType === "css-animation") {
3200 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
3201 restoreAnimationName();
3202 }
3203 return void 0;
3204 }, [mounted, open, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]);
3205 useOpenChangeComplete({
3206 enabled: open && mounted && panelTransitionStatus === "idle",
3207 open: true,
3208 ref: panelRef,
3209 onComplete() {
3210 if (!open) {
3211 return;
3212 }
3213 setDimensions(EMPTY_DIMENSIONS, false);
3214 }
3215 });
3216 React18.useEffect(() => {
3217 if (open || !mounted || panelTransitionStatus !== "ending") {
3218 return void 0;
3219 }
3220 const panel = panelRef.current;
3221 if (!panel) {
3222 return void 0;
3223 }
3224 const abortController = new AbortController();
3225 let endingStyleFrame = -1;
3226 function handleComplete() {
3227 if (latestStateRef.current.open) {
3228 return;
3229 }
3230 setMounted(false);
3231 setDimensions(EMPTY_DIMENSIONS, false);
3232 }
3233 endingStyleFrame = AnimationFrame.request(() => {
3234 if (!abortController.signal.aborted) {
3235 runOnceCloseAnimationsFinish(handleComplete, abortController.signal);
3236 }
3237 });
3238 return () => {
3239 AnimationFrame.cancel(endingStyleFrame);
3240 abortController.abort();
3241 };
3242 }, [latestStateRef, mounted, open, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]);
3243 useIsoLayoutEffect(() => {
3244 const panel = panelRef.current;
3245 if (!panel || !hiddenUntilFound || !hidden) {
3246 return;
3247 }
3248 panel.setAttribute("hidden", "until-found");
3249 }, [hidden, hiddenUntilFound]);
3250 React18.useEffect(function registerBeforeMatchListener() {
3251 const panel = panelRef.current;
3252 if (!panel) {
3253 return void 0;
3254 }
3255 function handleBeforeMatch(event) {
3256 shouldSkipNextOpenRef.current = true;
3257 setOpen(true);
3258 onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event));
3259 }
3260 return addEventListener(panel, "beforematch", handleBeforeMatch);
3261 }, [onOpenChange, setOpen]);
3262 const shouldRender = keepMounted || hiddenUntilFound || mounted || open;
3263 return {
3264 height: renderedDimensions.height,
3265 props: {
3266 ...shouldPersistHiddenTransitionStyles ? {
3267 [CollapsiblePanelDataAttributes.startingStyle]: ""
3268 } : void 0,
3269 hidden,
3270 id: idParam
3271 },
3272 ref: mergedPanelRef,
3273 shouldPreventOpenAnimation,
3274 shouldRender,
3275 transitionStatus: panelTransitionStatus,
3276 width: renderedDimensions.width
3277 };
3278 }
3279 function getDimensions(element) {
3280 return {
3281 height: element.scrollHeight,
3282 width: element.scrollWidth
3283 };
3284 }
3285 function getAnimationType(element, hasSuppressedMountAnimation = false) {
3286 const panelStyles = getWindow(element).getComputedStyle(element);
3287 const hasAnimation = (panelStyles.animationName.split(",").map((name) => name.trim()).some((name) => name !== "" && name !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration);
3288 const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration);
3289 if (hasAnimation && hasTransition) {
3290 if (true) {
3291 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
3292 }
3293 return "css-transition";
3294 }
3295 if (hasTransition) {
3296 return "css-transition";
3297 }
3298 if (hasAnimation) {
3299 return "css-animation";
3300 }
3301 return "none";
3302 }
3303 function hasNonZeroDuration(value) {
3304 return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0);
3305 }
3306 function setTemporaryStyle(element, property, value) {
3307 const previousValue = element.style.getPropertyValue(property);
3308 const previousPriority = element.style.getPropertyPriority(property);
3309 element.style.setProperty(property, value);
3310 return () => {
3311 if (previousValue === "") {
3312 element.style.removeProperty(property);
3313 return;
3314 }
3315 element.style.setProperty(property, previousValue, previousPriority);
3316 };
3317 }
3318 function resetLayoutStyles(element) {
3319 const originalLayoutStyles = {
3320 "justify-content": element.style.justifyContent,
3321 "align-items": element.style.alignItems,
3322 "align-content": element.style.alignContent,
3323 "justify-items": element.style.justifyItems
3324 };
3325 Object.keys(originalLayoutStyles).forEach((key) => {
3326 element.style.setProperty(key, "initial", "important");
3327 });
3328 function restoreLayoutStyles() {
3329 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
3330 if (value === "") {
3331 element.style.removeProperty(key);
3332 return;
3333 }
3334 element.style.setProperty(key, value);
3335 });
3336 }
3337 const frame = AnimationFrame.request(restoreLayoutStyles);
3338 return () => {
3339 AnimationFrame.cancel(frame);
3340 restoreLayoutStyles();
3341 };
3342 }
3343
3344 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
3345 var React19 = __toESM(require_react(), 1);
3346 function useOnFirstRender(fn) {
3347 const ref = React19.useRef(true);
3348 if (ref.current) {
3349 ref.current = false;
3350 fn();
3351 }
3352 }
3353
3354 // node_modules/@base-ui/utils/esm/useTimeout.js
3355 var EMPTY3 = 0;
3356 var Timeout = class _Timeout {
3357 static create() {
3358 return new _Timeout();
3359 }
3360 currentId = EMPTY3;
3361 /**
3362 * Executes `fn` after `delay`, clearing any previously scheduled call.
3363 */
3364 start(delay, fn) {
3365 this.clear();
3366 this.currentId = setTimeout(() => {
3367 this.currentId = EMPTY3;
3368 fn();
3369 }, delay);
3370 }
3371 isStarted() {
3372 return this.currentId !== EMPTY3;
3373 }
3374 clear = () => {
3375 if (this.currentId !== EMPTY3) {
3376 clearTimeout(this.currentId);
3377 this.currentId = EMPTY3;
3378 }
3379 };
3380 disposeEffect = () => {
3381 return this.clear;
3382 };
3383 };
3384 function useTimeout() {
3385 const timeout = useRefWithInit(Timeout.create).current;
3386 useOnMount(timeout.disposeEffect);
3387 return timeout;
3388 }
3389
3390 // node_modules/@base-ui/utils/esm/useScrollLock.js
3391 var originalHtmlStyles = {};
3392 var originalBodyStyles = {};
3393 var originalHtmlScrollBehavior = "";
3394 function hasInsetScrollbars(referenceElement) {
3395 if (typeof document === "undefined") {
3396 return false;
3397 }
3398 const doc = ownerDocument(referenceElement);
3399 const win = getWindow(doc);
3400 return win.innerWidth - doc.documentElement.clientWidth > 0;
3401 }
3402 function supportsStableScrollbarGutter(referenceElement) {
3403 const supported = typeof CSS !== "undefined" && CSS.supports && CSS.supports("scrollbar-gutter", "stable");
3404 if (!supported || typeof document === "undefined") {
3405 return false;
3406 }
3407 const doc = ownerDocument(referenceElement);
3408 const html = doc.documentElement;
3409 const body = doc.body;
3410 const scrollContainer = isOverflowElement(html) ? html : body;
3411 const originalScrollContainerOverflowY = scrollContainer.style.overflowY;
3412 const originalHtmlStyleGutter = html.style.scrollbarGutter;
3413 html.style.scrollbarGutter = "stable";
3414 scrollContainer.style.overflowY = "scroll";
3415 const before = scrollContainer.offsetWidth;
3416 scrollContainer.style.overflowY = "hidden";
3417 const after = scrollContainer.offsetWidth;
3418 scrollContainer.style.overflowY = originalScrollContainerOverflowY;
3419 html.style.scrollbarGutter = originalHtmlStyleGutter;
3420 return before === after;
3421 }
3422 function preventScrollOverlayScrollbars(referenceElement) {
3423 const doc = ownerDocument(referenceElement);
3424 const html = doc.documentElement;
3425 const body = doc.body;
3426 const elementToLock = isOverflowElement(html) ? html : body;
3427 const originalElementToLockStyles = {
3428 overflowY: elementToLock.style.overflowY,
3429 overflowX: elementToLock.style.overflowX
3430 };
3431 Object.assign(elementToLock.style, {
3432 overflowY: "hidden",
3433 overflowX: "hidden"
3434 });
3435 return () => {
3436 Object.assign(elementToLock.style, originalElementToLockStyles);
3437 };
3438 }
3439 function preventScrollInsetScrollbars(referenceElement) {
3440 const doc = ownerDocument(referenceElement);
3441 const html = doc.documentElement;
3442 const body = doc.body;
3443 const win = getWindow(html);
3444 let scrollTop = 0;
3445 let scrollLeft = 0;
3446 let updateGutterOnly = false;
3447 const resizeFrame = AnimationFrame.create();
3448 if (isWebKit2 && (win.visualViewport?.scale ?? 1) !== 1) {
3449 return () => {
3450 };
3451 }
3452 function lockScroll() {
3453 const htmlStyles = win.getComputedStyle(html);
3454 const bodyStyles = win.getComputedStyle(body);
3455 const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || "";
3456 const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges");
3457 const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable";
3458 scrollTop = html.scrollTop;
3459 scrollLeft = html.scrollLeft;
3460 originalHtmlStyles = {
3461 scrollbarGutter: html.style.scrollbarGutter,
3462 overflowY: html.style.overflowY,
3463 overflowX: html.style.overflowX
3464 };
3465 originalHtmlScrollBehavior = html.style.scrollBehavior;
3466 originalBodyStyles = {
3467 position: body.style.position,
3468 height: body.style.height,
3469 width: body.style.width,
3470 boxSizing: body.style.boxSizing,
3471 overflowY: body.style.overflowY,
3472 overflowX: body.style.overflowX,
3473 scrollBehavior: body.style.scrollBehavior
3474 };
3475 const isScrollableY = html.scrollHeight > html.clientHeight;
3476 const isScrollableX = html.scrollWidth > html.clientWidth;
3477 const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll";
3478 const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll";
3479 const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth);
3480 const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight);
3481 const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);
3482 const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);
3483 const elementToLock = isOverflowElement(html) ? html : body;
3484 updateGutterOnly = supportsStableScrollbarGutter(referenceElement);
3485 if (updateGutterOnly) {
3486 html.style.scrollbarGutter = scrollbarGutterValue;
3487 elementToLock.style.overflowY = "hidden";
3488 elementToLock.style.overflowX = "hidden";
3489 return;
3490 }
3491 Object.assign(html.style, {
3492 scrollbarGutter: scrollbarGutterValue,
3493 overflowY: "hidden",
3494 overflowX: "hidden"
3495 });
3496 if (isScrollableY || hasConstantOverflowY) {
3497 html.style.overflowY = "scroll";
3498 }
3499 if (isScrollableX || hasConstantOverflowX) {
3500 html.style.overflowX = "scroll";
3501 }
3502 Object.assign(body.style, {
3503 position: "relative",
3504 height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : "100dvh",
3505 width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : "100vw",
3506 boxSizing: "border-box",
3507 overflow: "hidden",
3508 scrollBehavior: "unset"
3509 });
3510 body.scrollTop = scrollTop;
3511 body.scrollLeft = scrollLeft;
3512 html.setAttribute("data-base-ui-scroll-locked", "");
3513 html.style.scrollBehavior = "unset";
3514 }
3515 function cleanup() {
3516 Object.assign(html.style, originalHtmlStyles);
3517 Object.assign(body.style, originalBodyStyles);
3518 if (!updateGutterOnly) {
3519 html.scrollTop = scrollTop;
3520 html.scrollLeft = scrollLeft;
3521 html.removeAttribute("data-base-ui-scroll-locked");
3522 html.style.scrollBehavior = originalHtmlScrollBehavior;
3523 }
3524 }
3525 function handleResize() {
3526 cleanup();
3527 resizeFrame.request(lockScroll);
3528 }
3529 lockScroll();
3530 const unsubscribeResize = addEventListener(win, "resize", handleResize);
3531 return () => {
3532 resizeFrame.cancel();
3533 cleanup();
3534 if (typeof win.removeEventListener === "function") {
3535 unsubscribeResize();
3536 }
3537 };
3538 }
3539 var ScrollLocker = class {
3540 lockCount = 0;
3541 restore = null;
3542 timeoutLock = Timeout.create();
3543 timeoutUnlock = Timeout.create();
3544 acquire(referenceElement) {
3545 this.lockCount += 1;
3546 if (this.lockCount === 1 && this.restore === null) {
3547 this.timeoutLock.start(0, () => this.lock(referenceElement));
3548 }
3549 return this.release;
3550 }
3551 release = () => {
3552 this.lockCount -= 1;
3553 if (this.lockCount === 0 && this.restore) {
3554 this.timeoutUnlock.start(0, this.unlock);
3555 }
3556 };
3557 unlock = () => {
3558 if (this.lockCount === 0 && this.restore) {
3559 this.restore?.();
3560 this.restore = null;
3561 }
3562 };
3563 lock(referenceElement) {
3564 if (this.lockCount === 0 || this.restore !== null) {
3565 return;
3566 }
3567 const doc = ownerDocument(referenceElement);
3568 const html = doc.documentElement;
3569 const htmlOverflowY = getWindow(html).getComputedStyle(html).overflowY;
3570 if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") {
3571 this.restore = NOOP;
3572 return;
3573 }
3574 const hasOverlayScrollbars = isIOS || !hasInsetScrollbars(referenceElement);
3575 this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement);
3576 }
3577 };
3578 var SCROLL_LOCKER = new ScrollLocker();
3579 function useScrollLock(enabled = true, referenceElement = null) {
3580 useIsoLayoutEffect(() => {
3581 if (!enabled) {
3582 return void 0;
3583 }
3584 return SCROLL_LOCKER.acquire(referenceElement);
3585 }, [enabled, referenceElement]);
3586 }
3587
3588 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3589 var React20 = __toESM(require_react(), 1);
3590
3591 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
3592 function resolveValue(value, pointerType) {
3593 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3594 return 0;
3595 }
3596 if (typeof value === "function") {
3597 return value();
3598 }
3599 return value;
3600 }
3601 function getDelay(value, prop, pointerType) {
3602 const result = resolveValue(value, pointerType);
3603 if (typeof result === "number") {
3604 return result;
3605 }
3606 return result?.[prop];
3607 }
3608 function getRestMs(value) {
3609 if (typeof value === "function") {
3610 return value();
3611 }
3612 return value;
3613 }
3614 function isClickLikeOpenEvent(openEventType, interactedInside) {
3615 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3616 }
3617 function isHoverOpenEvent(openEventType) {
3618 return openEventType?.includes("mouse") && openEventType !== "mousedown";
3619 }
3620
3621 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3622 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
3623 var FloatingDelayGroupContext = /* @__PURE__ */ React20.createContext({
3624 hasProvider: false,
3625 timeoutMs: 0,
3626 delayRef: {
3627 current: 0
3628 },
3629 initialDelayRef: {
3630 current: 0
3631 },
3632 timeout: new Timeout(),
3633 currentIdRef: {
3634 current: null
3635 },
3636 currentContextRef: {
3637 current: null
3638 }
3639 });
3640 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3641 function FloatingDelayGroup(props) {
3642 const {
3643 children,
3644 delay,
3645 timeoutMs = 0
3646 } = props;
3647 const delayRef = React20.useRef(delay);
3648 const initialDelayRef = React20.useRef(delay);
3649 const currentIdRef = React20.useRef(null);
3650 const currentContextRef = React20.useRef(null);
3651 const timeout = useTimeout();
3652 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
3653 value: React20.useMemo(() => ({
3654 hasProvider: true,
3655 delayRef,
3656 initialDelayRef,
3657 currentIdRef,
3658 timeoutMs,
3659 currentContextRef,
3660 timeout
3661 }), [timeoutMs, timeout]),
3662 children
3663 });
3664 }
3665 function useDelayGroup(context, options = {
3666 open: false
3667 }) {
3668 const {
3669 open
3670 } = options;
3671 const store = "rootStore" in context ? context.rootStore : context;
3672 const floatingId = store.useState("floatingId");
3673 const groupContext = React20.useContext(FloatingDelayGroupContext);
3674 const {
3675 currentIdRef,
3676 delayRef,
3677 timeoutMs,
3678 initialDelayRef,
3679 currentContextRef,
3680 hasProvider,
3681 timeout
3682 } = groupContext;
3683 const [isInstantPhase, setIsInstantPhase] = React20.useState(false);
3684 useIsoLayoutEffect(() => {
3685 function unset() {
3686 setIsInstantPhase(false);
3687 currentContextRef.current?.setIsInstantPhase(false);
3688 currentIdRef.current = null;
3689 currentContextRef.current = null;
3690 delayRef.current = initialDelayRef.current;
3691 }
3692 if (!currentIdRef.current) {
3693 return void 0;
3694 }
3695 if (!open && currentIdRef.current === floatingId) {
3696 setIsInstantPhase(false);
3697 if (timeoutMs) {
3698 const closingId = floatingId;
3699 timeout.start(timeoutMs, () => {
3700 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3701 return;
3702 }
3703 unset();
3704 });
3705 return () => {
3706 timeout.clear();
3707 };
3708 }
3709 unset();
3710 }
3711 return void 0;
3712 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3713 useIsoLayoutEffect(() => {
3714 if (!open) {
3715 return;
3716 }
3717 const prevContext = currentContextRef.current;
3718 const prevId = currentIdRef.current;
3719 timeout.clear();
3720 currentContextRef.current = {
3721 onOpenChange: store.setOpen,
3722 setIsInstantPhase
3723 };
3724 currentIdRef.current = floatingId;
3725 delayRef.current = {
3726 open: 0,
3727 close: getDelay(initialDelayRef.current, "close")
3728 };
3729 if (prevId !== null && prevId !== floatingId) {
3730 setIsInstantPhase(true);
3731 prevContext?.setIsInstantPhase(true);
3732 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3733 } else {
3734 setIsInstantPhase(false);
3735 prevContext?.setIsInstantPhase(false);
3736 }
3737 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3738 useIsoLayoutEffect(() => {
3739 return () => {
3740 currentContextRef.current = null;
3741 };
3742 }, [currentContextRef]);
3743 return React20.useMemo(() => ({
3744 hasProvider,
3745 delayRef,
3746 isInstantPhase
3747 }), [hasProvider, delayRef, isInstantPhase]);
3748 }
3749
3750 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingFocusManager.js
3751 var React24 = __toESM(require_react(), 1);
3752
3753 // node_modules/@base-ui/utils/esm/mergeCleanups.js
3754 function mergeCleanups(...cleanups) {
3755 return () => {
3756 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3757 const cleanup = cleanups[i2];
3758 if (cleanup) {
3759 cleanup();
3760 }
3761 }
3762 };
3763 }
3764
3765 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3766 var React21 = __toESM(require_react(), 1);
3767
3768 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3769 var visuallyHiddenBase = {
3770 clipPath: "inset(50%)",
3771 overflow: "hidden",
3772 whiteSpace: "nowrap",
3773 border: 0,
3774 padding: 0,
3775 width: 1,
3776 height: 1,
3777 margin: -1
3778 };
3779 var visuallyHidden = {
3780 ...visuallyHiddenBase,
3781 position: "fixed",
3782 top: 0,
3783 left: 0
3784 };
3785 var visuallyHiddenInput = {
3786 ...visuallyHiddenBase,
3787 position: "absolute"
3788 };
3789
3790 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3791 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3792 var FocusGuard = /* @__PURE__ */ React21.forwardRef(function FocusGuard2(props, ref) {
3793 const [role, setRole] = React21.useState();
3794 useIsoLayoutEffect(() => {
3795 if (isSafari) {
3796 setRole("button");
3797 }
3798 }, []);
3799 const restProps = {
3800 tabIndex: 0,
3801 // Role is only for VoiceOver
3802 role
3803 };
3804 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3805 ...props,
3806 ref,
3807 style: visuallyHidden,
3808 "aria-hidden": role ? void 0 : true,
3809 ...restProps,
3810 "data-base-ui-focus-guard": ""
3811 });
3812 });
3813 if (true) FocusGuard.displayName = "FocusGuard";
3814
3815 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3816 function createAttribute(name) {
3817 return `data-base-ui-${name}`;
3818 }
3819
3820 // node_modules/@base-ui/react/esm/floating-ui-react/utils/enqueueFocus.js
3821 var rafId = 0;
3822 function enqueueFocus(el, options = {}) {
3823 const {
3824 preventScroll = false,
3825 sync: sync2 = false,
3826 shouldFocus
3827 } = options;
3828 cancelAnimationFrame(rafId);
3829 function exec() {
3830 if (shouldFocus && !shouldFocus()) {
3831 return;
3832 }
3833 el?.focus({
3834 preventScroll
3835 });
3836 }
3837 if (sync2) {
3838 exec();
3839 return NOOP;
3840 }
3841 const currentRafId = requestAnimationFrame(exec);
3842 rafId = currentRafId;
3843 return () => {
3844 if (rafId === currentRafId) {
3845 cancelAnimationFrame(currentRafId);
3846 rafId = 0;
3847 }
3848 };
3849 }
3850
3851 // node_modules/@base-ui/react/esm/floating-ui-react/utils/markOthers.js
3852 var counters = {
3853 inert: /* @__PURE__ */ new WeakMap(),
3854 "aria-hidden": /* @__PURE__ */ new WeakMap()
3855 };
3856 var markerName = "data-base-ui-inert";
3857 var uncontrolledElementsSets = {
3858 inert: /* @__PURE__ */ new WeakSet(),
3859 "aria-hidden": /* @__PURE__ */ new WeakSet()
3860 };
3861 var markerCounterMap = /* @__PURE__ */ new WeakMap();
3862 var lockCount = 0;
3863 function getUncontrolledElementsSet(controlAttribute) {
3864 return uncontrolledElementsSets[controlAttribute];
3865 }
3866 function unwrapHost(node) {
3867 if (!node) {
3868 return null;
3869 }
3870 return isShadowRoot(node) ? node.host : unwrapHost(node.parentNode);
3871 }
3872 var correctElements = (parent, targets) => targets.map((target) => {
3873 if (parent.contains(target)) {
3874 return target;
3875 }
3876 const correctedTarget = unwrapHost(target);
3877 if (parent.contains(correctedTarget)) {
3878 return correctedTarget;
3879 }
3880 return null;
3881 }).filter((x2) => x2 != null);
3882 var buildKeepSet = (targets) => {
3883 const keep = /* @__PURE__ */ new Set();
3884 targets.forEach((target) => {
3885 let node = target;
3886 while (node && !keep.has(node)) {
3887 keep.add(node);
3888 node = node.parentNode;
3889 }
3890 });
3891 return keep;
3892 };
3893 var collectOutsideElements = (root, keepElements, stopElements) => {
3894 const outside = [];
3895 const walk = (parent) => {
3896 if (!parent || stopElements.has(parent)) {
3897 return;
3898 }
3899 Array.from(parent.children).forEach((node) => {
3900 if (getNodeName(node) === "script") {
3901 return;
3902 }
3903 if (keepElements.has(node)) {
3904 walk(node);
3905 } else {
3906 outside.push(node);
3907 }
3908 });
3909 };
3910 walk(root);
3911 return outside;
3912 };
3913 function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert, {
3914 mark = true,
3915 markerIgnoreElements = []
3916 }) {
3917 const controlAttribute = inert ? "inert" : ariaHidden ? "aria-hidden" : null;
3918 let counterMap = null;
3919 let uncontrolledElementsSet = null;
3920 const avoidElements = correctElements(body, uncorrectedAvoidElements);
3921 const markerIgnoreTargets = mark ? correctElements(body, markerIgnoreElements) : [];
3922 const markerIgnoreSet = new Set(markerIgnoreTargets);
3923 const markerTargets = mark ? collectOutsideElements(body, buildKeepSet(avoidElements), new Set(avoidElements)).filter((target) => !markerIgnoreSet.has(target)) : [];
3924 const hiddenElements = [];
3925 const markedElements = [];
3926 if (controlAttribute) {
3927 const map = counters[controlAttribute];
3928 const currentUncontrolledElementsSet = getUncontrolledElementsSet(controlAttribute);
3929 uncontrolledElementsSet = currentUncontrolledElementsSet;
3930 counterMap = map;
3931 const ariaLiveElements = correctElements(body, Array.from(body.querySelectorAll("[aria-live]")));
3932 const controlElements = avoidElements.concat(ariaLiveElements);
3933 const controlTargets = collectOutsideElements(body, buildKeepSet(controlElements), new Set(controlElements));
3934 controlTargets.forEach((node) => {
3935 const attr2 = node.getAttribute(controlAttribute);
3936 const alreadyHidden = attr2 !== null && attr2 !== "false";
3937 const counterValue = (map.get(node) || 0) + 1;
3938 map.set(node, counterValue);
3939 hiddenElements.push(node);
3940 if (counterValue === 1 && alreadyHidden) {
3941 currentUncontrolledElementsSet.add(node);
3942 }
3943 if (!alreadyHidden) {
3944 node.setAttribute(controlAttribute, controlAttribute === "inert" ? "" : "true");
3945 }
3946 });
3947 }
3948 if (mark) {
3949 markerTargets.forEach((node) => {
3950 const markerValue = (markerCounterMap.get(node) || 0) + 1;
3951 markerCounterMap.set(node, markerValue);
3952 markedElements.push(node);
3953 if (markerValue === 1) {
3954 node.setAttribute(markerName, "");
3955 }
3956 });
3957 }
3958 lockCount += 1;
3959 return () => {
3960 if (counterMap) {
3961 hiddenElements.forEach((element) => {
3962 const currentCounterValue = counterMap.get(element) || 0;
3963 const counterValue = currentCounterValue - 1;
3964 counterMap.set(element, counterValue);
3965 if (!counterValue) {
3966 if (!uncontrolledElementsSet?.has(element) && controlAttribute) {
3967 element.removeAttribute(controlAttribute);
3968 }
3969 uncontrolledElementsSet?.delete(element);
3970 }
3971 });
3972 }
3973 if (mark) {
3974 markedElements.forEach((element) => {
3975 const markerValue = (markerCounterMap.get(element) || 0) - 1;
3976 markerCounterMap.set(element, markerValue);
3977 if (!markerValue) {
3978 element.removeAttribute(markerName);
3979 }
3980 });
3981 }
3982 lockCount -= 1;
3983 if (!lockCount) {
3984 counters.inert = /* @__PURE__ */ new WeakMap();
3985 counters["aria-hidden"] = /* @__PURE__ */ new WeakMap();
3986 uncontrolledElementsSets.inert = /* @__PURE__ */ new WeakSet();
3987 uncontrolledElementsSets["aria-hidden"] = /* @__PURE__ */ new WeakSet();
3988 markerCounterMap = /* @__PURE__ */ new WeakMap();
3989 }
3990 };
3991 }
3992 function markOthers(avoidElements, options = {}) {
3993 const {
3994 ariaHidden = false,
3995 inert = false,
3996 mark = true,
3997 markerIgnoreElements = []
3998 } = options;
3999 const body = ownerDocument(avoidElements[0]).body;
4000 return applyAttributeToOthers(avoidElements, body, ariaHidden, inert, {
4001 mark,
4002 markerIgnoreElements
4003 });
4004 }
4005
4006 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
4007 var React22 = __toESM(require_react(), 1);
4008 var ReactDOM2 = __toESM(require_react_dom(), 1);
4009
4010 // node_modules/@base-ui/react/esm/internals/constants.js
4011 var PATIENT_CLICK_THRESHOLD = 500;
4012 var DISABLED_TRANSITIONS_STYLE = {
4013 style: {
4014 transition: "none"
4015 }
4016 };
4017 var CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
4018 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
4019 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
4020 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
4021 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
4022 var POPUP_COLLISION_AVOIDANCE = {
4023 fallbackAxisSide: "end"
4024 };
4025 var ownerVisuallyHidden = {
4026 clipPath: "inset(50%)",
4027 position: "fixed",
4028 top: 0,
4029 left: 0
4030 };
4031
4032 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
4033 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
4034 var PortalContext = /* @__PURE__ */ React22.createContext(null);
4035 if (true) PortalContext.displayName = "PortalContext";
4036 var usePortalContext = () => React22.useContext(PortalContext);
4037 var attr = createAttribute("portal");
4038 function useFloatingPortalNode(props = {}) {
4039 const {
4040 ref,
4041 container: containerProp,
4042 componentProps = EMPTY_OBJECT,
4043 elementProps
4044 } = props;
4045 const uniqueId = useId();
4046 const portalContext = usePortalContext();
4047 const parentPortalNode = portalContext?.portalNode;
4048 const [containerElement, setContainerElement] = React22.useState(null);
4049 const [portalNode, setPortalNode] = React22.useState(null);
4050 const setPortalNodeRef = useStableCallback((node) => {
4051 if (node !== null) {
4052 setPortalNode(node);
4053 }
4054 });
4055 const containerRef = React22.useRef(null);
4056 useIsoLayoutEffect(() => {
4057 if (containerProp === null) {
4058 if (containerRef.current) {
4059 containerRef.current = null;
4060 setPortalNode(null);
4061 setContainerElement(null);
4062 }
4063 return;
4064 }
4065 if (uniqueId == null) {
4066 return;
4067 }
4068 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
4069 if (resolvedContainer == null) {
4070 if (containerRef.current) {
4071 containerRef.current = null;
4072 setPortalNode(null);
4073 setContainerElement(null);
4074 }
4075 return;
4076 }
4077 if (containerRef.current !== resolvedContainer) {
4078 containerRef.current = resolvedContainer;
4079 setPortalNode(null);
4080 setContainerElement(resolvedContainer);
4081 }
4082 }, [containerProp, parentPortalNode, uniqueId]);
4083 const portalElement = useRenderElement("div", componentProps, {
4084 ref: [ref, setPortalNodeRef],
4085 props: [{
4086 id: uniqueId,
4087 [attr]: ""
4088 }, elementProps]
4089 });
4090 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
4091 return {
4092 portalNode,
4093 portalSubtree
4094 };
4095 }
4096 var FloatingPortal = /* @__PURE__ */ React22.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
4097 const {
4098 render: render4,
4099 className,
4100 style,
4101 children,
4102 container,
4103 renderGuards,
4104 ...elementProps
4105 } = componentProps;
4106 const {
4107 portalNode,
4108 portalSubtree
4109 } = useFloatingPortalNode({
4110 container,
4111 ref: forwardedRef,
4112 componentProps,
4113 elementProps
4114 });
4115 const beforeOutsideRef = React22.useRef(null);
4116 const afterOutsideRef = React22.useRef(null);
4117 const beforeInsideRef = React22.useRef(null);
4118 const afterInsideRef = React22.useRef(null);
4119 const [focusManagerState, setFocusManagerState] = React22.useState(null);
4120 const focusInsideDisabledRef = React22.useRef(false);
4121 const modal = focusManagerState?.modal;
4122 const open = focusManagerState?.open;
4123 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
4124 React22.useEffect(() => {
4125 if (!portalNode || modal) {
4126 return void 0;
4127 }
4128 function onFocus(event) {
4129 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
4130 if (event.type === "focusin") {
4131 if (focusInsideDisabledRef.current) {
4132 enableFocusInside(portalNode);
4133 focusInsideDisabledRef.current = false;
4134 }
4135 } else {
4136 disableFocusInside(portalNode);
4137 focusInsideDisabledRef.current = true;
4138 }
4139 }
4140 }
4141 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
4142 }, [portalNode, modal]);
4143 React22.useEffect(() => {
4144 if (!portalNode || open !== false) {
4145 return;
4146 }
4147 enableFocusInside(portalNode);
4148 focusInsideDisabledRef.current = false;
4149 }, [open, portalNode]);
4150 const portalContextValue = React22.useMemo(() => ({
4151 beforeOutsideRef,
4152 afterOutsideRef,
4153 beforeInsideRef,
4154 afterInsideRef,
4155 portalNode,
4156 setFocusManagerState
4157 }), [portalNode]);
4158 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React22.Fragment, {
4159 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
4160 value: portalContextValue,
4161 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
4162 "data-type": "outside",
4163 ref: beforeOutsideRef,
4164 onFocus: (event) => {
4165 if (isOutsideEvent(event, portalNode)) {
4166 beforeInsideRef.current?.focus();
4167 } else {
4168 const domReference = focusManagerState ? focusManagerState.domReference : null;
4169 const prevTabbable = getPreviousTabbable(domReference);
4170 prevTabbable?.focus();
4171 }
4172 }
4173 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
4174 "aria-owns": portalNode.id,
4175 style: ownerVisuallyHidden
4176 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
4177 "data-type": "outside",
4178 ref: afterOutsideRef,
4179 onFocus: (event) => {
4180 if (isOutsideEvent(event, portalNode)) {
4181 afterInsideRef.current?.focus();
4182 } else {
4183 const domReference = focusManagerState ? focusManagerState.domReference : null;
4184 const nextTabbable = getNextTabbable(domReference);
4185 nextTabbable?.focus();
4186 if (focusManagerState?.closeOnFocusOut) {
4187 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
4188 }
4189 }
4190 }
4191 })]
4192 })]
4193 });
4194 });
4195 if (true) FloatingPortal.displayName = "FloatingPortal";
4196
4197 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
4198 var React23 = __toESM(require_react(), 1);
4199
4200 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
4201 function createEventEmitter() {
4202 const map = /* @__PURE__ */ new Map();
4203 return {
4204 emit(event, data) {
4205 map.get(event)?.forEach((listener) => listener(data));
4206 },
4207 on(event, listener) {
4208 if (!map.has(event)) {
4209 map.set(event, /* @__PURE__ */ new Set());
4210 }
4211 map.get(event).add(listener);
4212 },
4213 off(event, listener) {
4214 map.get(event)?.delete(listener);
4215 }
4216 };
4217 }
4218
4219 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTreeStore.js
4220 var FloatingTreeStore = class {
4221 nodesRef = {
4222 current: []
4223 };
4224 events = createEventEmitter();
4225 addNode(node) {
4226 this.nodesRef.current.push(node);
4227 }
4228 removeNode(node) {
4229 const index2 = this.nodesRef.current.findIndex((n2) => n2 === node);
4230 if (index2 !== -1) {
4231 this.nodesRef.current.splice(index2, 1);
4232 }
4233 }
4234 };
4235
4236 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
4237 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
4238 var FloatingNodeContext = /* @__PURE__ */ React23.createContext(null);
4239 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
4240 var FloatingTreeContext = /* @__PURE__ */ React23.createContext(null);
4241 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
4242 var useFloatingParentNodeId = () => React23.useContext(FloatingNodeContext)?.id || null;
4243 var useFloatingTree = (externalTree) => {
4244 const contextTree = React23.useContext(FloatingTreeContext);
4245 return externalTree ?? contextTree;
4246 };
4247 function useFloatingNodeId(externalTree) {
4248 const id = useId();
4249 const tree = useFloatingTree(externalTree);
4250 const parentId = useFloatingParentNodeId();
4251 useIsoLayoutEffect(() => {
4252 if (!id) {
4253 return void 0;
4254 }
4255 const node = {
4256 id,
4257 parentId
4258 };
4259 tree?.addNode(node);
4260 return () => {
4261 tree?.removeNode(node);
4262 };
4263 }, [tree, id, parentId]);
4264 return id;
4265 }
4266 function FloatingNode(props) {
4267 const {
4268 children,
4269 id
4270 } = props;
4271 const parentId = useFloatingParentNodeId();
4272 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingNodeContext.Provider, {
4273 value: React23.useMemo(() => ({
4274 id,
4275 parentId
4276 }), [id, parentId]),
4277 children
4278 });
4279 }
4280 function FloatingTree(props) {
4281 const {
4282 children,
4283 externalTree
4284 } = props;
4285 const tree = useRefWithInit(() => externalTree ?? new FloatingTreeStore()).current;
4286 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingTreeContext.Provider, {
4287 value: tree,
4288 children
4289 });
4290 }
4291
4292 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingFocusManager.js
4293 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
4294 function getEventType(event, lastInteractionType) {
4295 const win = getWindow(getTarget(event));
4296 if (event instanceof win.KeyboardEvent) {
4297 return "keyboard";
4298 }
4299 if (event instanceof win.FocusEvent) {
4300 return lastInteractionType || "keyboard";
4301 }
4302 if ("pointerType" in event) {
4303 return event.pointerType || "keyboard";
4304 }
4305 if ("touches" in event) {
4306 return "touch";
4307 }
4308 if (event instanceof win.MouseEvent) {
4309 return lastInteractionType || (event.detail === 0 ? "keyboard" : "mouse");
4310 }
4311 return "";
4312 }
4313 var LIST_LIMIT = 20;
4314 var previouslyFocusedElements = [];
4315 function clearDisconnectedPreviouslyFocusedElements() {
4316 previouslyFocusedElements = previouslyFocusedElements.filter((entry) => {
4317 return entry.deref()?.isConnected;
4318 });
4319 }
4320 function addPreviouslyFocusedElement(element) {
4321 clearDisconnectedPreviouslyFocusedElements();
4322 if (element && getNodeName(element) !== "body") {
4323 previouslyFocusedElements.push(new WeakRef(element));
4324 if (previouslyFocusedElements.length > LIST_LIMIT) {
4325 previouslyFocusedElements = previouslyFocusedElements.slice(-LIST_LIMIT);
4326 }
4327 }
4328 }
4329 function getPreviouslyFocusedElement() {
4330 clearDisconnectedPreviouslyFocusedElements();
4331 return previouslyFocusedElements[previouslyFocusedElements.length - 1]?.deref();
4332 }
4333 function getFirstTabbableElement(container) {
4334 if (!container) {
4335 return null;
4336 }
4337 if (isTabbable(container)) {
4338 return container;
4339 }
4340 return tabbable(container)[0] || container;
4341 }
4342 function handleTabIndex(floatingFocusElement, orderRef) {
4343 if (floatingFocusElement.hasAttribute("tabindex") && !floatingFocusElement.hasAttribute("data-tabindex")) {
4344 return;
4345 }
4346 if (!orderRef.current.includes("floating") && !floatingFocusElement.getAttribute("role")?.includes("dialog")) {
4347 return;
4348 }
4349 const focusableElements = focusable(floatingFocusElement);
4350 const tabbableContent = focusableElements.filter((element) => {
4351 const dataTabIndex = element.getAttribute("data-tabindex") || "";
4352 return isTabbable(element) || element.hasAttribute("data-tabindex") && !dataTabIndex.startsWith("-");
4353 });
4354 const tabIndex = floatingFocusElement.getAttribute("tabindex");
4355 if (orderRef.current.includes("floating") || tabbableContent.length === 0) {
4356 if (tabIndex !== "0") {
4357 floatingFocusElement.setAttribute("tabindex", "0");
4358 }
4359 } else if (tabIndex !== "-1" || floatingFocusElement.hasAttribute("data-tabindex") && floatingFocusElement.getAttribute("data-tabindex") !== "-1") {
4360 floatingFocusElement.setAttribute("tabindex", "-1");
4361 floatingFocusElement.setAttribute("data-tabindex", "-1");
4362 }
4363 }
4364 function FloatingFocusManager(props) {
4365 const {
4366 context,
4367 children,
4368 disabled: disabled2 = false,
4369 initialFocus = true,
4370 returnFocus = true,
4371 restoreFocus = false,
4372 modal = true,
4373 closeOnFocusOut = true,
4374 openInteractionType = "",
4375 nextFocusableElement,
4376 previousFocusableElement,
4377 beforeContentFocusGuardRef,
4378 externalTree,
4379 getInsideElements
4380 } = props;
4381 const store = "rootStore" in context ? context.rootStore : context;
4382 const open = store.useState("open");
4383 const domReference = store.useState("domReferenceElement");
4384 const floating = store.useState("floatingElement");
4385 const {
4386 events,
4387 dataRef
4388 } = store.context;
4389 const getNodeId = useStableCallback(() => dataRef.current.floatingContext?.nodeId);
4390 const ignoreInitialFocus = initialFocus === false;
4391 const isUntrappedTypeableCombobox = isTypeableCombobox(domReference) && ignoreInitialFocus;
4392 const orderRef = React24.useRef(["content"]);
4393 const initialFocusRef = useValueAsRef(initialFocus);
4394 const returnFocusRef = useValueAsRef(returnFocus);
4395 const openInteractionTypeRef = useValueAsRef(openInteractionType);
4396 const tree = useFloatingTree(externalTree);
4397 const portalContext = usePortalContext();
4398 const preventReturnFocusRef = React24.useRef(false);
4399 const isPointerDownRef = React24.useRef(false);
4400 const pointerDownOutsideRef = React24.useRef(false);
4401 const lastFocusedTabbableRef = React24.useRef(null);
4402 const closeTypeRef = React24.useRef("");
4403 const lastInteractionTypeRef = React24.useRef("");
4404 const beforeGuardRef = React24.useRef(null);
4405 const afterGuardRef = React24.useRef(null);
4406 const mergedBeforeGuardRef = useMergedRefs(beforeGuardRef, beforeContentFocusGuardRef, portalContext?.beforeInsideRef);
4407 const mergedAfterGuardRef = useMergedRefs(afterGuardRef, portalContext?.afterInsideRef);
4408 const blurTimeout = useTimeout();
4409 const pointerDownTimeout = useTimeout();
4410 const restoreFocusFrame = useAnimationFrame();
4411 const isInsidePortal = portalContext != null;
4412 const floatingFocusElement = getFloatingFocusElement(floating);
4413 const getTabbableContent = useStableCallback((container = floatingFocusElement) => {
4414 return container ? tabbable(container) : [];
4415 });
4416 const getResolvedInsideElements = useStableCallback(() => getInsideElements?.().filter((element) => element != null) ?? []);
4417 React24.useEffect(() => {
4418 if (disabled2 || !modal) {
4419 return void 0;
4420 }
4421 function onKeyDown(event) {
4422 if (event.key === "Tab") {
4423 if (contains(floatingFocusElement, activeElement(ownerDocument(floatingFocusElement))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
4424 stopEvent(event);
4425 }
4426 }
4427 }
4428 const doc = ownerDocument(floatingFocusElement);
4429 return addEventListener(doc, "keydown", onKeyDown);
4430 }, [disabled2, floatingFocusElement, modal, isUntrappedTypeableCombobox, getTabbableContent]);
4431 React24.useEffect(() => {
4432 if (disabled2 || !open) {
4433 return void 0;
4434 }
4435 const doc = ownerDocument(floatingFocusElement);
4436 function clearPointerDownOutside() {
4437 pointerDownOutsideRef.current = false;
4438 }
4439 function onPointerDown(event) {
4440 const target = getTarget(event);
4441 const insideElements = getResolvedInsideElements();
4442 const pointerTargetInside = contains(floating, target) || contains(domReference, target) || contains(portalContext?.portalNode, target) || insideElements.some((element) => element === target || contains(element, target));
4443 pointerDownOutsideRef.current = !pointerTargetInside;
4444 lastInteractionTypeRef.current = event.pointerType || "keyboard";
4445 if (target?.closest(`[${CLICK_TRIGGER_IDENTIFIER}]`)) {
4446 isPointerDownRef.current = true;
4447 }
4448 }
4449 function onKeyDown() {
4450 lastInteractionTypeRef.current = "keyboard";
4451 }
4452 return mergeCleanups(addEventListener(doc, "pointerdown", onPointerDown, true), addEventListener(doc, "pointerup", clearPointerDownOutside, true), addEventListener(doc, "pointercancel", clearPointerDownOutside, true), addEventListener(doc, "keydown", onKeyDown, true));
4453 }, [disabled2, floating, domReference, floatingFocusElement, open, portalContext, getResolvedInsideElements]);
4454 React24.useEffect(() => {
4455 if (disabled2 || !closeOnFocusOut) {
4456 return void 0;
4457 }
4458 const doc = ownerDocument(floatingFocusElement);
4459 function handlePointerDown() {
4460 isPointerDownRef.current = true;
4461 pointerDownTimeout.start(0, () => {
4462 isPointerDownRef.current = false;
4463 });
4464 }
4465 function handleFocusIn(event) {
4466 const target = getTarget(event);
4467 if (isTabbable(target)) {
4468 lastFocusedTabbableRef.current = target;
4469 }
4470 }
4471 function handleFocusOutside(event) {
4472 const relatedTarget = event.relatedTarget;
4473 const currentTarget = event.currentTarget;
4474 const target = getTarget(event);
4475 queueMicrotask(() => {
4476 const nodeId = getNodeId();
4477 const triggers = store.context.triggerElements;
4478 const insideElements = getResolvedInsideElements();
4479 const isRelatedFocusGuard = relatedTarget?.hasAttribute(createAttribute("focus-guard")) && [beforeGuardRef.current, afterGuardRef.current, portalContext?.beforeInsideRef.current, portalContext?.afterInsideRef.current, portalContext?.beforeOutsideRef.current, portalContext?.afterOutsideRef.current, resolveRef(previousFocusableElement), resolveRef(nextFocusableElement)].includes(relatedTarget);
4480 const movedToUnrelatedNode = !(contains(domReference, relatedTarget) || contains(floating, relatedTarget) || contains(relatedTarget, floating) || contains(portalContext?.portalNode, relatedTarget) || insideElements.some((element) => element === relatedTarget || contains(element, relatedTarget)) || relatedTarget != null && triggers.hasElement(relatedTarget) || triggers.hasMatchingElement((trigger) => contains(trigger, relatedTarget)) || isRelatedFocusGuard || tree && (getNodeChildren(tree.nodesRef.current, nodeId).find((node) => contains(node.context?.elements.floating, relatedTarget) || contains(node.context?.elements.domReference, relatedTarget)) || getNodeAncestors(tree.nodesRef.current, nodeId).find((node) => [node.context?.elements.floating, getFloatingFocusElement(node.context?.elements.floating)].includes(relatedTarget) || node.context?.elements.domReference === relatedTarget)));
4481 if (currentTarget === domReference && floatingFocusElement) {
4482 handleTabIndex(floatingFocusElement, orderRef);
4483 }
4484 if (restoreFocus && currentTarget !== domReference && !isElementVisible(target) && activeElement(doc) === doc.body) {
4485 if (isHTMLElement(floatingFocusElement)) {
4486 floatingFocusElement.focus();
4487 if (restoreFocus === "popup") {
4488 restoreFocusFrame.request(() => {
4489 floatingFocusElement.focus();
4490 });
4491 return;
4492 }
4493 }
4494 const tabbableContent = getTabbableContent();
4495 const prevTabbable = lastFocusedTabbableRef.current;
4496 const nodeToFocus = (prevTabbable && tabbableContent.includes(prevTabbable) ? prevTabbable : null) || tabbableContent[tabbableContent.length - 1] || floatingFocusElement;
4497 if (isHTMLElement(nodeToFocus)) {
4498 nodeToFocus.focus();
4499 }
4500 }
4501 if (dataRef.current.insideReactTree) {
4502 dataRef.current.insideReactTree = false;
4503 return;
4504 }
4505 if ((isUntrappedTypeableCombobox ? true : !modal) && relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
4506 // For an "untrapped" typeable combobox (input role=combobox with
4507 // initialFocus=false), re-opening the popup and tabbing out should still close it even
4508 // when the previously focused element (e.g. the next tabbable outside the popup) is
4509 // focused again. Otherwise, the popup remains open on the second Tab sequence:
4510 // click input -> Tab (closes) -> click input -> Tab.
4511 // Allow closing when `isUntrappedTypeableCombobox` regardless of the previously focused element.
4512 (isUntrappedTypeableCombobox || relatedTarget !== getPreviouslyFocusedElement())) {
4513 preventReturnFocusRef.current = true;
4514 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event));
4515 }
4516 });
4517 }
4518 function markInsideReactTree() {
4519 if (pointerDownOutsideRef.current) {
4520 return;
4521 }
4522 dataRef.current.insideReactTree = true;
4523 blurTimeout.start(0, () => {
4524 dataRef.current.insideReactTree = false;
4525 });
4526 }
4527 const domReferenceElement = isHTMLElement(domReference) ? domReference : null;
4528 if (!floating && !domReferenceElement) {
4529 return void 0;
4530 }
4531 return mergeCleanups(domReferenceElement && addEventListener(domReferenceElement, "focusout", handleFocusOutside), domReferenceElement && addEventListener(domReferenceElement, "pointerdown", handlePointerDown), floating && addEventListener(floating, "focusin", handleFocusIn), floating && addEventListener(floating, "focusout", handleFocusOutside), floating && portalContext && addEventListener(floating, "focusout", markInsideReactTree, true));
4532 }, [disabled2, domReference, floating, floatingFocusElement, modal, tree, portalContext, store, closeOnFocusOut, restoreFocus, getTabbableContent, isUntrappedTypeableCombobox, getNodeId, orderRef, dataRef, blurTimeout, pointerDownTimeout, restoreFocusFrame, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]);
4533 React24.useEffect(() => {
4534 if (disabled2 || !floating || !open) {
4535 return void 0;
4536 }
4537 const portalNodes = Array.from(portalContext?.portalNode?.querySelectorAll(`[${createAttribute("portal")}]`) || []);
4538 const ancestors = tree ? getNodeAncestors(tree.nodesRef.current, getNodeId()) : [];
4539 const rootAncestorComboboxDomReference = ancestors.find((node) => isTypeableCombobox(node.context?.elements.domReference || null))?.context?.elements.domReference;
4540 const controlInsideElements = [floating, ...portalNodes, beforeGuardRef.current, afterGuardRef.current, portalContext?.beforeOutsideRef.current, portalContext?.afterOutsideRef.current, ...getResolvedInsideElements()];
4541 const insideElements = [...controlInsideElements, rootAncestorComboboxDomReference, resolveRef(previousFocusableElement), resolveRef(nextFocusableElement), isUntrappedTypeableCombobox ? domReference : null].filter((x2) => x2 != null);
4542 const ariaHiddenCleanup = markOthers(insideElements, {
4543 ariaHidden: modal || isUntrappedTypeableCombobox,
4544 mark: false
4545 });
4546 const markerInsideElements = [floating, ...portalNodes].filter((x2) => x2 != null);
4547 const markerCleanup = markOthers(markerInsideElements);
4548 return () => {
4549 markerCleanup();
4550 ariaHiddenCleanup();
4551 };
4552 }, [open, disabled2, domReference, floating, modal, portalContext, isUntrappedTypeableCombobox, tree, getNodeId, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]);
4553 useIsoLayoutEffect(() => {
4554 if (!open || disabled2 || !isHTMLElement(floatingFocusElement)) {
4555 return;
4556 }
4557 const doc = ownerDocument(floatingFocusElement);
4558 const previouslyFocusedElement = activeElement(doc);
4559 queueMicrotask(() => {
4560 const initialFocusValueOrFn = initialFocusRef.current;
4561 const resolvedInitialFocus = typeof initialFocusValueOrFn === "function" ? initialFocusValueOrFn(openInteractionTypeRef.current || "") : initialFocusValueOrFn;
4562 if (resolvedInitialFocus === void 0 || resolvedInitialFocus === false) {
4563 return;
4564 }
4565 const focusAlreadyInsideFloatingEl = contains(floatingFocusElement, previouslyFocusedElement);
4566 if (focusAlreadyInsideFloatingEl) {
4567 return;
4568 }
4569 let focusableElements = null;
4570 const getDefaultFocusElement = () => {
4571 if (focusableElements == null) {
4572 focusableElements = getTabbableContent(floatingFocusElement);
4573 }
4574 return focusableElements[0] || floatingFocusElement;
4575 };
4576 let elToFocus;
4577 if (resolvedInitialFocus === true || resolvedInitialFocus === null) {
4578 elToFocus = getDefaultFocusElement();
4579 } else {
4580 elToFocus = resolveRef(resolvedInitialFocus);
4581 }
4582 elToFocus = elToFocus || getDefaultFocusElement();
4583 const hadFocusInside = contains(floatingFocusElement, activeElement(doc));
4584 enqueueFocus(elToFocus, {
4585 preventScroll: elToFocus === floatingFocusElement,
4586 shouldFocus() {
4587 if (hadFocusInside) {
4588 return true;
4589 }
4590 const currentActiveElement = activeElement(doc);
4591 const focusMovedInside = currentActiveElement !== elToFocus && contains(floatingFocusElement, currentActiveElement);
4592 return !focusMovedInside;
4593 }
4594 });
4595 });
4596 }, [disabled2, open, floatingFocusElement, getTabbableContent, initialFocusRef, openInteractionTypeRef]);
4597 useIsoLayoutEffect(() => {
4598 if (disabled2 || !floatingFocusElement) {
4599 return void 0;
4600 }
4601 const doc = ownerDocument(floatingFocusElement);
4602 const previouslyFocusedElement = activeElement(doc);
4603 addPreviouslyFocusedElement(previouslyFocusedElement);
4604 function onOpenChangeLocal(details) {
4605 if (!details.open) {
4606 closeTypeRef.current = getEventType(details.nativeEvent, lastInteractionTypeRef.current);
4607 }
4608 if (details.reason === reason_parts_exports.triggerHover && details.nativeEvent.type === "mouseleave") {
4609 preventReturnFocusRef.current = true;
4610 }
4611 if (details.reason !== reason_parts_exports.outsidePress) {
4612 return;
4613 }
4614 if (details.nested) {
4615 preventReturnFocusRef.current = false;
4616 } else if (isVirtualClick(details.nativeEvent) || isVirtualPointerEvent(details.nativeEvent)) {
4617 preventReturnFocusRef.current = false;
4618 } else {
4619 let isPreventScrollSupported = false;
4620 ownerDocument(floatingFocusElement).createElement("div").focus({
4621 get preventScroll() {
4622 isPreventScrollSupported = true;
4623 return false;
4624 }
4625 });
4626 if (isPreventScrollSupported) {
4627 preventReturnFocusRef.current = false;
4628 } else {
4629 preventReturnFocusRef.current = true;
4630 }
4631 }
4632 }
4633 events.on("openchange", onOpenChangeLocal);
4634 function getReturnElement() {
4635 const returnFocusValueOrFn = returnFocusRef.current;
4636 let resolvedReturnFocusValue = typeof returnFocusValueOrFn === "function" ? returnFocusValueOrFn(closeTypeRef.current) : returnFocusValueOrFn;
4637 if (resolvedReturnFocusValue === void 0 || resolvedReturnFocusValue === false) {
4638 return null;
4639 }
4640 if (resolvedReturnFocusValue === null) {
4641 resolvedReturnFocusValue = true;
4642 }
4643 if (typeof resolvedReturnFocusValue === "boolean") {
4644 if (domReference?.isConnected) {
4645 return domReference;
4646 }
4647 return getPreviouslyFocusedElement() || null;
4648 }
4649 const fallback = domReference?.isConnected ? domReference : getPreviouslyFocusedElement();
4650 return resolveRef(resolvedReturnFocusValue) || fallback || null;
4651 }
4652 return () => {
4653 events.off("openchange", onOpenChangeLocal);
4654 const activeEl = activeElement(doc);
4655 const insideElements = getResolvedInsideElements();
4656 const isFocusInsideFloatingTree = contains(floating, activeEl) || insideElements.some((element) => element === activeEl || contains(element, activeEl)) || tree && getNodeChildren(tree.nodesRef.current, getNodeId(), false).some((node) => contains(node.context?.elements.floating, activeEl));
4657 const returnFocusValueOrFn = returnFocusRef.current;
4658 const returnElement = getReturnElement();
4659 queueMicrotask(() => {
4660 const tabbableReturnElement = getFirstTabbableElement(returnElement);
4661 const hasExplicitReturnFocus = typeof returnFocusValueOrFn !== "boolean";
4662 if (returnFocusValueOrFn && !preventReturnFocusRef.current && isHTMLElement(tabbableReturnElement) && // If the focus moved somewhere else after mount, avoid returning focus
4663 // since it likely entered a different element which should be
4664 // respected: https://github.com/floating-ui/floating-ui/issues/2607
4665 (!hasExplicitReturnFocus && tabbableReturnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)) {
4666 tabbableReturnElement.focus({
4667 preventScroll: true
4668 });
4669 }
4670 preventReturnFocusRef.current = false;
4671 });
4672 };
4673 }, [disabled2, floating, floatingFocusElement, returnFocusRef, events, tree, domReference, getNodeId, getResolvedInsideElements]);
4674 useIsoLayoutEffect(() => {
4675 if (!isWebKit2 || open || !floating) {
4676 return;
4677 }
4678 const activeEl = activeElement(ownerDocument(floating));
4679 if (!isHTMLElement(activeEl) || !isTypeableElement(activeEl)) {
4680 return;
4681 }
4682 if (contains(floating, activeEl)) {
4683 activeEl.blur();
4684 }
4685 }, [open, floating]);
4686 useIsoLayoutEffect(() => {
4687 if (disabled2 || !portalContext) {
4688 return void 0;
4689 }
4690 portalContext.setFocusManagerState({
4691 modal,
4692 closeOnFocusOut,
4693 open,
4694 onOpenChange: store.setOpen,
4695 domReference
4696 });
4697 return () => {
4698 portalContext.setFocusManagerState(null);
4699 };
4700 }, [disabled2, portalContext, modal, open, store, closeOnFocusOut, domReference]);
4701 useIsoLayoutEffect(() => {
4702 if (disabled2 || !floatingFocusElement) {
4703 return void 0;
4704 }
4705 handleTabIndex(floatingFocusElement, orderRef);
4706 return () => {
4707 queueMicrotask(clearDisconnectedPreviouslyFocusedElements);
4708 };
4709 }, [disabled2, floatingFocusElement, orderRef]);
4710 const shouldRenderGuards = !disabled2 && (modal ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal);
4711 return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React24.Fragment, {
4712 children: [shouldRenderGuards && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FocusGuard, {
4713 "data-type": "inside",
4714 ref: mergedBeforeGuardRef,
4715 onFocus: (event) => {
4716 if (modal) {
4717 const els = getTabbableContent();
4718 enqueueFocus(els[els.length - 1]);
4719 } else if (portalContext?.portalNode) {
4720 preventReturnFocusRef.current = false;
4721 if (isOutsideEvent(event, portalContext.portalNode)) {
4722 const nextTabbable = getNextTabbable(domReference);
4723 nextTabbable?.focus();
4724 } else {
4725 resolveRef(previousFocusableElement ?? portalContext.beforeOutsideRef)?.focus();
4726 }
4727 }
4728 }
4729 }), children, shouldRenderGuards && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FocusGuard, {
4730 "data-type": "inside",
4731 ref: mergedAfterGuardRef,
4732 onFocus: (event) => {
4733 if (modal) {
4734 enqueueFocus(getTabbableContent()[0]);
4735 } else if (portalContext?.portalNode) {
4736 if (closeOnFocusOut) {
4737 preventReturnFocusRef.current = true;
4738 }
4739 if (isOutsideEvent(event, portalContext.portalNode)) {
4740 const prevTabbable = getPreviousTabbable(domReference);
4741 prevTabbable?.focus();
4742 } else {
4743 resolveRef(nextFocusableElement ?? portalContext.afterOutsideRef)?.focus();
4744 }
4745 }
4746 }
4747 })]
4748 });
4749 }
4750
4751 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClick.js
4752 var React25 = __toESM(require_react(), 1);
4753 function useClick(context, props = {}) {
4754 const {
4755 enabled = true,
4756 event: eventOption = "click",
4757 toggle = true,
4758 ignoreMouse = false,
4759 stickIfOpen = true,
4760 touchOpenDelay = 0,
4761 reason = reason_parts_exports.triggerPress
4762 } = props;
4763 const store = "rootStore" in context ? context.rootStore : context;
4764 const dataRef = store.context.dataRef;
4765 const pointerTypeRef = React25.useRef(void 0);
4766 const frame = useAnimationFrame();
4767 const touchOpenTimeout = useTimeout();
4768 const reference = React25.useMemo(() => {
4769 function setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType) {
4770 const details = createChangeEventDetails(reason, nativeEvent, target);
4771 if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
4772 touchOpenTimeout.start(touchOpenDelay, () => {
4773 store.setOpen(true, details);
4774 });
4775 } else {
4776 store.setOpen(nextOpen, details);
4777 }
4778 }
4779 function getNextOpen(open, currentTarget, isClickLikeOpenEvent2) {
4780 const openEvent = dataRef.current.openEvent;
4781 const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== currentTarget;
4782 if (open && hasClickedOnInactiveTrigger) {
4783 return true;
4784 }
4785 if (!open) {
4786 return true;
4787 }
4788 if (!toggle) {
4789 return true;
4790 }
4791 if (openEvent && stickIfOpen) {
4792 return !isClickLikeOpenEvent2(openEvent.type);
4793 }
4794 return false;
4795 }
4796 return {
4797 onPointerDown(event) {
4798 pointerTypeRef.current = event.pointerType;
4799 },
4800 onMouseDown(event) {
4801 const pointerType = pointerTypeRef.current;
4802 const nativeEvent = event.nativeEvent;
4803 const open = store.select("open");
4804 if (event.button !== 0 || eventOption === "click" || isMouseLikePointerType(pointerType, true) && ignoreMouse) {
4805 return;
4806 }
4807 const nextOpen = getNextOpen(open, event.currentTarget, (openEventType) => openEventType === "click" || openEventType === "mousedown");
4808 const target = getTarget(nativeEvent);
4809 if (isTypeableElement(target)) {
4810 setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType);
4811 return;
4812 }
4813 const eventCurrentTarget = event.currentTarget;
4814 frame.request(() => {
4815 setOpenWithTouchDelay(nextOpen, nativeEvent, eventCurrentTarget, pointerType);
4816 });
4817 },
4818 onClick(event) {
4819 if (eventOption === "mousedown-only") {
4820 return;
4821 }
4822 const pointerType = pointerTypeRef.current;
4823 if (eventOption === "mousedown" && pointerType) {
4824 pointerTypeRef.current = void 0;
4825 return;
4826 }
4827 if (isMouseLikePointerType(pointerType, true) && ignoreMouse) {
4828 return;
4829 }
4830 const open = store.select("open");
4831 const nextOpen = getNextOpen(open, event.currentTarget, (openEventType) => openEventType === "click" || openEventType === "mousedown" || openEventType === "keydown" || openEventType === "keyup");
4832 setOpenWithTouchDelay(nextOpen, event.nativeEvent, event.currentTarget, pointerType);
4833 },
4834 onKeyDown() {
4835 pointerTypeRef.current = void 0;
4836 }
4837 };
4838 }, [dataRef, eventOption, ignoreMouse, reason, store, stickIfOpen, toggle, frame, touchOpenTimeout, touchOpenDelay]);
4839 return React25.useMemo(() => enabled ? {
4840 reference
4841 } : EMPTY_OBJECT, [enabled, reference]);
4842 }
4843
4844 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
4845 var React26 = __toESM(require_react(), 1);
4846 function createVirtualElement(domElement, data) {
4847 let offsetX = null;
4848 let offsetY = null;
4849 let isAutoUpdateEvent = false;
4850 return {
4851 contextElement: domElement || void 0,
4852 getBoundingClientRect() {
4853 const domRect = domElement?.getBoundingClientRect() || {
4854 width: 0,
4855 height: 0,
4856 x: 0,
4857 y: 0
4858 };
4859 const isXAxis = data.axis === "x" || data.axis === "both";
4860 const isYAxis = data.axis === "y" || data.axis === "both";
4861 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
4862 let width = domRect.width;
4863 let height = domRect.height;
4864 let x2 = domRect.x;
4865 let y2 = domRect.y;
4866 if (offsetX == null && data.x && isXAxis) {
4867 offsetX = domRect.x - data.x;
4868 }
4869 if (offsetY == null && data.y && isYAxis) {
4870 offsetY = domRect.y - data.y;
4871 }
4872 x2 -= offsetX || 0;
4873 y2 -= offsetY || 0;
4874 width = 0;
4875 height = 0;
4876 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
4877 width = data.axis === "y" ? domRect.width : 0;
4878 height = data.axis === "x" ? domRect.height : 0;
4879 x2 = isXAxis && data.x != null ? data.x : x2;
4880 y2 = isYAxis && data.y != null ? data.y : y2;
4881 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
4882 height = data.axis === "x" ? domRect.height : height;
4883 width = data.axis === "y" ? domRect.width : width;
4884 }
4885 isAutoUpdateEvent = true;
4886 return {
4887 width,
4888 height,
4889 x: x2,
4890 y: y2,
4891 top: y2,
4892 right: x2 + width,
4893 bottom: y2 + height,
4894 left: x2
4895 };
4896 }
4897 };
4898 }
4899 function isMouseBasedEvent(event) {
4900 return event != null && event.clientX != null;
4901 }
4902 function useClientPoint(context, props = {}) {
4903 const {
4904 enabled = true,
4905 axis = "both"
4906 } = props;
4907 const store = "rootStore" in context ? context.rootStore : context;
4908 const open = store.useState("open");
4909 const floating = store.useState("floatingElement");
4910 const domReference = store.useState("domReferenceElement");
4911 const dataRef = store.context.dataRef;
4912 const initialRef = React26.useRef(false);
4913 const cleanupListenerRef = React26.useRef(null);
4914 const [pointerType, setPointerType] = React26.useState();
4915 const [reactive, setReactive] = React26.useState([]);
4916 const resetReference = useStableCallback((reference2) => {
4917 store.set("positionReference", reference2);
4918 });
4919 const setReference = useStableCallback((newX, newY, referenceElement) => {
4920 if (initialRef.current) {
4921 return;
4922 }
4923 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
4924 return;
4925 }
4926 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
4927 x: newX,
4928 y: newY,
4929 axis,
4930 dataRef,
4931 pointerType
4932 }));
4933 });
4934 const handleReferenceEnterOrMove = useStableCallback((event) => {
4935 if (!open) {
4936 setReference(event.clientX, event.clientY, event.currentTarget);
4937 } else if (!cleanupListenerRef.current) {
4938 setReference(event.clientX, event.clientY, event.currentTarget);
4939 setReactive([]);
4940 }
4941 });
4942 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
4943 React26.useEffect(() => {
4944 if (!enabled) {
4945 resetReference(domReference);
4946 return void 0;
4947 }
4948 if (!openCheck) {
4949 return void 0;
4950 }
4951 function cleanupListener() {
4952 cleanupListenerRef.current?.();
4953 cleanupListenerRef.current = null;
4954 }
4955 const win = getWindow(floating);
4956 function handleMouseMove(event) {
4957 const target = getTarget(event);
4958 if (!contains(floating, target)) {
4959 setReference(event.clientX, event.clientY);
4960 } else {
4961 cleanupListener();
4962 }
4963 }
4964 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
4965 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
4966 } else {
4967 resetReference(domReference);
4968 }
4969 return cleanupListener;
4970 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
4971 React26.useEffect(() => () => {
4972 store.set("positionReference", null);
4973 }, [store]);
4974 React26.useEffect(() => {
4975 if (enabled && !floating) {
4976 initialRef.current = false;
4977 }
4978 }, [enabled, floating]);
4979 React26.useEffect(() => {
4980 if (!enabled && open) {
4981 initialRef.current = true;
4982 }
4983 }, [enabled, open]);
4984 const reference = React26.useMemo(() => {
4985 function setPointerTypeRef(event) {
4986 setPointerType(event.pointerType);
4987 }
4988 return {
4989 onPointerDown: setPointerTypeRef,
4990 onPointerEnter: setPointerTypeRef,
4991 onMouseMove: handleReferenceEnterOrMove,
4992 onMouseEnter: handleReferenceEnterOrMove
4993 };
4994 }, [handleReferenceEnterOrMove]);
4995 return React26.useMemo(() => enabled ? {
4996 reference,
4997 trigger: reference
4998 } : {}, [enabled, reference]);
4999 }
5000
5001 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
5002 var React27 = __toESM(require_react(), 1);
5003 var bubbleHandlerKeys = {
5004 intentional: "onClick",
5005 sloppy: "onPointerDown"
5006 };
5007 function alwaysFalse() {
5008 return false;
5009 }
5010 function normalizeProp(normalizable) {
5011 return {
5012 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
5013 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
5014 };
5015 }
5016 function useDismiss(context, props = {}) {
5017 const {
5018 enabled = true,
5019 escapeKey: escapeKey2 = true,
5020 outsidePress: outsidePressProp = true,
5021 outsidePressEvent = "sloppy",
5022 referencePress = alwaysFalse,
5023 referencePressEvent = "sloppy",
5024 bubbles,
5025 externalTree
5026 } = props;
5027 const store = "rootStore" in context ? context.rootStore : context;
5028 const open = store.useState("open");
5029 const floatingElement = store.useState("floatingElement");
5030 const {
5031 dataRef
5032 } = store.context;
5033 const tree = useFloatingTree(externalTree);
5034 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
5035 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
5036 const outsidePressEnabled = outsidePress2 !== false;
5037 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
5038 const {
5039 escapeKey: escapeKeyBubbles,
5040 outsidePress: outsidePressBubbles
5041 } = normalizeProp(bubbles);
5042 const pressStartedInsideRef = React27.useRef(false);
5043 const pressStartPreventedRef = React27.useRef(false);
5044 const suppressNextOutsideClickRef = React27.useRef(false);
5045 const isComposingRef = React27.useRef(false);
5046 const currentPointerTypeRef = React27.useRef("");
5047 const touchStateRef = React27.useRef(null);
5048 const cancelDismissOnEndTimeout = useTimeout();
5049 const clearInsideReactTreeTimeout = useTimeout();
5050 const clearInsideReactTree = useStableCallback(() => {
5051 clearInsideReactTreeTimeout.clear();
5052 dataRef.current.insideReactTree = false;
5053 });
5054 const hasBlockingChild = useStableCallback((bubbleKey) => {
5055 const nodeId = dataRef.current.floatingContext?.nodeId;
5056 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
5057 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
5058 });
5059 const isEventWithinOwnElements = useStableCallback((event) => {
5060 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
5061 });
5062 const closeOnReferencePress = useStableCallback((event) => {
5063 if (!referencePress()) {
5064 return;
5065 }
5066 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
5067 });
5068 const closeOnEscapeKeyDown = useStableCallback((event) => {
5069 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
5070 return;
5071 }
5072 if (isComposingRef.current) {
5073 return;
5074 }
5075 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
5076 return;
5077 }
5078 const native = isReactEvent(event) ? event.nativeEvent : event;
5079 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
5080 store.setOpen(false, eventDetails);
5081 if (!eventDetails.isCanceled) {
5082 event.preventDefault();
5083 }
5084 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
5085 event.stopPropagation();
5086 }
5087 });
5088 const markInsideReactTree = useStableCallback(() => {
5089 dataRef.current.insideReactTree = true;
5090 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
5091 });
5092 const markPressStartedInsideReactTree = useStableCallback((event) => {
5093 if (!open || !enabled || event.button !== 0) {
5094 return;
5095 }
5096 const target = getTarget(event.nativeEvent);
5097 if (!contains(store.select("floatingElement"), target)) {
5098 return;
5099 }
5100 if (!pressStartedInsideRef.current) {
5101 pressStartedInsideRef.current = true;
5102 pressStartPreventedRef.current = false;
5103 }
5104 });
5105 const markInsidePressStartPrevented = useStableCallback((event) => {
5106 if (!open || !enabled) {
5107 return;
5108 }
5109 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
5110 return;
5111 }
5112 if (pressStartedInsideRef.current) {
5113 pressStartPreventedRef.current = true;
5114 }
5115 });
5116 React27.useEffect(() => {
5117 if (!open || !enabled) {
5118 return void 0;
5119 }
5120 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
5121 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
5122 const compositionTimeout = new Timeout();
5123 const preventedPressSuppressionTimeout = new Timeout();
5124 function handleCompositionStart() {
5125 compositionTimeout.clear();
5126 isComposingRef.current = true;
5127 }
5128 function handleCompositionEnd() {
5129 compositionTimeout.start(
5130 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
5131 // Only apply to WebKit for the test to remain 0ms.
5132 isWebKit() ? 5 : 0,
5133 () => {
5134 isComposingRef.current = false;
5135 }
5136 );
5137 }
5138 function suppressImmediateOutsideClickAfterPreventedStart() {
5139 suppressNextOutsideClickRef.current = true;
5140 preventedPressSuppressionTimeout.start(0, () => {
5141 suppressNextOutsideClickRef.current = false;
5142 });
5143 }
5144 function resetPressStartState() {
5145 pressStartedInsideRef.current = false;
5146 pressStartPreventedRef.current = false;
5147 }
5148 function getOutsidePressEvent() {
5149 const type = currentPointerTypeRef.current;
5150 const computedType = type === "pen" || !type ? "mouse" : type;
5151 const outsidePressEventValue = getOutsidePressEventProp();
5152 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
5153 if (typeof resolved === "string") {
5154 return resolved;
5155 }
5156 return resolved[computedType];
5157 }
5158 function shouldIgnoreEvent(event) {
5159 const computedOutsidePressEvent = getOutsidePressEvent();
5160 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
5161 }
5162 function isEventWithinFloatingTree(event) {
5163 const nodeId = dataRef.current.floatingContext?.nodeId;
5164 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
5165 return isEventWithinOwnElements(event) || targetIsInsideChildren;
5166 }
5167 function closeOnPressOutside(event) {
5168 if (shouldIgnoreEvent(event)) {
5169 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
5170 preventedPressSuppressionTimeout.clear();
5171 suppressNextOutsideClickRef.current = false;
5172 }
5173 clearInsideReactTree();
5174 return;
5175 }
5176 if (dataRef.current.insideReactTree) {
5177 clearInsideReactTree();
5178 return;
5179 }
5180 const target = getTarget(event);
5181 const inertSelector = `[${createAttribute("inert")}]`;
5182 const targetRoot = isElement(target) ? target.getRootNode() : null;
5183 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
5184 const triggers = store.context.triggerElements;
5185 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
5186 return;
5187 }
5188 let targetRootAncestor = isElement(target) ? target : null;
5189 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
5190 const nextParent = getParentNode(targetRootAncestor);
5191 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
5192 break;
5193 }
5194 targetRootAncestor = nextParent;
5195 }
5196 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
5197 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
5198 // element was injected after the floating element rendered.
5199 markers.every((marker) => !contains(targetRootAncestor, marker))) {
5200 return;
5201 }
5202 if (isHTMLElement(target) && !("touches" in event)) {
5203 const lastTraversableNode = isLastTraversableNode(target);
5204 const style = getComputedStyle2(target);
5205 const scrollRe = /auto|scroll/;
5206 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
5207 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
5208 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
5209 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
5210 const isRTL7 = style.direction === "rtl";
5211 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
5212 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
5213 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
5214 return;
5215 }
5216 }
5217 if (isEventWithinFloatingTree(event)) {
5218 return;
5219 }
5220 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
5221 preventedPressSuppressionTimeout.clear();
5222 suppressNextOutsideClickRef.current = false;
5223 return;
5224 }
5225 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
5226 return;
5227 }
5228 if (hasBlockingChild("__outsidePressBubbles")) {
5229 return;
5230 }
5231 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
5232 clearInsideReactTree();
5233 }
5234 function handlePointerDown(event) {
5235 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
5236 return;
5237 }
5238 closeOnPressOutside(event);
5239 }
5240 function handleTouchStart(event) {
5241 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
5242 return;
5243 }
5244 const touch = event.touches[0];
5245 if (touch) {
5246 touchStateRef.current = {
5247 startTime: Date.now(),
5248 startX: touch.clientX,
5249 startY: touch.clientY,
5250 dismissOnTouchEnd: false,
5251 dismissOnMouseDown: true
5252 };
5253 cancelDismissOnEndTimeout.start(1e3, () => {
5254 if (touchStateRef.current) {
5255 touchStateRef.current.dismissOnTouchEnd = false;
5256 touchStateRef.current.dismissOnMouseDown = false;
5257 }
5258 });
5259 }
5260 }
5261 function addTargetEventListenerOnce(event, listener) {
5262 const target = getTarget(event);
5263 if (!target) {
5264 return;
5265 }
5266 const unsubscribe2 = addEventListener(target, event.type, () => {
5267 listener(event);
5268 unsubscribe2();
5269 });
5270 }
5271 function handleTouchStartCapture(event) {
5272 currentPointerTypeRef.current = "touch";
5273 addTargetEventListenerOnce(event, handleTouchStart);
5274 }
5275 function closeOnPressOutsideCapture(event) {
5276 cancelDismissOnEndTimeout.clear();
5277 if (event.type === "pointerdown") {
5278 currentPointerTypeRef.current = event.pointerType;
5279 }
5280 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
5281 return;
5282 }
5283 addTargetEventListenerOnce(event, (targetEvent) => {
5284 if (targetEvent.type === "pointerdown") {
5285 handlePointerDown(targetEvent);
5286 } else {
5287 closeOnPressOutside(targetEvent);
5288 }
5289 });
5290 }
5291 function handlePressEndCapture(event) {
5292 if (!pressStartedInsideRef.current) {
5293 return;
5294 }
5295 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
5296 resetPressStartState();
5297 if (getOutsidePressEvent() !== "intentional") {
5298 return;
5299 }
5300 if (event.type === "pointercancel") {
5301 if (pressStartedInsideDefaultPrevented) {
5302 suppressImmediateOutsideClickAfterPreventedStart();
5303 }
5304 return;
5305 }
5306 if (isEventWithinFloatingTree(event)) {
5307 return;
5308 }
5309 if (pressStartedInsideDefaultPrevented) {
5310 suppressImmediateOutsideClickAfterPreventedStart();
5311 return;
5312 }
5313 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
5314 return;
5315 }
5316 preventedPressSuppressionTimeout.clear();
5317 suppressNextOutsideClickRef.current = true;
5318 clearInsideReactTree();
5319 }
5320 function handleTouchMove(event) {
5321 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
5322 return;
5323 }
5324 const touch = event.touches[0];
5325 if (!touch) {
5326 return;
5327 }
5328 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
5329 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
5330 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
5331 if (distance > 5) {
5332 touchStateRef.current.dismissOnTouchEnd = true;
5333 }
5334 if (distance > 10) {
5335 closeOnPressOutside(event);
5336 cancelDismissOnEndTimeout.clear();
5337 touchStateRef.current = null;
5338 }
5339 }
5340 function handleTouchMoveCapture(event) {
5341 addTargetEventListenerOnce(event, handleTouchMove);
5342 }
5343 function handleTouchEnd(event) {
5344 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
5345 return;
5346 }
5347 if (touchStateRef.current.dismissOnTouchEnd) {
5348 closeOnPressOutside(event);
5349 }
5350 cancelDismissOnEndTimeout.clear();
5351 touchStateRef.current = null;
5352 }
5353 function handleTouchEndCapture(event) {
5354 addTargetEventListenerOnce(event, handleTouchEnd);
5355 }
5356 const doc = ownerDocument(floatingElement);
5357 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)));
5358 return () => {
5359 unsubscribe();
5360 compositionTimeout.clear();
5361 preventedPressSuppressionTimeout.clear();
5362 resetPressStartState();
5363 suppressNextOutsideClickRef.current = false;
5364 };
5365 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
5366 React27.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
5367 const reference = React27.useMemo(() => ({
5368 onKeyDown: closeOnEscapeKeyDown,
5369 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
5370 ...referencePressEvent !== "intentional" && {
5371 onClick: closeOnReferencePress
5372 }
5373 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
5374 const floating = React27.useMemo(() => ({
5375 onKeyDown: closeOnEscapeKeyDown,
5376 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
5377 // `onPointerDown`, such as with <NumberField.ScrubArea>.
5378 // See https://github.com/mui/base-ui/pull/3379
5379 onPointerDown: markInsidePressStartPrevented,
5380 onMouseDown: markInsidePressStartPrevented,
5381 onClickCapture: markInsideReactTree,
5382 onMouseDownCapture(event) {
5383 markInsideReactTree();
5384 markPressStartedInsideReactTree(event);
5385 },
5386 onPointerDownCapture(event) {
5387 markInsideReactTree();
5388 markPressStartedInsideReactTree(event);
5389 },
5390 onMouseUpCapture: markInsideReactTree,
5391 onTouchEndCapture: markInsideReactTree,
5392 onTouchMoveCapture: markInsideReactTree
5393 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
5394 return React27.useMemo(() => enabled ? {
5395 reference,
5396 floating,
5397 trigger: reference
5398 } : {}, [enabled, reference, floating]);
5399 }
5400
5401 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
5402 var React34 = __toESM(require_react(), 1);
5403
5404 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
5405 function computeCoordsFromPlacement(_ref, placement, rtl) {
5406 let {
5407 reference,
5408 floating
5409 } = _ref;
5410 const sideAxis = getSideAxis(placement);
5411 const alignmentAxis = getAlignmentAxis(placement);
5412 const alignLength = getAxisLength(alignmentAxis);
5413 const side = getSide(placement);
5414 const isVertical = sideAxis === "y";
5415 const commonX = reference.x + reference.width / 2 - floating.width / 2;
5416 const commonY = reference.y + reference.height / 2 - floating.height / 2;
5417 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
5418 let coords;
5419 switch (side) {
5420 case "top":
5421 coords = {
5422 x: commonX,
5423 y: reference.y - floating.height
5424 };
5425 break;
5426 case "bottom":
5427 coords = {
5428 x: commonX,
5429 y: reference.y + reference.height
5430 };
5431 break;
5432 case "right":
5433 coords = {
5434 x: reference.x + reference.width,
5435 y: commonY
5436 };
5437 break;
5438 case "left":
5439 coords = {
5440 x: reference.x - floating.width,
5441 y: commonY
5442 };
5443 break;
5444 default:
5445 coords = {
5446 x: reference.x,
5447 y: reference.y
5448 };
5449 }
5450 switch (getAlignment(placement)) {
5451 case "start":
5452 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
5453 break;
5454 case "end":
5455 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
5456 break;
5457 }
5458 return coords;
5459 }
5460 async function detectOverflow(state, options) {
5461 var _await$platform$isEle;
5462 if (options === void 0) {
5463 options = {};
5464 }
5465 const {
5466 x: x2,
5467 y: y2,
5468 platform: platform3,
5469 rects,
5470 elements,
5471 strategy
5472 } = state;
5473 const {
5474 boundary = "clippingAncestors",
5475 rootBoundary = "viewport",
5476 elementContext = "floating",
5477 altBoundary = false,
5478 padding = 0
5479 } = evaluate(options, state);
5480 const paddingObject = getPaddingObject(padding);
5481 const altContext = elementContext === "floating" ? "reference" : "floating";
5482 const element = elements[altBoundary ? altContext : elementContext];
5483 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
5484 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)),
5485 boundary,
5486 rootBoundary,
5487 strategy
5488 }));
5489 const rect = elementContext === "floating" ? {
5490 x: x2,
5491 y: y2,
5492 width: rects.floating.width,
5493 height: rects.floating.height
5494 } : rects.reference;
5495 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
5496 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
5497 x: 1,
5498 y: 1
5499 } : {
5500 x: 1,
5501 y: 1
5502 };
5503 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
5504 elements,
5505 rect,
5506 offsetParent,
5507 strategy
5508 }) : rect);
5509 return {
5510 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
5511 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
5512 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
5513 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
5514 };
5515 }
5516 var MAX_RESET_COUNT = 50;
5517 var computePosition = async (reference, floating, config) => {
5518 const {
5519 placement = "bottom",
5520 strategy = "absolute",
5521 middleware = [],
5522 platform: platform3
5523 } = config;
5524 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
5525 ...platform3,
5526 detectOverflow
5527 };
5528 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
5529 let rects = await platform3.getElementRects({
5530 reference,
5531 floating,
5532 strategy
5533 });
5534 let {
5535 x: x2,
5536 y: y2
5537 } = computeCoordsFromPlacement(rects, placement, rtl);
5538 let statefulPlacement = placement;
5539 let resetCount = 0;
5540 const middlewareData = {};
5541 for (let i2 = 0; i2 < middleware.length; i2++) {
5542 const currentMiddleware = middleware[i2];
5543 if (!currentMiddleware) {
5544 continue;
5545 }
5546 const {
5547 name,
5548 fn
5549 } = currentMiddleware;
5550 const {
5551 x: nextX,
5552 y: nextY,
5553 data,
5554 reset
5555 } = await fn({
5556 x: x2,
5557 y: y2,
5558 initialPlacement: placement,
5559 placement: statefulPlacement,
5560 strategy,
5561 middlewareData,
5562 rects,
5563 platform: platformWithDetectOverflow,
5564 elements: {
5565 reference,
5566 floating
5567 }
5568 });
5569 x2 = nextX != null ? nextX : x2;
5570 y2 = nextY != null ? nextY : y2;
5571 middlewareData[name] = {
5572 ...middlewareData[name],
5573 ...data
5574 };
5575 if (reset && resetCount < MAX_RESET_COUNT) {
5576 resetCount++;
5577 if (typeof reset === "object") {
5578 if (reset.placement) {
5579 statefulPlacement = reset.placement;
5580 }
5581 if (reset.rects) {
5582 rects = reset.rects === true ? await platform3.getElementRects({
5583 reference,
5584 floating,
5585 strategy
5586 }) : reset.rects;
5587 }
5588 ({
5589 x: x2,
5590 y: y2
5591 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
5592 }
5593 i2 = -1;
5594 }
5595 }
5596 return {
5597 x: x2,
5598 y: y2,
5599 placement: statefulPlacement,
5600 strategy,
5601 middlewareData
5602 };
5603 };
5604 var flip = function(options) {
5605 if (options === void 0) {
5606 options = {};
5607 }
5608 return {
5609 name: "flip",
5610 options,
5611 async fn(state) {
5612 var _middlewareData$arrow, _middlewareData$flip;
5613 const {
5614 placement,
5615 middlewareData,
5616 rects,
5617 initialPlacement,
5618 platform: platform3,
5619 elements
5620 } = state;
5621 const {
5622 mainAxis: checkMainAxis = true,
5623 crossAxis: checkCrossAxis = true,
5624 fallbackPlacements: specifiedFallbackPlacements,
5625 fallbackStrategy = "bestFit",
5626 fallbackAxisSideDirection = "none",
5627 flipAlignment = true,
5628 ...detectOverflowOptions
5629 } = evaluate(options, state);
5630 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
5631 return {};
5632 }
5633 const side = getSide(placement);
5634 const initialSideAxis = getSideAxis(initialPlacement);
5635 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
5636 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
5637 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
5638 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
5639 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
5640 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
5641 }
5642 const placements2 = [initialPlacement, ...fallbackPlacements];
5643 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5644 const overflows = [];
5645 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
5646 if (checkMainAxis) {
5647 overflows.push(overflow[side]);
5648 }
5649 if (checkCrossAxis) {
5650 const sides2 = getAlignmentSides(placement, rects, rtl);
5651 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
5652 }
5653 overflowsData = [...overflowsData, {
5654 placement,
5655 overflows
5656 }];
5657 if (!overflows.every((side2) => side2 <= 0)) {
5658 var _middlewareData$flip2, _overflowsData$filter;
5659 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
5660 const nextPlacement = placements2[nextIndex];
5661 if (nextPlacement) {
5662 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
5663 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
5664 // overflows the main axis.
5665 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
5666 return {
5667 data: {
5668 index: nextIndex,
5669 overflows: overflowsData
5670 },
5671 reset: {
5672 placement: nextPlacement
5673 }
5674 };
5675 }
5676 }
5677 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;
5678 if (!resetPlacement) {
5679 switch (fallbackStrategy) {
5680 case "bestFit": {
5681 var _overflowsData$filter2;
5682 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
5683 if (hasFallbackAxisSideDirection) {
5684 const currentSideAxis = getSideAxis(d2.placement);
5685 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
5686 // reading directions favoring greater width.
5687 currentSideAxis === "y";
5688 }
5689 return true;
5690 }).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];
5691 if (placement2) {
5692 resetPlacement = placement2;
5693 }
5694 break;
5695 }
5696 case "initialPlacement":
5697 resetPlacement = initialPlacement;
5698 break;
5699 }
5700 }
5701 if (placement !== resetPlacement) {
5702 return {
5703 reset: {
5704 placement: resetPlacement
5705 }
5706 };
5707 }
5708 }
5709 return {};
5710 }
5711 };
5712 };
5713 function getSideOffsets(overflow, rect) {
5714 return {
5715 top: overflow.top - rect.height,
5716 right: overflow.right - rect.width,
5717 bottom: overflow.bottom - rect.height,
5718 left: overflow.left - rect.width
5719 };
5720 }
5721 function isAnySideFullyClipped(overflow) {
5722 return sides.some((side) => overflow[side] >= 0);
5723 }
5724 var hide = function(options) {
5725 if (options === void 0) {
5726 options = {};
5727 }
5728 return {
5729 name: "hide",
5730 options,
5731 async fn(state) {
5732 const {
5733 rects,
5734 platform: platform3
5735 } = state;
5736 const {
5737 strategy = "referenceHidden",
5738 ...detectOverflowOptions
5739 } = evaluate(options, state);
5740 switch (strategy) {
5741 case "referenceHidden": {
5742 const overflow = await platform3.detectOverflow(state, {
5743 ...detectOverflowOptions,
5744 elementContext: "reference"
5745 });
5746 const offsets = getSideOffsets(overflow, rects.reference);
5747 return {
5748 data: {
5749 referenceHiddenOffsets: offsets,
5750 referenceHidden: isAnySideFullyClipped(offsets)
5751 }
5752 };
5753 }
5754 case "escaped": {
5755 const overflow = await platform3.detectOverflow(state, {
5756 ...detectOverflowOptions,
5757 altBoundary: true
5758 });
5759 const offsets = getSideOffsets(overflow, rects.floating);
5760 return {
5761 data: {
5762 escapedOffsets: offsets,
5763 escaped: isAnySideFullyClipped(offsets)
5764 }
5765 };
5766 }
5767 default: {
5768 return {};
5769 }
5770 }
5771 }
5772 };
5773 };
5774 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
5775 async function convertValueToCoords(state, options) {
5776 const {
5777 placement,
5778 platform: platform3,
5779 elements
5780 } = state;
5781 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
5782 const side = getSide(placement);
5783 const alignment = getAlignment(placement);
5784 const isVertical = getSideAxis(placement) === "y";
5785 const mainAxisMulti = originSides.has(side) ? -1 : 1;
5786 const crossAxisMulti = rtl && isVertical ? -1 : 1;
5787 const rawValue = evaluate(options, state);
5788 let {
5789 mainAxis,
5790 crossAxis,
5791 alignmentAxis
5792 } = typeof rawValue === "number" ? {
5793 mainAxis: rawValue,
5794 crossAxis: 0,
5795 alignmentAxis: null
5796 } : {
5797 mainAxis: rawValue.mainAxis || 0,
5798 crossAxis: rawValue.crossAxis || 0,
5799 alignmentAxis: rawValue.alignmentAxis
5800 };
5801 if (alignment && typeof alignmentAxis === "number") {
5802 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
5803 }
5804 return isVertical ? {
5805 x: crossAxis * crossAxisMulti,
5806 y: mainAxis * mainAxisMulti
5807 } : {
5808 x: mainAxis * mainAxisMulti,
5809 y: crossAxis * crossAxisMulti
5810 };
5811 }
5812 var offset = function(options) {
5813 if (options === void 0) {
5814 options = 0;
5815 }
5816 return {
5817 name: "offset",
5818 options,
5819 async fn(state) {
5820 var _middlewareData$offse, _middlewareData$arrow;
5821 const {
5822 x: x2,
5823 y: y2,
5824 placement,
5825 middlewareData
5826 } = state;
5827 const diffCoords = await convertValueToCoords(state, options);
5828 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
5829 return {};
5830 }
5831 return {
5832 x: x2 + diffCoords.x,
5833 y: y2 + diffCoords.y,
5834 data: {
5835 ...diffCoords,
5836 placement
5837 }
5838 };
5839 }
5840 };
5841 };
5842 var shift = function(options) {
5843 if (options === void 0) {
5844 options = {};
5845 }
5846 return {
5847 name: "shift",
5848 options,
5849 async fn(state) {
5850 const {
5851 x: x2,
5852 y: y2,
5853 placement,
5854 platform: platform3
5855 } = state;
5856 const {
5857 mainAxis: checkMainAxis = true,
5858 crossAxis: checkCrossAxis = false,
5859 limiter = {
5860 fn: (_ref) => {
5861 let {
5862 x: x3,
5863 y: y3
5864 } = _ref;
5865 return {
5866 x: x3,
5867 y: y3
5868 };
5869 }
5870 },
5871 ...detectOverflowOptions
5872 } = evaluate(options, state);
5873 const coords = {
5874 x: x2,
5875 y: y2
5876 };
5877 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5878 const crossAxis = getSideAxis(getSide(placement));
5879 const mainAxis = getOppositeAxis(crossAxis);
5880 let mainAxisCoord = coords[mainAxis];
5881 let crossAxisCoord = coords[crossAxis];
5882 if (checkMainAxis) {
5883 const minSide = mainAxis === "y" ? "top" : "left";
5884 const maxSide = mainAxis === "y" ? "bottom" : "right";
5885 const min2 = mainAxisCoord + overflow[minSide];
5886 const max2 = mainAxisCoord - overflow[maxSide];
5887 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
5888 }
5889 if (checkCrossAxis) {
5890 const minSide = crossAxis === "y" ? "top" : "left";
5891 const maxSide = crossAxis === "y" ? "bottom" : "right";
5892 const min2 = crossAxisCoord + overflow[minSide];
5893 const max2 = crossAxisCoord - overflow[maxSide];
5894 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
5895 }
5896 const limitedCoords = limiter.fn({
5897 ...state,
5898 [mainAxis]: mainAxisCoord,
5899 [crossAxis]: crossAxisCoord
5900 });
5901 return {
5902 ...limitedCoords,
5903 data: {
5904 x: limitedCoords.x - x2,
5905 y: limitedCoords.y - y2,
5906 enabled: {
5907 [mainAxis]: checkMainAxis,
5908 [crossAxis]: checkCrossAxis
5909 }
5910 }
5911 };
5912 }
5913 };
5914 };
5915 var limitShift = function(options) {
5916 if (options === void 0) {
5917 options = {};
5918 }
5919 return {
5920 options,
5921 fn(state) {
5922 const {
5923 x: x2,
5924 y: y2,
5925 placement,
5926 rects,
5927 middlewareData
5928 } = state;
5929 const {
5930 offset: offset4 = 0,
5931 mainAxis: checkMainAxis = true,
5932 crossAxis: checkCrossAxis = true
5933 } = evaluate(options, state);
5934 const coords = {
5935 x: x2,
5936 y: y2
5937 };
5938 const crossAxis = getSideAxis(placement);
5939 const mainAxis = getOppositeAxis(crossAxis);
5940 let mainAxisCoord = coords[mainAxis];
5941 let crossAxisCoord = coords[crossAxis];
5942 const rawOffset = evaluate(offset4, state);
5943 const computedOffset = typeof rawOffset === "number" ? {
5944 mainAxis: rawOffset,
5945 crossAxis: 0
5946 } : {
5947 mainAxis: 0,
5948 crossAxis: 0,
5949 ...rawOffset
5950 };
5951 if (checkMainAxis) {
5952 const len = mainAxis === "y" ? "height" : "width";
5953 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
5954 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
5955 if (mainAxisCoord < limitMin) {
5956 mainAxisCoord = limitMin;
5957 } else if (mainAxisCoord > limitMax) {
5958 mainAxisCoord = limitMax;
5959 }
5960 }
5961 if (checkCrossAxis) {
5962 var _middlewareData$offse, _middlewareData$offse2;
5963 const len = mainAxis === "y" ? "width" : "height";
5964 const isOriginSide = originSides.has(getSide(placement));
5965 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);
5966 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);
5967 if (crossAxisCoord < limitMin) {
5968 crossAxisCoord = limitMin;
5969 } else if (crossAxisCoord > limitMax) {
5970 crossAxisCoord = limitMax;
5971 }
5972 }
5973 return {
5974 [mainAxis]: mainAxisCoord,
5975 [crossAxis]: crossAxisCoord
5976 };
5977 }
5978 };
5979 };
5980 var size = function(options) {
5981 if (options === void 0) {
5982 options = {};
5983 }
5984 return {
5985 name: "size",
5986 options,
5987 async fn(state) {
5988 var _state$middlewareData, _state$middlewareData2;
5989 const {
5990 placement,
5991 rects,
5992 platform: platform3,
5993 elements
5994 } = state;
5995 const {
5996 apply = () => {
5997 },
5998 ...detectOverflowOptions
5999 } = evaluate(options, state);
6000 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
6001 const side = getSide(placement);
6002 const alignment = getAlignment(placement);
6003 const isYAxis = getSideAxis(placement) === "y";
6004 const {
6005 width,
6006 height
6007 } = rects.floating;
6008 let heightSide;
6009 let widthSide;
6010 if (side === "top" || side === "bottom") {
6011 heightSide = side;
6012 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
6013 } else {
6014 widthSide = side;
6015 heightSide = alignment === "end" ? "top" : "bottom";
6016 }
6017 const maximumClippingHeight = height - overflow.top - overflow.bottom;
6018 const maximumClippingWidth = width - overflow.left - overflow.right;
6019 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
6020 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
6021 const noShift = !state.middlewareData.shift;
6022 let availableHeight = overflowAvailableHeight;
6023 let availableWidth = overflowAvailableWidth;
6024 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
6025 availableWidth = maximumClippingWidth;
6026 }
6027 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
6028 availableHeight = maximumClippingHeight;
6029 }
6030 if (noShift && !alignment) {
6031 const xMin = max(overflow.left, 0);
6032 const xMax = max(overflow.right, 0);
6033 const yMin = max(overflow.top, 0);
6034 const yMax = max(overflow.bottom, 0);
6035 if (isYAxis) {
6036 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
6037 } else {
6038 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
6039 }
6040 }
6041 await apply({
6042 ...state,
6043 availableWidth,
6044 availableHeight
6045 });
6046 const nextDimensions = await platform3.getDimensions(elements.floating);
6047 if (width !== nextDimensions.width || height !== nextDimensions.height) {
6048 return {
6049 reset: {
6050 rects: true
6051 }
6052 };
6053 }
6054 return {};
6055 }
6056 };
6057 };
6058
6059 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
6060 function getCssDimensions(element) {
6061 const css = getComputedStyle2(element);
6062 let width = parseFloat(css.width) || 0;
6063 let height = parseFloat(css.height) || 0;
6064 const hasOffset = isHTMLElement(element);
6065 const offsetWidth = hasOffset ? element.offsetWidth : width;
6066 const offsetHeight = hasOffset ? element.offsetHeight : height;
6067 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
6068 if (shouldFallback) {
6069 width = offsetWidth;
6070 height = offsetHeight;
6071 }
6072 return {
6073 width,
6074 height,
6075 $: shouldFallback
6076 };
6077 }
6078 function unwrapElement(element) {
6079 return !isElement(element) ? element.contextElement : element;
6080 }
6081 function getScale(element) {
6082 const domElement = unwrapElement(element);
6083 if (!isHTMLElement(domElement)) {
6084 return createCoords(1);
6085 }
6086 const rect = domElement.getBoundingClientRect();
6087 const {
6088 width,
6089 height,
6090 $: $2
6091 } = getCssDimensions(domElement);
6092 let x2 = ($2 ? round(rect.width) : rect.width) / width;
6093 let y2 = ($2 ? round(rect.height) : rect.height) / height;
6094 if (!x2 || !Number.isFinite(x2)) {
6095 x2 = 1;
6096 }
6097 if (!y2 || !Number.isFinite(y2)) {
6098 y2 = 1;
6099 }
6100 return {
6101 x: x2,
6102 y: y2
6103 };
6104 }
6105 var noOffsets = /* @__PURE__ */ createCoords(0);
6106 function getVisualOffsets(element) {
6107 const win = getWindow(element);
6108 if (!isWebKit() || !win.visualViewport) {
6109 return noOffsets;
6110 }
6111 return {
6112 x: win.visualViewport.offsetLeft,
6113 y: win.visualViewport.offsetTop
6114 };
6115 }
6116 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
6117 if (isFixed === void 0) {
6118 isFixed = false;
6119 }
6120 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
6121 return false;
6122 }
6123 return isFixed;
6124 }
6125 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
6126 if (includeScale === void 0) {
6127 includeScale = false;
6128 }
6129 if (isFixedStrategy === void 0) {
6130 isFixedStrategy = false;
6131 }
6132 const clientRect = element.getBoundingClientRect();
6133 const domElement = unwrapElement(element);
6134 let scale = createCoords(1);
6135 if (includeScale) {
6136 if (offsetParent) {
6137 if (isElement(offsetParent)) {
6138 scale = getScale(offsetParent);
6139 }
6140 } else {
6141 scale = getScale(element);
6142 }
6143 }
6144 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
6145 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
6146 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
6147 let width = clientRect.width / scale.x;
6148 let height = clientRect.height / scale.y;
6149 if (domElement) {
6150 const win = getWindow(domElement);
6151 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
6152 let currentWin = win;
6153 let currentIFrame = getFrameElement(currentWin);
6154 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
6155 const iframeScale = getScale(currentIFrame);
6156 const iframeRect = currentIFrame.getBoundingClientRect();
6157 const css = getComputedStyle2(currentIFrame);
6158 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
6159 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
6160 x2 *= iframeScale.x;
6161 y2 *= iframeScale.y;
6162 width *= iframeScale.x;
6163 height *= iframeScale.y;
6164 x2 += left;
6165 y2 += top;
6166 currentWin = getWindow(currentIFrame);
6167 currentIFrame = getFrameElement(currentWin);
6168 }
6169 }
6170 return rectToClientRect({
6171 width,
6172 height,
6173 x: x2,
6174 y: y2
6175 });
6176 }
6177 function getWindowScrollBarX(element, rect) {
6178 const leftScroll = getNodeScroll(element).scrollLeft;
6179 if (!rect) {
6180 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
6181 }
6182 return rect.left + leftScroll;
6183 }
6184 function getHTMLOffset(documentElement, scroll) {
6185 const htmlRect = documentElement.getBoundingClientRect();
6186 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
6187 const y2 = htmlRect.top + scroll.scrollTop;
6188 return {
6189 x: x2,
6190 y: y2
6191 };
6192 }
6193 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
6194 let {
6195 elements,
6196 rect,
6197 offsetParent,
6198 strategy
6199 } = _ref;
6200 const isFixed = strategy === "fixed";
6201 const documentElement = getDocumentElement(offsetParent);
6202 const topLayer = elements ? isTopLayer(elements.floating) : false;
6203 if (offsetParent === documentElement || topLayer && isFixed) {
6204 return rect;
6205 }
6206 let scroll = {
6207 scrollLeft: 0,
6208 scrollTop: 0
6209 };
6210 let scale = createCoords(1);
6211 const offsets = createCoords(0);
6212 const isOffsetParentAnElement = isHTMLElement(offsetParent);
6213 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
6214 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
6215 scroll = getNodeScroll(offsetParent);
6216 }
6217 if (isOffsetParentAnElement) {
6218 const offsetRect = getBoundingClientRect(offsetParent);
6219 scale = getScale(offsetParent);
6220 offsets.x = offsetRect.x + offsetParent.clientLeft;
6221 offsets.y = offsetRect.y + offsetParent.clientTop;
6222 }
6223 }
6224 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
6225 return {
6226 width: rect.width * scale.x,
6227 height: rect.height * scale.y,
6228 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
6229 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
6230 };
6231 }
6232 function getClientRects(element) {
6233 return Array.from(element.getClientRects());
6234 }
6235 function getDocumentRect(element) {
6236 const html = getDocumentElement(element);
6237 const scroll = getNodeScroll(element);
6238 const body = element.ownerDocument.body;
6239 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
6240 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
6241 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
6242 const y2 = -scroll.scrollTop;
6243 if (getComputedStyle2(body).direction === "rtl") {
6244 x2 += max(html.clientWidth, body.clientWidth) - width;
6245 }
6246 return {
6247 width,
6248 height,
6249 x: x2,
6250 y: y2
6251 };
6252 }
6253 var SCROLLBAR_MAX = 25;
6254 function getViewportRect(element, strategy) {
6255 const win = getWindow(element);
6256 const html = getDocumentElement(element);
6257 const visualViewport = win.visualViewport;
6258 let width = html.clientWidth;
6259 let height = html.clientHeight;
6260 let x2 = 0;
6261 let y2 = 0;
6262 if (visualViewport) {
6263 width = visualViewport.width;
6264 height = visualViewport.height;
6265 const visualViewportBased = isWebKit();
6266 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
6267 x2 = visualViewport.offsetLeft;
6268 y2 = visualViewport.offsetTop;
6269 }
6270 }
6271 const windowScrollbarX = getWindowScrollBarX(html);
6272 if (windowScrollbarX <= 0) {
6273 const doc = html.ownerDocument;
6274 const body = doc.body;
6275 const bodyStyles = getComputedStyle(body);
6276 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
6277 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
6278 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
6279 width -= clippingStableScrollbarWidth;
6280 }
6281 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
6282 width += windowScrollbarX;
6283 }
6284 return {
6285 width,
6286 height,
6287 x: x2,
6288 y: y2
6289 };
6290 }
6291 function getInnerBoundingClientRect(element, strategy) {
6292 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
6293 const top = clientRect.top + element.clientTop;
6294 const left = clientRect.left + element.clientLeft;
6295 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
6296 const width = element.clientWidth * scale.x;
6297 const height = element.clientHeight * scale.y;
6298 const x2 = left * scale.x;
6299 const y2 = top * scale.y;
6300 return {
6301 width,
6302 height,
6303 x: x2,
6304 y: y2
6305 };
6306 }
6307 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
6308 let rect;
6309 if (clippingAncestor === "viewport") {
6310 rect = getViewportRect(element, strategy);
6311 } else if (clippingAncestor === "document") {
6312 rect = getDocumentRect(getDocumentElement(element));
6313 } else if (isElement(clippingAncestor)) {
6314 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
6315 } else {
6316 const visualOffsets = getVisualOffsets(element);
6317 rect = {
6318 x: clippingAncestor.x - visualOffsets.x,
6319 y: clippingAncestor.y - visualOffsets.y,
6320 width: clippingAncestor.width,
6321 height: clippingAncestor.height
6322 };
6323 }
6324 return rectToClientRect(rect);
6325 }
6326 function hasFixedPositionAncestor(element, stopNode) {
6327 const parentNode = getParentNode(element);
6328 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
6329 return false;
6330 }
6331 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
6332 }
6333 function getClippingElementAncestors(element, cache) {
6334 const cachedResult = cache.get(element);
6335 if (cachedResult) {
6336 return cachedResult;
6337 }
6338 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
6339 let currentContainingBlockComputedStyle = null;
6340 const elementIsFixed = getComputedStyle2(element).position === "fixed";
6341 let currentNode = elementIsFixed ? getParentNode(element) : element;
6342 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
6343 const computedStyle = getComputedStyle2(currentNode);
6344 const currentNodeIsContaining = isContainingBlock(currentNode);
6345 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
6346 currentContainingBlockComputedStyle = null;
6347 }
6348 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
6349 if (shouldDropCurrentNode) {
6350 result = result.filter((ancestor) => ancestor !== currentNode);
6351 } else {
6352 currentContainingBlockComputedStyle = computedStyle;
6353 }
6354 currentNode = getParentNode(currentNode);
6355 }
6356 cache.set(element, result);
6357 return result;
6358 }
6359 function getClippingRect(_ref) {
6360 let {
6361 element,
6362 boundary,
6363 rootBoundary,
6364 strategy
6365 } = _ref;
6366 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
6367 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
6368 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
6369 let top = firstRect.top;
6370 let right = firstRect.right;
6371 let bottom = firstRect.bottom;
6372 let left = firstRect.left;
6373 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
6374 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
6375 top = max(rect.top, top);
6376 right = min(rect.right, right);
6377 bottom = min(rect.bottom, bottom);
6378 left = max(rect.left, left);
6379 }
6380 return {
6381 width: right - left,
6382 height: bottom - top,
6383 x: left,
6384 y: top
6385 };
6386 }
6387 function getDimensions2(element) {
6388 const {
6389 width,
6390 height
6391 } = getCssDimensions(element);
6392 return {
6393 width,
6394 height
6395 };
6396 }
6397 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
6398 const isOffsetParentAnElement = isHTMLElement(offsetParent);
6399 const documentElement = getDocumentElement(offsetParent);
6400 const isFixed = strategy === "fixed";
6401 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
6402 let scroll = {
6403 scrollLeft: 0,
6404 scrollTop: 0
6405 };
6406 const offsets = createCoords(0);
6407 function setLeftRTLScrollbarOffset() {
6408 offsets.x = getWindowScrollBarX(documentElement);
6409 }
6410 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
6411 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
6412 scroll = getNodeScroll(offsetParent);
6413 }
6414 if (isOffsetParentAnElement) {
6415 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
6416 offsets.x = offsetRect.x + offsetParent.clientLeft;
6417 offsets.y = offsetRect.y + offsetParent.clientTop;
6418 } else if (documentElement) {
6419 setLeftRTLScrollbarOffset();
6420 }
6421 }
6422 if (isFixed && !isOffsetParentAnElement && documentElement) {
6423 setLeftRTLScrollbarOffset();
6424 }
6425 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
6426 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
6427 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
6428 return {
6429 x: x2,
6430 y: y2,
6431 width: rect.width,
6432 height: rect.height
6433 };
6434 }
6435 function isStaticPositioned(element) {
6436 return getComputedStyle2(element).position === "static";
6437 }
6438 function getTrueOffsetParent(element, polyfill) {
6439 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
6440 return null;
6441 }
6442 if (polyfill) {
6443 return polyfill(element);
6444 }
6445 let rawOffsetParent = element.offsetParent;
6446 if (getDocumentElement(element) === rawOffsetParent) {
6447 rawOffsetParent = rawOffsetParent.ownerDocument.body;
6448 }
6449 return rawOffsetParent;
6450 }
6451 function getOffsetParent(element, polyfill) {
6452 const win = getWindow(element);
6453 if (isTopLayer(element)) {
6454 return win;
6455 }
6456 if (!isHTMLElement(element)) {
6457 let svgOffsetParent = getParentNode(element);
6458 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
6459 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
6460 return svgOffsetParent;
6461 }
6462 svgOffsetParent = getParentNode(svgOffsetParent);
6463 }
6464 return win;
6465 }
6466 let offsetParent = getTrueOffsetParent(element, polyfill);
6467 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
6468 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
6469 }
6470 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
6471 return win;
6472 }
6473 return offsetParent || getContainingBlock(element) || win;
6474 }
6475 var getElementRects = async function(data) {
6476 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
6477 const getDimensionsFn = this.getDimensions;
6478 const floatingDimensions = await getDimensionsFn(data.floating);
6479 return {
6480 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
6481 floating: {
6482 x: 0,
6483 y: 0,
6484 width: floatingDimensions.width,
6485 height: floatingDimensions.height
6486 }
6487 };
6488 };
6489 function isRTL(element) {
6490 return getComputedStyle2(element).direction === "rtl";
6491 }
6492 var platform2 = {
6493 convertOffsetParentRelativeRectToViewportRelativeRect,
6494 getDocumentElement,
6495 getClippingRect,
6496 getOffsetParent,
6497 getElementRects,
6498 getClientRects,
6499 getDimensions: getDimensions2,
6500 getScale,
6501 isElement,
6502 isRTL
6503 };
6504 function rectsAreEqual(a2, b2) {
6505 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
6506 }
6507 function observeMove(element, onMove) {
6508 let io = null;
6509 let timeoutId;
6510 const root = getDocumentElement(element);
6511 function cleanup() {
6512 var _io;
6513 clearTimeout(timeoutId);
6514 (_io = io) == null || _io.disconnect();
6515 io = null;
6516 }
6517 function refresh(skip, threshold) {
6518 if (skip === void 0) {
6519 skip = false;
6520 }
6521 if (threshold === void 0) {
6522 threshold = 1;
6523 }
6524 cleanup();
6525 const elementRectForRootMargin = element.getBoundingClientRect();
6526 const {
6527 left,
6528 top,
6529 width,
6530 height
6531 } = elementRectForRootMargin;
6532 if (!skip) {
6533 onMove();
6534 }
6535 if (!width || !height) {
6536 return;
6537 }
6538 const insetTop = floor(top);
6539 const insetRight = floor(root.clientWidth - (left + width));
6540 const insetBottom = floor(root.clientHeight - (top + height));
6541 const insetLeft = floor(left);
6542 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
6543 const options = {
6544 rootMargin,
6545 threshold: max(0, min(1, threshold)) || 1
6546 };
6547 let isFirstUpdate = true;
6548 function handleObserve(entries) {
6549 const ratio = entries[0].intersectionRatio;
6550 if (ratio !== threshold) {
6551 if (!isFirstUpdate) {
6552 return refresh();
6553 }
6554 if (!ratio) {
6555 timeoutId = setTimeout(() => {
6556 refresh(false, 1e-7);
6557 }, 1e3);
6558 } else {
6559 refresh(false, ratio);
6560 }
6561 }
6562 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
6563 refresh();
6564 }
6565 isFirstUpdate = false;
6566 }
6567 try {
6568 io = new IntersectionObserver(handleObserve, {
6569 ...options,
6570 // Handle <iframe>s
6571 root: root.ownerDocument
6572 });
6573 } catch (_e) {
6574 io = new IntersectionObserver(handleObserve, options);
6575 }
6576 io.observe(element);
6577 }
6578 refresh(true);
6579 return cleanup;
6580 }
6581 function autoUpdate(reference, floating, update2, options) {
6582 if (options === void 0) {
6583 options = {};
6584 }
6585 const {
6586 ancestorScroll = true,
6587 ancestorResize = true,
6588 elementResize = typeof ResizeObserver === "function",
6589 layoutShift = typeof IntersectionObserver === "function",
6590 animationFrame = false
6591 } = options;
6592 const referenceEl = unwrapElement(reference);
6593 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
6594 ancestors.forEach((ancestor) => {
6595 ancestorScroll && ancestor.addEventListener("scroll", update2, {
6596 passive: true
6597 });
6598 ancestorResize && ancestor.addEventListener("resize", update2);
6599 });
6600 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
6601 let reobserveFrame = -1;
6602 let resizeObserver = null;
6603 if (elementResize) {
6604 resizeObserver = new ResizeObserver((_ref) => {
6605 let [firstEntry] = _ref;
6606 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
6607 resizeObserver.unobserve(floating);
6608 cancelAnimationFrame(reobserveFrame);
6609 reobserveFrame = requestAnimationFrame(() => {
6610 var _resizeObserver;
6611 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
6612 });
6613 }
6614 update2();
6615 });
6616 if (referenceEl && !animationFrame) {
6617 resizeObserver.observe(referenceEl);
6618 }
6619 if (floating) {
6620 resizeObserver.observe(floating);
6621 }
6622 }
6623 let frameId;
6624 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
6625 if (animationFrame) {
6626 frameLoop();
6627 }
6628 function frameLoop() {
6629 const nextRefRect = getBoundingClientRect(reference);
6630 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
6631 update2();
6632 }
6633 prevRefRect = nextRefRect;
6634 frameId = requestAnimationFrame(frameLoop);
6635 }
6636 update2();
6637 return () => {
6638 var _resizeObserver2;
6639 ancestors.forEach((ancestor) => {
6640 ancestorScroll && ancestor.removeEventListener("scroll", update2);
6641 ancestorResize && ancestor.removeEventListener("resize", update2);
6642 });
6643 cleanupIo == null || cleanupIo();
6644 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
6645 resizeObserver = null;
6646 if (animationFrame) {
6647 cancelAnimationFrame(frameId);
6648 }
6649 };
6650 }
6651 var offset2 = offset;
6652 var shift2 = shift;
6653 var flip2 = flip;
6654 var size2 = size;
6655 var hide2 = hide;
6656 var limitShift2 = limitShift;
6657 var computePosition2 = (reference, floating, options) => {
6658 const cache = /* @__PURE__ */ new Map();
6659 const mergedOptions = {
6660 platform: platform2,
6661 ...options
6662 };
6663 const platformWithCache = {
6664 ...mergedOptions.platform,
6665 _c: cache
6666 };
6667 return computePosition(reference, floating, {
6668 ...mergedOptions,
6669 platform: platformWithCache
6670 });
6671 };
6672
6673 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
6674 var React28 = __toESM(require_react(), 1);
6675 var import_react2 = __toESM(require_react(), 1);
6676 var ReactDOM3 = __toESM(require_react_dom(), 1);
6677 var isClient = typeof document !== "undefined";
6678 var noop2 = function noop3() {
6679 };
6680 var index = isClient ? import_react2.useLayoutEffect : noop2;
6681 function deepEqual(a2, b2) {
6682 if (a2 === b2) {
6683 return true;
6684 }
6685 if (typeof a2 !== typeof b2) {
6686 return false;
6687 }
6688 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
6689 return true;
6690 }
6691 let length;
6692 let i2;
6693 let keys;
6694 if (a2 && b2 && typeof a2 === "object") {
6695 if (Array.isArray(a2)) {
6696 length = a2.length;
6697 if (length !== b2.length) return false;
6698 for (i2 = length; i2-- !== 0; ) {
6699 if (!deepEqual(a2[i2], b2[i2])) {
6700 return false;
6701 }
6702 }
6703 return true;
6704 }
6705 keys = Object.keys(a2);
6706 length = keys.length;
6707 if (length !== Object.keys(b2).length) {
6708 return false;
6709 }
6710 for (i2 = length; i2-- !== 0; ) {
6711 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
6712 return false;
6713 }
6714 }
6715 for (i2 = length; i2-- !== 0; ) {
6716 const key = keys[i2];
6717 if (key === "_owner" && a2.$$typeof) {
6718 continue;
6719 }
6720 if (!deepEqual(a2[key], b2[key])) {
6721 return false;
6722 }
6723 }
6724 return true;
6725 }
6726 return a2 !== a2 && b2 !== b2;
6727 }
6728 function getDPR(element) {
6729 if (typeof window === "undefined") {
6730 return 1;
6731 }
6732 const win = element.ownerDocument.defaultView || window;
6733 return win.devicePixelRatio || 1;
6734 }
6735 function roundByDPR(element, value) {
6736 const dpr = getDPR(element);
6737 return Math.round(value * dpr) / dpr;
6738 }
6739 function useLatestRef(value) {
6740 const ref = React28.useRef(value);
6741 index(() => {
6742 ref.current = value;
6743 });
6744 return ref;
6745 }
6746 function useFloating(options) {
6747 if (options === void 0) {
6748 options = {};
6749 }
6750 const {
6751 placement = "bottom",
6752 strategy = "absolute",
6753 middleware = [],
6754 platform: platform3,
6755 elements: {
6756 reference: externalReference,
6757 floating: externalFloating
6758 } = {},
6759 transform = true,
6760 whileElementsMounted,
6761 open
6762 } = options;
6763 const [data, setData] = React28.useState({
6764 x: 0,
6765 y: 0,
6766 strategy,
6767 placement,
6768 middlewareData: {},
6769 isPositioned: false
6770 });
6771 const [latestMiddleware, setLatestMiddleware] = React28.useState(middleware);
6772 if (!deepEqual(latestMiddleware, middleware)) {
6773 setLatestMiddleware(middleware);
6774 }
6775 const [_reference, _setReference] = React28.useState(null);
6776 const [_floating, _setFloating] = React28.useState(null);
6777 const setReference = React28.useCallback((node) => {
6778 if (node !== referenceRef.current) {
6779 referenceRef.current = node;
6780 _setReference(node);
6781 }
6782 }, []);
6783 const setFloating = React28.useCallback((node) => {
6784 if (node !== floatingRef.current) {
6785 floatingRef.current = node;
6786 _setFloating(node);
6787 }
6788 }, []);
6789 const referenceEl = externalReference || _reference;
6790 const floatingEl = externalFloating || _floating;
6791 const referenceRef = React28.useRef(null);
6792 const floatingRef = React28.useRef(null);
6793 const dataRef = React28.useRef(data);
6794 const hasWhileElementsMounted = whileElementsMounted != null;
6795 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
6796 const platformRef = useLatestRef(platform3);
6797 const openRef = useLatestRef(open);
6798 const update2 = React28.useCallback(() => {
6799 if (!referenceRef.current || !floatingRef.current) {
6800 return;
6801 }
6802 const config = {
6803 placement,
6804 strategy,
6805 middleware: latestMiddleware
6806 };
6807 if (platformRef.current) {
6808 config.platform = platformRef.current;
6809 }
6810 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
6811 const fullData = {
6812 ...data2,
6813 // The floating element's position may be recomputed while it's closed
6814 // but still mounted (such as when transitioning out). To ensure
6815 // `isPositioned` will be `false` initially on the next open, avoid
6816 // setting it to `true` when `open === false` (must be specified).
6817 isPositioned: openRef.current !== false
6818 };
6819 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
6820 dataRef.current = fullData;
6821 ReactDOM3.flushSync(() => {
6822 setData(fullData);
6823 });
6824 }
6825 });
6826 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
6827 index(() => {
6828 if (open === false && dataRef.current.isPositioned) {
6829 dataRef.current.isPositioned = false;
6830 setData((data2) => ({
6831 ...data2,
6832 isPositioned: false
6833 }));
6834 }
6835 }, [open]);
6836 const isMountedRef = React28.useRef(false);
6837 index(() => {
6838 isMountedRef.current = true;
6839 return () => {
6840 isMountedRef.current = false;
6841 };
6842 }, []);
6843 index(() => {
6844 if (referenceEl) referenceRef.current = referenceEl;
6845 if (floatingEl) floatingRef.current = floatingEl;
6846 if (referenceEl && floatingEl) {
6847 if (whileElementsMountedRef.current) {
6848 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
6849 }
6850 update2();
6851 }
6852 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
6853 const refs = React28.useMemo(() => ({
6854 reference: referenceRef,
6855 floating: floatingRef,
6856 setReference,
6857 setFloating
6858 }), [setReference, setFloating]);
6859 const elements = React28.useMemo(() => ({
6860 reference: referenceEl,
6861 floating: floatingEl
6862 }), [referenceEl, floatingEl]);
6863 const floatingStyles = React28.useMemo(() => {
6864 const initialStyles = {
6865 position: strategy,
6866 left: 0,
6867 top: 0
6868 };
6869 if (!elements.floating) {
6870 return initialStyles;
6871 }
6872 const x2 = roundByDPR(elements.floating, data.x);
6873 const y2 = roundByDPR(elements.floating, data.y);
6874 if (transform) {
6875 return {
6876 ...initialStyles,
6877 transform: "translate(" + x2 + "px, " + y2 + "px)",
6878 ...getDPR(elements.floating) >= 1.5 && {
6879 willChange: "transform"
6880 }
6881 };
6882 }
6883 return {
6884 position: strategy,
6885 left: x2,
6886 top: y2
6887 };
6888 }, [strategy, transform, elements.floating, data.x, data.y]);
6889 return React28.useMemo(() => ({
6890 ...data,
6891 update: update2,
6892 refs,
6893 elements,
6894 floatingStyles
6895 }), [data, update2, refs, elements, floatingStyles]);
6896 }
6897 var offset3 = (options, deps) => {
6898 const result = offset2(options);
6899 return {
6900 name: result.name,
6901 fn: result.fn,
6902 options: [options, deps]
6903 };
6904 };
6905 var shift3 = (options, deps) => {
6906 const result = shift2(options);
6907 return {
6908 name: result.name,
6909 fn: result.fn,
6910 options: [options, deps]
6911 };
6912 };
6913 var limitShift3 = (options, deps) => {
6914 const result = limitShift2(options);
6915 return {
6916 fn: result.fn,
6917 options: [options, deps]
6918 };
6919 };
6920 var flip3 = (options, deps) => {
6921 const result = flip2(options);
6922 return {
6923 name: result.name,
6924 fn: result.fn,
6925 options: [options, deps]
6926 };
6927 };
6928 var size3 = (options, deps) => {
6929 const result = size2(options);
6930 return {
6931 name: result.name,
6932 fn: result.fn,
6933 options: [options, deps]
6934 };
6935 };
6936 var hide3 = (options, deps) => {
6937 const result = hide2(options);
6938 return {
6939 name: result.name,
6940 fn: result.fn,
6941 options: [options, deps]
6942 };
6943 };
6944
6945 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
6946 var React33 = __toESM(require_react(), 1);
6947
6948 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
6949 var React32 = __toESM(require_react(), 1);
6950
6951 // node_modules/@base-ui/utils/esm/store/createSelector.js
6952 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
6953 if (other.length > 0) {
6954 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
6955 }
6956 let selector2;
6957 if (a2 && b2 && c2 && d2 && e2 && f2) {
6958 selector2 = (state, a1, a22, a3) => {
6959 const va = a2(state, a1, a22, a3);
6960 const vb = b2(state, a1, a22, a3);
6961 const vc = c2(state, a1, a22, a3);
6962 const vd = d2(state, a1, a22, a3);
6963 const ve = e2(state, a1, a22, a3);
6964 return f2(va, vb, vc, vd, ve, a1, a22, a3);
6965 };
6966 } else if (a2 && b2 && c2 && d2 && e2) {
6967 selector2 = (state, a1, a22, a3) => {
6968 const va = a2(state, a1, a22, a3);
6969 const vb = b2(state, a1, a22, a3);
6970 const vc = c2(state, a1, a22, a3);
6971 const vd = d2(state, a1, a22, a3);
6972 return e2(va, vb, vc, vd, a1, a22, a3);
6973 };
6974 } else if (a2 && b2 && c2 && d2) {
6975 selector2 = (state, a1, a22, a3) => {
6976 const va = a2(state, a1, a22, a3);
6977 const vb = b2(state, a1, a22, a3);
6978 const vc = c2(state, a1, a22, a3);
6979 return d2(va, vb, vc, a1, a22, a3);
6980 };
6981 } else if (a2 && b2 && c2) {
6982 selector2 = (state, a1, a22, a3) => {
6983 const va = a2(state, a1, a22, a3);
6984 const vb = b2(state, a1, a22, a3);
6985 return c2(va, vb, a1, a22, a3);
6986 };
6987 } else if (a2 && b2) {
6988 selector2 = (state, a1, a22, a3) => {
6989 const va = a2(state, a1, a22, a3);
6990 return b2(va, a1, a22, a3);
6991 };
6992 } else if (a2) {
6993 selector2 = a2;
6994 } else {
6995 throw (
6996 /* minify-error-disabled */
6997 new Error("Missing arguments")
6998 );
6999 }
7000 return selector2;
7001 };
7002
7003 // node_modules/@base-ui/utils/esm/store/useStore.js
7004 var React30 = __toESM(require_react(), 1);
7005 var import_shim = __toESM(require_shim(), 1);
7006 var import_with_selector = __toESM(require_with_selector(), 1);
7007
7008 // node_modules/@base-ui/utils/esm/fastHooks.js
7009 var React29 = __toESM(require_react(), 1);
7010 var hooks = [];
7011 var currentInstance = void 0;
7012 function getInstance() {
7013 return currentInstance;
7014 }
7015 function register(hook) {
7016 hooks.push(hook);
7017 }
7018 function fastComponent(fn) {
7019 const FastComponent = (props, forwardedRef) => {
7020 const instance = useRefWithInit(createInstance).current;
7021 let result;
7022 try {
7023 currentInstance = instance;
7024 for (const hook of hooks) {
7025 hook.before(instance);
7026 }
7027 result = fn(props, forwardedRef);
7028 for (const hook of hooks) {
7029 hook.after(instance);
7030 }
7031 instance.didInitialize = true;
7032 } finally {
7033 currentInstance = void 0;
7034 }
7035 return result;
7036 };
7037 FastComponent.displayName = fn.displayName || fn.name;
7038 return FastComponent;
7039 }
7040 function fastComponentRef(fn) {
7041 return /* @__PURE__ */ React29.forwardRef(fastComponent(fn));
7042 }
7043 function createInstance() {
7044 return {
7045 didInitialize: false
7046 };
7047 }
7048
7049 // node_modules/@base-ui/utils/esm/store/useStore.js
7050 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
7051 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
7052 function useStore(store, selector2, a1, a2, a3) {
7053 return useStoreImplementation(store, selector2, a1, a2, a3);
7054 }
7055 function useStoreR19(store, selector2, a1, a2, a3) {
7056 const getSelection = React30.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
7057 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
7058 }
7059 register({
7060 before(instance) {
7061 instance.syncIndex = 0;
7062 if (!instance.didInitialize) {
7063 instance.syncTick = 1;
7064 instance.syncHooks = [];
7065 instance.didChangeStore = true;
7066 instance.getSnapshot = () => {
7067 let didChange2 = false;
7068 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
7069 const hook = instance.syncHooks[i2];
7070 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
7071 if (hook.didChange || !Object.is(hook.value, value)) {
7072 didChange2 = true;
7073 hook.value = value;
7074 hook.didChange = false;
7075 }
7076 }
7077 if (didChange2) {
7078 instance.syncTick += 1;
7079 }
7080 return instance.syncTick;
7081 };
7082 }
7083 },
7084 after(instance) {
7085 if (instance.syncHooks.length > 0) {
7086 if (instance.didChangeStore) {
7087 instance.didChangeStore = false;
7088 instance.subscribe = (onStoreChange) => {
7089 const stores = /* @__PURE__ */ new Set();
7090 for (const hook of instance.syncHooks) {
7091 stores.add(hook.store);
7092 }
7093 const unsubscribes = [];
7094 for (const store of stores) {
7095 unsubscribes.push(store.subscribe(onStoreChange));
7096 }
7097 return () => {
7098 for (const unsubscribe of unsubscribes) {
7099 unsubscribe();
7100 }
7101 };
7102 };
7103 }
7104 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
7105 }
7106 }
7107 });
7108 function useStoreFast(store, selector2, a1, a2, a3) {
7109 const instance = getInstance();
7110 if (!instance) {
7111 return useStoreR19(store, selector2, a1, a2, a3);
7112 }
7113 const index2 = instance.syncIndex;
7114 instance.syncIndex += 1;
7115 let hook;
7116 if (!instance.didInitialize) {
7117 hook = {
7118 store,
7119 selector: selector2,
7120 a1,
7121 a2,
7122 a3,
7123 value: selector2(store.getSnapshot(), a1, a2, a3),
7124 didChange: false
7125 };
7126 instance.syncHooks.push(hook);
7127 } else {
7128 hook = instance.syncHooks[index2];
7129 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
7130 if (hook.store !== store) {
7131 instance.didChangeStore = true;
7132 }
7133 hook.store = store;
7134 hook.selector = selector2;
7135 hook.a1 = a1;
7136 hook.a2 = a2;
7137 hook.a3 = a3;
7138 hook.didChange = true;
7139 }
7140 }
7141 return hook.value;
7142 }
7143 function useStoreLegacy(store, selector2, a1, a2, a3) {
7144 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
7145 }
7146
7147 // node_modules/@base-ui/utils/esm/store/Store.js
7148 var Store = class {
7149 /**
7150 * The current state of the store.
7151 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
7152 * 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).
7153 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
7154 *
7155 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
7156 */
7157 // Internal state to handle recursive `setState()` calls
7158 constructor(state) {
7159 this.state = state;
7160 this.listeners = /* @__PURE__ */ new Set();
7161 this.updateTick = 0;
7162 }
7163 /**
7164 * Registers a listener that will be called whenever the store's state changes.
7165 *
7166 * @param fn The listener function to be called on state changes.
7167 * @returns A function to unsubscribe the listener.
7168 */
7169 subscribe = (fn) => {
7170 this.listeners.add(fn);
7171 return () => {
7172 this.listeners.delete(fn);
7173 };
7174 };
7175 /**
7176 * Returns the current state of the store.
7177 */
7178 getSnapshot = () => {
7179 return this.state;
7180 };
7181 /**
7182 * Updates the entire store's state and notifies all registered listeners.
7183 *
7184 * @param newState The new state to set for the store.
7185 */
7186 setState(newState) {
7187 if (this.state === newState) {
7188 return;
7189 }
7190 this.state = newState;
7191 this.updateTick += 1;
7192 const currentTick = this.updateTick;
7193 for (const listener of this.listeners) {
7194 if (currentTick !== this.updateTick) {
7195 return;
7196 }
7197 listener(newState);
7198 }
7199 }
7200 /**
7201 * Merges the provided changes into the current state and notifies listeners if there are changes.
7202 *
7203 * @param changes An object containing the changes to apply to the current state.
7204 */
7205 update(changes) {
7206 for (const key in changes) {
7207 if (!Object.is(this.state[key], changes[key])) {
7208 this.setState({
7209 ...this.state,
7210 ...changes
7211 });
7212 return;
7213 }
7214 }
7215 }
7216 /**
7217 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
7218 *
7219 * @param key The key in the store's state to update.
7220 * @param value The new value to set for the specified key.
7221 */
7222 set(key, value) {
7223 if (!Object.is(this.state[key], value)) {
7224 this.setState({
7225 ...this.state,
7226 [key]: value
7227 });
7228 }
7229 }
7230 /**
7231 * Gives the state a new reference and updates all registered listeners.
7232 */
7233 notifyAll() {
7234 const newState = {
7235 ...this.state
7236 };
7237 this.setState(newState);
7238 }
7239 use(selector2, a1, a2, a3) {
7240 return useStore(this, selector2, a1, a2, a3);
7241 }
7242 };
7243
7244 // node_modules/@base-ui/utils/esm/store/ReactStore.js
7245 var React31 = __toESM(require_react(), 1);
7246 var ReactStore = class extends Store {
7247 /**
7248 * Creates a new ReactStore instance.
7249 *
7250 * @param state Initial state of the store.
7251 * @param context Non-reactive context values.
7252 * @param selectors Optional selectors for use with `useState`.
7253 */
7254 constructor(state, context = {}, selectors4) {
7255 super(state);
7256 this.context = context;
7257 this.selectors = selectors4;
7258 }
7259 /**
7260 * Non-reactive values such as refs, callbacks, etc.
7261 */
7262 /**
7263 * Synchronizes a single external value into the store.
7264 *
7265 * Note that the while the value in `state` is updated immediately, the value returned
7266 * by `useState` is updated before the next render (similarly to React's `useState`).
7267 */
7268 useSyncedValue(key, value) {
7269 React31.useDebugValue(key);
7270 const store = this;
7271 useIsoLayoutEffect(() => {
7272 if (store.state[key] !== value) {
7273 store.set(key, value);
7274 }
7275 }, [store, key, value]);
7276 }
7277 /**
7278 * Synchronizes a single external value into the store and
7279 * cleans it up (sets to `undefined`) on unmount.
7280 *
7281 * Note that the while the value in `state` is updated immediately, the value returned
7282 * by `useState` is updated before the next render (similarly to React's `useState`).
7283 */
7284 useSyncedValueWithCleanup(key, value) {
7285 const store = this;
7286 useIsoLayoutEffect(() => {
7287 if (store.state[key] !== value) {
7288 store.set(key, value);
7289 }
7290 return () => {
7291 store.set(key, void 0);
7292 };
7293 }, [store, key, value]);
7294 }
7295 /**
7296 * Synchronizes multiple external values into the store.
7297 *
7298 * Note that the while the values in `state` are updated immediately, the values returned
7299 * by `useState` are updated before the next render (similarly to React's `useState`).
7300 */
7301 useSyncedValues(statePart) {
7302 const store = this;
7303 if (true) {
7304 React31.useDebugValue(statePart, (p2) => Object.keys(p2));
7305 const keys = React31.useRef(Object.keys(statePart)).current;
7306 const nextKeys = Object.keys(statePart);
7307 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
7308 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
7309 }
7310 }
7311 const dependencies = Object.values(statePart);
7312 useIsoLayoutEffect(() => {
7313 store.update(statePart);
7314 }, [store, ...dependencies]);
7315 }
7316 /**
7317 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
7318 * is non-undefined, the store's state at `key` is updated to match `controlled`.
7319 */
7320 useControlledProp(key, controlled) {
7321 React31.useDebugValue(key);
7322 const store = this;
7323 const isControlled = controlled !== void 0;
7324 useIsoLayoutEffect(() => {
7325 if (isControlled && !Object.is(store.state[key], controlled)) {
7326 store.setState({
7327 ...store.state,
7328 [key]: controlled
7329 });
7330 }
7331 }, [store, key, controlled, isControlled]);
7332 if (true) {
7333 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
7334 if (!cache.has(key)) {
7335 cache.set(key, isControlled);
7336 }
7337 const previouslyControlled = cache.get(key);
7338 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
7339 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).`);
7340 }
7341 }
7342 }
7343 /** Gets the current value from the store using a selector with the provided key.
7344 *
7345 * @param key Key of the selector to use.
7346 */
7347 select(key, a1, a2, a3) {
7348 const selector2 = this.selectors[key];
7349 return selector2(this.state, a1, a2, a3);
7350 }
7351 /**
7352 * Returns a value from the store's state using a selector function.
7353 * Used to subscribe to specific parts of the state.
7354 * This methods causes a rerender whenever the selected state changes.
7355 *
7356 * @param key Key of the selector to use.
7357 */
7358 useState(key, a1, a2, a3) {
7359 React31.useDebugValue(key);
7360 return useStore(this, this.selectors[key], a1, a2, a3);
7361 }
7362 /**
7363 * Wraps a function with `useStableCallback` to ensure it has a stable reference
7364 * and assigns it to the context.
7365 *
7366 * @param key Key of the event callback. Must be a function in the context.
7367 * @param fn Function to assign.
7368 */
7369 useContextCallback(key, fn) {
7370 React31.useDebugValue(key);
7371 const stableFunction = useStableCallback(fn ?? NOOP);
7372 this.context[key] = stableFunction;
7373 }
7374 /**
7375 * Returns a stable setter function for a specific key in the store's state.
7376 * It's commonly used to pass as a ref callback to React elements.
7377 *
7378 * @param key Key of the state to set.
7379 */
7380 useStateSetter(key) {
7381 const ref = React31.useRef(void 0);
7382 if (ref.current === void 0) {
7383 ref.current = (value) => {
7384 this.set(key, value);
7385 };
7386 }
7387 return ref.current;
7388 }
7389 /**
7390 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
7391 *
7392 * @param key Key of the selector to observe.
7393 * @param listener Listener function called when the selector result changes.
7394 */
7395 observe(selector2, listener) {
7396 let selectFn;
7397 if (typeof selector2 === "function") {
7398 selectFn = selector2;
7399 } else {
7400 selectFn = this.selectors[selector2];
7401 }
7402 let prevValue = selectFn(this.state);
7403 listener(prevValue, prevValue, this);
7404 return this.subscribe((nextState) => {
7405 const nextValue = selectFn(nextState);
7406 if (!Object.is(prevValue, nextValue)) {
7407 const oldValue = prevValue;
7408 prevValue = nextValue;
7409 listener(nextValue, oldValue, this);
7410 }
7411 });
7412 }
7413 };
7414
7415 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
7416 var selectors = {
7417 open: createSelector((state) => state.open),
7418 transitionStatus: createSelector((state) => state.transitionStatus),
7419 domReferenceElement: createSelector((state) => state.domReferenceElement),
7420 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
7421 floatingElement: createSelector((state) => state.floatingElement),
7422 floatingId: createSelector((state) => state.floatingId)
7423 };
7424 var FloatingRootStore = class extends ReactStore {
7425 constructor(options) {
7426 const {
7427 syncOnly,
7428 nested,
7429 onOpenChange,
7430 triggerElements,
7431 ...initialState
7432 } = options;
7433 super({
7434 ...initialState,
7435 positionReference: initialState.referenceElement,
7436 domReferenceElement: initialState.referenceElement
7437 }, {
7438 onOpenChange,
7439 dataRef: {
7440 current: {}
7441 },
7442 events: createEventEmitter(),
7443 nested,
7444 triggerElements
7445 }, selectors);
7446 this.syncOnly = syncOnly;
7447 }
7448 /**
7449 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
7450 */
7451 syncOpenEvent = (newOpen, event) => {
7452 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
7453 // click events to upgrade a hover-open.
7454 event != null && isClickLikeEvent(event)) {
7455 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
7456 }
7457 };
7458 /**
7459 * Runs the root-owned side effects for an open state change.
7460 */
7461 dispatchOpenChange = (newOpen, eventDetails) => {
7462 this.syncOpenEvent(newOpen, eventDetails.event);
7463 const details = {
7464 open: newOpen,
7465 reason: eventDetails.reason,
7466 nativeEvent: eventDetails.event,
7467 nested: this.context.nested,
7468 triggerElement: eventDetails.trigger
7469 };
7470 this.context.events.emit("openchange", details);
7471 };
7472 /**
7473 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
7474 *
7475 * @param newOpen The new open state.
7476 * @param eventDetails Details about the event that triggered the open state change.
7477 */
7478 setOpen = (newOpen, eventDetails) => {
7479 if (this.syncOnly) {
7480 this.context.onOpenChange?.(newOpen, eventDetails);
7481 return;
7482 }
7483 this.dispatchOpenChange(newOpen, eventDetails);
7484 this.context.onOpenChange?.(newOpen, eventDetails);
7485 };
7486 };
7487
7488 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
7489 function useSyncedFloatingRootContext(options) {
7490 const {
7491 popupStore,
7492 treatPopupAsFloatingElement = false,
7493 floatingRootContext: floatingRootContextProp,
7494 floatingId,
7495 nested,
7496 onOpenChange
7497 } = options;
7498 const open = popupStore.useState("open");
7499 const referenceElement = popupStore.useState("activeTriggerElement");
7500 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
7501 const triggerElements = popupStore.context.triggerElements;
7502 const handleOpenChange = onOpenChange;
7503 const internalStoreRef = React32.useRef(null);
7504 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
7505 internalStoreRef.current = new FloatingRootStore({
7506 open,
7507 transitionStatus: void 0,
7508 referenceElement,
7509 floatingElement,
7510 triggerElements,
7511 onOpenChange: handleOpenChange,
7512 floatingId,
7513 syncOnly: true,
7514 nested
7515 });
7516 }
7517 const store = floatingRootContextProp ?? internalStoreRef.current;
7518 popupStore.useSyncedValue("floatingId", floatingId);
7519 useIsoLayoutEffect(() => {
7520 const valuesToSync = {
7521 open,
7522 floatingId,
7523 referenceElement,
7524 floatingElement
7525 };
7526 if (isElement(referenceElement)) {
7527 valuesToSync.domReferenceElement = referenceElement;
7528 }
7529 if (store.state.positionReference === store.state.referenceElement) {
7530 valuesToSync.positionReference = referenceElement;
7531 }
7532 store.update(valuesToSync);
7533 }, [open, floatingId, referenceElement, floatingElement, store]);
7534 store.context.onOpenChange = handleOpenChange;
7535 store.context.nested = nested;
7536 return store;
7537 }
7538
7539 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
7540 var FOCUSABLE_POPUP_PROPS = {
7541 tabIndex: -1,
7542 [FOCUSABLE_ATTRIBUTE]: ""
7543 };
7544 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
7545 const floatingId = useId();
7546 const nested = useFloatingParentNodeId() != null;
7547 const internalStoreRef = React33.useRef(null);
7548 if (externalStore === void 0 && internalStoreRef.current === null) {
7549 internalStoreRef.current = createStore2(floatingId, nested);
7550 }
7551 const store = externalStore ?? internalStoreRef.current;
7552 useSyncedFloatingRootContext({
7553 popupStore: store,
7554 treatPopupAsFloatingElement,
7555 floatingRootContext: store.state.floatingRootContext,
7556 floatingId,
7557 nested,
7558 onOpenChange: store.setOpen
7559 });
7560 return {
7561 store,
7562 internalStore: internalStoreRef.current
7563 };
7564 }
7565 function useTriggerRegistration(id, store) {
7566 const registeredElementIdRef = React33.useRef(null);
7567 const registeredElementRef = React33.useRef(null);
7568 return React33.useCallback((element) => {
7569 if (id === void 0) {
7570 return;
7571 }
7572 let shouldSyncTriggerCount = false;
7573 if (registeredElementIdRef.current !== null) {
7574 const registeredId = registeredElementIdRef.current;
7575 const registeredElement = registeredElementRef.current;
7576 const currentElement = store.context.triggerElements.getById(registeredId);
7577 if (registeredElement && currentElement === registeredElement) {
7578 store.context.triggerElements.delete(registeredId);
7579 shouldSyncTriggerCount = true;
7580 }
7581 registeredElementIdRef.current = null;
7582 registeredElementRef.current = null;
7583 }
7584 if (element !== null) {
7585 registeredElementIdRef.current = id;
7586 registeredElementRef.current = element;
7587 store.context.triggerElements.add(id, element);
7588 shouldSyncTriggerCount = true;
7589 }
7590 if (shouldSyncTriggerCount) {
7591 const triggerCount = store.context.triggerElements.size;
7592 if (store.select("open") && store.state.triggerCount !== triggerCount) {
7593 store.set("triggerCount", triggerCount);
7594 }
7595 }
7596 }, [store, id]);
7597 }
7598 function setOpenTriggerState(state, open, trigger) {
7599 const triggerId = trigger?.id ?? null;
7600 if (triggerId || open) {
7601 state.activeTriggerId = triggerId;
7602 state.activeTriggerElement = trigger ?? null;
7603 }
7604 }
7605 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
7606 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
7607 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
7608 const registerTrigger = useStableCallback((element) => {
7609 baseRegisterTrigger(element);
7610 if (!element) {
7611 return;
7612 }
7613 const open = store.select("open");
7614 const activeTriggerId = store.select("activeTriggerId");
7615 if (activeTriggerId === triggerId) {
7616 store.update({
7617 activeTriggerElement: element,
7618 ...open ? stateUpdates : null
7619 });
7620 return;
7621 }
7622 if (activeTriggerId == null && open) {
7623 store.update({
7624 activeTriggerId: triggerId,
7625 activeTriggerElement: element,
7626 ...stateUpdates
7627 });
7628 }
7629 });
7630 useIsoLayoutEffect(() => {
7631 if (isMountedByThisTrigger) {
7632 store.update({
7633 activeTriggerElement: triggerElementRef.current,
7634 ...stateUpdates
7635 });
7636 }
7637 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
7638 return {
7639 registerTrigger,
7640 isMountedByThisTrigger
7641 };
7642 }
7643 function useImplicitActiveTrigger(store) {
7644 const open = store.useState("open");
7645 const reactiveTriggerCount = store.useState("triggerCount");
7646 useIsoLayoutEffect(() => {
7647 if (!open) {
7648 if (store.state.triggerCount !== 0) {
7649 store.set("triggerCount", 0);
7650 }
7651 return;
7652 }
7653 const triggerCount = store.context.triggerElements.size;
7654 const stateUpdates = {};
7655 if (store.state.triggerCount !== triggerCount) {
7656 stateUpdates.triggerCount = triggerCount;
7657 }
7658 if (!store.select("activeTriggerId") && triggerCount === 1) {
7659 const iteratorResult = store.context.triggerElements.entries().next();
7660 if (!iteratorResult.done) {
7661 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
7662 stateUpdates.activeTriggerId = implicitTriggerId;
7663 stateUpdates.activeTriggerElement = implicitTriggerElement;
7664 }
7665 }
7666 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
7667 store.update(stateUpdates);
7668 }
7669 }, [open, store, reactiveTriggerCount]);
7670 }
7671 function useOpenStateTransitions(open, store, onUnmount) {
7672 const {
7673 mounted,
7674 setMounted,
7675 transitionStatus
7676 } = useTransitionStatus(open);
7677 store.useSyncedValues({
7678 mounted,
7679 transitionStatus
7680 });
7681 const forceUnmount = useStableCallback(() => {
7682 setMounted(false);
7683 store.update({
7684 activeTriggerId: null,
7685 activeTriggerElement: null,
7686 mounted: false,
7687 preventUnmountingOnClose: false
7688 });
7689 onUnmount?.();
7690 store.context.onOpenChangeComplete?.(false);
7691 });
7692 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
7693 useOpenChangeComplete({
7694 enabled: mounted && !open && !preventUnmountingOnClose,
7695 open,
7696 ref: store.context.popupRef,
7697 onComplete() {
7698 if (!open) {
7699 forceUnmount();
7700 }
7701 }
7702 });
7703 return {
7704 forceUnmount,
7705 transitionStatus
7706 };
7707 }
7708 function usePopupInteractionProps(store, statePart) {
7709 store.useSyncedValues(statePart);
7710 useIsoLayoutEffect(() => () => {
7711 store.update({
7712 activeTriggerProps: EMPTY_OBJECT,
7713 inactiveTriggerProps: EMPTY_OBJECT,
7714 popupProps: EMPTY_OBJECT
7715 });
7716 }, [store]);
7717 }
7718 function usePopupRootSync(store, open) {
7719 useIsoLayoutEffect(() => {
7720 if (!open && store.state.openMethod !== null) {
7721 store.set("openMethod", null);
7722 }
7723 }, [open, store]);
7724 useIsoLayoutEffect(() => () => {
7725 if (store.state.openMethod !== null) {
7726 store.set("openMethod", null);
7727 }
7728 }, [store]);
7729 }
7730
7731 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
7732 var PopupTriggerMap = class {
7733 constructor() {
7734 this.elementsSet = /* @__PURE__ */ new Set();
7735 this.idMap = /* @__PURE__ */ new Map();
7736 }
7737 /**
7738 * Adds a trigger element with the given ID.
7739 *
7740 * Note: The provided element is assumed to not be registered under multiple IDs.
7741 */
7742 add(id, element) {
7743 const existingElement = this.idMap.get(id);
7744 if (existingElement === element) {
7745 return;
7746 }
7747 if (existingElement !== void 0) {
7748 this.elementsSet.delete(existingElement);
7749 }
7750 this.elementsSet.add(element);
7751 this.idMap.set(id, element);
7752 if (true) {
7753 if (this.elementsSet.size !== this.idMap.size) {
7754 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
7755 }
7756 }
7757 }
7758 /**
7759 * Removes the trigger element with the given ID.
7760 */
7761 delete(id) {
7762 const element = this.idMap.get(id);
7763 if (element) {
7764 this.elementsSet.delete(element);
7765 this.idMap.delete(id);
7766 }
7767 }
7768 /**
7769 * Whether the given element is registered as a trigger.
7770 */
7771 hasElement(element) {
7772 return this.elementsSet.has(element);
7773 }
7774 /**
7775 * Whether there is a registered trigger element matching the given predicate.
7776 */
7777 hasMatchingElement(predicate) {
7778 for (const element of this.elementsSet) {
7779 if (predicate(element)) {
7780 return true;
7781 }
7782 }
7783 return false;
7784 }
7785 /**
7786 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
7787 */
7788 getById(id) {
7789 return this.idMap.get(id);
7790 }
7791 /**
7792 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
7793 */
7794 entries() {
7795 return this.idMap.entries();
7796 }
7797 /**
7798 * Returns an iterable of all registered trigger elements.
7799 */
7800 elements() {
7801 return this.elementsSet.values();
7802 }
7803 /**
7804 * Returns the number of registered trigger elements.
7805 */
7806 get size() {
7807 return this.idMap.size;
7808 }
7809 };
7810
7811 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
7812 function getEmptyRootContext() {
7813 return new FloatingRootStore({
7814 open: false,
7815 transitionStatus: void 0,
7816 floatingElement: null,
7817 referenceElement: null,
7818 triggerElements: new PopupTriggerMap(),
7819 floatingId: void 0,
7820 syncOnly: false,
7821 nested: false,
7822 onOpenChange: void 0
7823 });
7824 }
7825
7826 // node_modules/@base-ui/react/esm/utils/popups/store.js
7827 function createInitialPopupStoreState() {
7828 return {
7829 open: false,
7830 openProp: void 0,
7831 mounted: false,
7832 transitionStatus: void 0,
7833 floatingRootContext: getEmptyRootContext(),
7834 floatingId: void 0,
7835 triggerCount: 0,
7836 preventUnmountingOnClose: false,
7837 payload: void 0,
7838 activeTriggerId: null,
7839 activeTriggerElement: null,
7840 triggerIdProp: void 0,
7841 popupElement: null,
7842 positionerElement: null,
7843 activeTriggerProps: EMPTY_OBJECT,
7844 inactiveTriggerProps: EMPTY_OBJECT,
7845 popupProps: EMPTY_OBJECT
7846 };
7847 }
7848 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
7849 return new FloatingRootStore({
7850 open: false,
7851 transitionStatus: void 0,
7852 floatingElement: null,
7853 referenceElement: null,
7854 triggerElements,
7855 floatingId,
7856 syncOnly: true,
7857 nested,
7858 onOpenChange: void 0
7859 });
7860 }
7861 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
7862 var openSelector = createSelector((state) => state.openProp ?? state.open);
7863 var popupIdSelector = createSelector((state) => {
7864 const popupId = state.popupElement?.id ?? state.floatingId;
7865 return popupId || void 0;
7866 });
7867 function triggerOwnsOpenPopup(state, triggerId) {
7868 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
7869 }
7870 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
7871 if (triggerOwnsOpenPopup(state, triggerId)) {
7872 return true;
7873 }
7874 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
7875 }
7876 var popupStoreSelectors = {
7877 open: openSelector,
7878 mounted: createSelector((state) => state.mounted),
7879 transitionStatus: createSelector((state) => state.transitionStatus),
7880 floatingRootContext: createSelector((state) => state.floatingRootContext),
7881 triggerCount: createSelector((state) => state.triggerCount),
7882 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
7883 payload: createSelector((state) => state.payload),
7884 activeTriggerId: activeTriggerIdSelector,
7885 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
7886 popupId: popupIdSelector,
7887 /**
7888 * Whether the trigger with the given ID was used to open the popup.
7889 */
7890 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
7891 /**
7892 * Whether the popup is open and was activated by a trigger with the given ID.
7893 */
7894 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
7895 /**
7896 * Whether the popup is mounted and was activated by a trigger with the given ID.
7897 */
7898 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
7899 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
7900 /**
7901 * Popup id for the trigger that currently owns the open popup.
7902 */
7903 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
7904 popupProps: createSelector((state) => state.popupProps),
7905 popupElement: createSelector((state) => state.popupElement),
7906 positionerElement: createSelector((state) => state.positionerElement)
7907 };
7908
7909 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
7910 function useFloatingRootContext(options) {
7911 const {
7912 open = false,
7913 onOpenChange,
7914 elements = {}
7915 } = options;
7916 const floatingId = useId();
7917 const nested = useFloatingParentNodeId() != null;
7918 if (true) {
7919 const optionDomReference = elements.reference;
7920 if (optionDomReference && !isElement(optionDomReference)) {
7921 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
7922 }
7923 }
7924 const store = useRefWithInit(() => new FloatingRootStore({
7925 open,
7926 transitionStatus: void 0,
7927 onOpenChange,
7928 referenceElement: elements.reference ?? null,
7929 floatingElement: elements.floating ?? null,
7930 triggerElements: new PopupTriggerMap(),
7931 floatingId,
7932 syncOnly: false,
7933 nested
7934 })).current;
7935 useIsoLayoutEffect(() => {
7936 const valuesToSync = {
7937 open,
7938 floatingId
7939 };
7940 if (elements.reference !== void 0) {
7941 valuesToSync.referenceElement = elements.reference;
7942 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
7943 }
7944 if (elements.floating !== void 0) {
7945 valuesToSync.floatingElement = elements.floating;
7946 }
7947 store.update(valuesToSync);
7948 }, [open, floatingId, elements.reference, elements.floating, store]);
7949 store.context.onOpenChange = onOpenChange;
7950 store.context.nested = nested;
7951 return store;
7952 }
7953
7954 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
7955 function useFloating2(options = {}) {
7956 const {
7957 nodeId,
7958 externalTree
7959 } = options;
7960 const internalStore = useFloatingRootContext(options);
7961 const store = options.rootContext || internalStore;
7962 const referenceElement = store.useState("referenceElement");
7963 const floatingElement = store.useState("floatingElement");
7964 const domReferenceElement = store.useState("domReferenceElement");
7965 const open = store.useState("open");
7966 const floatingId = store.useState("floatingId");
7967 const [positionReference, setPositionReferenceRaw] = React34.useState(null);
7968 const [localDomReference, setLocalDomReference] = React34.useState(void 0);
7969 const [localFloatingElement, setLocalFloatingElement] = React34.useState(void 0);
7970 const domReferenceRef = React34.useRef(null);
7971 const tree = useFloatingTree(externalTree);
7972 const storeElements = React34.useMemo(() => ({
7973 reference: referenceElement,
7974 floating: floatingElement,
7975 domReference: domReferenceElement
7976 }), [referenceElement, floatingElement, domReferenceElement]);
7977 const position = useFloating({
7978 ...options,
7979 elements: {
7980 ...storeElements,
7981 ...positionReference && {
7982 reference: positionReference
7983 }
7984 }
7985 });
7986 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7987 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
7988 store.useSyncedValue("referenceElement", localDomReference ?? null);
7989 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
7990 store.useSyncedValue("floatingElement", syncedFloatingElement);
7991 const setPositionReference = React34.useCallback((node) => {
7992 const computedPositionReference = isElement(node) ? {
7993 getBoundingClientRect: () => node.getBoundingClientRect(),
7994 getClientRects: () => node.getClientRects(),
7995 contextElement: node
7996 } : node;
7997 setPositionReferenceRaw(computedPositionReference);
7998 position.refs.setReference(computedPositionReference);
7999 }, [position.refs]);
8000 const setReference = React34.useCallback((node) => {
8001 if (isElement(node) || node === null) {
8002 domReferenceRef.current = node;
8003 setLocalDomReference(node);
8004 }
8005 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
8006 // `null` to support `positionReference` + an unstable `reference`
8007 // callback ref.
8008 node !== null && !isElement(node)) {
8009 position.refs.setReference(node);
8010 }
8011 }, [position.refs, setLocalDomReference]);
8012 const setFloating = React34.useCallback((node) => {
8013 setLocalFloatingElement(node);
8014 position.refs.setFloating(node);
8015 }, [position.refs]);
8016 const refs = React34.useMemo(() => ({
8017 ...position.refs,
8018 setReference,
8019 setFloating,
8020 setPositionReference,
8021 domReference: domReferenceRef
8022 }), [position.refs, setReference, setFloating, setPositionReference]);
8023 const elements = React34.useMemo(() => ({
8024 ...position.elements,
8025 domReference: domReferenceElement
8026 }), [position.elements, domReferenceElement]);
8027 const context = React34.useMemo(() => ({
8028 ...position,
8029 dataRef: store.context.dataRef,
8030 open,
8031 onOpenChange: store.setOpen,
8032 events: store.context.events,
8033 floatingId,
8034 refs,
8035 elements,
8036 nodeId,
8037 rootStore: store
8038 }), [position, refs, elements, nodeId, store, open, floatingId]);
8039 useIsoLayoutEffect(() => {
8040 if (domReferenceElement) {
8041 domReferenceRef.current = domReferenceElement;
8042 }
8043 }, [domReferenceElement]);
8044 useIsoLayoutEffect(() => {
8045 store.context.dataRef.current.floatingContext = context;
8046 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
8047 if (node) {
8048 node.context = context;
8049 }
8050 });
8051 return React34.useMemo(() => ({
8052 ...position,
8053 context,
8054 refs,
8055 elements,
8056 rootStore: store
8057 }), [position, refs, elements, context, store]);
8058 }
8059
8060 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
8061 var React35 = __toESM(require_react(), 1);
8062 var isMacSafari = isMac && isSafari;
8063 function useFocus(context, props = {}) {
8064 const {
8065 enabled = true,
8066 delay
8067 } = props;
8068 const store = "rootStore" in context ? context.rootStore : context;
8069 const {
8070 events,
8071 dataRef
8072 } = store.context;
8073 const blockFocusRef = React35.useRef(false);
8074 const blockedReferenceRef = React35.useRef(null);
8075 const keyboardModalityRef = React35.useRef(true);
8076 const timeout = useTimeout();
8077 React35.useEffect(() => {
8078 const domReference = store.select("domReferenceElement");
8079 if (!enabled) {
8080 return void 0;
8081 }
8082 const win = getWindow(domReference);
8083 function onBlur() {
8084 const currentDomReference = store.select("domReferenceElement");
8085 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
8086 blockFocusRef.current = true;
8087 }
8088 }
8089 function onKeyDown() {
8090 keyboardModalityRef.current = true;
8091 }
8092 function onPointerDown() {
8093 keyboardModalityRef.current = false;
8094 }
8095 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
8096 }, [store, enabled]);
8097 React35.useEffect(() => {
8098 if (!enabled) {
8099 return void 0;
8100 }
8101 function onOpenChangeLocal(details) {
8102 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
8103 const referenceElement = store.select("domReferenceElement");
8104 if (isElement(referenceElement)) {
8105 blockedReferenceRef.current = referenceElement;
8106 blockFocusRef.current = true;
8107 }
8108 }
8109 }
8110 events.on("openchange", onOpenChangeLocal);
8111 return () => {
8112 events.off("openchange", onOpenChangeLocal);
8113 };
8114 }, [events, enabled, store]);
8115 const reference = React35.useMemo(() => {
8116 function resetBlockedFocus() {
8117 blockFocusRef.current = false;
8118 blockedReferenceRef.current = null;
8119 }
8120 return {
8121 onMouseLeave() {
8122 resetBlockedFocus();
8123 },
8124 onFocus(event) {
8125 const focusTarget = event.currentTarget;
8126 if (blockFocusRef.current) {
8127 if (blockedReferenceRef.current === focusTarget) {
8128 return;
8129 }
8130 resetBlockedFocus();
8131 }
8132 const target = getTarget(event.nativeEvent);
8133 if (isElement(target)) {
8134 if (isMacSafari && !event.relatedTarget) {
8135 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
8136 return;
8137 }
8138 } else if (!matchesFocusVisible(target)) {
8139 return;
8140 }
8141 }
8142 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
8143 const {
8144 nativeEvent,
8145 currentTarget
8146 } = event;
8147 const delayValue = typeof delay === "function" ? delay() : delay;
8148 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
8149 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
8150 return;
8151 }
8152 timeout.start(delayValue, () => {
8153 if (blockFocusRef.current) {
8154 return;
8155 }
8156 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
8157 });
8158 },
8159 onBlur(event) {
8160 resetBlockedFocus();
8161 const relatedTarget = event.relatedTarget;
8162 const nativeEvent = event.nativeEvent;
8163 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
8164 timeout.start(0, () => {
8165 const domReference = store.select("domReferenceElement");
8166 const activeEl = activeElement(ownerDocument(domReference));
8167 if (!relatedTarget && activeEl === domReference) {
8168 return;
8169 }
8170 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
8171 return;
8172 }
8173 const nextFocusedElement = relatedTarget ?? activeEl;
8174 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
8175 return;
8176 }
8177 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
8178 });
8179 }
8180 };
8181 }, [dataRef, delay, store, timeout]);
8182 return React35.useMemo(() => enabled ? {
8183 reference,
8184 trigger: reference
8185 } : {}, [enabled, reference]);
8186 }
8187
8188 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
8189 var React36 = __toESM(require_react(), 1);
8190
8191 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
8192 var HoverInteraction = class _HoverInteraction {
8193 constructor() {
8194 this.pointerType = void 0;
8195 this.interactedInside = false;
8196 this.handler = void 0;
8197 this.blockMouseMove = true;
8198 this.performedPointerEventsMutation = false;
8199 this.pointerEventsScopeElement = null;
8200 this.pointerEventsReferenceElement = null;
8201 this.pointerEventsFloatingElement = null;
8202 this.restTimeoutPending = false;
8203 this.openChangeTimeout = new Timeout();
8204 this.restTimeout = new Timeout();
8205 this.handleCloseOptions = void 0;
8206 }
8207 static create() {
8208 return new _HoverInteraction();
8209 }
8210 dispose = () => {
8211 this.openChangeTimeout.clear();
8212 this.restTimeout.clear();
8213 };
8214 disposeEffect = () => {
8215 return this.dispose;
8216 };
8217 };
8218 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
8219 function clearSafePolygonPointerEventsMutation(instance) {
8220 if (!instance.performedPointerEventsMutation) {
8221 return;
8222 }
8223 const scopeElement = instance.pointerEventsScopeElement;
8224 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
8225 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
8226 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
8227 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
8228 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
8229 }
8230 instance.performedPointerEventsMutation = false;
8231 instance.pointerEventsScopeElement = null;
8232 instance.pointerEventsReferenceElement = null;
8233 instance.pointerEventsFloatingElement = null;
8234 }
8235 function applySafePolygonPointerEventsMutation(instance, options) {
8236 const {
8237 scopeElement,
8238 referenceElement,
8239 floatingElement
8240 } = options;
8241 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
8242 if (existingOwner && existingOwner !== instance) {
8243 clearSafePolygonPointerEventsMutation(existingOwner);
8244 }
8245 clearSafePolygonPointerEventsMutation(instance);
8246 instance.performedPointerEventsMutation = true;
8247 instance.pointerEventsScopeElement = scopeElement;
8248 instance.pointerEventsReferenceElement = referenceElement;
8249 instance.pointerEventsFloatingElement = floatingElement;
8250 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
8251 scopeElement.style.pointerEvents = "none";
8252 referenceElement.style.pointerEvents = "auto";
8253 floatingElement.style.pointerEvents = "auto";
8254 }
8255 function useHoverInteractionSharedState(store) {
8256 const data = store.context.dataRef.current;
8257 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
8258 if (!data.hoverInteractionState) {
8259 data.hoverInteractionState = instance;
8260 }
8261 useOnMount(data.hoverInteractionState.disposeEffect);
8262 return data.hoverInteractionState;
8263 }
8264
8265 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
8266 function useHoverFloatingInteraction(context, parameters = {}) {
8267 const {
8268 enabled = true,
8269 closeDelay: closeDelayProp = 0,
8270 nodeId: nodeIdProp
8271 } = parameters;
8272 const store = "rootStore" in context ? context.rootStore : context;
8273 const open = store.useState("open");
8274 const floatingElement = store.useState("floatingElement");
8275 const domReferenceElement = store.useState("domReferenceElement");
8276 const {
8277 dataRef
8278 } = store.context;
8279 const tree = useFloatingTree();
8280 const parentId = useFloatingParentNodeId();
8281 const instance = useHoverInteractionSharedState(store);
8282 const childClosedTimeout = useTimeout();
8283 const isClickLikeOpenEvent2 = useStableCallback(() => {
8284 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
8285 });
8286 const isHoverOpen = useStableCallback(() => {
8287 return isHoverOpenEvent(dataRef.current.openEvent?.type);
8288 });
8289 const clearPointerEvents = useStableCallback(() => {
8290 clearSafePolygonPointerEventsMutation(instance);
8291 });
8292 useIsoLayoutEffect(() => {
8293 if (!open) {
8294 instance.pointerType = void 0;
8295 instance.restTimeoutPending = false;
8296 instance.interactedInside = false;
8297 clearPointerEvents();
8298 }
8299 }, [open, instance, clearPointerEvents]);
8300 React36.useEffect(() => {
8301 return clearPointerEvents;
8302 }, [clearPointerEvents]);
8303 useIsoLayoutEffect(() => {
8304 if (!enabled) {
8305 return void 0;
8306 }
8307 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
8308 const ref = domReferenceElement;
8309 const floatingEl = floatingElement;
8310 const doc = ownerDocument(floatingElement);
8311 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
8312 if (parentFloating) {
8313 parentFloating.style.pointerEvents = "";
8314 }
8315 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
8316 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
8317 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
8318 applySafePolygonPointerEventsMutation(instance, {
8319 scopeElement,
8320 referenceElement: ref,
8321 floatingElement: floatingEl
8322 });
8323 return () => {
8324 clearPointerEvents();
8325 };
8326 }
8327 return void 0;
8328 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
8329 React36.useEffect(() => {
8330 if (!enabled) {
8331 return void 0;
8332 }
8333 function hasParentChildren() {
8334 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
8335 }
8336 function closeWithDelay(event) {
8337 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
8338 const close = () => {
8339 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8340 tree?.events.emit("floating.closed", event);
8341 };
8342 if (closeDelay) {
8343 instance.openChangeTimeout.start(closeDelay, close);
8344 } else {
8345 instance.openChangeTimeout.clear();
8346 close();
8347 }
8348 }
8349 function handleInteractInside(event) {
8350 const target = getTarget(event);
8351 if (!isInteractiveElement(target)) {
8352 instance.interactedInside = false;
8353 return;
8354 }
8355 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
8356 }
8357 function onFloatingMouseEnter() {
8358 instance.openChangeTimeout.clear();
8359 childClosedTimeout.clear();
8360 tree?.events.off("floating.closed", onNodeClosed);
8361 clearPointerEvents();
8362 }
8363 function onFloatingMouseLeave(event) {
8364 if (hasParentChildren() && tree) {
8365 tree.events.on("floating.closed", onNodeClosed);
8366 return;
8367 }
8368 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
8369 return;
8370 }
8371 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
8372 const relatedTarget = event.relatedTarget;
8373 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
8374 if (isMovingIntoDescendantFloating) {
8375 return;
8376 }
8377 if (instance.handler) {
8378 instance.handler(event);
8379 return;
8380 }
8381 clearPointerEvents();
8382 if (!isClickLikeOpenEvent2()) {
8383 closeWithDelay(event);
8384 }
8385 }
8386 function onNodeClosed(event) {
8387 if (!tree || !parentId || hasParentChildren()) {
8388 return;
8389 }
8390 childClosedTimeout.start(0, () => {
8391 tree.events.off("floating.closed", onNodeClosed);
8392 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8393 tree.events.emit("floating.closed", event);
8394 });
8395 }
8396 const floating = floatingElement;
8397 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
8398 tree?.events.off("floating.closed", onNodeClosed);
8399 });
8400 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
8401 }
8402
8403 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
8404 var React37 = __toESM(require_react(), 1);
8405 var ReactDOM4 = __toESM(require_react_dom(), 1);
8406 var EMPTY_REF = {
8407 current: null
8408 };
8409 function useHoverReferenceInteraction(context, props = {}) {
8410 const {
8411 enabled = true,
8412 delay = 0,
8413 handleClose = null,
8414 mouseOnly = false,
8415 restMs = 0,
8416 move = true,
8417 triggerElementRef = EMPTY_REF,
8418 externalTree,
8419 isActiveTrigger = true,
8420 getHandleCloseContext,
8421 isClosing,
8422 shouldOpen: shouldOpenProp
8423 } = props;
8424 const store = "rootStore" in context ? context.rootStore : context;
8425 const {
8426 dataRef,
8427 events
8428 } = store.context;
8429 const tree = useFloatingTree(externalTree);
8430 const instance = useHoverInteractionSharedState(store);
8431 const isHoverCloseActiveRef = React37.useRef(false);
8432 const handleCloseRef = useValueAsRef(handleClose);
8433 const delayRef = useValueAsRef(delay);
8434 const restMsRef = useValueAsRef(restMs);
8435 const enabledRef = useValueAsRef(enabled);
8436 const shouldOpenRef = useValueAsRef(shouldOpenProp);
8437 const isClosingRef = useValueAsRef(isClosing);
8438 const isClickLikeOpenEvent2 = useStableCallback(() => {
8439 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
8440 });
8441 const checkShouldOpen = useStableCallback(() => {
8442 return shouldOpenRef.current?.() !== false;
8443 });
8444 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
8445 const allTriggers = store.context.triggerElements;
8446 if (allTriggers.hasElement(currentTarget)) {
8447 return !currentDomReference || !contains(currentDomReference, currentTarget);
8448 }
8449 if (!isElement(target)) {
8450 return false;
8451 }
8452 const targetElement = target;
8453 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
8454 });
8455 const cleanupMouseMoveHandler = useStableCallback(() => {
8456 if (!instance.handler) {
8457 return;
8458 }
8459 const doc = ownerDocument(store.select("domReferenceElement"));
8460 doc.removeEventListener("mousemove", instance.handler);
8461 instance.handler = void 0;
8462 });
8463 const clearPointerEvents = useStableCallback(() => {
8464 clearSafePolygonPointerEventsMutation(instance);
8465 });
8466 if (isActiveTrigger) {
8467 instance.handleCloseOptions = handleCloseRef.current?.__options;
8468 }
8469 React37.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
8470 React37.useEffect(() => {
8471 if (!enabled) {
8472 return void 0;
8473 }
8474 function onOpenChangeLocal(details) {
8475 if (!details.open) {
8476 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
8477 cleanupMouseMoveHandler();
8478 instance.openChangeTimeout.clear();
8479 instance.restTimeout.clear();
8480 instance.blockMouseMove = true;
8481 instance.restTimeoutPending = false;
8482 } else {
8483 isHoverCloseActiveRef.current = false;
8484 }
8485 }
8486 events.on("openchange", onOpenChangeLocal);
8487 return () => {
8488 events.off("openchange", onOpenChangeLocal);
8489 };
8490 }, [enabled, events, instance, cleanupMouseMoveHandler]);
8491 React37.useEffect(() => {
8492 if (!enabled) {
8493 return void 0;
8494 }
8495 function closeWithDelay(event, runElseBranch = true) {
8496 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
8497 if (closeDelay) {
8498 instance.openChangeTimeout.start(closeDelay, () => {
8499 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8500 tree?.events.emit("floating.closed", event);
8501 });
8502 } else if (runElseBranch) {
8503 instance.openChangeTimeout.clear();
8504 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8505 tree?.events.emit("floating.closed", event);
8506 }
8507 }
8508 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
8509 if (!isElement(trigger)) {
8510 return void 0;
8511 }
8512 function onMouseEnter(event) {
8513 instance.openChangeTimeout.clear();
8514 instance.blockMouseMove = false;
8515 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
8516 return;
8517 }
8518 const restMsValue = getRestMs(restMsRef.current);
8519 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
8520 const eventTarget = getTarget(event);
8521 const currentTarget = event.currentTarget ?? null;
8522 const currentDomReference = store.select("domReferenceElement");
8523 let triggerNode = currentTarget;
8524 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
8525 for (const triggerElement of store.context.triggerElements.elements()) {
8526 if (contains(triggerElement, eventTarget)) {
8527 triggerNode = triggerElement;
8528 break;
8529 }
8530 }
8531 }
8532 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
8533 triggerNode = currentDomReference;
8534 }
8535 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
8536 const isOpen = store.select("open");
8537 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
8538 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
8539 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
8540 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
8541 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
8542 const shouldOpen = !isOpen || isOverInactive;
8543 if (shouldOpenImmediately) {
8544 if (checkShouldOpen()) {
8545 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
8546 }
8547 return;
8548 }
8549 if (isRestOnlyDelay) {
8550 return;
8551 }
8552 if (openDelay) {
8553 instance.openChangeTimeout.start(openDelay, () => {
8554 if (shouldOpen && checkShouldOpen()) {
8555 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
8556 }
8557 });
8558 } else if (shouldOpen) {
8559 if (checkShouldOpen()) {
8560 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
8561 }
8562 }
8563 }
8564 function onMouseLeave(event) {
8565 if (isClickLikeOpenEvent2()) {
8566 clearPointerEvents();
8567 return;
8568 }
8569 cleanupMouseMoveHandler();
8570 const domReferenceElement = store.select("domReferenceElement");
8571 const doc = ownerDocument(domReferenceElement);
8572 instance.restTimeout.clear();
8573 instance.restTimeoutPending = false;
8574 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
8575 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
8576 return;
8577 }
8578 if (handleCloseRef.current && handleCloseContextBase) {
8579 if (!store.select("open")) {
8580 instance.openChangeTimeout.clear();
8581 }
8582 const currentTrigger = triggerElementRef.current;
8583 instance.handler = handleCloseRef.current({
8584 ...handleCloseContextBase,
8585 tree,
8586 x: event.clientX,
8587 y: event.clientY,
8588 onClose() {
8589 clearPointerEvents();
8590 cleanupMouseMoveHandler();
8591 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
8592 closeWithDelay(event, true);
8593 }
8594 }
8595 });
8596 doc.addEventListener("mousemove", instance.handler);
8597 instance.handler(event);
8598 return;
8599 }
8600 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
8601 if (shouldClose) {
8602 closeWithDelay(event);
8603 }
8604 }
8605 if (move) {
8606 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
8607 once: true
8608 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
8609 }
8610 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
8611 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
8612 return React37.useMemo(() => {
8613 if (!enabled) {
8614 return void 0;
8615 }
8616 function setPointerRef(event) {
8617 instance.pointerType = event.pointerType;
8618 }
8619 return {
8620 onPointerDown: setPointerRef,
8621 onPointerEnter: setPointerRef,
8622 onMouseMove(event) {
8623 const {
8624 nativeEvent
8625 } = event;
8626 const trigger = event.currentTarget;
8627 const currentDomReference = store.select("domReferenceElement");
8628 const currentOpen = store.select("open");
8629 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
8630 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
8631 return;
8632 }
8633 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
8634 const floatingElement = store.select("floatingElement");
8635 if (floatingElement) {
8636 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
8637 applySafePolygonPointerEventsMutation(instance, {
8638 scopeElement,
8639 referenceElement: trigger,
8640 floatingElement
8641 });
8642 }
8643 }
8644 const restMsValue = getRestMs(restMsRef.current);
8645 if (currentOpen && !isOverInactive || restMsValue === 0) {
8646 return;
8647 }
8648 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
8649 return;
8650 }
8651 instance.restTimeout.clear();
8652 function handleMouseMove() {
8653 instance.restTimeoutPending = false;
8654 if (isClickLikeOpenEvent2()) {
8655 return;
8656 }
8657 const latestOpen = store.select("open");
8658 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
8659 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
8660 }
8661 }
8662 if (instance.pointerType === "touch") {
8663 ReactDOM4.flushSync(() => {
8664 handleMouseMove();
8665 });
8666 } else if (isOverInactive && currentOpen) {
8667 handleMouseMove();
8668 } else {
8669 instance.restTimeoutPending = true;
8670 instance.restTimeout.start(restMsValue, handleMouseMove);
8671 }
8672 }
8673 };
8674 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
8675 }
8676
8677 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
8678 var CURSOR_SPEED_THRESHOLD = 0.1;
8679 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
8680 var POLYGON_BUFFER = 0.5;
8681 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
8682 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
8683 }
8684 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
8685 let isInsideValue = false;
8686 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
8687 isInsideValue = !isInsideValue;
8688 }
8689 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
8690 isInsideValue = !isInsideValue;
8691 }
8692 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
8693 isInsideValue = !isInsideValue;
8694 }
8695 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
8696 isInsideValue = !isInsideValue;
8697 }
8698 return isInsideValue;
8699 }
8700 function isInsideRect(pointX, pointY, rect) {
8701 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
8702 }
8703 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
8704 const minX = Math.min(x1, x2);
8705 const maxX = Math.max(x1, x2);
8706 const minY = Math.min(y1, y2);
8707 const maxY = Math.max(y1, y2);
8708 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
8709 }
8710 function safePolygon(options = {}) {
8711 const {
8712 blockPointerEvents = false
8713 } = options;
8714 const timeout = new Timeout();
8715 const fn = ({
8716 x: x2,
8717 y: y2,
8718 placement,
8719 elements,
8720 onClose,
8721 nodeId,
8722 tree
8723 }) => {
8724 const side = placement?.split("-")[0];
8725 let hasLanded = false;
8726 let lastX = null;
8727 let lastY = null;
8728 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
8729 function isCursorMovingSlowly(nextX, nextY) {
8730 const currentTime = performance.now();
8731 const elapsedTime = currentTime - lastCursorTime;
8732 if (lastX === null || lastY === null || elapsedTime === 0) {
8733 lastX = nextX;
8734 lastY = nextY;
8735 lastCursorTime = currentTime;
8736 return false;
8737 }
8738 const deltaX = nextX - lastX;
8739 const deltaY = nextY - lastY;
8740 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
8741 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
8742 lastX = nextX;
8743 lastY = nextY;
8744 lastCursorTime = currentTime;
8745 return distanceSquared < thresholdSquared;
8746 }
8747 function close() {
8748 timeout.clear();
8749 onClose();
8750 }
8751 return function onMouseMove(event) {
8752 timeout.clear();
8753 const domReference = elements.domReference;
8754 const floating = elements.floating;
8755 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
8756 return void 0;
8757 }
8758 const {
8759 clientX,
8760 clientY
8761 } = event;
8762 const target = getTarget(event);
8763 const isLeave = event.type === "mouseleave";
8764 const isOverFloatingEl = contains(floating, target);
8765 const isOverReferenceEl = contains(domReference, target);
8766 if (isOverFloatingEl) {
8767 hasLanded = true;
8768 if (!isLeave) {
8769 return void 0;
8770 }
8771 }
8772 if (isOverReferenceEl) {
8773 hasLanded = false;
8774 if (!isLeave) {
8775 hasLanded = true;
8776 return void 0;
8777 }
8778 }
8779 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
8780 return void 0;
8781 }
8782 function hasOpenChildNode() {
8783 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
8784 }
8785 function closeIfNoOpenChild() {
8786 if (!hasOpenChildNode()) {
8787 close();
8788 }
8789 }
8790 if (hasOpenChildNode()) {
8791 return void 0;
8792 }
8793 const refRect = domReference.getBoundingClientRect();
8794 const rect = floating.getBoundingClientRect();
8795 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
8796 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
8797 const isFloatingWider = rect.width > refRect.width;
8798 const isFloatingTaller = rect.height > refRect.height;
8799 const left = (isFloatingWider ? refRect : rect).left;
8800 const right = (isFloatingWider ? refRect : rect).right;
8801 const top = (isFloatingTaller ? refRect : rect).top;
8802 const bottom = (isFloatingTaller ? refRect : rect).bottom;
8803 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) {
8804 closeIfNoOpenChild();
8805 return void 0;
8806 }
8807 let isInsideTroughRect = false;
8808 switch (side) {
8809 case "top":
8810 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
8811 break;
8812 case "bottom":
8813 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
8814 break;
8815 case "left":
8816 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
8817 break;
8818 case "right":
8819 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
8820 break;
8821 default:
8822 }
8823 if (isInsideTroughRect) {
8824 return void 0;
8825 }
8826 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
8827 closeIfNoOpenChild();
8828 return void 0;
8829 }
8830 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
8831 closeIfNoOpenChild();
8832 return void 0;
8833 }
8834 let isInsidePolygon = false;
8835 switch (side) {
8836 case "top": {
8837 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8838 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8839 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8840 const cursorPointY = y2 + POLYGON_BUFFER + 1;
8841 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
8842 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
8843 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8844 break;
8845 }
8846 case "bottom": {
8847 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8848 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8849 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8850 const cursorPointY = y2 - POLYGON_BUFFER;
8851 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
8852 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
8853 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8854 break;
8855 }
8856 case "left": {
8857 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8858 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8859 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8860 const cursorPointX = x2 + POLYGON_BUFFER + 1;
8861 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
8862 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
8863 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
8864 break;
8865 }
8866 case "right": {
8867 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8868 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8869 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8870 const cursorPointX = x2 - POLYGON_BUFFER;
8871 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
8872 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
8873 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
8874 break;
8875 }
8876 default:
8877 }
8878 if (!isInsidePolygon) {
8879 closeIfNoOpenChild();
8880 } else if (!hasLanded) {
8881 timeout.start(40, closeIfNoOpenChild);
8882 }
8883 return void 0;
8884 };
8885 };
8886 fn.__options = {
8887 ...options,
8888 blockPointerEvents
8889 };
8890 return fn;
8891 }
8892
8893 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
8894 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
8895 CommonPopupDataAttributes2["open"] = "data-open";
8896 CommonPopupDataAttributes2["closed"] = "data-closed";
8897 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
8898 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
8899 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
8900 CommonPopupDataAttributes2["side"] = "data-side";
8901 CommonPopupDataAttributes2["align"] = "data-align";
8902 return CommonPopupDataAttributes2;
8903 })({});
8904 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
8905 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
8906 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
8907 return CommonTriggerDataAttributes2;
8908 })({});
8909 var TRIGGER_HOOK = {
8910 [CommonTriggerDataAttributes.popupOpen]: ""
8911 };
8912 var PRESSABLE_TRIGGER_HOOK = {
8913 [CommonTriggerDataAttributes.popupOpen]: "",
8914 [CommonTriggerDataAttributes.pressed]: ""
8915 };
8916 var POPUP_OPEN_HOOK = {
8917 [CommonPopupDataAttributes.open]: ""
8918 };
8919 var POPUP_CLOSED_HOOK = {
8920 [CommonPopupDataAttributes.closed]: ""
8921 };
8922 var ANCHOR_HIDDEN_HOOK = {
8923 [CommonPopupDataAttributes.anchorHidden]: ""
8924 };
8925 var triggerOpenStateMapping2 = {
8926 open(value) {
8927 if (value) {
8928 return TRIGGER_HOOK;
8929 }
8930 return null;
8931 }
8932 };
8933 var pressableTriggerOpenStateMapping = {
8934 open(value) {
8935 if (value) {
8936 return PRESSABLE_TRIGGER_HOOK;
8937 }
8938 return null;
8939 }
8940 };
8941 var popupStateMapping = {
8942 open(value) {
8943 if (value) {
8944 return POPUP_OPEN_HOOK;
8945 }
8946 return POPUP_CLOSED_HOOK;
8947 },
8948 anchorHidden(value) {
8949 if (value) {
8950 return ANCHOR_HIDDEN_HOOK;
8951 }
8952 return null;
8953 }
8954 };
8955
8956 // node_modules/@base-ui/utils/esm/inertValue.js
8957 function inertValue(value) {
8958 if (isReactVersionAtLeast(19)) {
8959 return value;
8960 }
8961 return value ? "true" : void 0;
8962 }
8963
8964 // node_modules/@base-ui/react/esm/utils/InternalBackdrop.js
8965 var React38 = __toESM(require_react(), 1);
8966 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8967 var InternalBackdrop = /* @__PURE__ */ React38.forwardRef(function InternalBackdrop2(props, ref) {
8968 const {
8969 cutout,
8970 ...otherProps
8971 } = props;
8972 let clipPath;
8973 if (cutout) {
8974 const rect = cutout.getBoundingClientRect();
8975 clipPath = `polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${rect.left}px ${rect.top}px,${rect.left}px ${rect.bottom}px,${rect.right}px ${rect.bottom}px,${rect.right}px ${rect.top}px,${rect.left}px ${rect.top}px)`;
8976 }
8977 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
8978 ref,
8979 role: "presentation",
8980 "data-base-ui-inert": "",
8981 ...otherProps,
8982 style: {
8983 position: "fixed",
8984 inset: 0,
8985 userSelect: "none",
8986 WebkitUserSelect: "none",
8987 clipPath
8988 }
8989 });
8990 });
8991 if (true) InternalBackdrop.displayName = "InternalBackdrop";
8992
8993 // node_modules/@base-ui/react/esm/utils/useOpenInteractionType.js
8994 var React40 = __toESM(require_react(), 1);
8995
8996 // node_modules/@base-ui/utils/esm/useEnhancedClickHandler.js
8997 var React39 = __toESM(require_react(), 1);
8998 function useEnhancedClickHandler(handler) {
8999 const lastClickInteractionTypeRef = React39.useRef("");
9000 const handlePointerDown = React39.useCallback((event) => {
9001 if (event.defaultPrevented) {
9002 return;
9003 }
9004 lastClickInteractionTypeRef.current = event.pointerType;
9005 handler(event, event.pointerType);
9006 }, [handler]);
9007 const handleClick = React39.useCallback((event) => {
9008 if (event.detail === 0) {
9009 handler(event, "keyboard");
9010 return;
9011 }
9012 if ("pointerType" in event) {
9013 handler(event, event.pointerType);
9014 } else {
9015 handler(event, lastClickInteractionTypeRef.current);
9016 }
9017 lastClickInteractionTypeRef.current = "";
9018 }, [handler]);
9019 return {
9020 onClick: handleClick,
9021 onPointerDown: handlePointerDown
9022 };
9023 }
9024
9025 // node_modules/@base-ui/react/esm/utils/useOpenInteractionType.js
9026 function useOpenMethodTriggerProps(open, setOpenMethod) {
9027 const handleTriggerClick = useStableCallback((_, interactionType) => {
9028 const isOpen = typeof open === "function" ? open() : open;
9029 if (!isOpen) {
9030 setOpenMethod(interactionType || // On iOS Safari, the hitslop around touch targets means tapping outside an element's
9031 // bounds does not fire `pointerdown` but does fire `mousedown`. The `interactionType`
9032 // will be "" in that case.
9033 (isIOS ? "touch" : ""));
9034 }
9035 });
9036 const {
9037 onClick,
9038 onPointerDown
9039 } = useEnhancedClickHandler(handleTriggerClick);
9040 return React40.useMemo(() => ({
9041 onClick,
9042 onPointerDown
9043 }), [onClick, onPointerDown]);
9044 }
9045
9046 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
9047 var React41 = __toESM(require_react(), 1);
9048
9049 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
9050 var baseArrow = (options) => ({
9051 name: "arrow",
9052 options,
9053 async fn(state) {
9054 const {
9055 x: x2,
9056 y: y2,
9057 placement,
9058 rects,
9059 platform: platform3,
9060 elements,
9061 middlewareData
9062 } = state;
9063 const {
9064 element,
9065 padding = 0,
9066 offsetParent = "real"
9067 } = evaluate(options, state) || {};
9068 if (element == null) {
9069 return {};
9070 }
9071 const paddingObject = getPaddingObject(padding);
9072 const coords = {
9073 x: x2,
9074 y: y2
9075 };
9076 const axis = getAlignmentAxis(placement);
9077 const length = getAxisLength(axis);
9078 const arrowDimensions = await platform3.getDimensions(element);
9079 const isYAxis = axis === "y";
9080 const minProp = isYAxis ? "top" : "left";
9081 const maxProp = isYAxis ? "bottom" : "right";
9082 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
9083 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
9084 const startDiff = coords[axis] - rects.reference[axis];
9085 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
9086 let clientSize = elements.floating[clientProp] || rects.floating[length];
9087 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
9088 clientSize = elements.floating[clientProp] || rects.floating[length];
9089 }
9090 const centerToReference = endDiff / 2 - startDiff / 2;
9091 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
9092 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
9093 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
9094 const min2 = minPadding;
9095 const max2 = clientSize - arrowDimensions[length] - maxPadding;
9096 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
9097 const offset4 = clamp(min2, center, max2);
9098 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
9099 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
9100 return {
9101 [axis]: coords[axis] + alignmentOffset,
9102 data: {
9103 [axis]: offset4,
9104 centerOffset: center - offset4 - alignmentOffset,
9105 ...shouldAddOffset && {
9106 alignmentOffset
9107 }
9108 },
9109 reset: shouldAddOffset
9110 };
9111 }
9112 });
9113 var arrow4 = (options, deps) => ({
9114 ...baseArrow(options),
9115 options: [options, deps]
9116 });
9117
9118 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
9119 var hide4 = {
9120 name: "hide",
9121 async fn(state) {
9122 const {
9123 width,
9124 height,
9125 x: x2,
9126 y: y2
9127 } = state.rects.reference;
9128 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
9129 const nativeHideResult = await hide3().fn(state);
9130 return {
9131 data: {
9132 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
9133 }
9134 };
9135 }
9136 };
9137
9138 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
9139 var DEFAULT_SIDES = {
9140 sideX: "left",
9141 sideY: "top"
9142 };
9143 var adaptiveOrigin = {
9144 name: "adaptiveOrigin",
9145 async fn(state) {
9146 const {
9147 x: rawX,
9148 y: rawY,
9149 rects: {
9150 floating: floatRect
9151 },
9152 elements: {
9153 floating
9154 },
9155 platform: platform3,
9156 strategy,
9157 placement
9158 } = state;
9159 const win = getWindow(floating);
9160 const styles = win.getComputedStyle(floating);
9161 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
9162 if (!hasTransition) {
9163 return {
9164 x: rawX,
9165 y: rawY,
9166 data: DEFAULT_SIDES
9167 };
9168 }
9169 const offsetParent = await platform3.getOffsetParent?.(floating);
9170 let offsetDimensions = {
9171 width: 0,
9172 height: 0
9173 };
9174 if (strategy === "fixed" && win?.visualViewport) {
9175 offsetDimensions = {
9176 width: win.visualViewport.width,
9177 height: win.visualViewport.height
9178 };
9179 } else if (offsetParent === win) {
9180 const doc = ownerDocument(floating);
9181 offsetDimensions = {
9182 width: doc.documentElement.clientWidth,
9183 height: doc.documentElement.clientHeight
9184 };
9185 } else if (await platform3.isElement?.(offsetParent)) {
9186 offsetDimensions = await platform3.getDimensions(offsetParent);
9187 }
9188 const currentSide = getSide(placement);
9189 let x2 = rawX;
9190 let y2 = rawY;
9191 if (currentSide === "left") {
9192 x2 = offsetDimensions.width - (rawX + floatRect.width);
9193 }
9194 if (currentSide === "top") {
9195 y2 = offsetDimensions.height - (rawY + floatRect.height);
9196 }
9197 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
9198 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
9199 return {
9200 x: x2,
9201 y: y2,
9202 data: {
9203 sideX,
9204 sideY
9205 }
9206 };
9207 }
9208 };
9209
9210 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
9211 function getLogicalSide(sideParam, renderedSide, isRtl) {
9212 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
9213 const logicalRight = isRtl ? "inline-start" : "inline-end";
9214 const logicalLeft = isRtl ? "inline-end" : "inline-start";
9215 return {
9216 top: "top",
9217 right: isLogicalSideParam ? logicalRight : "right",
9218 bottom: "bottom",
9219 left: isLogicalSideParam ? logicalLeft : "left"
9220 }[renderedSide];
9221 }
9222 function getOffsetData(state, sideParam, isRtl) {
9223 const {
9224 rects,
9225 placement
9226 } = state;
9227 const data = {
9228 side: getLogicalSide(sideParam, getSide(placement), isRtl),
9229 align: getAlignment(placement) || "center",
9230 anchor: {
9231 width: rects.reference.width,
9232 height: rects.reference.height
9233 },
9234 positioner: {
9235 width: rects.floating.width,
9236 height: rects.floating.height
9237 }
9238 };
9239 return data;
9240 }
9241 function useAnchorPositioning(params) {
9242 const {
9243 // Public parameters
9244 anchor,
9245 positionMethod = "absolute",
9246 side: sideParam = "bottom",
9247 sideOffset = 0,
9248 align = "center",
9249 alignOffset = 0,
9250 collisionBoundary,
9251 collisionPadding: collisionPaddingParam = 5,
9252 sticky = false,
9253 arrowPadding = 5,
9254 disableAnchorTracking = false,
9255 inline: inlineMiddleware,
9256 // Private parameters
9257 keepMounted = false,
9258 floatingRootContext,
9259 mounted,
9260 collisionAvoidance,
9261 shiftCrossAxis = false,
9262 nodeId,
9263 adaptiveOrigin: adaptiveOrigin2,
9264 lazyFlip = false,
9265 externalTree
9266 } = params;
9267 const [mountSide, setMountSide] = React41.useState(null);
9268 if (!mounted && mountSide !== null) {
9269 setMountSide(null);
9270 }
9271 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
9272 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
9273 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
9274 const anchorFn = typeof anchor === "function" ? anchor : void 0;
9275 const anchorFnCallback = useStableCallback(anchorFn);
9276 const anchorDep = anchorFn ? anchorFnCallback : anchor;
9277 const anchorValueRef = useValueAsRef(anchor);
9278 const mountedRef = useValueAsRef(mounted);
9279 const direction = useDirection();
9280 const isRtl = direction === "rtl";
9281 const side = mountSide || {
9282 top: "top",
9283 right: "right",
9284 bottom: "bottom",
9285 left: "left",
9286 "inline-end": isRtl ? "left" : "right",
9287 "inline-start": isRtl ? "right" : "left"
9288 }[sideParam];
9289 const placement = align === "center" ? side : `${side}-${align}`;
9290 let collisionPadding = collisionPaddingParam;
9291 const bias = 1;
9292 const biasTop = sideParam === "bottom" ? bias : 0;
9293 const biasBottom = sideParam === "top" ? bias : 0;
9294 const biasLeft = sideParam === "right" ? bias : 0;
9295 const biasRight = sideParam === "left" ? bias : 0;
9296 if (typeof collisionPadding === "number") {
9297 collisionPadding = {
9298 top: collisionPadding + biasTop,
9299 right: collisionPadding + biasRight,
9300 bottom: collisionPadding + biasBottom,
9301 left: collisionPadding + biasLeft
9302 };
9303 } else if (collisionPadding) {
9304 collisionPadding = {
9305 top: (collisionPadding.top || 0) + biasTop,
9306 right: (collisionPadding.right || 0) + biasRight,
9307 bottom: (collisionPadding.bottom || 0) + biasBottom,
9308 left: (collisionPadding.left || 0) + biasLeft
9309 };
9310 }
9311 const commonCollisionProps = {
9312 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
9313 padding: collisionPadding
9314 };
9315 const arrowRef = React41.useRef(null);
9316 const sideOffsetRef = useValueAsRef(sideOffset);
9317 const alignOffsetRef = useValueAsRef(alignOffset);
9318 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
9319 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
9320 const middleware = [];
9321 if (inlineMiddleware) {
9322 middleware.push(inlineMiddleware);
9323 }
9324 middleware.push(offset3((state) => {
9325 const data = getOffsetData(state, sideParam, isRtl);
9326 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
9327 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
9328 return {
9329 mainAxis: sideAxis,
9330 crossAxis: alignAxis,
9331 alignmentAxis: alignAxis
9332 };
9333 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
9334 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
9335 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
9336 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
9337 ...commonCollisionProps,
9338 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
9339 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
9340 padding: {
9341 top: collisionPadding.top + bias,
9342 right: collisionPadding.right + bias,
9343 bottom: collisionPadding.bottom + bias,
9344 left: collisionPadding.left + bias
9345 },
9346 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
9347 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
9348 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
9349 });
9350 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
9351 const html = ownerDocument(data.elements.floating).documentElement;
9352 return {
9353 ...commonCollisionProps,
9354 // Use the Layout Viewport to avoid shifting around when pinch-zooming
9355 // for context menus.
9356 rootBoundary: shiftCrossAxis ? {
9357 x: 0,
9358 y: 0,
9359 width: html.clientWidth,
9360 height: html.clientHeight
9361 } : void 0,
9362 mainAxis: collisionAvoidanceAlign !== "none",
9363 crossAxis: crossAxisShiftEnabled,
9364 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
9365 if (!arrowRef.current) {
9366 return {};
9367 }
9368 const {
9369 width,
9370 height
9371 } = arrowRef.current.getBoundingClientRect();
9372 const sideAxis = getSideAxis(getSide(limitData.placement));
9373 const arrowSize = sideAxis === "y" ? width : height;
9374 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
9375 return {
9376 offset: arrowSize / 2 + offsetAmount / 2
9377 };
9378 })
9379 };
9380 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
9381 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
9382 middleware.push(shiftMiddleware, flipMiddleware);
9383 } else {
9384 middleware.push(flipMiddleware, shiftMiddleware);
9385 }
9386 middleware.push(size3({
9387 ...commonCollisionProps,
9388 apply({
9389 elements: {
9390 floating
9391 },
9392 availableWidth,
9393 availableHeight,
9394 rects
9395 }) {
9396 if (!mountedRef.current) {
9397 return;
9398 }
9399 const floatingStyle = floating.style;
9400 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
9401 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
9402 const dpr = getWindow(floating).devicePixelRatio || 1;
9403 const {
9404 x: x3,
9405 y: y3,
9406 width,
9407 height
9408 } = rects.reference;
9409 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
9410 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
9411 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
9412 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
9413 }
9414 }), arrow4((state) => ({
9415 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
9416 // we'll create a fake element.
9417 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
9418 padding: arrowPadding,
9419 offsetParent: "floating"
9420 }), [arrowPadding]), {
9421 name: "transformOrigin",
9422 fn(state) {
9423 const {
9424 elements: elements2,
9425 middlewareData: middlewareData2,
9426 placement: renderedPlacement2,
9427 rects,
9428 y: y3
9429 } = state;
9430 const currentRenderedSide = getSide(renderedPlacement2);
9431 const currentRenderedAxis = getSideAxis(currentRenderedSide);
9432 const arrowEl = arrowRef.current;
9433 const arrowX = middlewareData2.arrow?.x || 0;
9434 const arrowY = middlewareData2.arrow?.y || 0;
9435 const arrowWidth = arrowEl?.clientWidth || 0;
9436 const arrowHeight = arrowEl?.clientHeight || 0;
9437 const transformX = arrowX + arrowWidth / 2;
9438 const transformY = arrowY + arrowHeight / 2;
9439 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
9440 const halfAnchorHeight = rects.reference.height / 2;
9441 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
9442 const isOverlappingAnchor = shiftY > sideOffsetValue;
9443 const adjacentTransformOrigin = {
9444 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
9445 bottom: `${transformX}px ${-sideOffsetValue}px`,
9446 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
9447 right: `${-sideOffsetValue}px ${transformY}px`
9448 }[currentRenderedSide];
9449 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
9450 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
9451 return {};
9452 }
9453 }, hide4, adaptiveOrigin2);
9454 useIsoLayoutEffect(() => {
9455 if (!mounted && floatingRootContext) {
9456 floatingRootContext.update({
9457 referenceElement: null,
9458 floatingElement: null,
9459 domReferenceElement: null,
9460 positionReference: null
9461 });
9462 }
9463 }, [mounted, floatingRootContext]);
9464 const autoUpdateOptions = React41.useMemo(() => ({
9465 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
9466 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
9467 }), [disableAnchorTracking]);
9468 const {
9469 refs,
9470 elements,
9471 x: x2,
9472 y: y2,
9473 middlewareData,
9474 update: update2,
9475 placement: renderedPlacement,
9476 context,
9477 isPositioned,
9478 floatingStyles: originalFloatingStyles
9479 } = useFloating2({
9480 rootContext: floatingRootContext,
9481 open: keepMounted ? mounted : void 0,
9482 placement,
9483 middleware,
9484 strategy: positionMethod,
9485 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
9486 nodeId,
9487 externalTree
9488 });
9489 const {
9490 sideX,
9491 sideY
9492 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
9493 const resolvedPosition = isPositioned ? positionMethod : "fixed";
9494 const floatingStyles = React41.useMemo(() => {
9495 const base = adaptiveOrigin2 ? {
9496 position: resolvedPosition,
9497 [sideX]: x2,
9498 [sideY]: y2
9499 } : {
9500 position: resolvedPosition,
9501 ...originalFloatingStyles
9502 };
9503 if (!isPositioned) {
9504 base.opacity = 0;
9505 }
9506 return base;
9507 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
9508 const registeredPositionReferenceRef = React41.useRef(null);
9509 useIsoLayoutEffect(() => {
9510 if (!mounted) {
9511 return;
9512 }
9513 const anchorValue = anchorValueRef.current;
9514 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
9515 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
9516 const finalAnchor = unwrappedElement || null;
9517 if (finalAnchor !== registeredPositionReferenceRef.current) {
9518 refs.setPositionReference(finalAnchor);
9519 registeredPositionReferenceRef.current = finalAnchor;
9520 }
9521 }, [mounted, refs, anchorDep, anchorValueRef]);
9522 React41.useEffect(() => {
9523 if (!mounted) {
9524 return;
9525 }
9526 const anchorValue = anchorValueRef.current;
9527 if (typeof anchorValue === "function") {
9528 return;
9529 }
9530 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
9531 refs.setPositionReference(anchorValue.current);
9532 registeredPositionReferenceRef.current = anchorValue.current;
9533 }
9534 }, [mounted, refs, anchorDep, anchorValueRef]);
9535 React41.useEffect(() => {
9536 if (keepMounted && mounted && elements.domReference && elements.floating) {
9537 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
9538 }
9539 return void 0;
9540 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
9541 const renderedSide = getSide(renderedPlacement);
9542 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
9543 const renderedAlign = getAlignment(renderedPlacement) || "center";
9544 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
9545 useIsoLayoutEffect(() => {
9546 if (lazyFlip && mounted && isPositioned) {
9547 setMountSide(renderedSide);
9548 }
9549 }, [lazyFlip, mounted, isPositioned, renderedSide]);
9550 const arrowStyles = React41.useMemo(() => ({
9551 position: "absolute",
9552 top: middlewareData.arrow?.y,
9553 left: middlewareData.arrow?.x
9554 }), [middlewareData.arrow]);
9555 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
9556 return React41.useMemo(() => ({
9557 positionerStyles: floatingStyles,
9558 arrowStyles,
9559 arrowRef,
9560 arrowUncentered,
9561 side: logicalRenderedSide,
9562 align: renderedAlign,
9563 physicalSide: renderedSide,
9564 anchorHidden,
9565 refs,
9566 context,
9567 isPositioned,
9568 update: update2
9569 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
9570 }
9571 function isRef(param) {
9572 return param != null && "current" in param;
9573 }
9574
9575 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
9576 function getDisabledMountTransitionStyles(transitionStatus) {
9577 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
9578 }
9579
9580 // node_modules/@base-ui/react/esm/utils/usePositioner.js
9581 function usePositioner(componentProps, state, {
9582 styles,
9583 transitionStatus,
9584 props,
9585 refs,
9586 hidden,
9587 inert = false
9588 }) {
9589 const style = {
9590 ...styles
9591 };
9592 if (inert) {
9593 style.pointerEvents = "none";
9594 }
9595 return useRenderElement("div", componentProps, {
9596 state,
9597 ref: refs,
9598 props: [{
9599 role: "presentation",
9600 hidden,
9601 style
9602 }, getDisabledMountTransitionStyles(transitionStatus), props],
9603 stateAttributesMapping: popupStateMapping
9604 });
9605 }
9606
9607 // node_modules/@base-ui/react/esm/utils/useAnchoredPopupScrollLock.js
9608 var React42 = __toESM(require_react(), 1);
9609 var VIEWPORT_WIDTH_TOLERANCE_PX = 20;
9610 function useAnchoredPopupScrollLock(enabled, touchOpen, positionerElement, referenceElement) {
9611 const [touchOpenShouldLockScroll, setTouchOpenShouldLockScroll] = React42.useState(false);
9612 useIsoLayoutEffect(() => {
9613 if (!enabled || !touchOpen || positionerElement == null) {
9614 setTouchOpenShouldLockScroll(false);
9615 return;
9616 }
9617 const viewportWidth = ownerDocument(positionerElement).documentElement.clientWidth;
9618 const popupWidth = positionerElement.offsetWidth;
9619 setTouchOpenShouldLockScroll(viewportWidth > 0 && popupWidth > 0 && popupWidth >= viewportWidth - VIEWPORT_WIDTH_TOLERANCE_PX);
9620 }, [enabled, touchOpen, positionerElement]);
9621 useScrollLock(enabled && (!touchOpen || touchOpenShouldLockScroll), referenceElement);
9622 }
9623
9624 // node_modules/@base-ui/react/esm/button/Button.js
9625 var React43 = __toESM(require_react(), 1);
9626 var Button = /* @__PURE__ */ React43.forwardRef(function Button2(componentProps, forwardedRef) {
9627 const {
9628 render: render4,
9629 className,
9630 disabled: disabled2 = false,
9631 focusableWhenDisabled = false,
9632 nativeButton = true,
9633 style,
9634 ...elementProps
9635 } = componentProps;
9636 const {
9637 getButtonProps,
9638 buttonRef
9639 } = useButton({
9640 disabled: disabled2,
9641 focusableWhenDisabled,
9642 native: nativeButton
9643 });
9644 const state = {
9645 disabled: disabled2
9646 };
9647 return useRenderElement("button", componentProps, {
9648 state,
9649 ref: [forwardedRef, buttonRef],
9650 props: [elementProps, getButtonProps]
9651 });
9652 });
9653 if (true) Button.displayName = "Button";
9654
9655 // node_modules/@base-ui/react/esm/collapsible/index.parts.js
9656 var index_parts_exports = {};
9657 __export(index_parts_exports, {
9658 Panel: () => CollapsiblePanel,
9659 Root: () => CollapsibleRoot,
9660 Trigger: () => CollapsibleTrigger
9661 });
9662
9663 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
9664 var React44 = __toESM(require_react(), 1);
9665
9666 // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js
9667 var collapsibleStateAttributesMapping = {
9668 ...collapsibleOpenStateMapping,
9669 ...transitionStatusMapping
9670 };
9671
9672 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
9673 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
9674 var CollapsibleRoot = /* @__PURE__ */ React44.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
9675 const {
9676 render: render4,
9677 className,
9678 defaultOpen = false,
9679 disabled: disabled2 = false,
9680 onOpenChange: onOpenChangeProp,
9681 open,
9682 style,
9683 ...elementProps
9684 } = componentProps;
9685 const onOpenChange = useStableCallback(onOpenChangeProp);
9686 const collapsible = useCollapsibleRoot({
9687 open,
9688 defaultOpen,
9689 onOpenChange,
9690 disabled: disabled2
9691 });
9692 const state = React44.useMemo(() => ({
9693 open: collapsible.open,
9694 disabled: collapsible.disabled,
9695 transitionStatus: collapsible.transitionStatus
9696 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
9697 const contextValue = React44.useMemo(() => ({
9698 ...collapsible,
9699 onOpenChange,
9700 state
9701 }), [collapsible, onOpenChange, state]);
9702 const element = useRenderElement("div", componentProps, {
9703 state,
9704 ref: forwardedRef,
9705 props: elementProps,
9706 stateAttributesMapping: collapsibleStateAttributesMapping
9707 });
9708 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CollapsibleRootContext.Provider, {
9709 value: contextValue,
9710 children: element
9711 });
9712 });
9713 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
9714
9715 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js
9716 var React45 = __toESM(require_react(), 1);
9717 var stateAttributesMapping = {
9718 ...triggerOpenStateMapping,
9719 ...transitionStatusMapping
9720 };
9721 var CollapsibleTrigger = /* @__PURE__ */ React45.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
9722 const {
9723 panelId,
9724 open,
9725 handleTrigger,
9726 state,
9727 disabled: contextDisabled
9728 } = useCollapsibleRootContext();
9729 const {
9730 className,
9731 disabled: disabled2 = contextDisabled,
9732 id,
9733 render: render4,
9734 nativeButton = true,
9735 style,
9736 ...elementProps
9737 } = componentProps;
9738 const {
9739 getButtonProps,
9740 buttonRef
9741 } = useButton({
9742 disabled: disabled2,
9743 focusableWhenDisabled: true,
9744 native: nativeButton
9745 });
9746 const element = useRenderElement("button", componentProps, {
9747 state,
9748 ref: [forwardedRef, buttonRef],
9749 props: [{
9750 "aria-controls": open ? panelId : void 0,
9751 "aria-expanded": open,
9752 onClick: handleTrigger
9753 }, elementProps, getButtonProps],
9754 stateAttributesMapping
9755 });
9756 return element;
9757 });
9758 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
9759
9760 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
9761 var React46 = __toESM(require_react(), 1);
9762
9763 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js
9764 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
9765 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
9766 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
9767 return CollapsiblePanelCssVars2;
9768 })({});
9769
9770 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
9771 var CollapsiblePanel = /* @__PURE__ */ React46.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
9772 const {
9773 className,
9774 hiddenUntilFound: hiddenUntilFoundProp,
9775 keepMounted: keepMountedProp,
9776 render: render4,
9777 id: idProp,
9778 style,
9779 ...elementProps
9780 } = componentProps;
9781 if (true) {
9782 useIsoLayoutEffect(() => {
9783 if (hiddenUntilFoundProp && keepMountedProp === false) {
9784 warn("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.");
9785 }
9786 }, [hiddenUntilFoundProp, keepMountedProp]);
9787 }
9788 const {
9789 mounted,
9790 onOpenChange,
9791 open,
9792 panelId,
9793 setMounted,
9794 setPanelIdState,
9795 setOpen,
9796 state,
9797 transitionStatus
9798 } = useCollapsibleRootContext();
9799 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
9800 const keepMounted = keepMountedProp ?? false;
9801 useIsoLayoutEffect(() => {
9802 if (idProp) {
9803 setPanelIdState(idProp);
9804 return () => {
9805 setPanelIdState(void 0);
9806 };
9807 }
9808 return void 0;
9809 }, [idProp, setPanelIdState]);
9810 const {
9811 height,
9812 props,
9813 ref,
9814 shouldPreventOpenAnimation,
9815 shouldRender,
9816 transitionStatus: panelTransitionStatus,
9817 width
9818 } = useCollapsiblePanel({
9819 externalRef: forwardedRef,
9820 hiddenUntilFound,
9821 id: panelId,
9822 keepMounted,
9823 mounted,
9824 onOpenChange,
9825 open,
9826 setMounted,
9827 setOpen,
9828 transitionStatus
9829 });
9830 const panelState = {
9831 ...state,
9832 transitionStatus: panelTransitionStatus
9833 };
9834 const resolvedStyle = resolveStyle(style, panelState);
9835 const element = useRenderElement("div", {
9836 ...componentProps,
9837 style: void 0
9838 }, {
9839 state: panelState,
9840 ref,
9841 props: [
9842 props,
9843 {
9844 style: {
9845 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
9846 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
9847 }
9848 },
9849 elementProps,
9850 resolvedStyle ? {
9851 style: resolvedStyle
9852 } : void 0,
9853 // Resolve the public `style` prop so temporary `animationName: 'none'`
9854 // can still win after user's inline styles have been merged.
9855 shouldPreventOpenAnimation ? {
9856 style: {
9857 animationName: "none"
9858 }
9859 } : void 0
9860 ],
9861 stateAttributesMapping: collapsibleStateAttributesMapping
9862 });
9863 if (!shouldRender) {
9864 return null;
9865 }
9866 return element;
9867 });
9868 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
9869
9870 // node_modules/@base-ui/react/esm/toolbar/root/ToolbarRootContext.js
9871 var React47 = __toESM(require_react(), 1);
9872 var ToolbarRootContext = /* @__PURE__ */ React47.createContext(void 0);
9873 if (true) ToolbarRootContext.displayName = "ToolbarRootContext";
9874 function useToolbarRootContext(optional) {
9875 const context = React47.useContext(ToolbarRootContext);
9876 if (context === void 0 && !optional) {
9877 throw new Error(true ? "Base UI: ToolbarRootContext is missing. Toolbar parts must be placed within <Toolbar.Root>." : formatErrorMessage_default(69));
9878 }
9879 return context;
9880 }
9881
9882 // node_modules/@base-ui/react/esm/utils/popups/useTriggerFocusGuards.js
9883 var React48 = __toESM(require_react(), 1);
9884 var ReactDOM5 = __toESM(require_react_dom(), 1);
9885 function useTriggerFocusGuards(store, triggerElementRef) {
9886 const preFocusGuardRef = React48.useRef(null);
9887 function handlePreFocusGuardFocus(event) {
9888 ReactDOM5.flushSync(() => {
9889 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent, event.currentTarget));
9890 });
9891 const previousTabbable = getTabbableBeforeElement(preFocusGuardRef.current);
9892 previousTabbable?.focus();
9893 }
9894 function handleFocusTargetFocus(event) {
9895 const positionerElement = store.select("positionerElement");
9896 if (positionerElement && isOutsideEvent(event, positionerElement)) {
9897 store.context.beforeContentFocusGuardRef.current?.focus();
9898 } else {
9899 ReactDOM5.flushSync(() => {
9900 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent, event.currentTarget));
9901 });
9902 let nextTabbable = getTabbableAfterElement(store.context.triggerFocusTargetRef.current || triggerElementRef.current);
9903 while (nextTabbable !== null && contains(positionerElement, nextTabbable)) {
9904 const prevTabbable = nextTabbable;
9905 nextTabbable = getNextTabbable(nextTabbable);
9906 if (nextTabbable === prevTabbable) {
9907 break;
9908 }
9909 }
9910 nextTabbable?.focus();
9911 }
9912 }
9913 return {
9914 preFocusGuardRef,
9915 handlePreFocusGuardFocus,
9916 handleFocusTargetFocus
9917 };
9918 }
9919
9920 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
9921 var React51 = __toESM(require_react(), 1);
9922 var ReactDOM6 = __toESM(require_react_dom(), 1);
9923
9924 // node_modules/@base-ui/utils/esm/usePreviousValue.js
9925 var React49 = __toESM(require_react(), 1);
9926 function usePreviousValue(value) {
9927 const [state, setState] = React49.useState({
9928 current: value,
9929 previous: null
9930 });
9931 if (value !== state.current) {
9932 setState({
9933 current: value,
9934 previous: state.current
9935 });
9936 }
9937 return state.previous;
9938 }
9939
9940 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
9941 var React50 = __toESM(require_react(), 1);
9942
9943 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
9944 function getCssDimensions2(element) {
9945 const css = getComputedStyle2(element);
9946 let width = parseFloat(css.width) || 0;
9947 let height = parseFloat(css.height) || 0;
9948 const hasOffset = isHTMLElement(element);
9949 const offsetWidth = hasOffset ? element.offsetWidth : width;
9950 const offsetHeight = hasOffset ? element.offsetHeight : height;
9951 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
9952 if (shouldFallback) {
9953 width = offsetWidth;
9954 height = offsetHeight;
9955 }
9956 return {
9957 width,
9958 height
9959 };
9960 }
9961
9962 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
9963 var DEFAULT_ENABLED = () => true;
9964 function usePopupAutoResize(parameters) {
9965 const {
9966 popupElement,
9967 positionerElement,
9968 content,
9969 mounted,
9970 enabled = DEFAULT_ENABLED,
9971 onMeasureLayout: onMeasureLayoutParam,
9972 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
9973 side,
9974 direction
9975 } = parameters;
9976 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
9977 const animationFrame = useAnimationFrame();
9978 const committedDimensionsRef = React50.useRef(null);
9979 const liveDimensionsRef = React50.useRef(null);
9980 const isInitialRenderRef = React50.useRef(true);
9981 const restoreAnchoringStylesRef = React50.useRef(NOOP);
9982 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
9983 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
9984 const anchoringStyles = React50.useMemo(() => {
9985 let isOriginSide = side === "top";
9986 let isPhysicalLeft = side === "left";
9987 if (direction === "rtl") {
9988 isOriginSide = isOriginSide || side === "inline-end";
9989 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
9990 } else {
9991 isOriginSide = isOriginSide || side === "inline-start";
9992 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
9993 }
9994 return isOriginSide ? {
9995 position: "absolute",
9996 [side === "top" ? "bottom" : "top"]: "0",
9997 [isPhysicalLeft ? "right" : "left"]: "0"
9998 } : EMPTY_OBJECT;
9999 }, [side, direction]);
10000 useIsoLayoutEffect(() => {
10001 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
10002 restoreAnchoringStylesRef.current = NOOP;
10003 isInitialRenderRef.current = true;
10004 committedDimensionsRef.current = null;
10005 liveDimensionsRef.current = null;
10006 return void 0;
10007 }
10008 if (!popupElement || !positionerElement) {
10009 return void 0;
10010 }
10011 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
10012 const observer = new ResizeObserver((entries) => {
10013 const entry = entries[0];
10014 if (entry) {
10015 liveDimensionsRef.current = {
10016 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
10017 height: Math.ceil(entry.borderBoxSize[0].blockSize)
10018 };
10019 }
10020 });
10021 observer.observe(popupElement);
10022 setPopupCssSize(popupElement, "auto");
10023 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
10024 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
10025 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
10026 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
10027 "--available-width": "max-content",
10028 "--available-height": "max-content"
10029 });
10030 function restoreMeasurementOverrides() {
10031 restorePopupPosition();
10032 restorePopupTransform();
10033 restorePositionerAvailableSize();
10034 }
10035 function restoreMeasurementOverridesIncludingScale() {
10036 restoreMeasurementOverrides();
10037 restorePopupScale();
10038 }
10039 onMeasureLayout?.();
10040 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
10041 setPositionerCssSize(positionerElement, "max-content");
10042 const dimensions = getCssDimensions2(popupElement);
10043 committedDimensionsRef.current = dimensions;
10044 setPositionerCssSize(positionerElement, dimensions);
10045 restoreMeasurementOverridesIncludingScale();
10046 onMeasureLayoutComplete?.(null, dimensions);
10047 isInitialRenderRef.current = false;
10048 return () => {
10049 observer.disconnect();
10050 restoreAnchoringStylesRef.current();
10051 restoreAnchoringStylesRef.current = NOOP;
10052 };
10053 }
10054 setPopupCssSize(popupElement, "auto");
10055 setPositionerCssSize(positionerElement, "max-content");
10056 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
10057 const newDimensions = getCssDimensions2(popupElement);
10058 committedDimensionsRef.current = newDimensions;
10059 if (!previousDimensions) {
10060 setPositionerCssSize(positionerElement, newDimensions);
10061 restoreMeasurementOverridesIncludingScale();
10062 onMeasureLayoutComplete?.(null, newDimensions);
10063 return () => {
10064 observer.disconnect();
10065 animationFrame.cancel();
10066 restoreAnchoringStylesRef.current();
10067 restoreAnchoringStylesRef.current = NOOP;
10068 };
10069 }
10070 setPopupCssSize(popupElement, previousDimensions);
10071 restoreMeasurementOverridesIncludingScale();
10072 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
10073 setPositionerCssSize(positionerElement, newDimensions);
10074 const abortController = new AbortController();
10075 animationFrame.request(() => {
10076 setPopupCssSize(popupElement, newDimensions);
10077 runOnceAnimationsFinish(() => {
10078 popupElement.style.setProperty("--popup-width", "auto");
10079 popupElement.style.setProperty("--popup-height", "auto");
10080 }, abortController.signal);
10081 });
10082 return () => {
10083 observer.disconnect();
10084 abortController.abort();
10085 animationFrame.cancel();
10086 restoreAnchoringStylesRef.current();
10087 restoreAnchoringStylesRef.current = NOOP;
10088 };
10089 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
10090 }
10091 function overrideElementStyle(element, property, value) {
10092 const originalValue = element.style.getPropertyValue(property);
10093 element.style.setProperty(property, value);
10094 return () => {
10095 element.style.setProperty(property, originalValue);
10096 };
10097 }
10098 function applyElementStyles(element, styles) {
10099 const restorers = [];
10100 for (const [key, value] of Object.entries(styles)) {
10101 restorers.push(overrideElementStyle(element, key, value));
10102 }
10103 return restorers.length ? () => {
10104 restorers.forEach((restore) => restore());
10105 } : NOOP;
10106 }
10107 function setPopupCssSize(popupElement, size4) {
10108 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
10109 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
10110 popupElement.style.setProperty("--popup-width", width);
10111 popupElement.style.setProperty("--popup-height", height);
10112 }
10113 function setPositionerCssSize(positionerElement, size4) {
10114 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
10115 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
10116 positionerElement.style.setProperty("--positioner-width", width);
10117 positionerElement.style.setProperty("--positioner-height", height);
10118 }
10119
10120 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
10121 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
10122 function usePopupViewport(parameters) {
10123 const {
10124 store,
10125 side,
10126 cssVars,
10127 children
10128 } = parameters;
10129 const direction = useDirection();
10130 const activeTrigger = store.useState("activeTriggerElement");
10131 const activeTriggerId = store.useState("activeTriggerId");
10132 const open = store.useState("open");
10133 const payload = store.useState("payload");
10134 const mounted = store.useState("mounted");
10135 const popupElement = store.useState("popupElement");
10136 const positionerElement = store.useState("positionerElement");
10137 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
10138 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
10139 const capturedNodeRef = React51.useRef(null);
10140 const [previousContentNode, setPreviousContentNode] = React51.useState(null);
10141 const [newTriggerOffset, setNewTriggerOffset] = React51.useState(null);
10142 const currentContainerRef = React51.useRef(null);
10143 const previousContainerRef = React51.useRef(null);
10144 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
10145 const cleanupFrame = useAnimationFrame();
10146 const [previousContentDimensions, setPreviousContentDimensions] = React51.useState(null);
10147 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React51.useState(false);
10148 useIsoLayoutEffect(() => {
10149 store.set("hasViewport", true);
10150 return () => {
10151 store.set("hasViewport", false);
10152 };
10153 }, [store]);
10154 const handleMeasureLayout = useStableCallback(() => {
10155 currentContainerRef.current?.style.setProperty("animation", "none");
10156 currentContainerRef.current?.style.setProperty("transition", "none");
10157 previousContainerRef.current?.style.setProperty("display", "none");
10158 });
10159 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
10160 currentContainerRef.current?.style.removeProperty("animation");
10161 currentContainerRef.current?.style.removeProperty("transition");
10162 previousContainerRef.current?.style.removeProperty("display");
10163 if (previousDimensions) {
10164 setPreviousContentDimensions(previousDimensions);
10165 }
10166 });
10167 const lastHandledTriggerRef = React51.useRef(null);
10168 useIsoLayoutEffect(() => {
10169 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
10170 setPreviousContentNode(capturedNodeRef.current);
10171 setShowStartingStyleAttribute(true);
10172 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
10173 setNewTriggerOffset(offset4);
10174 cleanupFrame.request(() => {
10175 ReactDOM6.flushSync(() => {
10176 setShowStartingStyleAttribute(false);
10177 });
10178 onAnimationsFinished(() => {
10179 setPreviousContentNode(null);
10180 setPreviousContentDimensions(null);
10181 capturedNodeRef.current = null;
10182 });
10183 });
10184 lastHandledTriggerRef.current = activeTrigger;
10185 }
10186 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
10187 useIsoLayoutEffect(() => {
10188 const source = currentContainerRef.current;
10189 if (!source) {
10190 return;
10191 }
10192 const wrapper = ownerDocument(source).createElement("div");
10193 for (const child of Array.from(source.childNodes)) {
10194 wrapper.appendChild(child.cloneNode(true));
10195 }
10196 capturedNodeRef.current = wrapper;
10197 });
10198 const isTransitioning = previousContentNode != null;
10199 let childrenToRender;
10200 if (!isTransitioning) {
10201 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
10202 "data-current": true,
10203 ref: currentContainerRef,
10204 children
10205 }, currentContentKey);
10206 } else {
10207 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(React51.Fragment, {
10208 children: [/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
10209 "data-previous": true,
10210 inert: inertValue(true),
10211 ref: previousContainerRef,
10212 style: {
10213 ...previousContentDimensions ? {
10214 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
10215 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
10216 } : null,
10217 position: "absolute"
10218 },
10219 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
10220 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
10221 "data-current": true,
10222 ref: currentContainerRef,
10223 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
10224 children
10225 }, currentContentKey)]
10226 });
10227 }
10228 useIsoLayoutEffect(() => {
10229 const container = previousContainerRef.current;
10230 if (!container || !previousContentNode) {
10231 return;
10232 }
10233 container.replaceChildren(...Array.from(previousContentNode.childNodes));
10234 }, [previousContentNode]);
10235 usePopupAutoResize({
10236 popupElement,
10237 positionerElement,
10238 mounted,
10239 content: payload,
10240 onMeasureLayout: handleMeasureLayout,
10241 onMeasureLayoutComplete: handleMeasureLayoutComplete,
10242 side,
10243 direction
10244 });
10245 const state = {
10246 activationDirection: getActivationDirection(newTriggerOffset),
10247 transitioning: isTransitioning
10248 };
10249 return {
10250 children: childrenToRender,
10251 state
10252 };
10253 }
10254 function getActivationDirection(offset4) {
10255 if (!offset4) {
10256 return void 0;
10257 }
10258 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
10259 }
10260 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
10261 if (value > tolerance) {
10262 return positiveLabel;
10263 }
10264 if (value < -tolerance) {
10265 return negativeLabel;
10266 }
10267 return "";
10268 }
10269 function calculateRelativePosition(from, to) {
10270 const fromRect = from.getBoundingClientRect();
10271 const toRect = to.getBoundingClientRect();
10272 const fromCenter = {
10273 x: fromRect.left + fromRect.width / 2,
10274 y: fromRect.top + fromRect.height / 2
10275 };
10276 const toCenter = {
10277 x: toRect.left + toRect.width / 2,
10278 y: toRect.top + toRect.height / 2
10279 };
10280 return {
10281 horizontal: toCenter.x - fromCenter.x,
10282 vertical: toCenter.y - fromCenter.y
10283 };
10284 }
10285 function usePopupContentKey(activeTriggerId, payload) {
10286 const [contentKey, setContentKey] = React51.useState(0);
10287 const previousActiveTriggerIdRef = React51.useRef(activeTriggerId);
10288 const previousPayloadRef = React51.useRef(payload);
10289 const pendingPayloadUpdateRef = React51.useRef(false);
10290 useIsoLayoutEffect(() => {
10291 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
10292 const previousPayload = previousPayloadRef.current;
10293 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
10294 const payloadChanged = payload !== previousPayload;
10295 if (triggerIdChanged) {
10296 setContentKey((value) => value + 1);
10297 pendingPayloadUpdateRef.current = !payloadChanged;
10298 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
10299 setContentKey((value) => value + 1);
10300 pendingPayloadUpdateRef.current = false;
10301 }
10302 previousActiveTriggerIdRef.current = activeTriggerId;
10303 previousPayloadRef.current = payload;
10304 }, [activeTriggerId, payload]);
10305 return `${activeTriggerId ?? "current"}-${contentKey}`;
10306 }
10307
10308 // node_modules/@base-ui/react/esm/popover/index.parts.js
10309 var index_parts_exports2 = {};
10310 __export(index_parts_exports2, {
10311 Arrow: () => PopoverArrow,
10312 Backdrop: () => PopoverBackdrop,
10313 Close: () => PopoverClose,
10314 Description: () => PopoverDescription,
10315 Handle: () => PopoverHandle,
10316 Popup: () => PopoverPopup,
10317 Portal: () => PopoverPortal,
10318 Positioner: () => PopoverPositioner,
10319 Root: () => PopoverRoot,
10320 Title: () => PopoverTitle,
10321 Trigger: () => PopoverTrigger,
10322 Viewport: () => PopoverViewport,
10323 createHandle: () => createPopoverHandle
10324 });
10325
10326 // node_modules/@base-ui/react/esm/popover/root/PopoverRoot.js
10327 var React54 = __toESM(require_react(), 1);
10328
10329 // node_modules/@base-ui/react/esm/popover/root/PopoverRootContext.js
10330 var React52 = __toESM(require_react(), 1);
10331 var PopoverRootContext = /* @__PURE__ */ React52.createContext(void 0);
10332 if (true) PopoverRootContext.displayName = "PopoverRootContext";
10333 function usePopoverRootContext(optional) {
10334 const context = React52.useContext(PopoverRootContext);
10335 if (context === void 0 && !optional) {
10336 throw new Error(true ? "Base UI: PopoverRootContext is missing. Popover parts must be placed within <Popover.Root>." : formatErrorMessage_default(47));
10337 }
10338 return context;
10339 }
10340
10341 // node_modules/@base-ui/react/esm/popover/store/PopoverStore.js
10342 var React53 = __toESM(require_react(), 1);
10343 var ReactDOM7 = __toESM(require_react_dom(), 1);
10344 function createInitialState() {
10345 return {
10346 ...createInitialPopupStoreState(),
10347 disabled: false,
10348 modal: false,
10349 focusManagerModal: false,
10350 instantType: void 0,
10351 openMethod: null,
10352 openChangeReason: null,
10353 titleElementId: void 0,
10354 descriptionElementId: void 0,
10355 stickIfOpen: true,
10356 nested: false,
10357 openOnHover: false,
10358 closeDelay: 0,
10359 hasViewport: false
10360 };
10361 }
10362 var selectors2 = {
10363 ...popupStoreSelectors,
10364 disabled: createSelector((state) => state.disabled),
10365 instantType: createSelector((state) => state.instantType),
10366 openMethod: createSelector((state) => state.openMethod),
10367 openChangeReason: createSelector((state) => state.openChangeReason),
10368 modal: createSelector((state) => state.modal),
10369 focusManagerModal: createSelector((state) => state.focusManagerModal),
10370 stickIfOpen: createSelector((state) => state.stickIfOpen),
10371 titleElementId: createSelector((state) => state.titleElementId),
10372 descriptionElementId: createSelector((state) => state.descriptionElementId),
10373 openOnHover: createSelector((state) => state.openOnHover),
10374 closeDelay: createSelector((state) => state.closeDelay),
10375 hasViewport: createSelector((state) => state.hasViewport)
10376 };
10377 var PopoverStore = class _PopoverStore extends ReactStore {
10378 constructor(initialState, floatingId, nested = false) {
10379 const initial2 = {
10380 ...createInitialState(),
10381 ...initialState
10382 };
10383 const triggerElements = new PopupTriggerMap();
10384 if (initial2.open && initialState?.mounted === void 0) {
10385 initial2.mounted = true;
10386 }
10387 initial2.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
10388 super(initial2, {
10389 popupRef: /* @__PURE__ */ React53.createRef(),
10390 backdropRef: /* @__PURE__ */ React53.createRef(),
10391 internalBackdropRef: /* @__PURE__ */ React53.createRef(),
10392 onOpenChange: void 0,
10393 onOpenChangeComplete: void 0,
10394 triggerFocusTargetRef: /* @__PURE__ */ React53.createRef(),
10395 beforeContentFocusGuardRef: /* @__PURE__ */ React53.createRef(),
10396 stickIfOpenTimeout: new Timeout(),
10397 triggerElements
10398 }, selectors2);
10399 }
10400 setOpen = (nextOpen, eventDetails) => {
10401 const isHover = eventDetails.reason === reason_parts_exports.triggerHover;
10402 const isKeyboardClick = eventDetails.reason === reason_parts_exports.triggerPress && eventDetails.event.detail === 0;
10403 const isDismissClose = !nextOpen && (eventDetails.reason === reason_parts_exports.escapeKey || eventDetails.reason == null);
10404 eventDetails.preventUnmountOnClose = () => {
10405 this.set("preventUnmountingOnClose", true);
10406 };
10407 const activeTriggerId = this.select("activeTriggerId");
10408 if (!nextOpen && eventDetails.reason === reason_parts_exports.closePress && eventDetails.trigger == null && activeTriggerId != null) {
10409 eventDetails.trigger = this.context.triggerElements.getById(activeTriggerId) ?? this.select("activeTriggerElement") ?? void 0;
10410 }
10411 this.context.onOpenChange?.(nextOpen, eventDetails);
10412 if (eventDetails.isCanceled) {
10413 return;
10414 }
10415 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
10416 const changeState = () => {
10417 const updatedState = {
10418 open: nextOpen,
10419 openChangeReason: eventDetails.reason
10420 };
10421 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
10422 this.update(updatedState);
10423 };
10424 if (isHover) {
10425 this.set("stickIfOpen", true);
10426 this.context.stickIfOpenTimeout.start(PATIENT_CLICK_THRESHOLD, () => {
10427 this.set("stickIfOpen", false);
10428 });
10429 ReactDOM7.flushSync(changeState);
10430 } else {
10431 changeState();
10432 }
10433 if (isKeyboardClick || isDismissClose) {
10434 this.set("instantType", isKeyboardClick ? "click" : "dismiss");
10435 } else if (eventDetails.reason === reason_parts_exports.focusOut) {
10436 this.set("instantType", "focus");
10437 } else {
10438 this.set("instantType", void 0);
10439 }
10440 };
10441 static useStore(externalStore, initialState) {
10442 const {
10443 store,
10444 internalStore
10445 } = usePopupStore(externalStore, (floatingId, nested) => new _PopoverStore(initialState, floatingId, nested));
10446 React53.useEffect(() => internalStore?.disposeEffect(), [internalStore]);
10447 return store;
10448 }
10449 disposeEffect = () => {
10450 return this.context.stickIfOpenTimeout.disposeEffect();
10451 };
10452 };
10453
10454 // node_modules/@base-ui/react/esm/popover/root/PopoverRoot.js
10455 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
10456 function PopoverRootComponent({
10457 props
10458 }) {
10459 const {
10460 children,
10461 open: openProp,
10462 defaultOpen = false,
10463 onOpenChange,
10464 onOpenChangeComplete,
10465 modal = false,
10466 handle,
10467 triggerId: triggerIdProp,
10468 defaultTriggerId: defaultTriggerIdProp = null
10469 } = props;
10470 const store = PopoverStore.useStore(handle?.store, {
10471 modal,
10472 open: defaultOpen,
10473 openProp,
10474 activeTriggerId: defaultTriggerIdProp,
10475 triggerIdProp
10476 });
10477 useOnFirstRender(() => {
10478 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
10479 store.update({
10480 open: true,
10481 activeTriggerId: defaultTriggerIdProp
10482 });
10483 }
10484 });
10485 store.useControlledProp("openProp", openProp);
10486 store.useControlledProp("triggerIdProp", triggerIdProp);
10487 const open = store.useState("open");
10488 const mounted = store.useState("mounted");
10489 const payload = store.useState("payload");
10490 const nested = useFloatingParentNodeId() != null;
10491 store.useContextCallback("onOpenChange", onOpenChange);
10492 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
10493 usePopupRootSync(store, open);
10494 useImplicitActiveTrigger(store);
10495 const {
10496 forceUnmount
10497 } = useOpenStateTransitions(open, store, () => {
10498 store.update({
10499 stickIfOpen: true,
10500 openChangeReason: null
10501 });
10502 });
10503 store.useSyncedValues({
10504 modal,
10505 nested
10506 });
10507 React54.useEffect(() => {
10508 if (!open) {
10509 store.context.stickIfOpenTimeout.clear();
10510 }
10511 }, [store, open]);
10512 const handleImperativeClose = React54.useCallback(() => {
10513 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
10514 }, [store]);
10515 React54.useImperativeHandle(props.actionsRef, () => ({
10516 unmount: forceUnmount,
10517 close: handleImperativeClose
10518 }), [forceUnmount, handleImperativeClose]);
10519 const shouldRenderInteractions = open || mounted;
10520 const popoverContext = React54.useMemo(() => ({
10521 store
10522 }), [store]);
10523 return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(PopoverRootContext.Provider, {
10524 value: popoverContext,
10525 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverInteractions, {
10526 store,
10527 modal
10528 }), typeof children === "function" ? children({
10529 payload
10530 }) : children]
10531 });
10532 }
10533 function PopoverRoot(props) {
10534 if (usePopoverRootContext(true)) {
10535 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverRootComponent, {
10536 props
10537 });
10538 }
10539 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingTree, {
10540 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverRootComponent, {
10541 props
10542 })
10543 });
10544 }
10545 function PopoverInteractions({
10546 store,
10547 modal
10548 }) {
10549 const floatingRootContext = store.useState("floatingRootContext");
10550 const dismiss = useDismiss(floatingRootContext, {
10551 outsidePressEvent: {
10552 // Ensure `aria-hidden` on outside elements is removed immediately
10553 // on outside press when trapping focus.
10554 mouse: modal === "trap-focus" ? "sloppy" : "intentional",
10555 touch: "sloppy"
10556 }
10557 });
10558 const activeTriggerProps = dismiss.reference ?? EMPTY_OBJECT;
10559 const inactiveTriggerProps = dismiss.trigger ?? EMPTY_OBJECT;
10560 const popupProps = React54.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, dismiss.floating), [dismiss.floating]);
10561 usePopupInteractionProps(store, {
10562 activeTriggerProps,
10563 inactiveTriggerProps,
10564 popupProps
10565 });
10566 return null;
10567 }
10568
10569 // node_modules/@base-ui/react/esm/popover/trigger/PopoverTrigger.js
10570 var React55 = __toESM(require_react(), 1);
10571
10572 // node_modules/@base-ui/react/esm/popover/utils/constants.js
10573 var OPEN_DELAY = 300;
10574
10575 // node_modules/@base-ui/react/esm/popover/trigger/PopoverTrigger.js
10576 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
10577 var PopoverTrigger = /* @__PURE__ */ React55.forwardRef(function PopoverTrigger2(componentProps, forwardedRef) {
10578 const {
10579 render: render4,
10580 className,
10581 style,
10582 disabled: disabled2 = false,
10583 nativeButton = true,
10584 handle,
10585 payload,
10586 openOnHover = false,
10587 delay = OPEN_DELAY,
10588 closeDelay = 0,
10589 id: idProp,
10590 ...elementProps
10591 } = componentProps;
10592 const rootContext = usePopoverRootContext(true);
10593 const store = handle?.store ?? rootContext?.store;
10594 if (!store) {
10595 throw new Error(true ? "Base UI: <Popover.Trigger> must be either used within a <Popover.Root> component or provided with a handle." : formatErrorMessage_default(74));
10596 }
10597 const thisTriggerId = useBaseUiId(idProp);
10598 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
10599 const floatingContext = store.useState("floatingRootContext");
10600 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
10601 const popupId = store.useState("triggerPopupId", thisTriggerId);
10602 const triggerElementRef = React55.useRef(null);
10603 const {
10604 registerTrigger,
10605 isMountedByThisTrigger
10606 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
10607 payload,
10608 disabled: disabled2,
10609 openOnHover,
10610 closeDelay
10611 });
10612 const openReason = store.useState("openChangeReason");
10613 const stickIfOpen = store.useState("stickIfOpen");
10614 const openMethod = store.useState("openMethod");
10615 const focusManagerModal = store.useState("focusManagerModal");
10616 const hoverProps = useHoverReferenceInteraction(floatingContext, {
10617 enabled: floatingContext != null && openOnHover && (openMethod !== "touch" || openReason !== reason_parts_exports.triggerPress),
10618 mouseOnly: true,
10619 move: false,
10620 handleClose: safePolygon(),
10621 restMs: delay,
10622 delay: {
10623 close: closeDelay
10624 },
10625 triggerElementRef,
10626 isActiveTrigger: isTriggerActive,
10627 isClosing: () => store.select("transitionStatus") === "ending"
10628 });
10629 const click = useClick(floatingContext, {
10630 enabled: floatingContext != null,
10631 stickIfOpen
10632 });
10633 const interactionTypeProps = useOpenMethodTriggerProps(() => store.select("open"), (interactionType) => {
10634 store.set("openMethod", interactionType);
10635 });
10636 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
10637 const {
10638 getButtonProps,
10639 buttonRef
10640 } = useButton({
10641 disabled: disabled2,
10642 native: nativeButton
10643 });
10644 const stateAttributesMapping7 = {
10645 open(value) {
10646 if (value && openReason === reason_parts_exports.triggerPress) {
10647 return pressableTriggerOpenStateMapping.open(value);
10648 }
10649 return triggerOpenStateMapping2.open(value);
10650 }
10651 };
10652 const {
10653 preFocusGuardRef,
10654 handlePreFocusGuardFocus,
10655 handleFocusTargetFocus
10656 } = useTriggerFocusGuards(store, triggerElementRef);
10657 const state = {
10658 disabled: disabled2,
10659 open: isOpenedByThisTrigger
10660 };
10661 const element = useRenderElement("button", componentProps, {
10662 state,
10663 ref: [buttonRef, forwardedRef, registerTrigger, triggerElementRef],
10664 props: [click.reference, hoverProps, rootTriggerProps, interactionTypeProps, {
10665 [CLICK_TRIGGER_IDENTIFIER]: "",
10666 id: thisTriggerId,
10667 "aria-haspopup": "dialog",
10668 "aria-expanded": isOpenedByThisTrigger,
10669 "aria-controls": popupId
10670 }, elementProps, getButtonProps],
10671 stateAttributesMapping: stateAttributesMapping7
10672 });
10673 if (isMountedByThisTrigger && !focusManagerModal) {
10674 return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(React55.Fragment, {
10675 children: [/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FocusGuard, {
10676 ref: preFocusGuardRef,
10677 onFocus: handlePreFocusGuardFocus
10678 }), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React55.Fragment, {
10679 children: element
10680 }, thisTriggerId), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FocusGuard, {
10681 ref: store.context.triggerFocusTargetRef,
10682 onFocus: handleFocusTargetFocus
10683 })]
10684 });
10685 }
10686 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React55.Fragment, {
10687 children: element
10688 }, thisTriggerId);
10689 });
10690 if (true) PopoverTrigger.displayName = "PopoverTrigger";
10691
10692 // node_modules/@base-ui/react/esm/popover/portal/PopoverPortal.js
10693 var React57 = __toESM(require_react(), 1);
10694
10695 // node_modules/@base-ui/react/esm/popover/portal/PopoverPortalContext.js
10696 var React56 = __toESM(require_react(), 1);
10697 var PopoverPortalContext = /* @__PURE__ */ React56.createContext(void 0);
10698 if (true) PopoverPortalContext.displayName = "PopoverPortalContext";
10699 function usePopoverPortalContext() {
10700 const value = React56.useContext(PopoverPortalContext);
10701 if (value === void 0) {
10702 throw new Error(true ? "Base UI: <Popover.Portal> is missing." : formatErrorMessage_default(45));
10703 }
10704 return value;
10705 }
10706
10707 // node_modules/@base-ui/react/esm/popover/portal/PopoverPortal.js
10708 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
10709 var PopoverPortal = /* @__PURE__ */ React57.forwardRef(function PopoverPortal2(props, forwardedRef) {
10710 const {
10711 keepMounted = false,
10712 ...portalProps
10713 } = props;
10714 const {
10715 store
10716 } = usePopoverRootContext();
10717 const mounted = store.useState("mounted");
10718 const shouldRender = mounted || keepMounted;
10719 if (!shouldRender) {
10720 return null;
10721 }
10722 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopoverPortalContext.Provider, {
10723 value: keepMounted,
10724 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingPortal, {
10725 ref: forwardedRef,
10726 ...portalProps
10727 })
10728 });
10729 });
10730 if (true) PopoverPortal.displayName = "PopoverPortal";
10731
10732 // node_modules/@base-ui/react/esm/popover/positioner/PopoverPositioner.js
10733 var React59 = __toESM(require_react(), 1);
10734
10735 // node_modules/@base-ui/react/esm/popover/positioner/PopoverPositionerContext.js
10736 var React58 = __toESM(require_react(), 1);
10737 var PopoverPositionerContext = /* @__PURE__ */ React58.createContext(void 0);
10738 if (true) PopoverPositionerContext.displayName = "PopoverPositionerContext";
10739 function usePopoverPositionerContext() {
10740 const context = React58.useContext(PopoverPositionerContext);
10741 if (!context) {
10742 throw new Error(true ? "Base UI: PopoverPositionerContext is missing. PopoverPositioner parts must be placed within <Popover.Positioner>." : formatErrorMessage_default(46));
10743 }
10744 return context;
10745 }
10746
10747 // node_modules/@base-ui/react/esm/popover/positioner/PopoverPositioner.js
10748 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
10749 var PopoverPositioner = /* @__PURE__ */ React59.forwardRef(function PopoverPositioner2(componentProps, forwardedRef) {
10750 const {
10751 render: render4,
10752 className,
10753 style,
10754 anchor,
10755 positionMethod = "absolute",
10756 side = "bottom",
10757 align = "center",
10758 sideOffset = 0,
10759 alignOffset = 0,
10760 collisionBoundary = "clipping-ancestors",
10761 collisionPadding = 5,
10762 arrowPadding = 5,
10763 sticky = false,
10764 disableAnchorTracking = false,
10765 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
10766 ...elementProps
10767 } = componentProps;
10768 const {
10769 store
10770 } = usePopoverRootContext();
10771 const keepMounted = usePopoverPortalContext();
10772 const nodeId = useFloatingNodeId();
10773 const floatingRootContext = store.useState("floatingRootContext");
10774 const mounted = store.useState("mounted");
10775 const open = store.useState("open");
10776 const openReason = store.useState("openChangeReason");
10777 const triggerElement = store.useState("activeTriggerElement");
10778 const modal = store.useState("modal");
10779 const openMethod = store.useState("openMethod");
10780 const positionerElement = store.useState("positionerElement");
10781 const instantType = store.useState("instantType");
10782 const transitionStatus = store.useState("transitionStatus");
10783 const hasViewport = store.useState("hasViewport");
10784 const prevTriggerElementRef = React59.useRef(null);
10785 const runOnceAnimationsFinish = useAnimationsFinished(positionerElement, false, false);
10786 const positioning = useAnchorPositioning({
10787 anchor,
10788 floatingRootContext,
10789 positionMethod,
10790 mounted,
10791 side,
10792 sideOffset,
10793 align,
10794 alignOffset,
10795 arrowPadding,
10796 collisionBoundary,
10797 collisionPadding,
10798 sticky,
10799 disableAnchorTracking,
10800 keepMounted,
10801 nodeId,
10802 collisionAvoidance,
10803 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
10804 });
10805 const domReference = floatingRootContext.useState("domReferenceElement");
10806 useIsoLayoutEffect(() => {
10807 const currentTriggerElement = domReference;
10808 const prevTriggerElement = prevTriggerElementRef.current;
10809 if (currentTriggerElement) {
10810 prevTriggerElementRef.current = currentTriggerElement;
10811 }
10812 if (prevTriggerElement && currentTriggerElement && currentTriggerElement !== prevTriggerElement) {
10813 store.set("instantType", void 0);
10814 const ac = new AbortController();
10815 runOnceAnimationsFinish(() => {
10816 store.set("instantType", "trigger-change");
10817 }, ac.signal);
10818 return () => {
10819 ac.abort();
10820 };
10821 }
10822 return void 0;
10823 }, [domReference, runOnceAnimationsFinish, store]);
10824 useAnchoredPopupScrollLock(open && modal === true && openReason !== reason_parts_exports.triggerHover, openMethod === "touch", positionerElement, triggerElement);
10825 const setPositionerElement = React59.useCallback((element2) => {
10826 store.set("positionerElement", element2);
10827 }, [store]);
10828 const state = {
10829 open,
10830 side: positioning.side,
10831 align: positioning.align,
10832 anchorHidden: positioning.anchorHidden,
10833 instant: instantType
10834 };
10835 const element = usePositioner(componentProps, state, {
10836 styles: positioning.positionerStyles,
10837 transitionStatus,
10838 props: elementProps,
10839 refs: [forwardedRef, setPositionerElement],
10840 hidden: !mounted,
10841 inert: !open
10842 });
10843 return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(PopoverPositionerContext.Provider, {
10844 value: positioning,
10845 children: [mounted && modal === true && openReason !== reason_parts_exports.triggerHover && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(InternalBackdrop, {
10846 ref: store.context.internalBackdropRef,
10847 inert: inertValue(!open),
10848 cutout: triggerElement
10849 }), /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FloatingNode, {
10850 id: nodeId,
10851 children: element
10852 })]
10853 });
10854 });
10855 if (true) PopoverPositioner.displayName = "PopoverPositioner";
10856
10857 // node_modules/@base-ui/react/esm/popover/popup/PopoverPopup.js
10858 var React61 = __toESM(require_react(), 1);
10859
10860 // node_modules/@base-ui/react/esm/utils/closePart.js
10861 var React60 = __toESM(require_react(), 1);
10862 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
10863 var ClosePartContext = /* @__PURE__ */ React60.createContext(void 0);
10864 if (true) ClosePartContext.displayName = "ClosePartContext";
10865 function useClosePartCount() {
10866 const [closePartCount, setClosePartCount] = React60.useState(0);
10867 const register2 = useStableCallback(() => {
10868 setClosePartCount((count) => count + 1);
10869 return () => {
10870 setClosePartCount((count) => Math.max(0, count - 1));
10871 };
10872 });
10873 const context = React60.useMemo(() => ({
10874 register: register2
10875 }), [register2]);
10876 return {
10877 context,
10878 hasClosePart: closePartCount > 0
10879 };
10880 }
10881 function ClosePartProvider(props) {
10882 const {
10883 value,
10884 children
10885 } = props;
10886 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClosePartContext.Provider, {
10887 value,
10888 children
10889 });
10890 }
10891 function useClosePartRegistration() {
10892 const context = React60.useContext(ClosePartContext);
10893 useIsoLayoutEffect(() => {
10894 return context?.register();
10895 }, [context]);
10896 }
10897
10898 // node_modules/@base-ui/react/esm/popover/popup/PopoverPopup.js
10899 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
10900 var stateAttributesMapping2 = {
10901 ...popupStateMapping,
10902 ...transitionStatusMapping
10903 };
10904 var PopoverPopup = /* @__PURE__ */ React61.forwardRef(function PopoverPopup2(componentProps, forwardedRef) {
10905 const {
10906 render: render4,
10907 className,
10908 style,
10909 initialFocus,
10910 finalFocus,
10911 ...elementProps
10912 } = componentProps;
10913 const {
10914 store
10915 } = usePopoverRootContext();
10916 const positioner = usePopoverPositionerContext();
10917 const insideToolbar = useToolbarRootContext(true) != null;
10918 const {
10919 context: closePartContext,
10920 hasClosePart
10921 } = useClosePartCount();
10922 const open = store.useState("open");
10923 const openMethod = store.useState("openMethod");
10924 const instantType = store.useState("instantType");
10925 const transitionStatus = store.useState("transitionStatus");
10926 const popupProps = store.useState("popupProps");
10927 const titleId = store.useState("titleElementId");
10928 const descriptionId = store.useState("descriptionElementId");
10929 const modal = store.useState("modal");
10930 const mounted = store.useState("mounted");
10931 const openReason = store.useState("openChangeReason");
10932 const activeTriggerElement = store.useState("activeTriggerElement");
10933 const floatingContext = store.useState("floatingRootContext");
10934 const floatingId = floatingContext.useState("floatingId");
10935 const disabled2 = store.useState("disabled");
10936 const openOnHover = store.useState("openOnHover");
10937 const closeDelay = store.useState("closeDelay");
10938 const popupId = elementProps.id ?? floatingId;
10939 useOpenChangeComplete({
10940 open,
10941 ref: store.context.popupRef,
10942 onComplete() {
10943 if (open) {
10944 store.context.onOpenChangeComplete?.(true);
10945 }
10946 }
10947 });
10948 useHoverFloatingInteraction(floatingContext, {
10949 enabled: openOnHover && !disabled2,
10950 closeDelay
10951 });
10952 function defaultInitialFocus(interactionType) {
10953 if (interactionType === "touch") {
10954 return store.context.popupRef.current;
10955 }
10956 return true;
10957 }
10958 const resolvedInitialFocus = initialFocus === void 0 ? defaultInitialFocus : initialFocus;
10959 const focusManagerModal = modal !== false && hasClosePart;
10960 store.useSyncedValue("focusManagerModal", focusManagerModal);
10961 const setPopupElement = React61.useCallback((element2) => {
10962 store.set("popupElement", element2);
10963 }, [store]);
10964 const state = {
10965 open,
10966 side: positioner.side,
10967 align: positioner.align,
10968 instant: instantType,
10969 transitionStatus
10970 };
10971 const element = useRenderElement("div", componentProps, {
10972 state,
10973 ref: [forwardedRef, store.context.popupRef, setPopupElement],
10974 props: [popupProps, {
10975 id: popupId,
10976 role: "dialog",
10977 ...FOCUSABLE_POPUP_PROPS,
10978 "aria-labelledby": titleId,
10979 "aria-describedby": descriptionId,
10980 onKeyDown(event) {
10981 if (insideToolbar && COMPOSITE_KEYS.has(event.key)) {
10982 event.stopPropagation();
10983 }
10984 }
10985 }, getDisabledMountTransitionStyles(transitionStatus), elementProps],
10986 stateAttributesMapping: stateAttributesMapping2
10987 });
10988 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FloatingFocusManager, {
10989 context: floatingContext,
10990 openInteractionType: openMethod,
10991 modal: focusManagerModal,
10992 disabled: !mounted || openReason === reason_parts_exports.triggerHover,
10993 initialFocus: resolvedInitialFocus,
10994 returnFocus: finalFocus,
10995 restoreFocus: "popup",
10996 previousFocusableElement: isHTMLElement(activeTriggerElement) ? activeTriggerElement : void 0,
10997 nextFocusableElement: store.context.triggerFocusTargetRef,
10998 beforeContentFocusGuardRef: store.context.beforeContentFocusGuardRef,
10999 children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ClosePartProvider, {
11000 value: closePartContext,
11001 children: element
11002 })
11003 });
11004 });
11005 if (true) PopoverPopup.displayName = "PopoverPopup";
11006
11007 // node_modules/@base-ui/react/esm/popover/arrow/PopoverArrow.js
11008 var React62 = __toESM(require_react(), 1);
11009 var PopoverArrow = /* @__PURE__ */ React62.forwardRef(function PopoverArrow2(componentProps, forwardedRef) {
11010 const {
11011 render: render4,
11012 className,
11013 style,
11014 ...elementProps
11015 } = componentProps;
11016 const {
11017 store
11018 } = usePopoverRootContext();
11019 const open = store.useState("open");
11020 const {
11021 arrowRef,
11022 side,
11023 align,
11024 arrowUncentered,
11025 arrowStyles
11026 } = usePopoverPositionerContext();
11027 const state = {
11028 open,
11029 side,
11030 align,
11031 uncentered: arrowUncentered
11032 };
11033 const element = useRenderElement("div", componentProps, {
11034 state,
11035 ref: [forwardedRef, arrowRef],
11036 props: [{
11037 style: arrowStyles,
11038 "aria-hidden": true
11039 }, elementProps],
11040 stateAttributesMapping: popupStateMapping
11041 });
11042 return element;
11043 });
11044 if (true) PopoverArrow.displayName = "PopoverArrow";
11045
11046 // node_modules/@base-ui/react/esm/popover/backdrop/PopoverBackdrop.js
11047 var React63 = __toESM(require_react(), 1);
11048 var stateAttributesMapping3 = {
11049 ...popupStateMapping,
11050 ...transitionStatusMapping
11051 };
11052 var PopoverBackdrop = /* @__PURE__ */ React63.forwardRef(function PopoverBackdrop2(props, forwardedRef) {
11053 const {
11054 render: render4,
11055 className,
11056 style,
11057 ...elementProps
11058 } = props;
11059 const {
11060 store
11061 } = usePopoverRootContext();
11062 const open = store.useState("open");
11063 const mounted = store.useState("mounted");
11064 const transitionStatus = store.useState("transitionStatus");
11065 const openReason = store.useState("openChangeReason");
11066 const state = {
11067 open,
11068 transitionStatus
11069 };
11070 const element = useRenderElement("div", props, {
11071 state,
11072 ref: [store.context.backdropRef, forwardedRef],
11073 props: [{
11074 role: "presentation",
11075 hidden: !mounted,
11076 style: {
11077 pointerEvents: openReason === reason_parts_exports.triggerHover ? "none" : void 0,
11078 userSelect: "none",
11079 WebkitUserSelect: "none"
11080 }
11081 }, elementProps],
11082 stateAttributesMapping: stateAttributesMapping3
11083 });
11084 return element;
11085 });
11086 if (true) PopoverBackdrop.displayName = "PopoverBackdrop";
11087
11088 // node_modules/@base-ui/react/esm/popover/title/PopoverTitle.js
11089 var React64 = __toESM(require_react(), 1);
11090 var PopoverTitle = /* @__PURE__ */ React64.forwardRef(function PopoverTitle2(componentProps, forwardedRef) {
11091 const {
11092 render: render4,
11093 className,
11094 style,
11095 ...elementProps
11096 } = componentProps;
11097 const {
11098 store
11099 } = usePopoverRootContext();
11100 const id = useBaseUiId(elementProps.id);
11101 store.useSyncedValueWithCleanup("titleElementId", id);
11102 const element = useRenderElement("h2", componentProps, {
11103 ref: forwardedRef,
11104 props: [{
11105 id
11106 }, elementProps]
11107 });
11108 return element;
11109 });
11110 if (true) PopoverTitle.displayName = "PopoverTitle";
11111
11112 // node_modules/@base-ui/react/esm/popover/description/PopoverDescription.js
11113 var React65 = __toESM(require_react(), 1);
11114 var PopoverDescription = /* @__PURE__ */ React65.forwardRef(function PopoverDescription2(componentProps, forwardedRef) {
11115 const {
11116 render: render4,
11117 className,
11118 style,
11119 ...elementProps
11120 } = componentProps;
11121 const {
11122 store
11123 } = usePopoverRootContext();
11124 const id = useBaseUiId(elementProps.id);
11125 store.useSyncedValueWithCleanup("descriptionElementId", id);
11126 const element = useRenderElement("p", componentProps, {
11127 ref: forwardedRef,
11128 props: [{
11129 id
11130 }, elementProps]
11131 });
11132 return element;
11133 });
11134 if (true) PopoverDescription.displayName = "PopoverDescription";
11135
11136 // node_modules/@base-ui/react/esm/popover/close/PopoverClose.js
11137 var React66 = __toESM(require_react(), 1);
11138 var PopoverClose = /* @__PURE__ */ React66.forwardRef(function PopoverClose2(componentProps, forwardedRef) {
11139 const {
11140 render: render4,
11141 className,
11142 style,
11143 disabled: disabled2 = false,
11144 nativeButton = true,
11145 ...elementProps
11146 } = componentProps;
11147 const {
11148 buttonRef,
11149 getButtonProps
11150 } = useButton({
11151 disabled: disabled2,
11152 focusableWhenDisabled: false,
11153 native: nativeButton
11154 });
11155 const {
11156 store
11157 } = usePopoverRootContext();
11158 useClosePartRegistration();
11159 const element = useRenderElement("button", componentProps, {
11160 ref: [forwardedRef, buttonRef],
11161 props: [{
11162 onClick(event) {
11163 store.setOpen(false, createChangeEventDetails(reason_parts_exports.closePress, event.nativeEvent));
11164 }
11165 }, elementProps, getButtonProps]
11166 });
11167 return element;
11168 });
11169 if (true) PopoverClose.displayName = "PopoverClose";
11170
11171 // node_modules/@base-ui/react/esm/popover/viewport/PopoverViewport.js
11172 var React67 = __toESM(require_react(), 1);
11173
11174 // node_modules/@base-ui/react/esm/popover/viewport/PopoverViewportCssVars.js
11175 var PopoverViewportCssVars = /* @__PURE__ */ (function(PopoverViewportCssVars2) {
11176 PopoverViewportCssVars2["popupWidth"] = "--popup-width";
11177 PopoverViewportCssVars2["popupHeight"] = "--popup-height";
11178 return PopoverViewportCssVars2;
11179 })({});
11180
11181 // node_modules/@base-ui/react/esm/popover/viewport/PopoverViewport.js
11182 var stateAttributesMapping4 = {
11183 activationDirection: (value) => value ? {
11184 "data-activation-direction": value
11185 } : null
11186 };
11187 var PopoverViewport = /* @__PURE__ */ React67.forwardRef(function PopoverViewport2(componentProps, forwardedRef) {
11188 const {
11189 render: render4,
11190 className,
11191 style,
11192 children,
11193 ...elementProps
11194 } = componentProps;
11195 const {
11196 store
11197 } = usePopoverRootContext();
11198 const {
11199 side
11200 } = usePopoverPositionerContext();
11201 const instantType = store.useState("instantType");
11202 const {
11203 children: childrenToRender,
11204 state: viewportState
11205 } = usePopupViewport({
11206 store,
11207 side,
11208 cssVars: PopoverViewportCssVars,
11209 children
11210 });
11211 const state = {
11212 activationDirection: viewportState.activationDirection,
11213 transitioning: viewportState.transitioning,
11214 instant: instantType
11215 };
11216 return useRenderElement("div", componentProps, {
11217 state,
11218 ref: forwardedRef,
11219 props: [elementProps, {
11220 children: childrenToRender
11221 }],
11222 stateAttributesMapping: stateAttributesMapping4
11223 });
11224 });
11225 if (true) PopoverViewport.displayName = "PopoverViewport";
11226
11227 // node_modules/@base-ui/react/esm/popover/store/PopoverHandle.js
11228 var PopoverHandle = class {
11229 /**
11230 * Internal store holding the popover's state.
11231 * @internal
11232 */
11233 constructor() {
11234 this.store = new PopoverStore();
11235 }
11236 /**
11237 * Opens the popover and associates it with the trigger with the given id.
11238 * The trigger must be a Popover.Trigger component with this handle passed as a prop.
11239 *
11240 * @param triggerId ID of the trigger to associate with the popover.
11241 */
11242 open(triggerId) {
11243 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) ?? void 0 : void 0;
11244 if (triggerId && !triggerElement) {
11245 throw new Error(true ? `Base UI: PopoverHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(80, triggerId));
11246 }
11247 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
11248 }
11249 /**
11250 * Closes the popover.
11251 */
11252 close() {
11253 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
11254 }
11255 /**
11256 * Indicates whether the popover is currently open.
11257 */
11258 get isOpen() {
11259 return this.store.select("open");
11260 }
11261 };
11262 function createPopoverHandle() {
11263 return new PopoverHandle();
11264 }
11265
11266 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
11267 var React68 = __toESM(require_react(), 1);
11268 var ReactDOM8 = __toESM(require_react_dom(), 1);
11269 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
11270 var FloatingPortalLite = /* @__PURE__ */ React68.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
11271 const {
11272 children,
11273 container,
11274 className,
11275 render: render4,
11276 style,
11277 ...elementProps
11278 } = componentProps;
11279 const {
11280 portalNode,
11281 portalSubtree
11282 } = useFloatingPortalNode({
11283 container,
11284 ref: forwardedRef,
11285 componentProps,
11286 elementProps
11287 });
11288 if (!portalSubtree && !portalNode) {
11289 return null;
11290 }
11291 return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(React68.Fragment, {
11292 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM8.createPortal(children, portalNode)]
11293 });
11294 });
11295 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
11296
11297 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
11298 var index_parts_exports3 = {};
11299 __export(index_parts_exports3, {
11300 Arrow: () => TooltipArrow,
11301 Handle: () => TooltipHandle,
11302 Popup: () => TooltipPopup,
11303 Portal: () => TooltipPortal,
11304 Positioner: () => TooltipPositioner,
11305 Provider: () => TooltipProvider,
11306 Root: () => TooltipRoot,
11307 Trigger: () => TooltipTrigger,
11308 Viewport: () => TooltipViewport,
11309 createHandle: () => createTooltipHandle
11310 });
11311
11312 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
11313 var React71 = __toESM(require_react(), 1);
11314
11315 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
11316 var React69 = __toESM(require_react(), 1);
11317 var TooltipRootContext = /* @__PURE__ */ React69.createContext(void 0);
11318 if (true) TooltipRootContext.displayName = "TooltipRootContext";
11319 function useTooltipRootContext(optional) {
11320 const context = React69.useContext(TooltipRootContext);
11321 if (context === void 0 && !optional) {
11322 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
11323 }
11324 return context;
11325 }
11326
11327 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
11328 var React70 = __toESM(require_react(), 1);
11329 var ReactDOM9 = __toESM(require_react_dom(), 1);
11330 var selectors3 = {
11331 ...popupStoreSelectors,
11332 disabled: createSelector((state) => state.disabled),
11333 instantType: createSelector((state) => state.instantType),
11334 isInstantPhase: createSelector((state) => state.isInstantPhase),
11335 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
11336 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
11337 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
11338 closeOnClick: createSelector((state) => state.closeOnClick),
11339 closeDelay: createSelector((state) => state.closeDelay),
11340 hasViewport: createSelector((state) => state.hasViewport)
11341 };
11342 var TooltipStore = class _TooltipStore extends ReactStore {
11343 constructor(initialState, floatingId, nested = false) {
11344 const triggerElements = new PopupTriggerMap();
11345 const state = {
11346 ...createInitialState2(),
11347 ...initialState
11348 };
11349 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
11350 super(state, {
11351 popupRef: /* @__PURE__ */ React70.createRef(),
11352 onOpenChange: void 0,
11353 onOpenChangeComplete: void 0,
11354 triggerElements
11355 }, selectors3);
11356 }
11357 setOpen = (nextOpen, eventDetails) => {
11358 const reason = eventDetails.reason;
11359 const isHover = reason === reason_parts_exports.triggerHover;
11360 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
11361 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
11362 eventDetails.preventUnmountOnClose = () => {
11363 this.set("preventUnmountingOnClose", true);
11364 };
11365 this.context.onOpenChange?.(nextOpen, eventDetails);
11366 if (eventDetails.isCanceled) {
11367 return;
11368 }
11369 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
11370 const changeState = () => {
11371 const updatedState = {
11372 open: nextOpen,
11373 openChangeReason: reason
11374 };
11375 if (isFocusOpen) {
11376 updatedState.instantType = "focus";
11377 } else if (isDismissClose) {
11378 updatedState.instantType = "dismiss";
11379 } else if (reason === reason_parts_exports.triggerHover) {
11380 updatedState.instantType = void 0;
11381 }
11382 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
11383 this.update(updatedState);
11384 };
11385 if (isHover) {
11386 ReactDOM9.flushSync(changeState);
11387 } else {
11388 changeState();
11389 }
11390 };
11391 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
11392 cancelPendingOpen(event) {
11393 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
11394 }
11395 static useStore(externalStore, initialState) {
11396 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
11397 return store;
11398 }
11399 };
11400 function createInitialState2() {
11401 return {
11402 ...createInitialPopupStoreState(),
11403 disabled: false,
11404 instantType: void 0,
11405 isInstantPhase: false,
11406 trackCursorAxis: "none",
11407 disableHoverablePopup: false,
11408 openChangeReason: null,
11409 closeOnClick: true,
11410 closeDelay: 0,
11411 hasViewport: false
11412 };
11413 }
11414
11415 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
11416 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
11417 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
11418 const {
11419 disabled: disabled2 = false,
11420 defaultOpen = false,
11421 open: openProp,
11422 disableHoverablePopup = false,
11423 trackCursorAxis = "none",
11424 actionsRef,
11425 onOpenChange,
11426 onOpenChangeComplete,
11427 handle,
11428 triggerId: triggerIdProp,
11429 defaultTriggerId: defaultTriggerIdProp = null,
11430 children
11431 } = props;
11432 const store = TooltipStore.useStore(handle?.store, {
11433 open: defaultOpen,
11434 openProp,
11435 activeTriggerId: defaultTriggerIdProp,
11436 triggerIdProp
11437 });
11438 useOnFirstRender(() => {
11439 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
11440 store.update({
11441 open: true,
11442 activeTriggerId: defaultTriggerIdProp
11443 });
11444 }
11445 });
11446 store.useControlledProp("openProp", openProp);
11447 store.useControlledProp("triggerIdProp", triggerIdProp);
11448 store.useContextCallback("onOpenChange", onOpenChange);
11449 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
11450 const openState = store.useState("open");
11451 const open = !disabled2 && openState;
11452 const activeTriggerId = store.useState("activeTriggerId");
11453 const mounted = store.useState("mounted");
11454 const payload = store.useState("payload");
11455 store.useSyncedValues({
11456 trackCursorAxis,
11457 disableHoverablePopup
11458 });
11459 store.useSyncedValue("disabled", disabled2);
11460 useImplicitActiveTrigger(store);
11461 const {
11462 forceUnmount,
11463 transitionStatus
11464 } = useOpenStateTransitions(open, store);
11465 const isInstantPhase = store.useState("isInstantPhase");
11466 const instantType = store.useState("instantType");
11467 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
11468 const previousInstantTypeRef = React71.useRef(null);
11469 useIsoLayoutEffect(() => {
11470 if (openState && disabled2) {
11471 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
11472 }
11473 }, [openState, disabled2, store]);
11474 useIsoLayoutEffect(() => {
11475 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
11476 if (instantType !== "delay") {
11477 previousInstantTypeRef.current = instantType;
11478 }
11479 store.set("instantType", "delay");
11480 } else if (previousInstantTypeRef.current !== null) {
11481 store.set("instantType", previousInstantTypeRef.current);
11482 previousInstantTypeRef.current = null;
11483 }
11484 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
11485 useIsoLayoutEffect(() => {
11486 if (open) {
11487 if (activeTriggerId == null) {
11488 store.set("payload", void 0);
11489 }
11490 }
11491 }, [store, activeTriggerId, open]);
11492 const handleImperativeClose = React71.useCallback(() => {
11493 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
11494 }, [store]);
11495 React71.useImperativeHandle(actionsRef, () => ({
11496 unmount: forceUnmount,
11497 close: handleImperativeClose
11498 }), [forceUnmount, handleImperativeClose]);
11499 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
11500 return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(TooltipRootContext.Provider, {
11501 value: store,
11502 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipInteractions, {
11503 store,
11504 disabled: disabled2,
11505 trackCursorAxis
11506 }), typeof children === "function" ? children({
11507 payload
11508 }) : children]
11509 });
11510 });
11511 if (true) TooltipRoot.displayName = "TooltipRoot";
11512 function TooltipInteractions({
11513 store,
11514 disabled: disabled2,
11515 trackCursorAxis
11516 }) {
11517 const floatingRootContext = store.useState("floatingRootContext");
11518 const dismiss = useDismiss(floatingRootContext, {
11519 enabled: !disabled2,
11520 referencePress: () => store.select("closeOnClick")
11521 });
11522 const clientPoint = useClientPoint(floatingRootContext, {
11523 enabled: !disabled2 && trackCursorAxis !== "none",
11524 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
11525 });
11526 const activeTriggerProps = React71.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
11527 const inactiveTriggerProps = React71.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
11528 const popupProps = React71.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
11529 usePopupInteractionProps(store, {
11530 activeTriggerProps,
11531 inactiveTriggerProps,
11532 popupProps
11533 });
11534 return null;
11535 }
11536
11537 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
11538 var React73 = __toESM(require_react(), 1);
11539
11540 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
11541 var React72 = __toESM(require_react(), 1);
11542 var TooltipProviderContext = /* @__PURE__ */ React72.createContext(void 0);
11543 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
11544 function useTooltipProviderContext() {
11545 return React72.useContext(TooltipProviderContext);
11546 }
11547
11548 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
11549 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
11550 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
11551 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
11552 return TooltipTriggerDataAttributes2;
11553 })({});
11554
11555 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
11556 var OPEN_DELAY2 = 600;
11557
11558 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
11559 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
11560 function getTargetElement(event) {
11561 if ("composedPath" in event) {
11562 const path = event.composedPath();
11563 for (let i2 = 0; i2 < path.length; i2 += 1) {
11564 const element = path[i2];
11565 if (isElement(element)) {
11566 return element;
11567 }
11568 }
11569 }
11570 const target = event.target;
11571 if (isElement(target)) {
11572 return target;
11573 }
11574 return null;
11575 }
11576 function closestEnabledTooltipTrigger(element) {
11577 let current = element;
11578 while (current) {
11579 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
11580 return current;
11581 }
11582 const parentElement = current.parentElement;
11583 if (parentElement) {
11584 current = parentElement;
11585 continue;
11586 }
11587 const root = current.getRootNode();
11588 current = "host" in root && isElement(root.host) ? root.host : null;
11589 }
11590 return null;
11591 }
11592 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
11593 const {
11594 render: render4,
11595 className,
11596 style,
11597 handle,
11598 payload,
11599 disabled: disabledProp,
11600 delay,
11601 closeOnClick = true,
11602 closeDelay,
11603 id: idProp,
11604 ...elementProps
11605 } = componentProps;
11606 const rootContext = useTooltipRootContext(true);
11607 const store = handle?.store ?? rootContext;
11608 if (!store) {
11609 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));
11610 }
11611 const thisTriggerId = useBaseUiId(idProp);
11612 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
11613 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
11614 const floatingRootContext = store.useState("floatingRootContext");
11615 const triggerElementRef = React73.useRef(null);
11616 const delayWithDefault = delay ?? OPEN_DELAY2;
11617 const closeDelayWithDefault = closeDelay ?? 0;
11618 const {
11619 registerTrigger,
11620 isMountedByThisTrigger
11621 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
11622 payload,
11623 closeOnClick,
11624 closeDelay: closeDelayWithDefault
11625 });
11626 const providerContext = useTooltipProviderContext();
11627 const {
11628 delayRef,
11629 isInstantPhase,
11630 hasProvider
11631 } = useDelayGroup(floatingRootContext, {
11632 open: isOpenedByThisTrigger
11633 });
11634 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
11635 store.useSyncedValue("isInstantPhase", isInstantPhase);
11636 const rootDisabled = store.useState("disabled");
11637 const disabled2 = disabledProp ?? rootDisabled;
11638 const disabledRef = useValueAsRef(disabled2);
11639 const trackCursorAxis = store.useState("trackCursorAxis");
11640 const disableHoverablePopup = store.useState("disableHoverablePopup");
11641 const isNestedTriggerHoveredRef = React73.useRef(false);
11642 const nestedTriggerOpenTimeout = useTimeout();
11643 const pointerTypeRef = React73.useRef(void 0);
11644 function getOpenDelay() {
11645 const providerDelay = providerContext?.delay;
11646 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
11647 let computedOpenDelay = delayWithDefault;
11648 if (hasProvider) {
11649 if (groupOpenValue !== 0) {
11650 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
11651 } else {
11652 computedOpenDelay = 0;
11653 }
11654 }
11655 return computedOpenDelay;
11656 }
11657 function isEnabledNestedTriggerTarget(target) {
11658 const triggerEl = triggerElementRef.current;
11659 if (!triggerEl || !target) {
11660 return false;
11661 }
11662 const nearestTrigger = closestEnabledTooltipTrigger(target);
11663 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
11664 }
11665 function detectNestedTriggerHover(target) {
11666 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
11667 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
11668 if (nestedTriggerHovered) {
11669 hoverInteraction.openChangeTimeout.clear();
11670 hoverInteraction.restTimeout.clear();
11671 hoverInteraction.restTimeoutPending = false;
11672 nestedTriggerOpenTimeout.clear();
11673 }
11674 return nestedTriggerHovered;
11675 }
11676 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
11677 enabled: !disabled2,
11678 mouseOnly: true,
11679 move: false,
11680 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
11681 restMs: getOpenDelay,
11682 delay() {
11683 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
11684 let computedCloseDelay = closeDelayWithDefault;
11685 if (closeDelay == null && hasProvider) {
11686 computedCloseDelay = closeValue;
11687 }
11688 return {
11689 close: computedCloseDelay
11690 };
11691 },
11692 triggerElementRef,
11693 isActiveTrigger: isTriggerActive,
11694 isClosing: () => store.select("transitionStatus") === "ending",
11695 shouldOpen() {
11696 return !isNestedTriggerHoveredRef.current;
11697 }
11698 });
11699 const focusProps = useFocus(floatingRootContext, {
11700 enabled: !disabled2
11701 }).reference;
11702 const handleNestedTriggerHover = (event) => {
11703 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
11704 const target = getTargetElement(event);
11705 const nestedTriggerHovered = detectNestedTriggerHover(target);
11706 const triggerEl = triggerElementRef.current;
11707 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
11708 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
11709 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
11710 return;
11711 }
11712 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
11713 isMouseLikePointerType(pointerTypeRef.current)) {
11714 const open = () => {
11715 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
11716 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
11717 }
11718 };
11719 const openDelay = getOpenDelay();
11720 if (openDelay === 0) {
11721 nestedTriggerOpenTimeout.clear();
11722 open();
11723 } else {
11724 nestedTriggerOpenTimeout.start(openDelay, open);
11725 }
11726 }
11727 };
11728 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
11729 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
11730 const state = {
11731 open: isOpenedByThisTrigger
11732 };
11733 const element = useRenderElement("button", componentProps, {
11734 state,
11735 ref: [forwardedRef, registerTrigger, triggerElementRef],
11736 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
11737 onMouseOver(event) {
11738 handleNestedTriggerHover(event.nativeEvent);
11739 },
11740 onFocus(event) {
11741 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
11742 event.preventBaseUIHandler();
11743 }
11744 },
11745 onMouseLeave() {
11746 isNestedTriggerHoveredRef.current = false;
11747 nestedTriggerOpenTimeout.clear();
11748 pointerTypeRef.current = void 0;
11749 },
11750 onPointerEnter(event) {
11751 pointerTypeRef.current = event.pointerType;
11752 },
11753 onPointerDown(event) {
11754 pointerTypeRef.current = event.pointerType;
11755 store.set("closeOnClick", closeOnClick);
11756 if (closeOnClick && !store.select("open")) {
11757 store.cancelPendingOpen(event.nativeEvent);
11758 }
11759 },
11760 onClick(event) {
11761 if (closeOnClick && !store.select("open")) {
11762 store.cancelPendingOpen(event.nativeEvent);
11763 }
11764 },
11765 id: thisTriggerId,
11766 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
11767 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
11768 }, elementProps],
11769 stateAttributesMapping: triggerOpenStateMapping2
11770 });
11771 return element;
11772 });
11773 if (true) TooltipTrigger.displayName = "TooltipTrigger";
11774
11775 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
11776 var React75 = __toESM(require_react(), 1);
11777
11778 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
11779 var React74 = __toESM(require_react(), 1);
11780 var TooltipPortalContext = /* @__PURE__ */ React74.createContext(void 0);
11781 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
11782 function useTooltipPortalContext() {
11783 const value = React74.useContext(TooltipPortalContext);
11784 if (value === void 0) {
11785 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
11786 }
11787 return value;
11788 }
11789
11790 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
11791 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
11792 var TooltipPortal = /* @__PURE__ */ React75.forwardRef(function TooltipPortal2(props, forwardedRef) {
11793 const {
11794 keepMounted = false,
11795 ...portalProps
11796 } = props;
11797 const store = useTooltipRootContext();
11798 const mounted = store.useState("mounted");
11799 const shouldRender = mounted || keepMounted;
11800 if (!shouldRender) {
11801 return null;
11802 }
11803 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TooltipPortalContext.Provider, {
11804 value: keepMounted,
11805 children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FloatingPortalLite, {
11806 ref: forwardedRef,
11807 ...portalProps
11808 })
11809 });
11810 });
11811 if (true) TooltipPortal.displayName = "TooltipPortal";
11812
11813 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
11814 var React77 = __toESM(require_react(), 1);
11815
11816 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
11817 var React76 = __toESM(require_react(), 1);
11818 var TooltipPositionerContext = /* @__PURE__ */ React76.createContext(void 0);
11819 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
11820 function useTooltipPositionerContext() {
11821 const context = React76.useContext(TooltipPositionerContext);
11822 if (context === void 0) {
11823 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
11824 }
11825 return context;
11826 }
11827
11828 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
11829 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
11830 var TooltipPositioner = /* @__PURE__ */ React77.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
11831 const {
11832 render: render4,
11833 className,
11834 anchor,
11835 positionMethod = "absolute",
11836 side = "top",
11837 align = "center",
11838 sideOffset = 0,
11839 alignOffset = 0,
11840 collisionBoundary = "clipping-ancestors",
11841 collisionPadding = 5,
11842 arrowPadding = 5,
11843 sticky = false,
11844 disableAnchorTracking = false,
11845 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
11846 style,
11847 ...elementProps
11848 } = componentProps;
11849 const store = useTooltipRootContext();
11850 const keepMounted = useTooltipPortalContext();
11851 const open = store.useState("open");
11852 const mounted = store.useState("mounted");
11853 const trackCursorAxis = store.useState("trackCursorAxis");
11854 const disableHoverablePopup = store.useState("disableHoverablePopup");
11855 const floatingRootContext = store.useState("floatingRootContext");
11856 const instantType = store.useState("instantType");
11857 const transitionStatus = store.useState("transitionStatus");
11858 const hasViewport = store.useState("hasViewport");
11859 const positioning = useAnchorPositioning({
11860 anchor,
11861 positionMethod,
11862 floatingRootContext,
11863 mounted,
11864 side,
11865 sideOffset,
11866 align,
11867 alignOffset,
11868 collisionBoundary,
11869 collisionPadding,
11870 sticky,
11871 arrowPadding,
11872 disableAnchorTracking,
11873 keepMounted,
11874 collisionAvoidance,
11875 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
11876 });
11877 const state = React77.useMemo(() => ({
11878 open,
11879 side: positioning.side,
11880 align: positioning.align,
11881 anchorHidden: positioning.anchorHidden,
11882 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
11883 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
11884 const element = usePositioner(componentProps, state, {
11885 styles: positioning.positionerStyles,
11886 transitionStatus,
11887 props: elementProps,
11888 refs: [forwardedRef, store.useStateSetter("positionerElement")],
11889 hidden: !mounted,
11890 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
11891 });
11892 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipPositionerContext.Provider, {
11893 value: positioning,
11894 children: element
11895 });
11896 });
11897 if (true) TooltipPositioner.displayName = "TooltipPositioner";
11898
11899 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
11900 var React78 = __toESM(require_react(), 1);
11901 var stateAttributesMapping5 = {
11902 ...popupStateMapping,
11903 ...transitionStatusMapping
11904 };
11905 var TooltipPopup = /* @__PURE__ */ React78.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
11906 const {
11907 render: render4,
11908 className,
11909 style,
11910 ...elementProps
11911 } = componentProps;
11912 const store = useTooltipRootContext();
11913 const {
11914 side,
11915 align
11916 } = useTooltipPositionerContext();
11917 const open = store.useState("open");
11918 const instantType = store.useState("instantType");
11919 const transitionStatus = store.useState("transitionStatus");
11920 const popupProps = store.useState("popupProps");
11921 const floatingContext = store.useState("floatingRootContext");
11922 const disabled2 = store.useState("disabled");
11923 const closeDelay = store.useState("closeDelay");
11924 useOpenChangeComplete({
11925 open,
11926 ref: store.context.popupRef,
11927 onComplete() {
11928 if (open) {
11929 store.context.onOpenChangeComplete?.(true);
11930 }
11931 }
11932 });
11933 useHoverFloatingInteraction(floatingContext, {
11934 enabled: !disabled2,
11935 closeDelay
11936 });
11937 const setPopupElement = store.useStateSetter("popupElement");
11938 const state = {
11939 open,
11940 side,
11941 align,
11942 instant: instantType,
11943 transitionStatus
11944 };
11945 const element = useRenderElement("div", componentProps, {
11946 state,
11947 ref: [forwardedRef, store.context.popupRef, setPopupElement],
11948 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
11949 stateAttributesMapping: stateAttributesMapping5
11950 });
11951 return element;
11952 });
11953 if (true) TooltipPopup.displayName = "TooltipPopup";
11954
11955 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
11956 var React79 = __toESM(require_react(), 1);
11957 var TooltipArrow = /* @__PURE__ */ React79.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
11958 const {
11959 render: render4,
11960 className,
11961 style,
11962 ...elementProps
11963 } = componentProps;
11964 const store = useTooltipRootContext();
11965 const {
11966 arrowRef,
11967 side,
11968 align,
11969 arrowUncentered,
11970 arrowStyles
11971 } = useTooltipPositionerContext();
11972 const open = store.useState("open");
11973 const instantType = store.useState("instantType");
11974 const state = {
11975 open,
11976 side,
11977 align,
11978 uncentered: arrowUncentered,
11979 instant: instantType
11980 };
11981 const element = useRenderElement("div", componentProps, {
11982 state,
11983 ref: [forwardedRef, arrowRef],
11984 props: [{
11985 style: arrowStyles,
11986 "aria-hidden": true
11987 }, elementProps],
11988 stateAttributesMapping: popupStateMapping
11989 });
11990 return element;
11991 });
11992 if (true) TooltipArrow.displayName = "TooltipArrow";
11993
11994 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
11995 var React80 = __toESM(require_react(), 1);
11996 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
11997 var TooltipProvider = function TooltipProvider2(props) {
11998 const {
11999 delay,
12000 closeDelay,
12001 timeout = 400
12002 } = props;
12003 const contextValue = React80.useMemo(() => ({
12004 delay,
12005 closeDelay
12006 }), [delay, closeDelay]);
12007 const delayValue = React80.useMemo(() => ({
12008 open: delay,
12009 close: closeDelay
12010 }), [delay, closeDelay]);
12011 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TooltipProviderContext.Provider, {
12012 value: contextValue,
12013 children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FloatingDelayGroup, {
12014 delay: delayValue,
12015 timeoutMs: timeout,
12016 children: props.children
12017 })
12018 });
12019 };
12020 if (true) TooltipProvider.displayName = "TooltipProvider";
12021
12022 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
12023 var React81 = __toESM(require_react(), 1);
12024
12025 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
12026 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
12027 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
12028 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
12029 return TooltipViewportCssVars2;
12030 })({});
12031
12032 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
12033 var stateAttributesMapping6 = {
12034 activationDirection: (value) => value ? {
12035 "data-activation-direction": value
12036 } : null
12037 };
12038 var TooltipViewport = /* @__PURE__ */ React81.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
12039 const {
12040 render: render4,
12041 className,
12042 style,
12043 children,
12044 ...elementProps
12045 } = componentProps;
12046 const store = useTooltipRootContext();
12047 const positioner = useTooltipPositionerContext();
12048 const instantType = store.useState("instantType");
12049 const {
12050 children: childrenToRender,
12051 state: viewportState
12052 } = usePopupViewport({
12053 store,
12054 side: positioner.side,
12055 cssVars: TooltipViewportCssVars,
12056 children
12057 });
12058 const state = {
12059 activationDirection: viewportState.activationDirection,
12060 transitioning: viewportState.transitioning,
12061 instant: instantType
12062 };
12063 return useRenderElement("div", componentProps, {
12064 state,
12065 ref: forwardedRef,
12066 props: [elementProps, {
12067 children: childrenToRender
12068 }],
12069 stateAttributesMapping: stateAttributesMapping6
12070 });
12071 });
12072 if (true) TooltipViewport.displayName = "TooltipViewport";
12073
12074 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
12075 var TooltipHandle = class {
12076 /**
12077 * Internal store holding the tooltip state.
12078 * @internal
12079 */
12080 constructor() {
12081 this.store = new TooltipStore();
12082 }
12083 /**
12084 * Opens the tooltip and associates it with the trigger with the given ID.
12085 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
12086 *
12087 * This method should only be called in an event handler or an effect (not during rendering).
12088 *
12089 * @param triggerId ID of the trigger to associate with the tooltip.
12090 */
12091 open(triggerId) {
12092 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
12093 if (triggerId && !triggerElement) {
12094 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
12095 }
12096 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
12097 }
12098 /**
12099 * Closes the tooltip.
12100 */
12101 close() {
12102 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
12103 }
12104 /**
12105 * Indicates whether the tooltip is currently open.
12106 */
12107 get isOpen() {
12108 return this.store.select("open");
12109 }
12110 };
12111 function createTooltipHandle() {
12112 return new TooltipHandle();
12113 }
12114
12115 // node_modules/@base-ui/react/esm/use-render/useRender.js
12116 function useRender(params) {
12117 return useRenderElement(params.defaultTagName ?? "div", params, params);
12118 }
12119
12120 // packages/ui/build-module/text/text.mjs
12121 var import_element12 = __toESM(require_element(), 1);
12122 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
12123 function getRuntime() {
12124 const globalScope = globalThis;
12125 if (globalScope.__wpStyleRuntime) {
12126 return globalScope.__wpStyleRuntime;
12127 }
12128 globalScope.__wpStyleRuntime = {
12129 documents: /* @__PURE__ */ new Map(),
12130 styles: /* @__PURE__ */ new Map(),
12131 injectedStyles: /* @__PURE__ */ new WeakMap()
12132 };
12133 if (typeof document !== "undefined") {
12134 registerDocument(document);
12135 }
12136 return globalScope.__wpStyleRuntime;
12137 }
12138 function documentContainsStyleHash(targetDocument, hash) {
12139 if (!targetDocument.head) {
12140 return false;
12141 }
12142 for (const style of targetDocument.head.querySelectorAll(
12143 `style[${STYLE_HASH_ATTRIBUTE}]`
12144 )) {
12145 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
12146 return true;
12147 }
12148 }
12149 return false;
12150 }
12151 function injectStyle(targetDocument, hash, css) {
12152 if (!targetDocument.head) {
12153 return;
12154 }
12155 const runtime = getRuntime();
12156 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12157 if (!injectedStyles) {
12158 injectedStyles = /* @__PURE__ */ new Set();
12159 runtime.injectedStyles.set(targetDocument, injectedStyles);
12160 }
12161 if (injectedStyles.has(hash)) {
12162 return;
12163 }
12164 if (documentContainsStyleHash(targetDocument, hash)) {
12165 injectedStyles.add(hash);
12166 return;
12167 }
12168 const style = targetDocument.createElement("style");
12169 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
12170 style.appendChild(targetDocument.createTextNode(css));
12171 targetDocument.head.appendChild(style);
12172 injectedStyles.add(hash);
12173 }
12174 function registerDocument(targetDocument) {
12175 const runtime = getRuntime();
12176 runtime.documents.set(
12177 targetDocument,
12178 (runtime.documents.get(targetDocument) ?? 0) + 1
12179 );
12180 for (const [hash, css] of runtime.styles) {
12181 injectStyle(targetDocument, hash, css);
12182 }
12183 return () => {
12184 const count = runtime.documents.get(targetDocument);
12185 if (count === void 0) {
12186 return;
12187 }
12188 if (count <= 1) {
12189 runtime.documents.delete(targetDocument);
12190 return;
12191 }
12192 runtime.documents.set(targetDocument, count - 1);
12193 };
12194 }
12195 function registerStyle(hash, css) {
12196 const runtime = getRuntime();
12197 runtime.styles.set(hash, css);
12198 for (const targetDocument of runtime.documents.keys()) {
12199 injectStyle(targetDocument, hash, css);
12200 }
12201 }
12202 if (typeof process === "undefined" || true) {
12203 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)}}}');
12204 }
12205 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" };
12206 if (typeof process === "undefined" || true) {
12207 registerStyle("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-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)}");
12208 }
12209 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" };
12210 var Text = (0, import_element12.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
12211 const element = useRender({
12212 render: render4,
12213 defaultTagName: "span",
12214 ref,
12215 props: mergeProps(props, {
12216 className: clsx_default(
12217 style_default.text,
12218 global_css_defense_default.heading,
12219 global_css_defense_default.p,
12220 style_default[variant],
12221 className
12222 )
12223 })
12224 });
12225 return element;
12226 });
12227
12228 // packages/ui/build-module/badge/badge.mjs
12229 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
12230 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
12231 function getRuntime2() {
12232 const globalScope = globalThis;
12233 if (globalScope.__wpStyleRuntime) {
12234 return globalScope.__wpStyleRuntime;
12235 }
12236 globalScope.__wpStyleRuntime = {
12237 documents: /* @__PURE__ */ new Map(),
12238 styles: /* @__PURE__ */ new Map(),
12239 injectedStyles: /* @__PURE__ */ new WeakMap()
12240 };
12241 if (typeof document !== "undefined") {
12242 registerDocument2(document);
12243 }
12244 return globalScope.__wpStyleRuntime;
12245 }
12246 function documentContainsStyleHash2(targetDocument, hash) {
12247 if (!targetDocument.head) {
12248 return false;
12249 }
12250 for (const style of targetDocument.head.querySelectorAll(
12251 `style[${STYLE_HASH_ATTRIBUTE2}]`
12252 )) {
12253 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
12254 return true;
12255 }
12256 }
12257 return false;
12258 }
12259 function injectStyle2(targetDocument, hash, css) {
12260 if (!targetDocument.head) {
12261 return;
12262 }
12263 const runtime = getRuntime2();
12264 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12265 if (!injectedStyles) {
12266 injectedStyles = /* @__PURE__ */ new Set();
12267 runtime.injectedStyles.set(targetDocument, injectedStyles);
12268 }
12269 if (injectedStyles.has(hash)) {
12270 return;
12271 }
12272 if (documentContainsStyleHash2(targetDocument, hash)) {
12273 injectedStyles.add(hash);
12274 return;
12275 }
12276 const style = targetDocument.createElement("style");
12277 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
12278 style.appendChild(targetDocument.createTextNode(css));
12279 targetDocument.head.appendChild(style);
12280 injectedStyles.add(hash);
12281 }
12282 function registerDocument2(targetDocument) {
12283 const runtime = getRuntime2();
12284 runtime.documents.set(
12285 targetDocument,
12286 (runtime.documents.get(targetDocument) ?? 0) + 1
12287 );
12288 for (const [hash, css] of runtime.styles) {
12289 injectStyle2(targetDocument, hash, css);
12290 }
12291 return () => {
12292 const count = runtime.documents.get(targetDocument);
12293 if (count === void 0) {
12294 return;
12295 }
12296 if (count <= 1) {
12297 runtime.documents.delete(targetDocument);
12298 return;
12299 }
12300 runtime.documents.set(targetDocument, count - 1);
12301 };
12302 }
12303 function registerStyle2(hash, css) {
12304 const runtime = getRuntime2();
12305 runtime.styles.set(hash, css);
12306 for (const targetDocument of runtime.documents.keys()) {
12307 injectStyle2(targetDocument, hash, css);
12308 }
12309 }
12310 if (typeof process === "undefined" || true) {
12311 registerStyle2("9db2873e7f", "@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-background-surface-error,#f6e6e3);color:var(--wpds-color-foreground-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-background-surface-warning,#fde6be);color:var(--wpds-color-foreground-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-background-surface-caution,#fee995);color:var(--wpds-color-foreground-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-background-surface-success,#c6f7cd);color:var(--wpds-color-foreground-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-background-surface-info,#deebfa);color:var(--wpds-color-foreground-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-foreground-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))}}}");
12312 }
12313 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" };
12314 var Badge = (0, import_element13.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
12315 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
12316 Text,
12317 {
12318 ref,
12319 className: clsx_default(
12320 style_default2.badge,
12321 style_default2[`is-${intent}-intent`],
12322 className
12323 ),
12324 ...props,
12325 variant: "body-sm"
12326 }
12327 );
12328 });
12329
12330 // packages/ui/build-module/button/button.mjs
12331 var import_element14 = __toESM(require_element(), 1);
12332 var import_i18n = __toESM(require_i18n(), 1);
12333 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
12334 import { speak } from "@wordpress/a11y";
12335 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
12336 function getRuntime3() {
12337 const globalScope = globalThis;
12338 if (globalScope.__wpStyleRuntime) {
12339 return globalScope.__wpStyleRuntime;
12340 }
12341 globalScope.__wpStyleRuntime = {
12342 documents: /* @__PURE__ */ new Map(),
12343 styles: /* @__PURE__ */ new Map(),
12344 injectedStyles: /* @__PURE__ */ new WeakMap()
12345 };
12346 if (typeof document !== "undefined") {
12347 registerDocument3(document);
12348 }
12349 return globalScope.__wpStyleRuntime;
12350 }
12351 function documentContainsStyleHash3(targetDocument, hash) {
12352 if (!targetDocument.head) {
12353 return false;
12354 }
12355 for (const style of targetDocument.head.querySelectorAll(
12356 `style[${STYLE_HASH_ATTRIBUTE3}]`
12357 )) {
12358 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
12359 return true;
12360 }
12361 }
12362 return false;
12363 }
12364 function injectStyle3(targetDocument, hash, css) {
12365 if (!targetDocument.head) {
12366 return;
12367 }
12368 const runtime = getRuntime3();
12369 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12370 if (!injectedStyles) {
12371 injectedStyles = /* @__PURE__ */ new Set();
12372 runtime.injectedStyles.set(targetDocument, injectedStyles);
12373 }
12374 if (injectedStyles.has(hash)) {
12375 return;
12376 }
12377 if (documentContainsStyleHash3(targetDocument, hash)) {
12378 injectedStyles.add(hash);
12379 return;
12380 }
12381 const style = targetDocument.createElement("style");
12382 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
12383 style.appendChild(targetDocument.createTextNode(css));
12384 targetDocument.head.appendChild(style);
12385 injectedStyles.add(hash);
12386 }
12387 function registerDocument3(targetDocument) {
12388 const runtime = getRuntime3();
12389 runtime.documents.set(
12390 targetDocument,
12391 (runtime.documents.get(targetDocument) ?? 0) + 1
12392 );
12393 for (const [hash, css] of runtime.styles) {
12394 injectStyle3(targetDocument, hash, css);
12395 }
12396 return () => {
12397 const count = runtime.documents.get(targetDocument);
12398 if (count === void 0) {
12399 return;
12400 }
12401 if (count <= 1) {
12402 runtime.documents.delete(targetDocument);
12403 return;
12404 }
12405 runtime.documents.set(targetDocument, count - 1);
12406 };
12407 }
12408 function registerStyle3(hash, css) {
12409 const runtime = getRuntime3();
12410 runtime.styles.set(hash, css);
12411 for (const targetDocument of runtime.documents.keys()) {
12412 injectStyle3(targetDocument, hash, css);
12413 }
12414 }
12415 if (typeof process === "undefined" || true) {
12416 registerStyle3("4c317b0736", '@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:var(--wpds-typography-font-weight-medium,499);--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-background-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-background-interactive-brand-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-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:var(--wpds-dimension-size-lg,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:calc((var(--wpds-dimension-size-2xs, 16px) - var(--wpds-dimension-size-sm, 24px))/2);--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}@media (forced-colors:active){border-block-end-style:none;border-bottom-color:ButtonText;border-inline-start-style:none;border-left-color:ButtonText;border-right-color:ButtonText;border-top-color:ButtonText}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:var(--wpds-dimension-size-sm,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-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-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-background-interactive-brand-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-brand-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-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-background-interactive-brand-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-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-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:var(--wpds-dimension-size-md,32px)}._914b42f315c0e580__is-loading:not(.abbb272e2ce49bd6__is-unstyled){color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}@media (forced-colors:active){color:ButtonFace}*{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)}}}');
12417 }
12418 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" };
12419 if (typeof process === "undefined" || true) {
12420 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
12421 }
12422 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
12423 if (typeof process === "undefined" || true) {
12424 registerStyle3("5f8e7aa0bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
12425 }
12426 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" };
12427 if (typeof process === "undefined" || true) {
12428 registerStyle3("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-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)}");
12429 }
12430 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" };
12431 var Button3 = (0, import_element14.forwardRef)(
12432 function Button22({
12433 tone = "brand",
12434 variant = "solid",
12435 size: size4 = "default",
12436 className,
12437 focusableWhenDisabled = true,
12438 disabled: disabled2,
12439 loading,
12440 loadingAnnouncement = (0, import_i18n.__)("Loading"),
12441 children,
12442 ...props
12443 }, ref) {
12444 const mergedClassName = clsx_default(
12445 global_css_defense_default2.button,
12446 resets_default["box-sizing"],
12447 focus_default["outset-ring--focus-except-active"],
12448 variant !== "unstyled" && style_default3.button,
12449 style_default3[`is-${tone}`],
12450 style_default3[`is-${variant}`],
12451 style_default3[`is-${size4}`],
12452 loading && style_default3["is-loading"],
12453 className
12454 );
12455 (0, import_element14.useEffect)(() => {
12456 if (loading && loadingAnnouncement) {
12457 speak(loadingAnnouncement);
12458 }
12459 }, [loading, loadingAnnouncement]);
12460 return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
12461 Button,
12462 {
12463 ref,
12464 className: mergedClassName,
12465 focusableWhenDisabled,
12466 disabled: disabled2 ?? loading,
12467 ...props,
12468 children
12469 }
12470 );
12471 }
12472 );
12473
12474 // packages/ui/build-module/button/icon.mjs
12475 var import_element16 = __toESM(require_element(), 1);
12476
12477 // packages/ui/build-module/icon/icon.mjs
12478 var import_element15 = __toESM(require_element(), 1);
12479 var import_primitives = __toESM(require_primitives(), 1);
12480 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
12481 var Icon = (0, import_element15.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
12482 return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
12483 import_primitives.SVG,
12484 {
12485 ref,
12486 ...icon.props,
12487 ...restProps,
12488 width: size4,
12489 height: size4
12490 }
12491 );
12492 });
12493
12494 // packages/ui/build-module/button/icon.mjs
12495 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
12496 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
12497 function getRuntime4() {
12498 const globalScope = globalThis;
12499 if (globalScope.__wpStyleRuntime) {
12500 return globalScope.__wpStyleRuntime;
12501 }
12502 globalScope.__wpStyleRuntime = {
12503 documents: /* @__PURE__ */ new Map(),
12504 styles: /* @__PURE__ */ new Map(),
12505 injectedStyles: /* @__PURE__ */ new WeakMap()
12506 };
12507 if (typeof document !== "undefined") {
12508 registerDocument4(document);
12509 }
12510 return globalScope.__wpStyleRuntime;
12511 }
12512 function documentContainsStyleHash4(targetDocument, hash) {
12513 if (!targetDocument.head) {
12514 return false;
12515 }
12516 for (const style of targetDocument.head.querySelectorAll(
12517 `style[${STYLE_HASH_ATTRIBUTE4}]`
12518 )) {
12519 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
12520 return true;
12521 }
12522 }
12523 return false;
12524 }
12525 function injectStyle4(targetDocument, hash, css) {
12526 if (!targetDocument.head) {
12527 return;
12528 }
12529 const runtime = getRuntime4();
12530 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12531 if (!injectedStyles) {
12532 injectedStyles = /* @__PURE__ */ new Set();
12533 runtime.injectedStyles.set(targetDocument, injectedStyles);
12534 }
12535 if (injectedStyles.has(hash)) {
12536 return;
12537 }
12538 if (documentContainsStyleHash4(targetDocument, hash)) {
12539 injectedStyles.add(hash);
12540 return;
12541 }
12542 const style = targetDocument.createElement("style");
12543 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
12544 style.appendChild(targetDocument.createTextNode(css));
12545 targetDocument.head.appendChild(style);
12546 injectedStyles.add(hash);
12547 }
12548 function registerDocument4(targetDocument) {
12549 const runtime = getRuntime4();
12550 runtime.documents.set(
12551 targetDocument,
12552 (runtime.documents.get(targetDocument) ?? 0) + 1
12553 );
12554 for (const [hash, css] of runtime.styles) {
12555 injectStyle4(targetDocument, hash, css);
12556 }
12557 return () => {
12558 const count = runtime.documents.get(targetDocument);
12559 if (count === void 0) {
12560 return;
12561 }
12562 if (count <= 1) {
12563 runtime.documents.delete(targetDocument);
12564 return;
12565 }
12566 runtime.documents.set(targetDocument, count - 1);
12567 };
12568 }
12569 function registerStyle4(hash, css) {
12570 const runtime = getRuntime4();
12571 runtime.styles.set(hash, css);
12572 for (const targetDocument of runtime.documents.keys()) {
12573 injectStyle4(targetDocument, hash, css);
12574 }
12575 }
12576 if (typeof process === "undefined" || true) {
12577 registerStyle4("4c317b0736", '@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:var(--wpds-typography-font-weight-medium,499);--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-background-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-background-interactive-brand-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-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:var(--wpds-dimension-size-lg,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:calc((var(--wpds-dimension-size-2xs, 16px) - var(--wpds-dimension-size-sm, 24px))/2);--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}@media (forced-colors:active){border-block-end-style:none;border-bottom-color:ButtonText;border-inline-start-style:none;border-left-color:ButtonText;border-right-color:ButtonText;border-top-color:ButtonText}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:var(--wpds-dimension-size-sm,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-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-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-background-interactive-brand-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-brand-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-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-background-interactive-brand-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-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-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:var(--wpds-dimension-size-md,32px)}._914b42f315c0e580__is-loading:not(.abbb272e2ce49bd6__is-unstyled){color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}@media (forced-colors:active){color:ButtonFace}*{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)}}}');
12578 }
12579 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" };
12580 var ButtonIcon = (0, import_element16.forwardRef)(
12581 function ButtonIcon2({ className, icon, ...props }, ref) {
12582 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
12583 Icon,
12584 {
12585 ref,
12586 icon,
12587 className: clsx_default(style_default4.icon, className),
12588 size: 24,
12589 ...props
12590 }
12591 );
12592 }
12593 );
12594
12595 // packages/ui/build-module/button/index.mjs
12596 ButtonIcon.displayName = "Button.Icon";
12597 var Button4 = Object.assign(Button3, {
12598 /**
12599 * An icon component specifically designed to work well when rendered inside
12600 * a `Button` component.
12601 */
12602 Icon: ButtonIcon
12603 });
12604
12605 // packages/ui/build-module/card/index.mjs
12606 var card_exports = {};
12607 __export(card_exports, {
12608 Content: () => Content,
12609 FullBleed: () => FullBleed,
12610 Header: () => Header,
12611 Root: () => Root,
12612 Title: () => Title
12613 });
12614
12615 // packages/ui/build-module/card/root.mjs
12616 var import_element17 = __toESM(require_element(), 1);
12617 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
12618 function getRuntime5() {
12619 const globalScope = globalThis;
12620 if (globalScope.__wpStyleRuntime) {
12621 return globalScope.__wpStyleRuntime;
12622 }
12623 globalScope.__wpStyleRuntime = {
12624 documents: /* @__PURE__ */ new Map(),
12625 styles: /* @__PURE__ */ new Map(),
12626 injectedStyles: /* @__PURE__ */ new WeakMap()
12627 };
12628 if (typeof document !== "undefined") {
12629 registerDocument5(document);
12630 }
12631 return globalScope.__wpStyleRuntime;
12632 }
12633 function documentContainsStyleHash5(targetDocument, hash) {
12634 if (!targetDocument.head) {
12635 return false;
12636 }
12637 for (const style of targetDocument.head.querySelectorAll(
12638 `style[${STYLE_HASH_ATTRIBUTE5}]`
12639 )) {
12640 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
12641 return true;
12642 }
12643 }
12644 return false;
12645 }
12646 function injectStyle5(targetDocument, hash, css) {
12647 if (!targetDocument.head) {
12648 return;
12649 }
12650 const runtime = getRuntime5();
12651 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12652 if (!injectedStyles) {
12653 injectedStyles = /* @__PURE__ */ new Set();
12654 runtime.injectedStyles.set(targetDocument, injectedStyles);
12655 }
12656 if (injectedStyles.has(hash)) {
12657 return;
12658 }
12659 if (documentContainsStyleHash5(targetDocument, hash)) {
12660 injectedStyles.add(hash);
12661 return;
12662 }
12663 const style = targetDocument.createElement("style");
12664 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
12665 style.appendChild(targetDocument.createTextNode(css));
12666 targetDocument.head.appendChild(style);
12667 injectedStyles.add(hash);
12668 }
12669 function registerDocument5(targetDocument) {
12670 const runtime = getRuntime5();
12671 runtime.documents.set(
12672 targetDocument,
12673 (runtime.documents.get(targetDocument) ?? 0) + 1
12674 );
12675 for (const [hash, css] of runtime.styles) {
12676 injectStyle5(targetDocument, hash, css);
12677 }
12678 return () => {
12679 const count = runtime.documents.get(targetDocument);
12680 if (count === void 0) {
12681 return;
12682 }
12683 if (count <= 1) {
12684 runtime.documents.delete(targetDocument);
12685 return;
12686 }
12687 runtime.documents.set(targetDocument, count - 1);
12688 };
12689 }
12690 function registerStyle5(hash, css) {
12691 const runtime = getRuntime5();
12692 runtime.styles.set(hash, css);
12693 for (const targetDocument of runtime.documents.keys()) {
12694 injectStyle5(targetDocument, hash, css);
12695 }
12696 }
12697 if (typeof process === "undefined" || true) {
12698 registerStyle5("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
12699 }
12700 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
12701 if (typeof process === "undefined" || true) {
12702 registerStyle5("5d38cbdd27", "@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-background-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-foreground-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)}}}");
12703 }
12704 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
12705 var Root = (0, import_element17.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
12706 const mergedClassName = clsx_default(style_default5.root, resets_default2["box-sizing"]);
12707 const element = useRender({
12708 defaultTagName: "div",
12709 render: render4,
12710 ref,
12711 props: mergeProps({ className: mergedClassName }, restProps)
12712 });
12713 return element;
12714 });
12715
12716 // packages/ui/build-module/card/header.mjs
12717 var import_element18 = __toESM(require_element(), 1);
12718 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
12719 function getRuntime6() {
12720 const globalScope = globalThis;
12721 if (globalScope.__wpStyleRuntime) {
12722 return globalScope.__wpStyleRuntime;
12723 }
12724 globalScope.__wpStyleRuntime = {
12725 documents: /* @__PURE__ */ new Map(),
12726 styles: /* @__PURE__ */ new Map(),
12727 injectedStyles: /* @__PURE__ */ new WeakMap()
12728 };
12729 if (typeof document !== "undefined") {
12730 registerDocument6(document);
12731 }
12732 return globalScope.__wpStyleRuntime;
12733 }
12734 function documentContainsStyleHash6(targetDocument, hash) {
12735 if (!targetDocument.head) {
12736 return false;
12737 }
12738 for (const style of targetDocument.head.querySelectorAll(
12739 `style[${STYLE_HASH_ATTRIBUTE6}]`
12740 )) {
12741 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
12742 return true;
12743 }
12744 }
12745 return false;
12746 }
12747 function injectStyle6(targetDocument, hash, css) {
12748 if (!targetDocument.head) {
12749 return;
12750 }
12751 const runtime = getRuntime6();
12752 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12753 if (!injectedStyles) {
12754 injectedStyles = /* @__PURE__ */ new Set();
12755 runtime.injectedStyles.set(targetDocument, injectedStyles);
12756 }
12757 if (injectedStyles.has(hash)) {
12758 return;
12759 }
12760 if (documentContainsStyleHash6(targetDocument, hash)) {
12761 injectedStyles.add(hash);
12762 return;
12763 }
12764 const style = targetDocument.createElement("style");
12765 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
12766 style.appendChild(targetDocument.createTextNode(css));
12767 targetDocument.head.appendChild(style);
12768 injectedStyles.add(hash);
12769 }
12770 function registerDocument6(targetDocument) {
12771 const runtime = getRuntime6();
12772 runtime.documents.set(
12773 targetDocument,
12774 (runtime.documents.get(targetDocument) ?? 0) + 1
12775 );
12776 for (const [hash, css] of runtime.styles) {
12777 injectStyle6(targetDocument, hash, css);
12778 }
12779 return () => {
12780 const count = runtime.documents.get(targetDocument);
12781 if (count === void 0) {
12782 return;
12783 }
12784 if (count <= 1) {
12785 runtime.documents.delete(targetDocument);
12786 return;
12787 }
12788 runtime.documents.set(targetDocument, count - 1);
12789 };
12790 }
12791 function registerStyle6(hash, css) {
12792 const runtime = getRuntime6();
12793 runtime.styles.set(hash, css);
12794 for (const targetDocument of runtime.documents.keys()) {
12795 injectStyle6(targetDocument, hash, css);
12796 }
12797 }
12798 if (typeof process === "undefined" || true) {
12799 registerStyle6("5d38cbdd27", "@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-background-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-foreground-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)}}}");
12800 }
12801 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
12802 var Header = (0, import_element18.forwardRef)(
12803 function CardHeader({ render: render4, ...props }, ref) {
12804 const element = useRender({
12805 defaultTagName: "div",
12806 render: render4,
12807 ref,
12808 props: mergeProps({ className: style_default6.header }, props)
12809 });
12810 return element;
12811 }
12812 );
12813
12814 // packages/ui/build-module/card/content.mjs
12815 var import_element19 = __toESM(require_element(), 1);
12816 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
12817 function getRuntime7() {
12818 const globalScope = globalThis;
12819 if (globalScope.__wpStyleRuntime) {
12820 return globalScope.__wpStyleRuntime;
12821 }
12822 globalScope.__wpStyleRuntime = {
12823 documents: /* @__PURE__ */ new Map(),
12824 styles: /* @__PURE__ */ new Map(),
12825 injectedStyles: /* @__PURE__ */ new WeakMap()
12826 };
12827 if (typeof document !== "undefined") {
12828 registerDocument7(document);
12829 }
12830 return globalScope.__wpStyleRuntime;
12831 }
12832 function documentContainsStyleHash7(targetDocument, hash) {
12833 if (!targetDocument.head) {
12834 return false;
12835 }
12836 for (const style of targetDocument.head.querySelectorAll(
12837 `style[${STYLE_HASH_ATTRIBUTE7}]`
12838 )) {
12839 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
12840 return true;
12841 }
12842 }
12843 return false;
12844 }
12845 function injectStyle7(targetDocument, hash, css) {
12846 if (!targetDocument.head) {
12847 return;
12848 }
12849 const runtime = getRuntime7();
12850 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12851 if (!injectedStyles) {
12852 injectedStyles = /* @__PURE__ */ new Set();
12853 runtime.injectedStyles.set(targetDocument, injectedStyles);
12854 }
12855 if (injectedStyles.has(hash)) {
12856 return;
12857 }
12858 if (documentContainsStyleHash7(targetDocument, hash)) {
12859 injectedStyles.add(hash);
12860 return;
12861 }
12862 const style = targetDocument.createElement("style");
12863 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
12864 style.appendChild(targetDocument.createTextNode(css));
12865 targetDocument.head.appendChild(style);
12866 injectedStyles.add(hash);
12867 }
12868 function registerDocument7(targetDocument) {
12869 const runtime = getRuntime7();
12870 runtime.documents.set(
12871 targetDocument,
12872 (runtime.documents.get(targetDocument) ?? 0) + 1
12873 );
12874 for (const [hash, css] of runtime.styles) {
12875 injectStyle7(targetDocument, hash, css);
12876 }
12877 return () => {
12878 const count = runtime.documents.get(targetDocument);
12879 if (count === void 0) {
12880 return;
12881 }
12882 if (count <= 1) {
12883 runtime.documents.delete(targetDocument);
12884 return;
12885 }
12886 runtime.documents.set(targetDocument, count - 1);
12887 };
12888 }
12889 function registerStyle7(hash, css) {
12890 const runtime = getRuntime7();
12891 runtime.styles.set(hash, css);
12892 for (const targetDocument of runtime.documents.keys()) {
12893 injectStyle7(targetDocument, hash, css);
12894 }
12895 }
12896 if (typeof process === "undefined" || true) {
12897 registerStyle7("5d38cbdd27", "@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-background-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-foreground-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)}}}");
12898 }
12899 var style_default7 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
12900 var Content = (0, import_element19.forwardRef)(
12901 function CardContent({ render: render4, ...props }, ref) {
12902 const element = useRender({
12903 defaultTagName: "div",
12904 render: render4,
12905 ref,
12906 props: mergeProps({ className: style_default7.content }, props)
12907 });
12908 return element;
12909 }
12910 );
12911
12912 // packages/ui/build-module/card/full-bleed.mjs
12913 var import_element20 = __toESM(require_element(), 1);
12914 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
12915 function getRuntime8() {
12916 const globalScope = globalThis;
12917 if (globalScope.__wpStyleRuntime) {
12918 return globalScope.__wpStyleRuntime;
12919 }
12920 globalScope.__wpStyleRuntime = {
12921 documents: /* @__PURE__ */ new Map(),
12922 styles: /* @__PURE__ */ new Map(),
12923 injectedStyles: /* @__PURE__ */ new WeakMap()
12924 };
12925 if (typeof document !== "undefined") {
12926 registerDocument8(document);
12927 }
12928 return globalScope.__wpStyleRuntime;
12929 }
12930 function documentContainsStyleHash8(targetDocument, hash) {
12931 if (!targetDocument.head) {
12932 return false;
12933 }
12934 for (const style of targetDocument.head.querySelectorAll(
12935 `style[${STYLE_HASH_ATTRIBUTE8}]`
12936 )) {
12937 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
12938 return true;
12939 }
12940 }
12941 return false;
12942 }
12943 function injectStyle8(targetDocument, hash, css) {
12944 if (!targetDocument.head) {
12945 return;
12946 }
12947 const runtime = getRuntime8();
12948 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12949 if (!injectedStyles) {
12950 injectedStyles = /* @__PURE__ */ new Set();
12951 runtime.injectedStyles.set(targetDocument, injectedStyles);
12952 }
12953 if (injectedStyles.has(hash)) {
12954 return;
12955 }
12956 if (documentContainsStyleHash8(targetDocument, hash)) {
12957 injectedStyles.add(hash);
12958 return;
12959 }
12960 const style = targetDocument.createElement("style");
12961 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
12962 style.appendChild(targetDocument.createTextNode(css));
12963 targetDocument.head.appendChild(style);
12964 injectedStyles.add(hash);
12965 }
12966 function registerDocument8(targetDocument) {
12967 const runtime = getRuntime8();
12968 runtime.documents.set(
12969 targetDocument,
12970 (runtime.documents.get(targetDocument) ?? 0) + 1
12971 );
12972 for (const [hash, css] of runtime.styles) {
12973 injectStyle8(targetDocument, hash, css);
12974 }
12975 return () => {
12976 const count = runtime.documents.get(targetDocument);
12977 if (count === void 0) {
12978 return;
12979 }
12980 if (count <= 1) {
12981 runtime.documents.delete(targetDocument);
12982 return;
12983 }
12984 runtime.documents.set(targetDocument, count - 1);
12985 };
12986 }
12987 function registerStyle8(hash, css) {
12988 const runtime = getRuntime8();
12989 runtime.styles.set(hash, css);
12990 for (const targetDocument of runtime.documents.keys()) {
12991 injectStyle8(targetDocument, hash, css);
12992 }
12993 }
12994 if (typeof process === "undefined" || true) {
12995 registerStyle8("5d38cbdd27", "@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-background-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-foreground-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)}}}");
12996 }
12997 var style_default8 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
12998 var FullBleed = (0, import_element20.forwardRef)(
12999 function CardFullBleed({ render: render4, ...props }, ref) {
13000 const element = useRender({
13001 defaultTagName: "div",
13002 render: render4,
13003 ref,
13004 props: mergeProps(
13005 { className: style_default8.fullbleed },
13006 props
13007 )
13008 });
13009 return element;
13010 }
13011 );
13012
13013 // packages/ui/build-module/card/title.mjs
13014 var import_element21 = __toESM(require_element(), 1);
13015 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
13016 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", {});
13017 var Title = (0, import_element21.forwardRef)(
13018 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
13019 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
13020 Text,
13021 {
13022 ref,
13023 variant: "heading-lg",
13024 render: render4,
13025 ...props,
13026 children
13027 }
13028 );
13029 }
13030 );
13031
13032 // packages/ui/build-module/collapsible/panel.mjs
13033 var import_element22 = __toESM(require_element(), 1);
13034 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
13035 var Panel = (0, import_element22.forwardRef)(
13036 function CollapsiblePanel3(props, forwardedRef) {
13037 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
13038 }
13039 );
13040
13041 // packages/ui/build-module/collapsible/root.mjs
13042 var import_element23 = __toESM(require_element(), 1);
13043 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
13044 var Root2 = (0, import_element23.forwardRef)(
13045 function CollapsibleRoot3(props, forwardedRef) {
13046 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
13047 }
13048 );
13049
13050 // packages/ui/build-module/collapsible/trigger.mjs
13051 var import_element24 = __toESM(require_element(), 1);
13052 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
13053 var Trigger = (0, import_element24.forwardRef)(
13054 function CollapsibleTrigger3(props, forwardedRef) {
13055 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
13056 }
13057 );
13058
13059 // packages/ui/build-module/collapsible-card/index.mjs
13060 var collapsible_card_exports = {};
13061 __export(collapsible_card_exports, {
13062 Content: () => Content2,
13063 Header: () => Header2,
13064 HeaderDescription: () => HeaderDescription,
13065 Root: () => Root3
13066 });
13067
13068 // packages/ui/build-module/collapsible-card/root.mjs
13069 var import_element25 = __toESM(require_element(), 1);
13070 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
13071 var Root3 = (0, import_element25.forwardRef)(
13072 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
13073 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
13074 Root2,
13075 {
13076 ref,
13077 render: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Root, { render: render4 }),
13078 ...restProps
13079 }
13080 );
13081 }
13082 );
13083
13084 // packages/ui/build-module/collapsible-card/header.mjs
13085 var import_element27 = __toESM(require_element(), 1);
13086
13087 // packages/icons/build-module/library/arrow-down.mjs
13088 var import_primitives2 = __toESM(require_primitives(), 1);
13089 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
13090 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.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" }) });
13091
13092 // packages/icons/build-module/library/arrow-left.mjs
13093 var import_primitives3 = __toESM(require_primitives(), 1);
13094 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
13095 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.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" }) });
13096
13097 // packages/icons/build-module/library/arrow-right.mjs
13098 var import_primitives4 = __toESM(require_primitives(), 1);
13099 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
13100 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime31.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" }) });
13101
13102 // packages/icons/build-module/library/arrow-up.mjs
13103 var import_primitives5 = __toESM(require_primitives(), 1);
13104 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
13105 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
13106
13107 // packages/icons/build-module/library/block-table.mjs
13108 var import_primitives6 = __toESM(require_primitives(), 1);
13109 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
13110 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime33.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" }) });
13111
13112 // packages/icons/build-module/library/category.mjs
13113 var import_primitives7 = __toESM(require_primitives(), 1);
13114 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
13115 var category_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime34.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" }) });
13116
13117 // packages/icons/build-module/library/caution.mjs
13118 var import_primitives8 = __toESM(require_primitives(), 1);
13119 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
13120 var caution_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives8.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z" }) });
13121
13122 // packages/icons/build-module/library/check.mjs
13123 var import_primitives9 = __toESM(require_primitives(), 1);
13124 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
13125 var check_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives9.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
13126
13127 // packages/icons/build-module/library/chevron-down.mjs
13128 var import_primitives10 = __toESM(require_primitives(), 1);
13129 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
13130 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives10.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
13131
13132 // packages/icons/build-module/library/close-small.mjs
13133 var import_primitives11 = __toESM(require_primitives(), 1);
13134 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
13135 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives11.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" }) });
13136
13137 // packages/icons/build-module/library/cog.mjs
13138 var import_primitives12 = __toESM(require_primitives(), 1);
13139 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
13140 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives12.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" }) });
13141
13142 // packages/icons/build-module/library/copy.mjs
13143 var import_primitives13 = __toESM(require_primitives(), 1);
13144 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
13145 var copy_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives13.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z" }) });
13146
13147 // packages/icons/build-module/library/envelope.mjs
13148 var import_primitives14 = __toESM(require_primitives(), 1);
13149 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
13150 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives14.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" }) });
13151
13152 // packages/icons/build-module/library/error.mjs
13153 var import_primitives15 = __toESM(require_primitives(), 1);
13154 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
13155 var error_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives15.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" }) });
13156
13157 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
13158 var import_primitives16 = __toESM(require_primitives(), 1);
13159 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
13160 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives16.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) });
13161
13162 // packages/icons/build-module/library/format-list-bullets.mjs
13163 var import_primitives17 = __toESM(require_primitives(), 1);
13164 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
13165 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives17.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
13166
13167 // packages/icons/build-module/library/funnel.mjs
13168 var import_primitives18 = __toESM(require_primitives(), 1);
13169 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
13170 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
13171
13172 // packages/icons/build-module/library/info.mjs
13173 var import_primitives19 = __toESM(require_primitives(), 1);
13174 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
13175 var info_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives19.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" }) });
13176
13177 // packages/icons/build-module/library/link.mjs
13178 var import_primitives20 = __toESM(require_primitives(), 1);
13179 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
13180 var link_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime47.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" }) });
13181
13182 // packages/icons/build-module/library/mobile.mjs
13183 var import_primitives21 = __toESM(require_primitives(), 1);
13184 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
13185 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime48.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" }) });
13186
13187 // packages/icons/build-module/library/more-vertical.mjs
13188 var import_primitives22 = __toESM(require_primitives(), 1);
13189 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
13190 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
13191
13192 // packages/icons/build-module/library/next.mjs
13193 var import_primitives23 = __toESM(require_primitives(), 1);
13194 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
13195 var next_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime50.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" }) });
13196
13197 // packages/icons/build-module/library/pencil.mjs
13198 var import_primitives24 = __toESM(require_primitives(), 1);
13199 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
13200 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives24.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
13201
13202 // packages/icons/build-module/library/previous.mjs
13203 var import_primitives25 = __toESM(require_primitives(), 1);
13204 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
13205 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives25.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" }) });
13206
13207 // packages/icons/build-module/library/published.mjs
13208 var import_primitives26 = __toESM(require_primitives(), 1);
13209 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
13210 var published_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives26.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 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z" }) });
13211
13212 // packages/icons/build-module/library/scheduled.mjs
13213 var import_primitives27 = __toESM(require_primitives(), 1);
13214 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
13215 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime54.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" }) });
13216
13217 // packages/icons/build-module/library/search.mjs
13218 var import_primitives28 = __toESM(require_primitives(), 1);
13219 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13220 var search_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime55.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" }) });
13221
13222 // packages/icons/build-module/library/seen.mjs
13223 var import_primitives29 = __toESM(require_primitives(), 1);
13224 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13225 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime56.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" }) });
13226
13227 // packages/icons/build-module/library/trash.mjs
13228 var import_primitives30 = __toESM(require_primitives(), 1);
13229 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13230 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime57.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" }) });
13231
13232 // packages/icons/build-module/library/unseen.mjs
13233 var import_primitives31 = __toESM(require_primitives(), 1);
13234 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13235 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime58.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" }) });
13236
13237 // packages/ui/build-module/collapsible-card/context.mjs
13238 var import_element26 = __toESM(require_element(), 1);
13239 var HeaderDescriptionIdContext = (0, import_element26.createContext)({
13240 setDescriptionId: () => {
13241 }
13242 });
13243
13244 // packages/ui/build-module/collapsible-card/header.mjs
13245 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13246 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
13247 function getRuntime9() {
13248 const globalScope = globalThis;
13249 if (globalScope.__wpStyleRuntime) {
13250 return globalScope.__wpStyleRuntime;
13251 }
13252 globalScope.__wpStyleRuntime = {
13253 documents: /* @__PURE__ */ new Map(),
13254 styles: /* @__PURE__ */ new Map(),
13255 injectedStyles: /* @__PURE__ */ new WeakMap()
13256 };
13257 if (typeof document !== "undefined") {
13258 registerDocument9(document);
13259 }
13260 return globalScope.__wpStyleRuntime;
13261 }
13262 function documentContainsStyleHash9(targetDocument, hash) {
13263 if (!targetDocument.head) {
13264 return false;
13265 }
13266 for (const style of targetDocument.head.querySelectorAll(
13267 `style[${STYLE_HASH_ATTRIBUTE9}]`
13268 )) {
13269 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
13270 return true;
13271 }
13272 }
13273 return false;
13274 }
13275 function injectStyle9(targetDocument, hash, css) {
13276 if (!targetDocument.head) {
13277 return;
13278 }
13279 const runtime = getRuntime9();
13280 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13281 if (!injectedStyles) {
13282 injectedStyles = /* @__PURE__ */ new Set();
13283 runtime.injectedStyles.set(targetDocument, injectedStyles);
13284 }
13285 if (injectedStyles.has(hash)) {
13286 return;
13287 }
13288 if (documentContainsStyleHash9(targetDocument, hash)) {
13289 injectedStyles.add(hash);
13290 return;
13291 }
13292 const style = targetDocument.createElement("style");
13293 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
13294 style.appendChild(targetDocument.createTextNode(css));
13295 targetDocument.head.appendChild(style);
13296 injectedStyles.add(hash);
13297 }
13298 function registerDocument9(targetDocument) {
13299 const runtime = getRuntime9();
13300 runtime.documents.set(
13301 targetDocument,
13302 (runtime.documents.get(targetDocument) ?? 0) + 1
13303 );
13304 for (const [hash, css] of runtime.styles) {
13305 injectStyle9(targetDocument, hash, css);
13306 }
13307 return () => {
13308 const count = runtime.documents.get(targetDocument);
13309 if (count === void 0) {
13310 return;
13311 }
13312 if (count <= 1) {
13313 runtime.documents.delete(targetDocument);
13314 return;
13315 }
13316 runtime.documents.set(targetDocument, count - 1);
13317 };
13318 }
13319 function registerStyle9(hash, css) {
13320 const runtime = getRuntime9();
13321 runtime.styles.set(hash, css);
13322 for (const targetDocument of runtime.documents.keys()) {
13323 injectStyle9(targetDocument, hash, css);
13324 }
13325 }
13326 if (typeof process === "undefined" || true) {
13327 registerStyle9("ee46794e90", "@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-foreground-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)}}}}");
13328 }
13329 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" };
13330 if (typeof process === "undefined" || true) {
13331 registerStyle9("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-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)}");
13332 }
13333 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" };
13334 if (typeof process === "undefined" || true) {
13335 registerStyle9("5f8e7aa0bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
13336 }
13337 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" };
13338 var Header2 = (0, import_element27.forwardRef)(
13339 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
13340 const [descriptionId, setDescriptionId] = (0, import_element27.useState)();
13341 const contextValue = (0, import_element27.useMemo)(
13342 () => ({ setDescriptionId }),
13343 [setDescriptionId]
13344 );
13345 return useRender({
13346 defaultTagName: "div",
13347 render: render4,
13348 ref,
13349 props: mergeProps(restProps, {
13350 className: clsx_default(
13351 global_css_defense_default3.heading,
13352 style_default9["heading-wrapper"],
13353 className
13354 ),
13355 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13356 Trigger,
13357 {
13358 className: style_default9.header,
13359 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Header, {}),
13360 nativeButton: false,
13361 "aria-describedby": descriptionId,
13362 children: [
13363 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: style_default9["header-content"], children }),
13364 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13365 "div",
13366 {
13367 className: clsx_default(
13368 style_default9["header-trigger-positioner"]
13369 ),
13370 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13371 "div",
13372 {
13373 className: clsx_default(
13374 style_default9["header-trigger-wrapper"],
13375 global_css_defense_default3.div,
13376 // While the interactive trigger element is the whole header,
13377 // the focus ring will be displayed only on the icon to visually
13378 // emulate it being the button.
13379 focus_default2["outset-ring--focus-parent-visible"]
13380 ),
13381 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13382 Icon,
13383 {
13384 icon: chevron_down_default,
13385 className: style_default9["header-trigger"]
13386 }
13387 )
13388 }
13389 )
13390 }
13391 )
13392 ]
13393 }
13394 ) })
13395 })
13396 });
13397 }
13398 );
13399
13400 // packages/ui/build-module/collapsible-card/header-description.mjs
13401 var import_element28 = __toESM(require_element(), 1);
13402 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13403 var HeaderDescription = (0, import_element28.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
13404 const descriptionId = (0, import_element28.useId)();
13405 const { setDescriptionId } = (0, import_element28.useContext)(HeaderDescriptionIdContext);
13406 (0, import_element28.useEffect)(() => {
13407 setDescriptionId(descriptionId);
13408 return () => setDescriptionId(void 0);
13409 }, [descriptionId, setDescriptionId]);
13410 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13411 "div",
13412 {
13413 ref,
13414 id: descriptionId,
13415 "aria-hidden": "true",
13416 className,
13417 ...restProps,
13418 children
13419 }
13420 );
13421 });
13422
13423 // packages/ui/build-module/collapsible-card/content.mjs
13424 var import_element29 = __toESM(require_element(), 1);
13425 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13426 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
13427 function getRuntime10() {
13428 const globalScope = globalThis;
13429 if (globalScope.__wpStyleRuntime) {
13430 return globalScope.__wpStyleRuntime;
13431 }
13432 globalScope.__wpStyleRuntime = {
13433 documents: /* @__PURE__ */ new Map(),
13434 styles: /* @__PURE__ */ new Map(),
13435 injectedStyles: /* @__PURE__ */ new WeakMap()
13436 };
13437 if (typeof document !== "undefined") {
13438 registerDocument10(document);
13439 }
13440 return globalScope.__wpStyleRuntime;
13441 }
13442 function documentContainsStyleHash10(targetDocument, hash) {
13443 if (!targetDocument.head) {
13444 return false;
13445 }
13446 for (const style of targetDocument.head.querySelectorAll(
13447 `style[${STYLE_HASH_ATTRIBUTE10}]`
13448 )) {
13449 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
13450 return true;
13451 }
13452 }
13453 return false;
13454 }
13455 function injectStyle10(targetDocument, hash, css) {
13456 if (!targetDocument.head) {
13457 return;
13458 }
13459 const runtime = getRuntime10();
13460 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13461 if (!injectedStyles) {
13462 injectedStyles = /* @__PURE__ */ new Set();
13463 runtime.injectedStyles.set(targetDocument, injectedStyles);
13464 }
13465 if (injectedStyles.has(hash)) {
13466 return;
13467 }
13468 if (documentContainsStyleHash10(targetDocument, hash)) {
13469 injectedStyles.add(hash);
13470 return;
13471 }
13472 const style = targetDocument.createElement("style");
13473 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
13474 style.appendChild(targetDocument.createTextNode(css));
13475 targetDocument.head.appendChild(style);
13476 injectedStyles.add(hash);
13477 }
13478 function registerDocument10(targetDocument) {
13479 const runtime = getRuntime10();
13480 runtime.documents.set(
13481 targetDocument,
13482 (runtime.documents.get(targetDocument) ?? 0) + 1
13483 );
13484 for (const [hash, css] of runtime.styles) {
13485 injectStyle10(targetDocument, hash, css);
13486 }
13487 return () => {
13488 const count = runtime.documents.get(targetDocument);
13489 if (count === void 0) {
13490 return;
13491 }
13492 if (count <= 1) {
13493 runtime.documents.delete(targetDocument);
13494 return;
13495 }
13496 runtime.documents.set(targetDocument, count - 1);
13497 };
13498 }
13499 function registerStyle10(hash, css) {
13500 const runtime = getRuntime10();
13501 runtime.styles.set(hash, css);
13502 for (const targetDocument of runtime.documents.keys()) {
13503 injectStyle10(targetDocument, hash, css);
13504 }
13505 }
13506 if (typeof process === "undefined" || true) {
13507 registerStyle10("ee46794e90", "@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-foreground-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)}}}}");
13508 }
13509 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" };
13510 var Content2 = (0, import_element29.forwardRef)(
13511 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
13512 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13513 Panel,
13514 {
13515 ref,
13516 className: (state) => clsx_default(
13517 style_default10.content,
13518 state.open && state.transitionStatus === "idle" && style_default10.overflowVisible,
13519 className
13520 ),
13521 hiddenUntilFound,
13522 ...restProps,
13523 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13524 Content,
13525 {
13526 className: style_default10["content-inner"],
13527 render: render4,
13528 children
13529 }
13530 )
13531 }
13532 );
13533 }
13534 );
13535
13536 // packages/ui/build-module/utils/render-slot-with-children.mjs
13537 var import_element30 = __toESM(require_element(), 1);
13538 function renderSlotWithChildren(slot, defaultSlot, children) {
13539 return (0, import_element30.cloneElement)(slot ?? defaultSlot, { children });
13540 }
13541
13542 // packages/ui/build-module/utils/use-deprioritized-initial-focus.mjs
13543 var import_element31 = __toESM(require_element(), 1);
13544
13545 // node_modules/tabbable/dist/index.esm.js
13546 var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"];
13547 var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
13548 var NoElement = typeof Element === "undefined";
13549 var matches = NoElement ? function() {
13550 } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
13551 var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
13552 var _element$getRootNode;
13553 return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
13554 } : function(element) {
13555 return element === null || element === void 0 ? void 0 : element.ownerDocument;
13556 };
13557 var _isInert = function isInert(node, lookUp) {
13558 var _node$getAttribute;
13559 if (lookUp === void 0) {
13560 lookUp = true;
13561 }
13562 var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
13563 var inert = inertAtt === "" || inertAtt === "true";
13564 var result = inert || lookUp && node && // closest does not exist on shadow roots, so we fall back to a manual
13565 // lookup upward, in case it is not defined.
13566 (typeof node.closest === "function" ? node.closest("[inert]") : _isInert(node.parentNode));
13567 return result;
13568 };
13569 var isContentEditable = function isContentEditable2(node) {
13570 var _node$getAttribute2;
13571 var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
13572 return attValue === "" || attValue === "true";
13573 };
13574 var getCandidates = function getCandidates2(el, includeContainer, filter) {
13575 if (_isInert(el)) {
13576 return [];
13577 }
13578 var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
13579 if (includeContainer && matches.call(el, candidateSelector)) {
13580 candidates.unshift(el);
13581 }
13582 candidates = candidates.filter(filter);
13583 return candidates;
13584 };
13585 var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
13586 var candidates = [];
13587 var elementsToCheck = Array.from(elements);
13588 while (elementsToCheck.length) {
13589 var element = elementsToCheck.shift();
13590 if (_isInert(element, false)) {
13591 continue;
13592 }
13593 if (element.tagName === "SLOT") {
13594 var assigned = element.assignedElements();
13595 var content = assigned.length ? assigned : element.children;
13596 var nestedCandidates = _getCandidatesIteratively(content, true, options);
13597 if (options.flatten) {
13598 candidates.push.apply(candidates, nestedCandidates);
13599 } else {
13600 candidates.push({
13601 scopeParent: element,
13602 candidates: nestedCandidates
13603 });
13604 }
13605 } else {
13606 var validCandidate = matches.call(element, candidateSelector);
13607 if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
13608 candidates.push(element);
13609 }
13610 var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
13611 typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
13612 var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
13613 if (shadowRoot && validShadowRoot) {
13614 var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
13615 if (options.flatten) {
13616 candidates.push.apply(candidates, _nestedCandidates);
13617 } else {
13618 candidates.push({
13619 scopeParent: element,
13620 candidates: _nestedCandidates
13621 });
13622 }
13623 } else {
13624 elementsToCheck.unshift.apply(elementsToCheck, element.children);
13625 }
13626 }
13627 }
13628 return candidates;
13629 };
13630 var hasTabIndex = function hasTabIndex2(node) {
13631 return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
13632 };
13633 var getTabIndex2 = function getTabIndex3(node) {
13634 if (!node) {
13635 throw new Error("No node provided");
13636 }
13637 if (node.tabIndex < 0) {
13638 if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
13639 return 0;
13640 }
13641 }
13642 return node.tabIndex;
13643 };
13644 var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
13645 var tabIndex = getTabIndex2(node);
13646 if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
13647 return 0;
13648 }
13649 return tabIndex;
13650 };
13651 var sortOrderedTabbables = function sortOrderedTabbables2(a2, b2) {
13652 return a2.tabIndex === b2.tabIndex ? a2.documentOrder - b2.documentOrder : a2.tabIndex - b2.tabIndex;
13653 };
13654 var isInput = function isInput2(node) {
13655 return node.tagName === "INPUT";
13656 };
13657 var isHiddenInput = function isHiddenInput2(node) {
13658 return isInput(node) && node.type === "hidden";
13659 };
13660 var isDetailsWithSummary = function isDetailsWithSummary2(node) {
13661 var r3 = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
13662 return child.tagName === "SUMMARY";
13663 });
13664 return r3;
13665 };
13666 var getCheckedRadio = function getCheckedRadio2(nodes, form) {
13667 for (var i2 = 0; i2 < nodes.length; i2++) {
13668 if (nodes[i2].checked && nodes[i2].form === form) {
13669 return nodes[i2];
13670 }
13671 }
13672 };
13673 var isTabbableRadio2 = function isTabbableRadio3(node) {
13674 if (!node.name) {
13675 return true;
13676 }
13677 var radioScope = node.form || getRootNode(node);
13678 var queryRadios = function queryRadios2(name) {
13679 return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
13680 };
13681 var radioSet;
13682 if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
13683 radioSet = queryRadios(window.CSS.escape(node.name));
13684 } else {
13685 try {
13686 radioSet = queryRadios(node.name);
13687 } catch (err) {
13688 console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
13689 return false;
13690 }
13691 }
13692 var checked = getCheckedRadio(radioSet, node.form);
13693 return !checked || checked === node;
13694 };
13695 var isRadio = function isRadio2(node) {
13696 return isInput(node) && node.type === "radio";
13697 };
13698 var isNonTabbableRadio = function isNonTabbableRadio2(node) {
13699 return isRadio(node) && !isTabbableRadio2(node);
13700 };
13701 var isNodeAttached = function isNodeAttached2(node) {
13702 var _nodeRoot;
13703 var nodeRoot = node && getRootNode(node);
13704 var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
13705 var attached = false;
13706 if (nodeRoot && nodeRoot !== node) {
13707 var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
13708 attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
13709 while (!attached && nodeRootHost) {
13710 var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
13711 nodeRoot = getRootNode(nodeRootHost);
13712 nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
13713 attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
13714 }
13715 }
13716 return attached;
13717 };
13718 var isZeroArea = function isZeroArea2(node) {
13719 var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
13720 return width === 0 && height === 0;
13721 };
13722 var isHidden = function isHidden2(node, _ref) {
13723 var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
13724 if (displayCheck === "full-native") {
13725 if ("checkVisibility" in node) {
13726 var visible = node.checkVisibility({
13727 // Checking opacity might be desirable for some use cases, but natively,
13728 // opacity zero elements _are_ focusable and tabbable.
13729 checkOpacity: false,
13730 opacityProperty: false,
13731 contentVisibilityAuto: true,
13732 visibilityProperty: true,
13733 // This is an alias for `visibilityProperty`. Contemporary browsers
13734 // support both. However, this alias has wider browser support (Chrome
13735 // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
13736 // we include it anyway.
13737 checkVisibilityCSS: true
13738 });
13739 return !visible;
13740 }
13741 }
13742 if (getComputedStyle(node).visibility === "hidden") {
13743 return true;
13744 }
13745 var isDirectSummary = matches.call(node, "details>summary:first-of-type");
13746 var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
13747 if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
13748 return true;
13749 }
13750 if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
13751 // Element#checkVisibility is unsupported
13752 displayCheck === "full-native" || displayCheck === "legacy-full") {
13753 if (typeof getShadowRoot === "function") {
13754 var originalNode = node;
13755 while (node) {
13756 var parentElement = node.parentElement;
13757 var rootNode = getRootNode(node);
13758 if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
13759 return isZeroArea(node);
13760 } else if (node.assignedSlot) {
13761 node = node.assignedSlot;
13762 } else if (!parentElement && rootNode !== node.ownerDocument) {
13763 node = rootNode.host;
13764 } else {
13765 node = parentElement;
13766 }
13767 }
13768 node = originalNode;
13769 }
13770 if (isNodeAttached(node)) {
13771 return !node.getClientRects().length;
13772 }
13773 if (displayCheck !== "legacy-full") {
13774 return true;
13775 }
13776 } else if (displayCheck === "non-zero-area") {
13777 return isZeroArea(node);
13778 }
13779 return false;
13780 };
13781 var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
13782 if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
13783 var parentNode = node.parentElement;
13784 while (parentNode) {
13785 if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
13786 for (var i2 = 0; i2 < parentNode.children.length; i2++) {
13787 var child = parentNode.children.item(i2);
13788 if (child.tagName === "LEGEND") {
13789 return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
13790 }
13791 }
13792 return true;
13793 }
13794 parentNode = parentNode.parentElement;
13795 }
13796 }
13797 return false;
13798 };
13799 var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
13800 if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
13801 isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
13802 return false;
13803 }
13804 return true;
13805 };
13806 var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
13807 if (isNonTabbableRadio(node) || getTabIndex2(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
13808 return false;
13809 }
13810 return true;
13811 };
13812 var isShadowRootTabbable = function isShadowRootTabbable2(shadowHostNode) {
13813 var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
13814 if (isNaN(tabIndex) || tabIndex >= 0) {
13815 return true;
13816 }
13817 return false;
13818 };
13819 var _sortByOrder = function sortByOrder(candidates) {
13820 var regularTabbables = [];
13821 var orderedTabbables = [];
13822 candidates.forEach(function(item, i2) {
13823 var isScope = !!item.scopeParent;
13824 var element = isScope ? item.scopeParent : item;
13825 var candidateTabindex = getSortOrderTabIndex(element, isScope);
13826 var elements = isScope ? _sortByOrder(item.candidates) : element;
13827 if (candidateTabindex === 0) {
13828 isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
13829 } else {
13830 orderedTabbables.push({
13831 documentOrder: i2,
13832 tabIndex: candidateTabindex,
13833 item,
13834 isScope,
13835 content: elements
13836 });
13837 }
13838 });
13839 return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
13840 sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
13841 return acc;
13842 }, []).concat(regularTabbables);
13843 };
13844 var tabbable2 = function tabbable3(container, options) {
13845 options = options || {};
13846 var candidates;
13847 if (options.getShadowRoot) {
13848 candidates = _getCandidatesIteratively([container], options.includeContainer, {
13849 filter: isNodeMatchingSelectorTabbable.bind(null, options),
13850 flatten: false,
13851 getShadowRoot: options.getShadowRoot,
13852 shadowRootFilter: isShadowRootTabbable
13853 });
13854 } else {
13855 candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
13856 }
13857 return _sortByOrder(candidates);
13858 };
13859
13860 // packages/ui/build-module/utils/use-deprioritized-initial-focus.mjs
13861 var getTabbableOptions = () => ({
13862 getShadowRoot: true,
13863 displayCheck: typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
13864 });
13865 function useDeprioritizedInitialFocus({
13866 initialFocus,
13867 deprioritizedAttributes
13868 }) {
13869 const popupRef = (0, import_element31.useRef)(null);
13870 let resolvedInitialFocus = initialFocus;
13871 if (initialFocus === void 0 || initialFocus === true) {
13872 resolvedInitialFocus = (interactionType) => {
13873 if (interactionType === "touch") {
13874 return popupRef.current ?? true;
13875 }
13876 const popup = popupRef.current;
13877 if (!popup) {
13878 return true;
13879 }
13880 const tabbables = tabbable2(popup, getTabbableOptions());
13881 for (const el of tabbables) {
13882 if (el instanceof HTMLElement && !deprioritizedAttributes.some(
13883 (attr2) => el.hasAttribute(attr2)
13884 )) {
13885 return el;
13886 }
13887 }
13888 return true;
13889 };
13890 }
13891 return { resolvedInitialFocus, popupRef };
13892 }
13893
13894 // packages/ui/build-module/utils/theme-provider.mjs
13895 var theme = __toESM(require_theme(), 1);
13896
13897 // packages/ui/build-module/lock-unlock.mjs
13898 var import_private_apis = __toESM(require_private_apis(), 1);
13899 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
13900 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
13901 "@wordpress/ui"
13902 );
13903
13904 // packages/ui/build-module/utils/theme-provider.mjs
13905 function getThemeProvider() {
13906 const themePackage = theme;
13907 if (themePackage.ThemeProvider) {
13908 return themePackage.ThemeProvider;
13909 }
13910 if (!themePackage.privateApis) {
13911 throw new Error(
13912 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
13913 );
13914 }
13915 return unlock(
13916 themePackage.privateApis
13917 ).ThemeProvider;
13918 }
13919 var ThemeProvider = getThemeProvider();
13920
13921 // packages/ui/build-module/stack/stack.mjs
13922 var import_element32 = __toESM(require_element(), 1);
13923 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
13924 function getRuntime11() {
13925 const globalScope = globalThis;
13926 if (globalScope.__wpStyleRuntime) {
13927 return globalScope.__wpStyleRuntime;
13928 }
13929 globalScope.__wpStyleRuntime = {
13930 documents: /* @__PURE__ */ new Map(),
13931 styles: /* @__PURE__ */ new Map(),
13932 injectedStyles: /* @__PURE__ */ new WeakMap()
13933 };
13934 if (typeof document !== "undefined") {
13935 registerDocument11(document);
13936 }
13937 return globalScope.__wpStyleRuntime;
13938 }
13939 function documentContainsStyleHash11(targetDocument, hash) {
13940 if (!targetDocument.head) {
13941 return false;
13942 }
13943 for (const style of targetDocument.head.querySelectorAll(
13944 `style[${STYLE_HASH_ATTRIBUTE11}]`
13945 )) {
13946 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
13947 return true;
13948 }
13949 }
13950 return false;
13951 }
13952 function injectStyle11(targetDocument, hash, css) {
13953 if (!targetDocument.head) {
13954 return;
13955 }
13956 const runtime = getRuntime11();
13957 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13958 if (!injectedStyles) {
13959 injectedStyles = /* @__PURE__ */ new Set();
13960 runtime.injectedStyles.set(targetDocument, injectedStyles);
13961 }
13962 if (injectedStyles.has(hash)) {
13963 return;
13964 }
13965 if (documentContainsStyleHash11(targetDocument, hash)) {
13966 injectedStyles.add(hash);
13967 return;
13968 }
13969 const style = targetDocument.createElement("style");
13970 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
13971 style.appendChild(targetDocument.createTextNode(css));
13972 targetDocument.head.appendChild(style);
13973 injectedStyles.add(hash);
13974 }
13975 function registerDocument11(targetDocument) {
13976 const runtime = getRuntime11();
13977 runtime.documents.set(
13978 targetDocument,
13979 (runtime.documents.get(targetDocument) ?? 0) + 1
13980 );
13981 for (const [hash, css] of runtime.styles) {
13982 injectStyle11(targetDocument, hash, css);
13983 }
13984 return () => {
13985 const count = runtime.documents.get(targetDocument);
13986 if (count === void 0) {
13987 return;
13988 }
13989 if (count <= 1) {
13990 runtime.documents.delete(targetDocument);
13991 return;
13992 }
13993 runtime.documents.set(targetDocument, count - 1);
13994 };
13995 }
13996 function registerStyle11(hash, css) {
13997 const runtime = getRuntime11();
13998 runtime.styles.set(hash, css);
13999 for (const targetDocument of runtime.documents.keys()) {
14000 injectStyle11(targetDocument, hash, css);
14001 }
14002 }
14003 if (typeof process === "undefined" || true) {
14004 registerStyle11("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
14005 }
14006 var style_default11 = { "stack": "_19ce0419607e1896__stack" };
14007 var gapTokens = {
14008 xs: "var(--wpds-dimension-gap-xs, 4px)",
14009 sm: "var(--wpds-dimension-gap-sm, 8px)",
14010 md: "var(--wpds-dimension-gap-md, 12px)",
14011 lg: "var(--wpds-dimension-gap-lg, 16px)",
14012 xl: "var(--wpds-dimension-gap-xl, 24px)",
14013 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
14014 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
14015 };
14016 var Stack = (0, import_element32.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
14017 const style = {
14018 gap: gap && gapTokens[gap],
14019 alignItems: align,
14020 justifyContent: justify,
14021 flexDirection: direction,
14022 flexWrap: wrap
14023 };
14024 const element = useRender({
14025 render: render4,
14026 ref,
14027 props: mergeProps(props, { style, className: style_default11.stack })
14028 });
14029 return element;
14030 });
14031
14032 // packages/ui/build-module/icon-button/icon-button.mjs
14033 var import_element37 = __toESM(require_element(), 1);
14034
14035 // packages/ui/build-module/tooltip/index.mjs
14036 var tooltip_exports = {};
14037 __export(tooltip_exports, {
14038 Popup: () => Popup,
14039 Portal: () => Portal,
14040 Positioner: () => Positioner,
14041 Provider: () => Provider,
14042 Root: () => Root4,
14043 Trigger: () => Trigger2
14044 });
14045
14046 // packages/ui/build-module/tooltip/popup.mjs
14047 var import_element35 = __toESM(require_element(), 1);
14048
14049 // packages/ui/build-module/tooltip/portal.mjs
14050 var import_element33 = __toESM(require_element(), 1);
14051
14052 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
14053 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
14054 function getRuntime12() {
14055 const globalScope = globalThis;
14056 if (globalScope.__wpStyleRuntime) {
14057 return globalScope.__wpStyleRuntime;
14058 }
14059 globalScope.__wpStyleRuntime = {
14060 documents: /* @__PURE__ */ new Map(),
14061 styles: /* @__PURE__ */ new Map(),
14062 injectedStyles: /* @__PURE__ */ new WeakMap()
14063 };
14064 if (typeof document !== "undefined") {
14065 registerDocument12(document);
14066 }
14067 return globalScope.__wpStyleRuntime;
14068 }
14069 function documentContainsStyleHash12(targetDocument, hash) {
14070 if (!targetDocument.head) {
14071 return false;
14072 }
14073 for (const style of targetDocument.head.querySelectorAll(
14074 `style[${STYLE_HASH_ATTRIBUTE12}]`
14075 )) {
14076 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
14077 return true;
14078 }
14079 }
14080 return false;
14081 }
14082 function injectStyle12(targetDocument, hash, css) {
14083 if (!targetDocument.head) {
14084 return;
14085 }
14086 const runtime = getRuntime12();
14087 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14088 if (!injectedStyles) {
14089 injectedStyles = /* @__PURE__ */ new Set();
14090 runtime.injectedStyles.set(targetDocument, injectedStyles);
14091 }
14092 if (injectedStyles.has(hash)) {
14093 return;
14094 }
14095 if (documentContainsStyleHash12(targetDocument, hash)) {
14096 injectedStyles.add(hash);
14097 return;
14098 }
14099 const style = targetDocument.createElement("style");
14100 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
14101 style.appendChild(targetDocument.createTextNode(css));
14102 targetDocument.head.appendChild(style);
14103 injectedStyles.add(hash);
14104 }
14105 function registerDocument12(targetDocument) {
14106 const runtime = getRuntime12();
14107 runtime.documents.set(
14108 targetDocument,
14109 (runtime.documents.get(targetDocument) ?? 0) + 1
14110 );
14111 for (const [hash, css] of runtime.styles) {
14112 injectStyle12(targetDocument, hash, css);
14113 }
14114 return () => {
14115 const count = runtime.documents.get(targetDocument);
14116 if (count === void 0) {
14117 return;
14118 }
14119 if (count <= 1) {
14120 runtime.documents.delete(targetDocument);
14121 return;
14122 }
14123 runtime.documents.set(targetDocument, count - 1);
14124 };
14125 }
14126 function registerStyle12(hash, css) {
14127 const runtime = getRuntime12();
14128 runtime.styles.set(hash, css);
14129 for (const targetDocument of runtime.documents.keys()) {
14130 injectStyle12(targetDocument, hash, css);
14131 }
14132 }
14133 if (typeof process === "undefined" || true) {
14134 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}}}");
14135 }
14136 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
14137 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
14138 function resolveOwnerDocument() {
14139 return typeof document === "undefined" ? null : document;
14140 }
14141 function isInWordPressEnvironment() {
14142 let topWp;
14143 try {
14144 topWp = window.top?.wp;
14145 } catch {
14146 }
14147 const wp = topWp ?? window.wp;
14148 return typeof wp?.components === "object" && wp.components !== null;
14149 }
14150 var cachedSlot = null;
14151 function createSlot(ownerDocument2) {
14152 const element = ownerDocument2.createElement("div");
14153 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
14154 if (wp_compat_overlay_slot_default.slot) {
14155 element.classList.add(wp_compat_overlay_slot_default.slot);
14156 }
14157 ownerDocument2.body.appendChild(element);
14158 return element;
14159 }
14160 function getWpCompatOverlaySlot() {
14161 if (typeof window === "undefined") {
14162 return void 0;
14163 }
14164 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
14165 return void 0;
14166 }
14167 const ownerDocument2 = resolveOwnerDocument();
14168 if (!ownerDocument2 || !ownerDocument2.body) {
14169 return void 0;
14170 }
14171 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
14172 return cachedSlot;
14173 }
14174 const existing = ownerDocument2.querySelector(
14175 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
14176 );
14177 if (existing instanceof HTMLDivElement) {
14178 cachedSlot = existing;
14179 return existing;
14180 }
14181 if (cachedSlot?.isConnected) {
14182 cachedSlot.remove();
14183 }
14184 cachedSlot = createSlot(ownerDocument2);
14185 return cachedSlot;
14186 }
14187
14188 // packages/ui/build-module/tooltip/portal.mjs
14189 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
14190 var Portal = (0, import_element33.forwardRef)(
14191 function TooltipPortal3({ container, ...restProps }, ref) {
14192 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
14193 index_parts_exports3.Portal,
14194 {
14195 container: container ?? getWpCompatOverlaySlot(),
14196 ...restProps,
14197 ref
14198 }
14199 );
14200 }
14201 );
14202
14203 // packages/ui/build-module/tooltip/positioner.mjs
14204 var import_element34 = __toESM(require_element(), 1);
14205 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
14206 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
14207 function getRuntime13() {
14208 const globalScope = globalThis;
14209 if (globalScope.__wpStyleRuntime) {
14210 return globalScope.__wpStyleRuntime;
14211 }
14212 globalScope.__wpStyleRuntime = {
14213 documents: /* @__PURE__ */ new Map(),
14214 styles: /* @__PURE__ */ new Map(),
14215 injectedStyles: /* @__PURE__ */ new WeakMap()
14216 };
14217 if (typeof document !== "undefined") {
14218 registerDocument13(document);
14219 }
14220 return globalScope.__wpStyleRuntime;
14221 }
14222 function documentContainsStyleHash13(targetDocument, hash) {
14223 if (!targetDocument.head) {
14224 return false;
14225 }
14226 for (const style of targetDocument.head.querySelectorAll(
14227 `style[${STYLE_HASH_ATTRIBUTE13}]`
14228 )) {
14229 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
14230 return true;
14231 }
14232 }
14233 return false;
14234 }
14235 function injectStyle13(targetDocument, hash, css) {
14236 if (!targetDocument.head) {
14237 return;
14238 }
14239 const runtime = getRuntime13();
14240 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14241 if (!injectedStyles) {
14242 injectedStyles = /* @__PURE__ */ new Set();
14243 runtime.injectedStyles.set(targetDocument, injectedStyles);
14244 }
14245 if (injectedStyles.has(hash)) {
14246 return;
14247 }
14248 if (documentContainsStyleHash13(targetDocument, hash)) {
14249 injectedStyles.add(hash);
14250 return;
14251 }
14252 const style = targetDocument.createElement("style");
14253 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
14254 style.appendChild(targetDocument.createTextNode(css));
14255 targetDocument.head.appendChild(style);
14256 injectedStyles.add(hash);
14257 }
14258 function registerDocument13(targetDocument) {
14259 const runtime = getRuntime13();
14260 runtime.documents.set(
14261 targetDocument,
14262 (runtime.documents.get(targetDocument) ?? 0) + 1
14263 );
14264 for (const [hash, css] of runtime.styles) {
14265 injectStyle13(targetDocument, hash, css);
14266 }
14267 return () => {
14268 const count = runtime.documents.get(targetDocument);
14269 if (count === void 0) {
14270 return;
14271 }
14272 if (count <= 1) {
14273 runtime.documents.delete(targetDocument);
14274 return;
14275 }
14276 runtime.documents.set(targetDocument, count - 1);
14277 };
14278 }
14279 function registerStyle13(hash, css) {
14280 const runtime = getRuntime13();
14281 runtime.styles.set(hash, css);
14282 for (const targetDocument of runtime.documents.keys()) {
14283 injectStyle13(targetDocument, hash, css);
14284 }
14285 }
14286 if (typeof process === "undefined" || true) {
14287 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
14288 }
14289 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
14290 if (typeof process === "undefined" || true) {
14291 registerStyle13("789467362f", '@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-background-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-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
14292 }
14293 var style_default12 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
14294 var Positioner = (0, import_element34.forwardRef)(
14295 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
14296 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
14297 index_parts_exports3.Positioner,
14298 {
14299 ref,
14300 align,
14301 side,
14302 sideOffset,
14303 ...props,
14304 className: clsx_default(
14305 resets_default3["box-sizing"],
14306 style_default12.positioner,
14307 className
14308 )
14309 }
14310 );
14311 }
14312 );
14313
14314 // packages/ui/build-module/tooltip/popup.mjs
14315 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
14316 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
14317 function getRuntime14() {
14318 const globalScope = globalThis;
14319 if (globalScope.__wpStyleRuntime) {
14320 return globalScope.__wpStyleRuntime;
14321 }
14322 globalScope.__wpStyleRuntime = {
14323 documents: /* @__PURE__ */ new Map(),
14324 styles: /* @__PURE__ */ new Map(),
14325 injectedStyles: /* @__PURE__ */ new WeakMap()
14326 };
14327 if (typeof document !== "undefined") {
14328 registerDocument14(document);
14329 }
14330 return globalScope.__wpStyleRuntime;
14331 }
14332 function documentContainsStyleHash14(targetDocument, hash) {
14333 if (!targetDocument.head) {
14334 return false;
14335 }
14336 for (const style of targetDocument.head.querySelectorAll(
14337 `style[${STYLE_HASH_ATTRIBUTE14}]`
14338 )) {
14339 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
14340 return true;
14341 }
14342 }
14343 return false;
14344 }
14345 function injectStyle14(targetDocument, hash, css) {
14346 if (!targetDocument.head) {
14347 return;
14348 }
14349 const runtime = getRuntime14();
14350 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14351 if (!injectedStyles) {
14352 injectedStyles = /* @__PURE__ */ new Set();
14353 runtime.injectedStyles.set(targetDocument, injectedStyles);
14354 }
14355 if (injectedStyles.has(hash)) {
14356 return;
14357 }
14358 if (documentContainsStyleHash14(targetDocument, hash)) {
14359 injectedStyles.add(hash);
14360 return;
14361 }
14362 const style = targetDocument.createElement("style");
14363 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
14364 style.appendChild(targetDocument.createTextNode(css));
14365 targetDocument.head.appendChild(style);
14366 injectedStyles.add(hash);
14367 }
14368 function registerDocument14(targetDocument) {
14369 const runtime = getRuntime14();
14370 runtime.documents.set(
14371 targetDocument,
14372 (runtime.documents.get(targetDocument) ?? 0) + 1
14373 );
14374 for (const [hash, css] of runtime.styles) {
14375 injectStyle14(targetDocument, hash, css);
14376 }
14377 return () => {
14378 const count = runtime.documents.get(targetDocument);
14379 if (count === void 0) {
14380 return;
14381 }
14382 if (count <= 1) {
14383 runtime.documents.delete(targetDocument);
14384 return;
14385 }
14386 runtime.documents.set(targetDocument, count - 1);
14387 };
14388 }
14389 function registerStyle14(hash, css) {
14390 const runtime = getRuntime14();
14391 runtime.styles.set(hash, css);
14392 for (const targetDocument of runtime.documents.keys()) {
14393 injectStyle14(targetDocument, hash, css);
14394 }
14395 }
14396 if (typeof process === "undefined" || true) {
14397 registerStyle14("789467362f", '@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-background-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-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
14398 }
14399 var style_default13 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
14400 var POPUP_COLOR = { background: "#1e1e1e" };
14401 var Popup = (0, import_element35.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
14402 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14403 index_parts_exports3.Popup,
14404 {
14405 ref,
14406 className: clsx_default(style_default13.popup, className),
14407 ...props,
14408 children
14409 }
14410 ) });
14411 const positionedPopup = renderSlotWithChildren(
14412 positioner,
14413 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Positioner, {}),
14414 popupContent
14415 );
14416 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Portal, {}), positionedPopup);
14417 });
14418
14419 // packages/ui/build-module/tooltip/trigger.mjs
14420 var import_element36 = __toESM(require_element(), 1);
14421 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
14422 var Trigger2 = (0, import_element36.forwardRef)(
14423 function TooltipTrigger3(props, ref) {
14424 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(index_parts_exports3.Trigger, { ref, ...props });
14425 }
14426 );
14427
14428 // packages/ui/build-module/tooltip/root.mjs
14429 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14430 function Root4(props) {
14431 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(index_parts_exports3.Root, { ...props });
14432 }
14433
14434 // packages/ui/build-module/tooltip/provider.mjs
14435 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14436 function Provider({ ...props }) {
14437 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(index_parts_exports3.Provider, { ...props });
14438 }
14439
14440 // packages/ui/build-module/icon-button/icon-button.mjs
14441 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14442 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash";
14443 function getRuntime15() {
14444 const globalScope = globalThis;
14445 if (globalScope.__wpStyleRuntime) {
14446 return globalScope.__wpStyleRuntime;
14447 }
14448 globalScope.__wpStyleRuntime = {
14449 documents: /* @__PURE__ */ new Map(),
14450 styles: /* @__PURE__ */ new Map(),
14451 injectedStyles: /* @__PURE__ */ new WeakMap()
14452 };
14453 if (typeof document !== "undefined") {
14454 registerDocument15(document);
14455 }
14456 return globalScope.__wpStyleRuntime;
14457 }
14458 function documentContainsStyleHash15(targetDocument, hash) {
14459 if (!targetDocument.head) {
14460 return false;
14461 }
14462 for (const style of targetDocument.head.querySelectorAll(
14463 `style[${STYLE_HASH_ATTRIBUTE15}]`
14464 )) {
14465 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) {
14466 return true;
14467 }
14468 }
14469 return false;
14470 }
14471 function injectStyle15(targetDocument, hash, css) {
14472 if (!targetDocument.head) {
14473 return;
14474 }
14475 const runtime = getRuntime15();
14476 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14477 if (!injectedStyles) {
14478 injectedStyles = /* @__PURE__ */ new Set();
14479 runtime.injectedStyles.set(targetDocument, injectedStyles);
14480 }
14481 if (injectedStyles.has(hash)) {
14482 return;
14483 }
14484 if (documentContainsStyleHash15(targetDocument, hash)) {
14485 injectedStyles.add(hash);
14486 return;
14487 }
14488 const style = targetDocument.createElement("style");
14489 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash);
14490 style.appendChild(targetDocument.createTextNode(css));
14491 targetDocument.head.appendChild(style);
14492 injectedStyles.add(hash);
14493 }
14494 function registerDocument15(targetDocument) {
14495 const runtime = getRuntime15();
14496 runtime.documents.set(
14497 targetDocument,
14498 (runtime.documents.get(targetDocument) ?? 0) + 1
14499 );
14500 for (const [hash, css] of runtime.styles) {
14501 injectStyle15(targetDocument, hash, css);
14502 }
14503 return () => {
14504 const count = runtime.documents.get(targetDocument);
14505 if (count === void 0) {
14506 return;
14507 }
14508 if (count <= 1) {
14509 runtime.documents.delete(targetDocument);
14510 return;
14511 }
14512 runtime.documents.set(targetDocument, count - 1);
14513 };
14514 }
14515 function registerStyle15(hash, css) {
14516 const runtime = getRuntime15();
14517 runtime.styles.set(hash, css);
14518 for (const targetDocument of runtime.documents.keys()) {
14519 injectStyle15(targetDocument, hash, css);
14520 }
14521 }
14522 if (typeof process === "undefined" || true) {
14523 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}}}");
14524 }
14525 var style_default14 = { "icon-button": "_28cfdc260e755391__icon-button", "icon": "f1c70d719989a85a__icon" };
14526 var IconButton = (0, import_element37.forwardRef)(
14527 function IconButton2({
14528 label,
14529 className,
14530 // Prevent accidental forwarding of `children`
14531 children: _children,
14532 disabled: disabled2,
14533 focusableWhenDisabled = true,
14534 icon,
14535 size: size4,
14536 shortcut,
14537 positioner,
14538 ...restProps
14539 }, ref) {
14540 const classes = clsx_default(style_default14["icon-button"], className);
14541 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Root4, { children: [
14542 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14543 Trigger2,
14544 {
14545 ref,
14546 disabled: disabled2 && !focusableWhenDisabled,
14547 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14548 Button4,
14549 {
14550 ...restProps,
14551 size: size4,
14552 "aria-label": label,
14553 "aria-keyshortcuts": shortcut?.ariaKeyShortcut,
14554 disabled: disabled2,
14555 focusableWhenDisabled
14556 }
14557 ),
14558 className: classes,
14559 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14560 Icon,
14561 {
14562 icon,
14563 size: 24,
14564 className: style_default14.icon
14565 }
14566 )
14567 }
14568 ),
14569 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Popup, { positioner, children: [
14570 label,
14571 shortcut && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
14572 " ",
14573 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { "aria-hidden": "true", children: shortcut.displayShortcut })
14574 ] })
14575 ] })
14576 ] }) });
14577 }
14578 );
14579
14580 // packages/ui/build-module/utils/create-overlay-title-validation.mjs
14581 var import_element39 = __toESM(require_element(), 1);
14582
14583 // packages/ui/build-module/utils/use-schedule-validation.mjs
14584 var import_element38 = __toESM(require_element(), 1);
14585 function useScheduleValidation(validate) {
14586 const validateRef = (0, import_element38.useRef)(validate);
14587 validateRef.current = validate;
14588 const timerRef = (0, import_element38.useRef)(null);
14589 const unmountedRef = (0, import_element38.useRef)(false);
14590 const scheduleValidation = (0, import_element38.useCallback)(() => {
14591 if (unmountedRef.current) {
14592 return;
14593 }
14594 if (timerRef.current) {
14595 clearTimeout(timerRef.current);
14596 }
14597 timerRef.current = setTimeout(() => {
14598 validateRef.current();
14599 timerRef.current = null;
14600 }, 0);
14601 }, []);
14602 (0, import_element38.useEffect)(() => {
14603 unmountedRef.current = false;
14604 return () => {
14605 unmountedRef.current = true;
14606 if (timerRef.current) {
14607 clearTimeout(timerRef.current);
14608 }
14609 };
14610 }, []);
14611 return scheduleValidation;
14612 }
14613
14614 // packages/ui/build-module/utils/create-overlay-title-validation.mjs
14615 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14616 var VALIDATION_ENABLED = true;
14617 function createOverlayTitleValidation(componentName) {
14618 const componentNameLowerCase = componentName.toLowerCase();
14619 const OverlayValidationContext = VALIDATION_ENABLED ? (0, import_element39.createContext)(null) : null;
14620 function useValidationContextDev() {
14621 return (0, import_element39.useContext)(OverlayValidationContext);
14622 }
14623 function useValidationContextProd() {
14624 return null;
14625 }
14626 const useValidationContext = VALIDATION_ENABLED ? useValidationContextDev : useValidationContextProd;
14627 function ValidationProviderDev({
14628 children
14629 }) {
14630 const titleElementRef = (0, import_element39.useRef)(null);
14631 const scheduleValidation = useScheduleValidation(() => {
14632 const titleElement = titleElementRef.current;
14633 if (!titleElement) {
14634 throw new Error(
14635 `${componentName}: Missing <${componentName}.Title>. For accessibility, every ${componentNameLowerCase} requires a title. If needed, the title can be visually hidden but must not be omitted.`
14636 );
14637 }
14638 const textContent = titleElement.textContent?.trim();
14639 if (!textContent) {
14640 throw new Error(
14641 `${componentName}: <${componentName}.Title> cannot be empty. Provide meaningful text content for the ${componentNameLowerCase} title.`
14642 );
14643 }
14644 });
14645 const registerTitle = (0, import_element39.useCallback)(
14646 (element) => {
14647 titleElementRef.current = element;
14648 scheduleValidation();
14649 return () => {
14650 titleElementRef.current = null;
14651 scheduleValidation();
14652 };
14653 },
14654 [scheduleValidation]
14655 );
14656 const contextValue = (0, import_element39.useMemo)(
14657 () => ({ registerTitle }),
14658 [registerTitle]
14659 );
14660 (0, import_element39.useEffect)(() => {
14661 scheduleValidation();
14662 }, [scheduleValidation]);
14663 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(OverlayValidationContext.Provider, { value: contextValue, children });
14664 }
14665 function ValidationProviderProd({
14666 children
14667 }) {
14668 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_jsx_runtime69.Fragment, { children });
14669 }
14670 const ValidationProvider = VALIDATION_ENABLED ? ValidationProviderDev : ValidationProviderProd;
14671 return {
14672 ValidationProvider,
14673 useValidationContext
14674 };
14675 }
14676
14677 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
14678 var import_element40 = __toESM(require_element(), 1);
14679 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash";
14680 function getRuntime16() {
14681 const globalScope = globalThis;
14682 if (globalScope.__wpStyleRuntime) {
14683 return globalScope.__wpStyleRuntime;
14684 }
14685 globalScope.__wpStyleRuntime = {
14686 documents: /* @__PURE__ */ new Map(),
14687 styles: /* @__PURE__ */ new Map(),
14688 injectedStyles: /* @__PURE__ */ new WeakMap()
14689 };
14690 if (typeof document !== "undefined") {
14691 registerDocument16(document);
14692 }
14693 return globalScope.__wpStyleRuntime;
14694 }
14695 function documentContainsStyleHash16(targetDocument, hash) {
14696 if (!targetDocument.head) {
14697 return false;
14698 }
14699 for (const style of targetDocument.head.querySelectorAll(
14700 `style[${STYLE_HASH_ATTRIBUTE16}]`
14701 )) {
14702 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) {
14703 return true;
14704 }
14705 }
14706 return false;
14707 }
14708 function injectStyle16(targetDocument, hash, css) {
14709 if (!targetDocument.head) {
14710 return;
14711 }
14712 const runtime = getRuntime16();
14713 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14714 if (!injectedStyles) {
14715 injectedStyles = /* @__PURE__ */ new Set();
14716 runtime.injectedStyles.set(targetDocument, injectedStyles);
14717 }
14718 if (injectedStyles.has(hash)) {
14719 return;
14720 }
14721 if (documentContainsStyleHash16(targetDocument, hash)) {
14722 injectedStyles.add(hash);
14723 return;
14724 }
14725 const style = targetDocument.createElement("style");
14726 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash);
14727 style.appendChild(targetDocument.createTextNode(css));
14728 targetDocument.head.appendChild(style);
14729 injectedStyles.add(hash);
14730 }
14731 function registerDocument16(targetDocument) {
14732 const runtime = getRuntime16();
14733 runtime.documents.set(
14734 targetDocument,
14735 (runtime.documents.get(targetDocument) ?? 0) + 1
14736 );
14737 for (const [hash, css] of runtime.styles) {
14738 injectStyle16(targetDocument, hash, css);
14739 }
14740 return () => {
14741 const count = runtime.documents.get(targetDocument);
14742 if (count === void 0) {
14743 return;
14744 }
14745 if (count <= 1) {
14746 runtime.documents.delete(targetDocument);
14747 return;
14748 }
14749 runtime.documents.set(targetDocument, count - 1);
14750 };
14751 }
14752 function registerStyle16(hash, css) {
14753 const runtime = getRuntime16();
14754 runtime.styles.set(hash, css);
14755 for (const targetDocument of runtime.documents.keys()) {
14756 injectStyle16(targetDocument, hash, css);
14757 }
14758 }
14759 if (typeof process === "undefined" || true) {
14760 registerStyle16("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}}}");
14761 }
14762 var style_default15 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
14763 var VisuallyHidden = (0, import_element40.forwardRef)(
14764 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
14765 const element = useRender({
14766 render: render4,
14767 ref,
14768 props: mergeProps(
14769 { className: style_default15["visually-hidden"] },
14770 restProps,
14771 {
14772 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
14773 "data-visually-hidden": ""
14774 }
14775 )
14776 });
14777 return element;
14778 }
14779 );
14780
14781 // packages/ui/build-module/link/link.mjs
14782 var import_element41 = __toESM(require_element(), 1);
14783 var import_i18n2 = __toESM(require_i18n(), 1);
14784 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
14785 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash";
14786 function getRuntime17() {
14787 const globalScope = globalThis;
14788 if (globalScope.__wpStyleRuntime) {
14789 return globalScope.__wpStyleRuntime;
14790 }
14791 globalScope.__wpStyleRuntime = {
14792 documents: /* @__PURE__ */ new Map(),
14793 styles: /* @__PURE__ */ new Map(),
14794 injectedStyles: /* @__PURE__ */ new WeakMap()
14795 };
14796 if (typeof document !== "undefined") {
14797 registerDocument17(document);
14798 }
14799 return globalScope.__wpStyleRuntime;
14800 }
14801 function documentContainsStyleHash17(targetDocument, hash) {
14802 if (!targetDocument.head) {
14803 return false;
14804 }
14805 for (const style of targetDocument.head.querySelectorAll(
14806 `style[${STYLE_HASH_ATTRIBUTE17}]`
14807 )) {
14808 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) {
14809 return true;
14810 }
14811 }
14812 return false;
14813 }
14814 function injectStyle17(targetDocument, hash, css) {
14815 if (!targetDocument.head) {
14816 return;
14817 }
14818 const runtime = getRuntime17();
14819 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14820 if (!injectedStyles) {
14821 injectedStyles = /* @__PURE__ */ new Set();
14822 runtime.injectedStyles.set(targetDocument, injectedStyles);
14823 }
14824 if (injectedStyles.has(hash)) {
14825 return;
14826 }
14827 if (documentContainsStyleHash17(targetDocument, hash)) {
14828 injectedStyles.add(hash);
14829 return;
14830 }
14831 const style = targetDocument.createElement("style");
14832 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash);
14833 style.appendChild(targetDocument.createTextNode(css));
14834 targetDocument.head.appendChild(style);
14835 injectedStyles.add(hash);
14836 }
14837 function registerDocument17(targetDocument) {
14838 const runtime = getRuntime17();
14839 runtime.documents.set(
14840 targetDocument,
14841 (runtime.documents.get(targetDocument) ?? 0) + 1
14842 );
14843 for (const [hash, css] of runtime.styles) {
14844 injectStyle17(targetDocument, hash, css);
14845 }
14846 return () => {
14847 const count = runtime.documents.get(targetDocument);
14848 if (count === void 0) {
14849 return;
14850 }
14851 if (count <= 1) {
14852 runtime.documents.delete(targetDocument);
14853 return;
14854 }
14855 runtime.documents.set(targetDocument, count - 1);
14856 };
14857 }
14858 function registerStyle17(hash, css) {
14859 const runtime = getRuntime17();
14860 runtime.styles.set(hash, css);
14861 for (const targetDocument of runtime.documents.keys()) {
14862 injectStyle17(targetDocument, hash, css);
14863 }
14864 }
14865 if (typeof process === "undefined" || true) {
14866 registerStyle17("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
14867 }
14868 var resets_default4 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
14869 if (typeof process === "undefined" || true) {
14870 registerStyle17("5f8e7aa0bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
14871 }
14872 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" };
14873 if (typeof process === "undefined" || true) {
14874 registerStyle17("7e0119b657", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-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"}}}');
14875 }
14876 var style_default16 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
14877 if (typeof process === "undefined" || true) {
14878 registerStyle17("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-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)}");
14879 }
14880 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" };
14881 var Link = (0, import_element41.forwardRef)(function Link2({
14882 children,
14883 variant = "default",
14884 tone = "brand",
14885 openInNewTab = false,
14886 render: render4,
14887 className,
14888 ...props
14889 }, ref) {
14890 const element = useRender({
14891 render: render4,
14892 defaultTagName: "a",
14893 ref,
14894 props: mergeProps(props, {
14895 className: clsx_default(
14896 global_css_defense_default4.a,
14897 resets_default4["box-sizing"],
14898 focus_default3["outset-ring--focus"],
14899 variant !== "unstyled" && style_default16.link,
14900 variant !== "unstyled" && style_default16[`is-${tone}`],
14901 variant === "unstyled" && style_default16["is-unstyled"],
14902 className
14903 ),
14904 target: openInNewTab ? "_blank" : void 0,
14905 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
14906 children,
14907 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14908 "span",
14909 {
14910 className: style_default16["link-icon"],
14911 role: "img",
14912 "aria-label": (
14913 /* translators: accessibility text appended to link text */
14914 (0, import_i18n2.__)("(opens in a new tab)")
14915 )
14916 }
14917 )
14918 ] })
14919 })
14920 });
14921 return element;
14922 });
14923
14924 // packages/ui/build-module/notice/index.mjs
14925 var notice_exports = {};
14926 __export(notice_exports, {
14927 ActionButton: () => ActionButton,
14928 ActionLink: () => ActionLink,
14929 Actions: () => Actions,
14930 CloseIcon: () => CloseIcon,
14931 Description: () => Description,
14932 Root: () => Root5,
14933 Title: () => Title2
14934 });
14935
14936 // packages/ui/build-module/notice/root.mjs
14937 var import_element42 = __toESM(require_element(), 1);
14938 import { speak as speak2 } from "@wordpress/a11y";
14939 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
14940 var STYLE_HASH_ATTRIBUTE18 = "data-wp-hash";
14941 function getRuntime18() {
14942 const globalScope = globalThis;
14943 if (globalScope.__wpStyleRuntime) {
14944 return globalScope.__wpStyleRuntime;
14945 }
14946 globalScope.__wpStyleRuntime = {
14947 documents: /* @__PURE__ */ new Map(),
14948 styles: /* @__PURE__ */ new Map(),
14949 injectedStyles: /* @__PURE__ */ new WeakMap()
14950 };
14951 if (typeof document !== "undefined") {
14952 registerDocument18(document);
14953 }
14954 return globalScope.__wpStyleRuntime;
14955 }
14956 function documentContainsStyleHash18(targetDocument, hash) {
14957 if (!targetDocument.head) {
14958 return false;
14959 }
14960 for (const style of targetDocument.head.querySelectorAll(
14961 `style[${STYLE_HASH_ATTRIBUTE18}]`
14962 )) {
14963 if (style.getAttribute(STYLE_HASH_ATTRIBUTE18) === hash) {
14964 return true;
14965 }
14966 }
14967 return false;
14968 }
14969 function injectStyle18(targetDocument, hash, css) {
14970 if (!targetDocument.head) {
14971 return;
14972 }
14973 const runtime = getRuntime18();
14974 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14975 if (!injectedStyles) {
14976 injectedStyles = /* @__PURE__ */ new Set();
14977 runtime.injectedStyles.set(targetDocument, injectedStyles);
14978 }
14979 if (injectedStyles.has(hash)) {
14980 return;
14981 }
14982 if (documentContainsStyleHash18(targetDocument, hash)) {
14983 injectedStyles.add(hash);
14984 return;
14985 }
14986 const style = targetDocument.createElement("style");
14987 style.setAttribute(STYLE_HASH_ATTRIBUTE18, hash);
14988 style.appendChild(targetDocument.createTextNode(css));
14989 targetDocument.head.appendChild(style);
14990 injectedStyles.add(hash);
14991 }
14992 function registerDocument18(targetDocument) {
14993 const runtime = getRuntime18();
14994 runtime.documents.set(
14995 targetDocument,
14996 (runtime.documents.get(targetDocument) ?? 0) + 1
14997 );
14998 for (const [hash, css] of runtime.styles) {
14999 injectStyle18(targetDocument, hash, css);
15000 }
15001 return () => {
15002 const count = runtime.documents.get(targetDocument);
15003 if (count === void 0) {
15004 return;
15005 }
15006 if (count <= 1) {
15007 runtime.documents.delete(targetDocument);
15008 return;
15009 }
15010 runtime.documents.set(targetDocument, count - 1);
15011 };
15012 }
15013 function registerStyle18(hash, css) {
15014 const runtime = getRuntime18();
15015 runtime.styles.set(hash, css);
15016 for (const targetDocument of runtime.documents.keys()) {
15017 injectStyle18(targetDocument, hash, css);
15018 }
15019 }
15020 if (typeof process === "undefined" || true) {
15021 registerStyle18("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
15022 }
15023 var resets_default5 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
15024 if (typeof process === "undefined" || true) {
15025 registerStyle18("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}");
15026 }
15027 var style_default17 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15028 var icons = {
15029 neutral: null,
15030 info: info_default,
15031 warning: caution_default,
15032 success: published_default,
15033 error: error_default
15034 };
15035 function getDefaultPoliteness(intent) {
15036 return intent === "error" ? "assertive" : "polite";
15037 }
15038 function safeRenderToString(message2) {
15039 if (!message2) {
15040 return void 0;
15041 }
15042 if (typeof message2 === "string") {
15043 return message2;
15044 }
15045 try {
15046 return (0, import_element42.renderToString)(message2);
15047 } catch {
15048 return void 0;
15049 }
15050 }
15051 function useSpokenMessage(message2, politeness) {
15052 const spokenMessage = safeRenderToString(message2);
15053 (0, import_element42.useEffect)(() => {
15054 if (spokenMessage) {
15055 speak2(spokenMessage, politeness);
15056 }
15057 }, [spokenMessage, politeness]);
15058 }
15059 var Root5 = (0, import_element42.forwardRef)(function Notice({
15060 intent = "neutral",
15061 children,
15062 icon,
15063 spokenMessage = children,
15064 politeness = getDefaultPoliteness(intent),
15065 render: render4,
15066 ...restProps
15067 }, ref) {
15068 useSpokenMessage(spokenMessage, politeness);
15069 const iconElement = icon === null ? null : icon ?? icons[intent];
15070 const mergedClassName = clsx_default(
15071 style_default17.notice,
15072 style_default17[`is-${intent}`],
15073 resets_default5["box-sizing"]
15074 );
15075 const element = useRender({
15076 defaultTagName: "div",
15077 render: render4,
15078 ref,
15079 props: mergeProps(
15080 {
15081 className: mergedClassName,
15082 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
15083 children,
15084 iconElement && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15085 Icon,
15086 {
15087 className: style_default17.icon,
15088 icon: iconElement
15089 }
15090 )
15091 ] })
15092 },
15093 restProps
15094 )
15095 });
15096 return element;
15097 });
15098
15099 // packages/ui/build-module/notice/title.mjs
15100 var import_element43 = __toESM(require_element(), 1);
15101 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
15102 var STYLE_HASH_ATTRIBUTE19 = "data-wp-hash";
15103 function getRuntime19() {
15104 const globalScope = globalThis;
15105 if (globalScope.__wpStyleRuntime) {
15106 return globalScope.__wpStyleRuntime;
15107 }
15108 globalScope.__wpStyleRuntime = {
15109 documents: /* @__PURE__ */ new Map(),
15110 styles: /* @__PURE__ */ new Map(),
15111 injectedStyles: /* @__PURE__ */ new WeakMap()
15112 };
15113 if (typeof document !== "undefined") {
15114 registerDocument19(document);
15115 }
15116 return globalScope.__wpStyleRuntime;
15117 }
15118 function documentContainsStyleHash19(targetDocument, hash) {
15119 if (!targetDocument.head) {
15120 return false;
15121 }
15122 for (const style of targetDocument.head.querySelectorAll(
15123 `style[${STYLE_HASH_ATTRIBUTE19}]`
15124 )) {
15125 if (style.getAttribute(STYLE_HASH_ATTRIBUTE19) === hash) {
15126 return true;
15127 }
15128 }
15129 return false;
15130 }
15131 function injectStyle19(targetDocument, hash, css) {
15132 if (!targetDocument.head) {
15133 return;
15134 }
15135 const runtime = getRuntime19();
15136 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15137 if (!injectedStyles) {
15138 injectedStyles = /* @__PURE__ */ new Set();
15139 runtime.injectedStyles.set(targetDocument, injectedStyles);
15140 }
15141 if (injectedStyles.has(hash)) {
15142 return;
15143 }
15144 if (documentContainsStyleHash19(targetDocument, hash)) {
15145 injectedStyles.add(hash);
15146 return;
15147 }
15148 const style = targetDocument.createElement("style");
15149 style.setAttribute(STYLE_HASH_ATTRIBUTE19, hash);
15150 style.appendChild(targetDocument.createTextNode(css));
15151 targetDocument.head.appendChild(style);
15152 injectedStyles.add(hash);
15153 }
15154 function registerDocument19(targetDocument) {
15155 const runtime = getRuntime19();
15156 runtime.documents.set(
15157 targetDocument,
15158 (runtime.documents.get(targetDocument) ?? 0) + 1
15159 );
15160 for (const [hash, css] of runtime.styles) {
15161 injectStyle19(targetDocument, hash, css);
15162 }
15163 return () => {
15164 const count = runtime.documents.get(targetDocument);
15165 if (count === void 0) {
15166 return;
15167 }
15168 if (count <= 1) {
15169 runtime.documents.delete(targetDocument);
15170 return;
15171 }
15172 runtime.documents.set(targetDocument, count - 1);
15173 };
15174 }
15175 function registerStyle19(hash, css) {
15176 const runtime = getRuntime19();
15177 runtime.styles.set(hash, css);
15178 for (const targetDocument of runtime.documents.keys()) {
15179 injectStyle19(targetDocument, hash, css);
15180 }
15181 }
15182 if (typeof process === "undefined" || true) {
15183 registerStyle19("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}");
15184 }
15185 var style_default18 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15186 var Title2 = (0, import_element43.forwardRef)(
15187 function NoticeTitle({ className, ...props }, ref) {
15188 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15189 Text,
15190 {
15191 ref,
15192 variant: "heading-md",
15193 className: clsx_default(style_default18.title, className),
15194 ...props
15195 }
15196 );
15197 }
15198 );
15199
15200 // packages/ui/build-module/notice/description.mjs
15201 var import_element44 = __toESM(require_element(), 1);
15202 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
15203 var STYLE_HASH_ATTRIBUTE20 = "data-wp-hash";
15204 function getRuntime20() {
15205 const globalScope = globalThis;
15206 if (globalScope.__wpStyleRuntime) {
15207 return globalScope.__wpStyleRuntime;
15208 }
15209 globalScope.__wpStyleRuntime = {
15210 documents: /* @__PURE__ */ new Map(),
15211 styles: /* @__PURE__ */ new Map(),
15212 injectedStyles: /* @__PURE__ */ new WeakMap()
15213 };
15214 if (typeof document !== "undefined") {
15215 registerDocument20(document);
15216 }
15217 return globalScope.__wpStyleRuntime;
15218 }
15219 function documentContainsStyleHash20(targetDocument, hash) {
15220 if (!targetDocument.head) {
15221 return false;
15222 }
15223 for (const style of targetDocument.head.querySelectorAll(
15224 `style[${STYLE_HASH_ATTRIBUTE20}]`
15225 )) {
15226 if (style.getAttribute(STYLE_HASH_ATTRIBUTE20) === hash) {
15227 return true;
15228 }
15229 }
15230 return false;
15231 }
15232 function injectStyle20(targetDocument, hash, css) {
15233 if (!targetDocument.head) {
15234 return;
15235 }
15236 const runtime = getRuntime20();
15237 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15238 if (!injectedStyles) {
15239 injectedStyles = /* @__PURE__ */ new Set();
15240 runtime.injectedStyles.set(targetDocument, injectedStyles);
15241 }
15242 if (injectedStyles.has(hash)) {
15243 return;
15244 }
15245 if (documentContainsStyleHash20(targetDocument, hash)) {
15246 injectedStyles.add(hash);
15247 return;
15248 }
15249 const style = targetDocument.createElement("style");
15250 style.setAttribute(STYLE_HASH_ATTRIBUTE20, hash);
15251 style.appendChild(targetDocument.createTextNode(css));
15252 targetDocument.head.appendChild(style);
15253 injectedStyles.add(hash);
15254 }
15255 function registerDocument20(targetDocument) {
15256 const runtime = getRuntime20();
15257 runtime.documents.set(
15258 targetDocument,
15259 (runtime.documents.get(targetDocument) ?? 0) + 1
15260 );
15261 for (const [hash, css] of runtime.styles) {
15262 injectStyle20(targetDocument, hash, css);
15263 }
15264 return () => {
15265 const count = runtime.documents.get(targetDocument);
15266 if (count === void 0) {
15267 return;
15268 }
15269 if (count <= 1) {
15270 runtime.documents.delete(targetDocument);
15271 return;
15272 }
15273 runtime.documents.set(targetDocument, count - 1);
15274 };
15275 }
15276 function registerStyle20(hash, css) {
15277 const runtime = getRuntime20();
15278 runtime.styles.set(hash, css);
15279 for (const targetDocument of runtime.documents.keys()) {
15280 injectStyle20(targetDocument, hash, css);
15281 }
15282 }
15283 if (typeof process === "undefined" || true) {
15284 registerStyle20("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}");
15285 }
15286 var style_default19 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15287 var Description = (0, import_element44.forwardRef)(
15288 function NoticeDescription({ className, ...props }, ref) {
15289 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
15290 Text,
15291 {
15292 ref,
15293 variant: "body-md",
15294 className: clsx_default(style_default19.description, className),
15295 ...props
15296 }
15297 );
15298 }
15299 );
15300
15301 // packages/ui/build-module/notice/actions.mjs
15302 var import_element45 = __toESM(require_element(), 1);
15303 var STYLE_HASH_ATTRIBUTE21 = "data-wp-hash";
15304 function getRuntime21() {
15305 const globalScope = globalThis;
15306 if (globalScope.__wpStyleRuntime) {
15307 return globalScope.__wpStyleRuntime;
15308 }
15309 globalScope.__wpStyleRuntime = {
15310 documents: /* @__PURE__ */ new Map(),
15311 styles: /* @__PURE__ */ new Map(),
15312 injectedStyles: /* @__PURE__ */ new WeakMap()
15313 };
15314 if (typeof document !== "undefined") {
15315 registerDocument21(document);
15316 }
15317 return globalScope.__wpStyleRuntime;
15318 }
15319 function documentContainsStyleHash21(targetDocument, hash) {
15320 if (!targetDocument.head) {
15321 return false;
15322 }
15323 for (const style of targetDocument.head.querySelectorAll(
15324 `style[${STYLE_HASH_ATTRIBUTE21}]`
15325 )) {
15326 if (style.getAttribute(STYLE_HASH_ATTRIBUTE21) === hash) {
15327 return true;
15328 }
15329 }
15330 return false;
15331 }
15332 function injectStyle21(targetDocument, hash, css) {
15333 if (!targetDocument.head) {
15334 return;
15335 }
15336 const runtime = getRuntime21();
15337 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15338 if (!injectedStyles) {
15339 injectedStyles = /* @__PURE__ */ new Set();
15340 runtime.injectedStyles.set(targetDocument, injectedStyles);
15341 }
15342 if (injectedStyles.has(hash)) {
15343 return;
15344 }
15345 if (documentContainsStyleHash21(targetDocument, hash)) {
15346 injectedStyles.add(hash);
15347 return;
15348 }
15349 const style = targetDocument.createElement("style");
15350 style.setAttribute(STYLE_HASH_ATTRIBUTE21, hash);
15351 style.appendChild(targetDocument.createTextNode(css));
15352 targetDocument.head.appendChild(style);
15353 injectedStyles.add(hash);
15354 }
15355 function registerDocument21(targetDocument) {
15356 const runtime = getRuntime21();
15357 runtime.documents.set(
15358 targetDocument,
15359 (runtime.documents.get(targetDocument) ?? 0) + 1
15360 );
15361 for (const [hash, css] of runtime.styles) {
15362 injectStyle21(targetDocument, hash, css);
15363 }
15364 return () => {
15365 const count = runtime.documents.get(targetDocument);
15366 if (count === void 0) {
15367 return;
15368 }
15369 if (count <= 1) {
15370 runtime.documents.delete(targetDocument);
15371 return;
15372 }
15373 runtime.documents.set(targetDocument, count - 1);
15374 };
15375 }
15376 function registerStyle21(hash, css) {
15377 const runtime = getRuntime21();
15378 runtime.styles.set(hash, css);
15379 for (const targetDocument of runtime.documents.keys()) {
15380 injectStyle21(targetDocument, hash, css);
15381 }
15382 }
15383 if (typeof process === "undefined" || true) {
15384 registerStyle21("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}");
15385 }
15386 var style_default20 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15387 var Actions = (0, import_element45.forwardRef)(
15388 function NoticeActions({ render: render4, ...props }, ref) {
15389 const element = useRender({
15390 defaultTagName: "div",
15391 render: render4,
15392 ref,
15393 props: mergeProps(
15394 {
15395 className: style_default20.actions
15396 },
15397 props
15398 )
15399 });
15400 return element;
15401 }
15402 );
15403
15404 // packages/ui/build-module/notice/close-icon.mjs
15405 var import_element46 = __toESM(require_element(), 1);
15406 var import_i18n3 = __toESM(require_i18n(), 1);
15407 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
15408 var STYLE_HASH_ATTRIBUTE22 = "data-wp-hash";
15409 function getRuntime22() {
15410 const globalScope = globalThis;
15411 if (globalScope.__wpStyleRuntime) {
15412 return globalScope.__wpStyleRuntime;
15413 }
15414 globalScope.__wpStyleRuntime = {
15415 documents: /* @__PURE__ */ new Map(),
15416 styles: /* @__PURE__ */ new Map(),
15417 injectedStyles: /* @__PURE__ */ new WeakMap()
15418 };
15419 if (typeof document !== "undefined") {
15420 registerDocument22(document);
15421 }
15422 return globalScope.__wpStyleRuntime;
15423 }
15424 function documentContainsStyleHash22(targetDocument, hash) {
15425 if (!targetDocument.head) {
15426 return false;
15427 }
15428 for (const style of targetDocument.head.querySelectorAll(
15429 `style[${STYLE_HASH_ATTRIBUTE22}]`
15430 )) {
15431 if (style.getAttribute(STYLE_HASH_ATTRIBUTE22) === hash) {
15432 return true;
15433 }
15434 }
15435 return false;
15436 }
15437 function injectStyle22(targetDocument, hash, css) {
15438 if (!targetDocument.head) {
15439 return;
15440 }
15441 const runtime = getRuntime22();
15442 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15443 if (!injectedStyles) {
15444 injectedStyles = /* @__PURE__ */ new Set();
15445 runtime.injectedStyles.set(targetDocument, injectedStyles);
15446 }
15447 if (injectedStyles.has(hash)) {
15448 return;
15449 }
15450 if (documentContainsStyleHash22(targetDocument, hash)) {
15451 injectedStyles.add(hash);
15452 return;
15453 }
15454 const style = targetDocument.createElement("style");
15455 style.setAttribute(STYLE_HASH_ATTRIBUTE22, hash);
15456 style.appendChild(targetDocument.createTextNode(css));
15457 targetDocument.head.appendChild(style);
15458 injectedStyles.add(hash);
15459 }
15460 function registerDocument22(targetDocument) {
15461 const runtime = getRuntime22();
15462 runtime.documents.set(
15463 targetDocument,
15464 (runtime.documents.get(targetDocument) ?? 0) + 1
15465 );
15466 for (const [hash, css] of runtime.styles) {
15467 injectStyle22(targetDocument, hash, css);
15468 }
15469 return () => {
15470 const count = runtime.documents.get(targetDocument);
15471 if (count === void 0) {
15472 return;
15473 }
15474 if (count <= 1) {
15475 runtime.documents.delete(targetDocument);
15476 return;
15477 }
15478 runtime.documents.set(targetDocument, count - 1);
15479 };
15480 }
15481 function registerStyle22(hash, css) {
15482 const runtime = getRuntime22();
15483 runtime.styles.set(hash, css);
15484 for (const targetDocument of runtime.documents.keys()) {
15485 injectStyle22(targetDocument, hash, css);
15486 }
15487 }
15488 if (typeof process === "undefined" || true) {
15489 registerStyle22("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}");
15490 }
15491 var style_default21 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15492 var CloseIcon = (0, import_element46.forwardRef)(
15493 function NoticeCloseIcon({ className, icon = close_small_default, label = (0, import_i18n3.__)("Dismiss"), ...props }, ref) {
15494 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
15495 IconButton,
15496 {
15497 ...props,
15498 ref,
15499 className: clsx_default(style_default21["close-icon"], className),
15500 variant: "minimal",
15501 size: "small",
15502 tone: "neutral",
15503 icon,
15504 label
15505 }
15506 );
15507 }
15508 );
15509
15510 // packages/ui/build-module/notice/action-button.mjs
15511 var import_element47 = __toESM(require_element(), 1);
15512 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
15513 var STYLE_HASH_ATTRIBUTE23 = "data-wp-hash";
15514 function getRuntime23() {
15515 const globalScope = globalThis;
15516 if (globalScope.__wpStyleRuntime) {
15517 return globalScope.__wpStyleRuntime;
15518 }
15519 globalScope.__wpStyleRuntime = {
15520 documents: /* @__PURE__ */ new Map(),
15521 styles: /* @__PURE__ */ new Map(),
15522 injectedStyles: /* @__PURE__ */ new WeakMap()
15523 };
15524 if (typeof document !== "undefined") {
15525 registerDocument23(document);
15526 }
15527 return globalScope.__wpStyleRuntime;
15528 }
15529 function documentContainsStyleHash23(targetDocument, hash) {
15530 if (!targetDocument.head) {
15531 return false;
15532 }
15533 for (const style of targetDocument.head.querySelectorAll(
15534 `style[${STYLE_HASH_ATTRIBUTE23}]`
15535 )) {
15536 if (style.getAttribute(STYLE_HASH_ATTRIBUTE23) === hash) {
15537 return true;
15538 }
15539 }
15540 return false;
15541 }
15542 function injectStyle23(targetDocument, hash, css) {
15543 if (!targetDocument.head) {
15544 return;
15545 }
15546 const runtime = getRuntime23();
15547 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15548 if (!injectedStyles) {
15549 injectedStyles = /* @__PURE__ */ new Set();
15550 runtime.injectedStyles.set(targetDocument, injectedStyles);
15551 }
15552 if (injectedStyles.has(hash)) {
15553 return;
15554 }
15555 if (documentContainsStyleHash23(targetDocument, hash)) {
15556 injectedStyles.add(hash);
15557 return;
15558 }
15559 const style = targetDocument.createElement("style");
15560 style.setAttribute(STYLE_HASH_ATTRIBUTE23, hash);
15561 style.appendChild(targetDocument.createTextNode(css));
15562 targetDocument.head.appendChild(style);
15563 injectedStyles.add(hash);
15564 }
15565 function registerDocument23(targetDocument) {
15566 const runtime = getRuntime23();
15567 runtime.documents.set(
15568 targetDocument,
15569 (runtime.documents.get(targetDocument) ?? 0) + 1
15570 );
15571 for (const [hash, css] of runtime.styles) {
15572 injectStyle23(targetDocument, hash, css);
15573 }
15574 return () => {
15575 const count = runtime.documents.get(targetDocument);
15576 if (count === void 0) {
15577 return;
15578 }
15579 if (count <= 1) {
15580 runtime.documents.delete(targetDocument);
15581 return;
15582 }
15583 runtime.documents.set(targetDocument, count - 1);
15584 };
15585 }
15586 function registerStyle23(hash, css) {
15587 const runtime = getRuntime23();
15588 runtime.styles.set(hash, css);
15589 for (const targetDocument of runtime.documents.keys()) {
15590 injectStyle23(targetDocument, hash, css);
15591 }
15592 }
15593 if (typeof process === "undefined" || true) {
15594 registerStyle23("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}");
15595 }
15596 var style_default22 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15597 var ActionButton = (0, import_element47.forwardRef)(
15598 function NoticeActionButton({ className, loading, loadingAnnouncement, variant, ...props }, ref) {
15599 const loadingProps = loading !== void 0 ? { loading, loadingAnnouncement: loadingAnnouncement ?? "" } : {};
15600 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15601 Button4,
15602 {
15603 ...props,
15604 ...loadingProps,
15605 ref,
15606 size: "compact",
15607 tone: "neutral",
15608 variant,
15609 className: clsx_default(
15610 style_default22["action-button"],
15611 style_default22[`is-action-button-${variant}`],
15612 className
15613 )
15614 }
15615 );
15616 }
15617 );
15618
15619 // packages/ui/build-module/notice/action-link.mjs
15620 var import_element48 = __toESM(require_element(), 1);
15621 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15622 var STYLE_HASH_ATTRIBUTE24 = "data-wp-hash";
15623 function getRuntime24() {
15624 const globalScope = globalThis;
15625 if (globalScope.__wpStyleRuntime) {
15626 return globalScope.__wpStyleRuntime;
15627 }
15628 globalScope.__wpStyleRuntime = {
15629 documents: /* @__PURE__ */ new Map(),
15630 styles: /* @__PURE__ */ new Map(),
15631 injectedStyles: /* @__PURE__ */ new WeakMap()
15632 };
15633 if (typeof document !== "undefined") {
15634 registerDocument24(document);
15635 }
15636 return globalScope.__wpStyleRuntime;
15637 }
15638 function documentContainsStyleHash24(targetDocument, hash) {
15639 if (!targetDocument.head) {
15640 return false;
15641 }
15642 for (const style of targetDocument.head.querySelectorAll(
15643 `style[${STYLE_HASH_ATTRIBUTE24}]`
15644 )) {
15645 if (style.getAttribute(STYLE_HASH_ATTRIBUTE24) === hash) {
15646 return true;
15647 }
15648 }
15649 return false;
15650 }
15651 function injectStyle24(targetDocument, hash, css) {
15652 if (!targetDocument.head) {
15653 return;
15654 }
15655 const runtime = getRuntime24();
15656 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15657 if (!injectedStyles) {
15658 injectedStyles = /* @__PURE__ */ new Set();
15659 runtime.injectedStyles.set(targetDocument, injectedStyles);
15660 }
15661 if (injectedStyles.has(hash)) {
15662 return;
15663 }
15664 if (documentContainsStyleHash24(targetDocument, hash)) {
15665 injectedStyles.add(hash);
15666 return;
15667 }
15668 const style = targetDocument.createElement("style");
15669 style.setAttribute(STYLE_HASH_ATTRIBUTE24, hash);
15670 style.appendChild(targetDocument.createTextNode(css));
15671 targetDocument.head.appendChild(style);
15672 injectedStyles.add(hash);
15673 }
15674 function registerDocument24(targetDocument) {
15675 const runtime = getRuntime24();
15676 runtime.documents.set(
15677 targetDocument,
15678 (runtime.documents.get(targetDocument) ?? 0) + 1
15679 );
15680 for (const [hash, css] of runtime.styles) {
15681 injectStyle24(targetDocument, hash, css);
15682 }
15683 return () => {
15684 const count = runtime.documents.get(targetDocument);
15685 if (count === void 0) {
15686 return;
15687 }
15688 if (count <= 1) {
15689 runtime.documents.delete(targetDocument);
15690 return;
15691 }
15692 runtime.documents.set(targetDocument, count - 1);
15693 };
15694 }
15695 function registerStyle24(hash, css) {
15696 const runtime = getRuntime24();
15697 runtime.styles.set(hash, css);
15698 for (const targetDocument of runtime.documents.keys()) {
15699 injectStyle24(targetDocument, hash, css);
15700 }
15701 }
15702 if (typeof process === "undefined" || true) {
15703 registerStyle24("726c480820", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._4145abab73d17514__notice{--icon-height:var(--wpds-dimension-size-sm,24px);--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-background-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#a9c6e7);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-background-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#e1bc7c);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-background-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#94d29e);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-background-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#dab1aa);--wp-ui-notice-text-color:var(--wpds-color-foreground-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-foreground-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,transparent 50%,var(--wpds-color-background-interactive-neutral-weak-active,#ededed))}}}");
15704 }
15705 var style_default23 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15706 var ActionLink = (0, import_element48.forwardRef)(
15707 function NoticeActionLink({ className, render: render4, ...props }, ref) {
15708 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15709 Text,
15710 {
15711 ref,
15712 className: clsx_default(style_default23["action-link"], className),
15713 ...props,
15714 variant: "body-md",
15715 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Link, { tone: "neutral", variant: "default", render: render4 })
15716 }
15717 );
15718 }
15719 );
15720
15721 // packages/ui/build-module/popover/index.mjs
15722 var popover_exports = {};
15723 __export(popover_exports, {
15724 Arrow: () => Arrow,
15725 Close: () => Close,
15726 Description: () => Description2,
15727 Popup: () => Popup2,
15728 Portal: () => Portal2,
15729 Positioner: () => Positioner2,
15730 Root: () => Root6,
15731 Title: () => Title3,
15732 Trigger: () => Trigger3
15733 });
15734
15735 // packages/ui/build-module/popover/arrow.mjs
15736 var import_element49 = __toESM(require_element(), 1);
15737 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15738 var STYLE_HASH_ATTRIBUTE25 = "data-wp-hash";
15739 function getRuntime25() {
15740 const globalScope = globalThis;
15741 if (globalScope.__wpStyleRuntime) {
15742 return globalScope.__wpStyleRuntime;
15743 }
15744 globalScope.__wpStyleRuntime = {
15745 documents: /* @__PURE__ */ new Map(),
15746 styles: /* @__PURE__ */ new Map(),
15747 injectedStyles: /* @__PURE__ */ new WeakMap()
15748 };
15749 if (typeof document !== "undefined") {
15750 registerDocument25(document);
15751 }
15752 return globalScope.__wpStyleRuntime;
15753 }
15754 function documentContainsStyleHash25(targetDocument, hash) {
15755 if (!targetDocument.head) {
15756 return false;
15757 }
15758 for (const style of targetDocument.head.querySelectorAll(
15759 `style[${STYLE_HASH_ATTRIBUTE25}]`
15760 )) {
15761 if (style.getAttribute(STYLE_HASH_ATTRIBUTE25) === hash) {
15762 return true;
15763 }
15764 }
15765 return false;
15766 }
15767 function injectStyle25(targetDocument, hash, css) {
15768 if (!targetDocument.head) {
15769 return;
15770 }
15771 const runtime = getRuntime25();
15772 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15773 if (!injectedStyles) {
15774 injectedStyles = /* @__PURE__ */ new Set();
15775 runtime.injectedStyles.set(targetDocument, injectedStyles);
15776 }
15777 if (injectedStyles.has(hash)) {
15778 return;
15779 }
15780 if (documentContainsStyleHash25(targetDocument, hash)) {
15781 injectedStyles.add(hash);
15782 return;
15783 }
15784 const style = targetDocument.createElement("style");
15785 style.setAttribute(STYLE_HASH_ATTRIBUTE25, hash);
15786 style.appendChild(targetDocument.createTextNode(css));
15787 targetDocument.head.appendChild(style);
15788 injectedStyles.add(hash);
15789 }
15790 function registerDocument25(targetDocument) {
15791 const runtime = getRuntime25();
15792 runtime.documents.set(
15793 targetDocument,
15794 (runtime.documents.get(targetDocument) ?? 0) + 1
15795 );
15796 for (const [hash, css] of runtime.styles) {
15797 injectStyle25(targetDocument, hash, css);
15798 }
15799 return () => {
15800 const count = runtime.documents.get(targetDocument);
15801 if (count === void 0) {
15802 return;
15803 }
15804 if (count <= 1) {
15805 runtime.documents.delete(targetDocument);
15806 return;
15807 }
15808 runtime.documents.set(targetDocument, count - 1);
15809 };
15810 }
15811 function registerStyle25(hash, css) {
15812 const runtime = getRuntime25();
15813 runtime.styles.set(hash, css);
15814 for (const targetDocument of runtime.documents.keys()) {
15815 injectStyle25(targetDocument, hash, css);
15816 }
15817 }
15818 if (typeof process === "undefined" || true) {
15819 registerStyle25("7811a8079a", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._380b81b8f79fb10f__dropdown-motion{--wp-ui-dropdown-slide-distance:4px;--wp-ui-dropdown-slide-duration:var(--wpds-motion-duration-md,200ms);--wp-ui-dropdown-slide-easing:var(--wpds-motion-easing-expressive,cubic-bezier(0.25,0,0,1));--wp-ui-dropdown-fade-duration:var(--wpds-motion-duration-sm,100ms);--wp-ui-dropdown-fade-easing:linear;@media not (prefers-reduced-motion){transition-duration:var(--wp-ui-dropdown-slide-duration),var(--wp-ui-dropdown-fade-duration);transition-property:transform,opacity;transition-timing-function:var(--wp-ui-dropdown-slide-easing),var(--wp-ui-dropdown-fade-easing);will-change:transform,opacity}opacity:1;transform:translate(0);&[data-instant]{transition:none}&[data-ending-style],&[data-starting-style]{opacity:0}&[data-side=bottom][data-ending-style],&[data-side=bottom][data-starting-style]{transform:translateY(calc(var(--wp-ui-dropdown-slide-distance)*-1))}&[data-side=top][data-ending-style],&[data-side=top][data-starting-style]{transform:translateY(var(--wp-ui-dropdown-slide-distance))}&[data-side=left][data-ending-style],&[data-side=left][data-starting-style]{transform:translateX(var(--wp-ui-dropdown-slide-distance))}&[data-side=right][data-ending-style],&[data-side=right][data-starting-style]{transform:translateX(calc(var(--wp-ui-dropdown-slide-distance)*-1))}}}}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{outline:0}._972134b6cd5808d8__surface{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-md,0 2px 3px 0 #0000000d,0 4px 5px 0 #0000000a,0 12px 12px 0 #00000008,0 16px 16px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-md,24px);padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:transparent}@media (forced-colors:active){._972134b6cd5808d8__surface,.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-background-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:rgba(0,0,0,.15);inset:0;opacity:1;position:fixed;z-index:var(--wp-ui-popover-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}}}');
15820 }
15821 var style_default24 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup _380b81b8f79fb10f__dropdown-motion", "surface": "_972134b6cd5808d8__surface", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" };
15822 function DefaultArrowSvg(props) {
15823 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15824 "svg",
15825 {
15826 width: "20",
15827 height: "10",
15828 viewBox: "0 0 20 10",
15829 fill: "none",
15830 ...props,
15831 children: [
15832 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15833 "path",
15834 {
15835 d: "M20 10H0V8h1.465a4 4 0 0 0 2.676-1.027l5.19-4.388c.378-.341.96-.341 1.338 0l5.19 4.388A4 4 0 0 0 18.535 8H20z",
15836 className: style_default24["arrow-fill"]
15837 }
15838 ),
15839 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15840 "path",
15841 {
15842 d: "M10 3.097 4.81 7.486A5 5 0 0 1 1.465 8.77H0V8h1.465a4 4 0 0 0 2.676-1.027l5.19-4.388c.378-.341.96-.341 1.338 0l5.19 4.388A4 4 0 0 0 18.535 8H20v.77h-1.465a5 5 0 0 1-3.345-1.284z",
15843 className: style_default24["arrow-stroke"]
15844 }
15845 )
15846 ]
15847 }
15848 );
15849 }
15850 var Arrow = (0, import_element49.forwardRef)(function PopoverArrow3({ children, className, ...props }, ref) {
15851 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15852 index_parts_exports2.Arrow,
15853 {
15854 ref,
15855 className: clsx_default(style_default24.arrow, className),
15856 ...props,
15857 children: children ?? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(DefaultArrowSvg, {})
15858 }
15859 );
15860 });
15861
15862 // packages/ui/build-module/popover/close.mjs
15863 var import_element50 = __toESM(require_element(), 1);
15864 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
15865 var Close = (0, import_element50.forwardRef)(
15866 function PopoverClose3(props, ref) {
15867 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15868 index_parts_exports2.Close,
15869 {
15870 ref,
15871 "data-wp-ui-popover-close": "",
15872 ...props
15873 }
15874 );
15875 }
15876 );
15877
15878 // packages/ui/build-module/popover/description.mjs
15879 var import_element51 = __toESM(require_element(), 1);
15880 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15881 var Description2 = (0, import_element51.forwardRef)(
15882 function PopoverDescription3({ children, ...props }, ref) {
15883 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15884 Text,
15885 {
15886 ref,
15887 variant: "body-md",
15888 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(index_parts_exports2.Description, { ...props }),
15889 children
15890 }
15891 );
15892 }
15893 );
15894
15895 // packages/ui/build-module/popover/popup.mjs
15896 var import_element54 = __toESM(require_element(), 1);
15897 var import_compose = __toESM(require_compose(), 1);
15898
15899 // packages/ui/build-module/popover/context.mjs
15900 var popoverTitleValidation = createOverlayTitleValidation("Popover");
15901 var usePopoverValidationContext = popoverTitleValidation.useValidationContext;
15902 var PopoverValidationProvider = popoverTitleValidation.ValidationProvider;
15903
15904 // packages/ui/build-module/popover/portal.mjs
15905 var import_element52 = __toESM(require_element(), 1);
15906 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
15907 var Portal2 = (0, import_element52.forwardRef)(
15908 function PopoverPortal3(props, ref) {
15909 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(index_parts_exports2.Portal, { ref, ...props });
15910 }
15911 );
15912
15913 // packages/ui/build-module/popover/positioner.mjs
15914 var import_element53 = __toESM(require_element(), 1);
15915 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
15916 var STYLE_HASH_ATTRIBUTE26 = "data-wp-hash";
15917 function getRuntime26() {
15918 const globalScope = globalThis;
15919 if (globalScope.__wpStyleRuntime) {
15920 return globalScope.__wpStyleRuntime;
15921 }
15922 globalScope.__wpStyleRuntime = {
15923 documents: /* @__PURE__ */ new Map(),
15924 styles: /* @__PURE__ */ new Map(),
15925 injectedStyles: /* @__PURE__ */ new WeakMap()
15926 };
15927 if (typeof document !== "undefined") {
15928 registerDocument26(document);
15929 }
15930 return globalScope.__wpStyleRuntime;
15931 }
15932 function documentContainsStyleHash26(targetDocument, hash) {
15933 if (!targetDocument.head) {
15934 return false;
15935 }
15936 for (const style of targetDocument.head.querySelectorAll(
15937 `style[${STYLE_HASH_ATTRIBUTE26}]`
15938 )) {
15939 if (style.getAttribute(STYLE_HASH_ATTRIBUTE26) === hash) {
15940 return true;
15941 }
15942 }
15943 return false;
15944 }
15945 function injectStyle26(targetDocument, hash, css) {
15946 if (!targetDocument.head) {
15947 return;
15948 }
15949 const runtime = getRuntime26();
15950 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15951 if (!injectedStyles) {
15952 injectedStyles = /* @__PURE__ */ new Set();
15953 runtime.injectedStyles.set(targetDocument, injectedStyles);
15954 }
15955 if (injectedStyles.has(hash)) {
15956 return;
15957 }
15958 if (documentContainsStyleHash26(targetDocument, hash)) {
15959 injectedStyles.add(hash);
15960 return;
15961 }
15962 const style = targetDocument.createElement("style");
15963 style.setAttribute(STYLE_HASH_ATTRIBUTE26, hash);
15964 style.appendChild(targetDocument.createTextNode(css));
15965 targetDocument.head.appendChild(style);
15966 injectedStyles.add(hash);
15967 }
15968 function registerDocument26(targetDocument) {
15969 const runtime = getRuntime26();
15970 runtime.documents.set(
15971 targetDocument,
15972 (runtime.documents.get(targetDocument) ?? 0) + 1
15973 );
15974 for (const [hash, css] of runtime.styles) {
15975 injectStyle26(targetDocument, hash, css);
15976 }
15977 return () => {
15978 const count = runtime.documents.get(targetDocument);
15979 if (count === void 0) {
15980 return;
15981 }
15982 if (count <= 1) {
15983 runtime.documents.delete(targetDocument);
15984 return;
15985 }
15986 runtime.documents.set(targetDocument, count - 1);
15987 };
15988 }
15989 function registerStyle26(hash, css) {
15990 const runtime = getRuntime26();
15991 runtime.styles.set(hash, css);
15992 for (const targetDocument of runtime.documents.keys()) {
15993 injectStyle26(targetDocument, hash, css);
15994 }
15995 }
15996 if (typeof process === "undefined" || true) {
15997 registerStyle26("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
15998 }
15999 var resets_default6 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
16000 if (typeof process === "undefined" || true) {
16001 registerStyle26("7811a8079a", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._380b81b8f79fb10f__dropdown-motion{--wp-ui-dropdown-slide-distance:4px;--wp-ui-dropdown-slide-duration:var(--wpds-motion-duration-md,200ms);--wp-ui-dropdown-slide-easing:var(--wpds-motion-easing-expressive,cubic-bezier(0.25,0,0,1));--wp-ui-dropdown-fade-duration:var(--wpds-motion-duration-sm,100ms);--wp-ui-dropdown-fade-easing:linear;@media not (prefers-reduced-motion){transition-duration:var(--wp-ui-dropdown-slide-duration),var(--wp-ui-dropdown-fade-duration);transition-property:transform,opacity;transition-timing-function:var(--wp-ui-dropdown-slide-easing),var(--wp-ui-dropdown-fade-easing);will-change:transform,opacity}opacity:1;transform:translate(0);&[data-instant]{transition:none}&[data-ending-style],&[data-starting-style]{opacity:0}&[data-side=bottom][data-ending-style],&[data-side=bottom][data-starting-style]{transform:translateY(calc(var(--wp-ui-dropdown-slide-distance)*-1))}&[data-side=top][data-ending-style],&[data-side=top][data-starting-style]{transform:translateY(var(--wp-ui-dropdown-slide-distance))}&[data-side=left][data-ending-style],&[data-side=left][data-starting-style]{transform:translateX(var(--wp-ui-dropdown-slide-distance))}&[data-side=right][data-ending-style],&[data-side=right][data-starting-style]{transform:translateX(calc(var(--wp-ui-dropdown-slide-distance)*-1))}}}}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{outline:0}._972134b6cd5808d8__surface{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-md,0 2px 3px 0 #0000000d,0 4px 5px 0 #0000000a,0 12px 12px 0 #00000008,0 16px 16px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-md,24px);padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:transparent}@media (forced-colors:active){._972134b6cd5808d8__surface,.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-background-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:rgba(0,0,0,.15);inset:0;opacity:1;position:fixed;z-index:var(--wp-ui-popover-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}}}');
16002 }
16003 var style_default25 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup _380b81b8f79fb10f__dropdown-motion", "surface": "_972134b6cd5808d8__surface", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" };
16004 var Positioner2 = (0, import_element53.forwardRef)(
16005 function PopoverPositioner3({
16006 align = "center",
16007 // Matches the popup's border-radius (--wpds-border-radius-md).
16008 arrowPadding = 8,
16009 className,
16010 side = "bottom",
16011 sideOffset = 8,
16012 ...props
16013 }, ref) {
16014 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16015 index_parts_exports2.Positioner,
16016 {
16017 ref,
16018 align,
16019 arrowPadding,
16020 side,
16021 sideOffset,
16022 ...props,
16023 className: clsx_default(
16024 resets_default6["box-sizing"],
16025 style_default25.positioner,
16026 className
16027 )
16028 }
16029 );
16030 }
16031 );
16032
16033 // packages/ui/build-module/popover/popup.mjs
16034 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
16035 var STYLE_HASH_ATTRIBUTE27 = "data-wp-hash";
16036 function getRuntime27() {
16037 const globalScope = globalThis;
16038 if (globalScope.__wpStyleRuntime) {
16039 return globalScope.__wpStyleRuntime;
16040 }
16041 globalScope.__wpStyleRuntime = {
16042 documents: /* @__PURE__ */ new Map(),
16043 styles: /* @__PURE__ */ new Map(),
16044 injectedStyles: /* @__PURE__ */ new WeakMap()
16045 };
16046 if (typeof document !== "undefined") {
16047 registerDocument27(document);
16048 }
16049 return globalScope.__wpStyleRuntime;
16050 }
16051 function documentContainsStyleHash27(targetDocument, hash) {
16052 if (!targetDocument.head) {
16053 return false;
16054 }
16055 for (const style of targetDocument.head.querySelectorAll(
16056 `style[${STYLE_HASH_ATTRIBUTE27}]`
16057 )) {
16058 if (style.getAttribute(STYLE_HASH_ATTRIBUTE27) === hash) {
16059 return true;
16060 }
16061 }
16062 return false;
16063 }
16064 function injectStyle27(targetDocument, hash, css) {
16065 if (!targetDocument.head) {
16066 return;
16067 }
16068 const runtime = getRuntime27();
16069 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16070 if (!injectedStyles) {
16071 injectedStyles = /* @__PURE__ */ new Set();
16072 runtime.injectedStyles.set(targetDocument, injectedStyles);
16073 }
16074 if (injectedStyles.has(hash)) {
16075 return;
16076 }
16077 if (documentContainsStyleHash27(targetDocument, hash)) {
16078 injectedStyles.add(hash);
16079 return;
16080 }
16081 const style = targetDocument.createElement("style");
16082 style.setAttribute(STYLE_HASH_ATTRIBUTE27, hash);
16083 style.appendChild(targetDocument.createTextNode(css));
16084 targetDocument.head.appendChild(style);
16085 injectedStyles.add(hash);
16086 }
16087 function registerDocument27(targetDocument) {
16088 const runtime = getRuntime27();
16089 runtime.documents.set(
16090 targetDocument,
16091 (runtime.documents.get(targetDocument) ?? 0) + 1
16092 );
16093 for (const [hash, css] of runtime.styles) {
16094 injectStyle27(targetDocument, hash, css);
16095 }
16096 return () => {
16097 const count = runtime.documents.get(targetDocument);
16098 if (count === void 0) {
16099 return;
16100 }
16101 if (count <= 1) {
16102 runtime.documents.delete(targetDocument);
16103 return;
16104 }
16105 runtime.documents.set(targetDocument, count - 1);
16106 };
16107 }
16108 function registerStyle27(hash, css) {
16109 const runtime = getRuntime27();
16110 runtime.styles.set(hash, css);
16111 for (const targetDocument of runtime.documents.keys()) {
16112 injectStyle27(targetDocument, hash, css);
16113 }
16114 }
16115 if (typeof process === "undefined" || true) {
16116 registerStyle27("7811a8079a", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._380b81b8f79fb10f__dropdown-motion{--wp-ui-dropdown-slide-distance:4px;--wp-ui-dropdown-slide-duration:var(--wpds-motion-duration-md,200ms);--wp-ui-dropdown-slide-easing:var(--wpds-motion-easing-expressive,cubic-bezier(0.25,0,0,1));--wp-ui-dropdown-fade-duration:var(--wpds-motion-duration-sm,100ms);--wp-ui-dropdown-fade-easing:linear;@media not (prefers-reduced-motion){transition-duration:var(--wp-ui-dropdown-slide-duration),var(--wp-ui-dropdown-fade-duration);transition-property:transform,opacity;transition-timing-function:var(--wp-ui-dropdown-slide-easing),var(--wp-ui-dropdown-fade-easing);will-change:transform,opacity}opacity:1;transform:translate(0);&[data-instant]{transition:none}&[data-ending-style],&[data-starting-style]{opacity:0}&[data-side=bottom][data-ending-style],&[data-side=bottom][data-starting-style]{transform:translateY(calc(var(--wp-ui-dropdown-slide-distance)*-1))}&[data-side=top][data-ending-style],&[data-side=top][data-starting-style]{transform:translateY(var(--wp-ui-dropdown-slide-distance))}&[data-side=left][data-ending-style],&[data-side=left][data-starting-style]{transform:translateX(var(--wp-ui-dropdown-slide-distance))}&[data-side=right][data-ending-style],&[data-side=right][data-starting-style]{transform:translateX(calc(var(--wp-ui-dropdown-slide-distance)*-1))}}}}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{outline:0}._972134b6cd5808d8__surface{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-md,0 2px 3px 0 #0000000d,0 4px 5px 0 #0000000a,0 12px 12px 0 #00000008,0 16px 16px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-md,24px);padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:transparent}@media (forced-colors:active){._972134b6cd5808d8__surface,.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-background-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:rgba(0,0,0,.15);inset:0;opacity:1;position:fixed;z-index:var(--wp-ui-popover-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}}}');
16117 }
16118 var style_default26 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup _380b81b8f79fb10f__dropdown-motion", "surface": "_972134b6cd5808d8__surface", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" };
16119 var CLOSE_ATTR = "data-wp-ui-popover-close";
16120 var Popup2 = (0, import_element54.forwardRef)(function PopoverPopup3({
16121 backdrop = false,
16122 children,
16123 className,
16124 portal,
16125 positioner,
16126 finalFocus,
16127 initialFocus,
16128 variant = "default",
16129 ...props
16130 }, ref) {
16131 const { resolvedInitialFocus, popupRef } = useDeprioritizedInitialFocus({
16132 initialFocus,
16133 deprioritizedAttributes: [CLOSE_ATTR]
16134 });
16135 const mergedPopupRef = (0, import_compose.useMergeRefs)([ref, popupRef]);
16136 const useDefaultSurface = variant !== "unstyled";
16137 const validatedChildren = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(PopoverValidationProvider, { children });
16138 const popupChildren = useDefaultSurface ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: style_default26.surface, children: validatedChildren }) : validatedChildren;
16139 const backdropElement = backdrop ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(index_parts_exports2.Backdrop, { className: style_default26.backdrop }) : null;
16140 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
16141 index_parts_exports2.Popup,
16142 {
16143 ref: mergedPopupRef,
16144 initialFocus: resolvedInitialFocus,
16145 finalFocus,
16146 className: clsx_default(
16147 useDefaultSurface && style_default26.popup,
16148 className
16149 ),
16150 ...props,
16151 children: popupChildren
16152 }
16153 ) });
16154 const positionedPopup = renderSlotWithChildren(
16155 positioner,
16156 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Positioner2, {}),
16157 popupContent
16158 );
16159 const portalChildren = /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_jsx_runtime82.Fragment, { children: [
16160 backdropElement,
16161 positionedPopup
16162 ] });
16163 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Portal2, {}), portalChildren);
16164 });
16165
16166 // packages/ui/build-module/popover/root.mjs
16167 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
16168 function Root6(props) {
16169 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(index_parts_exports2.Root, { ...props });
16170 }
16171
16172 // packages/ui/build-module/popover/title.mjs
16173 var import_compose2 = __toESM(require_compose(), 1);
16174 var import_element55 = __toESM(require_element(), 1);
16175 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
16176 var STYLE_HASH_ATTRIBUTE28 = "data-wp-hash";
16177 function getRuntime28() {
16178 const globalScope = globalThis;
16179 if (globalScope.__wpStyleRuntime) {
16180 return globalScope.__wpStyleRuntime;
16181 }
16182 globalScope.__wpStyleRuntime = {
16183 documents: /* @__PURE__ */ new Map(),
16184 styles: /* @__PURE__ */ new Map(),
16185 injectedStyles: /* @__PURE__ */ new WeakMap()
16186 };
16187 if (typeof document !== "undefined") {
16188 registerDocument28(document);
16189 }
16190 return globalScope.__wpStyleRuntime;
16191 }
16192 function documentContainsStyleHash28(targetDocument, hash) {
16193 if (!targetDocument.head) {
16194 return false;
16195 }
16196 for (const style of targetDocument.head.querySelectorAll(
16197 `style[${STYLE_HASH_ATTRIBUTE28}]`
16198 )) {
16199 if (style.getAttribute(STYLE_HASH_ATTRIBUTE28) === hash) {
16200 return true;
16201 }
16202 }
16203 return false;
16204 }
16205 function injectStyle28(targetDocument, hash, css) {
16206 if (!targetDocument.head) {
16207 return;
16208 }
16209 const runtime = getRuntime28();
16210 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16211 if (!injectedStyles) {
16212 injectedStyles = /* @__PURE__ */ new Set();
16213 runtime.injectedStyles.set(targetDocument, injectedStyles);
16214 }
16215 if (injectedStyles.has(hash)) {
16216 return;
16217 }
16218 if (documentContainsStyleHash28(targetDocument, hash)) {
16219 injectedStyles.add(hash);
16220 return;
16221 }
16222 const style = targetDocument.createElement("style");
16223 style.setAttribute(STYLE_HASH_ATTRIBUTE28, hash);
16224 style.appendChild(targetDocument.createTextNode(css));
16225 targetDocument.head.appendChild(style);
16226 injectedStyles.add(hash);
16227 }
16228 function registerDocument28(targetDocument) {
16229 const runtime = getRuntime28();
16230 runtime.documents.set(
16231 targetDocument,
16232 (runtime.documents.get(targetDocument) ?? 0) + 1
16233 );
16234 for (const [hash, css] of runtime.styles) {
16235 injectStyle28(targetDocument, hash, css);
16236 }
16237 return () => {
16238 const count = runtime.documents.get(targetDocument);
16239 if (count === void 0) {
16240 return;
16241 }
16242 if (count <= 1) {
16243 runtime.documents.delete(targetDocument);
16244 return;
16245 }
16246 runtime.documents.set(targetDocument, count - 1);
16247 };
16248 }
16249 function registerStyle28(hash, css) {
16250 const runtime = getRuntime28();
16251 runtime.styles.set(hash, css);
16252 for (const targetDocument of runtime.documents.keys()) {
16253 injectStyle28(targetDocument, hash, css);
16254 }
16255 }
16256 if (typeof process === "undefined" || true) {
16257 registerStyle28("7811a8079a", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._380b81b8f79fb10f__dropdown-motion{--wp-ui-dropdown-slide-distance:4px;--wp-ui-dropdown-slide-duration:var(--wpds-motion-duration-md,200ms);--wp-ui-dropdown-slide-easing:var(--wpds-motion-easing-expressive,cubic-bezier(0.25,0,0,1));--wp-ui-dropdown-fade-duration:var(--wpds-motion-duration-sm,100ms);--wp-ui-dropdown-fade-easing:linear;@media not (prefers-reduced-motion){transition-duration:var(--wp-ui-dropdown-slide-duration),var(--wp-ui-dropdown-fade-duration);transition-property:transform,opacity;transition-timing-function:var(--wp-ui-dropdown-slide-easing),var(--wp-ui-dropdown-fade-easing);will-change:transform,opacity}opacity:1;transform:translate(0);&[data-instant]{transition:none}&[data-ending-style],&[data-starting-style]{opacity:0}&[data-side=bottom][data-ending-style],&[data-side=bottom][data-starting-style]{transform:translateY(calc(var(--wp-ui-dropdown-slide-distance)*-1))}&[data-side=top][data-ending-style],&[data-side=top][data-starting-style]{transform:translateY(var(--wp-ui-dropdown-slide-distance))}&[data-side=left][data-ending-style],&[data-side=left][data-starting-style]{transform:translateX(var(--wp-ui-dropdown-slide-distance))}&[data-side=right][data-ending-style],&[data-side=right][data-starting-style]{transform:translateX(calc(var(--wp-ui-dropdown-slide-distance)*-1))}}}}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{outline:0}._972134b6cd5808d8__surface{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-md,0 2px 3px 0 #0000000d,0 4px 5px 0 #0000000a,0 12px 12px 0 #00000008,0 16px 16px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-md,24px);padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:transparent}@media (forced-colors:active){._972134b6cd5808d8__surface,.e4d544aa033f05c6__backdrop~* ._972134b6cd5808d8__surface{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-background-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-foreground-content-neutral,#1e1e1e);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:rgba(0,0,0,.15);inset:0;opacity:1;position:fixed;z-index:var(--wp-ui-popover-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}}}');
16258 }
16259 var style_default27 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup _380b81b8f79fb10f__dropdown-motion", "surface": "_972134b6cd5808d8__surface", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" };
16260 var Title3 = (0, import_element55.forwardRef)(
16261 function PopoverTitle3({ children, ...props }, forwardedRef) {
16262 const validationContext = usePopoverValidationContext();
16263 const internalRef = (0, import_element55.useRef)(null);
16264 const mergedRef = (0, import_compose2.useMergeRefs)([internalRef, forwardedRef]);
16265 (0, import_element55.useEffect)(() => {
16266 if (validationContext) {
16267 return validationContext.registerTitle(internalRef.current);
16268 }
16269 return void 0;
16270 }, [validationContext]);
16271 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16272 Text,
16273 {
16274 ref: mergedRef,
16275 variant: "heading-xl",
16276 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(index_parts_exports2.Title, { ...props }),
16277 className: style_default27.title,
16278 children
16279 }
16280 );
16281 }
16282 );
16283
16284 // packages/ui/build-module/popover/trigger.mjs
16285 var import_element56 = __toESM(require_element(), 1);
16286 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
16287 var Trigger3 = (0, import_element56.forwardRef)(
16288 function PopoverTrigger3(props, ref) {
16289 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(index_parts_exports2.Trigger, { ref, ...props });
16290 }
16291 );
16292
16293 // packages/admin-ui/build-module/breadcrumbs/index.mjs
16294 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
16295 var STYLE_HASH_ATTRIBUTE29 = "data-wp-hash";
16296 function getRuntime29() {
16297 const globalScope = globalThis;
16298 if (globalScope.__wpStyleRuntime) {
16299 return globalScope.__wpStyleRuntime;
16300 }
16301 globalScope.__wpStyleRuntime = {
16302 documents: /* @__PURE__ */ new Map(),
16303 styles: /* @__PURE__ */ new Map(),
16304 injectedStyles: /* @__PURE__ */ new WeakMap()
16305 };
16306 if (typeof document !== "undefined") {
16307 registerDocument29(document);
16308 }
16309 return globalScope.__wpStyleRuntime;
16310 }
16311 function documentContainsStyleHash29(targetDocument, hash) {
16312 if (!targetDocument.head) {
16313 return false;
16314 }
16315 for (const style of targetDocument.head.querySelectorAll(
16316 `style[${STYLE_HASH_ATTRIBUTE29}]`
16317 )) {
16318 if (style.getAttribute(STYLE_HASH_ATTRIBUTE29) === hash) {
16319 return true;
16320 }
16321 }
16322 return false;
16323 }
16324 function injectStyle29(targetDocument, hash, css) {
16325 if (!targetDocument.head) {
16326 return;
16327 }
16328 const runtime = getRuntime29();
16329 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16330 if (!injectedStyles) {
16331 injectedStyles = /* @__PURE__ */ new Set();
16332 runtime.injectedStyles.set(targetDocument, injectedStyles);
16333 }
16334 if (injectedStyles.has(hash)) {
16335 return;
16336 }
16337 if (documentContainsStyleHash29(targetDocument, hash)) {
16338 injectedStyles.add(hash);
16339 return;
16340 }
16341 const style = targetDocument.createElement("style");
16342 style.setAttribute(STYLE_HASH_ATTRIBUTE29, hash);
16343 style.appendChild(targetDocument.createTextNode(css));
16344 targetDocument.head.appendChild(style);
16345 injectedStyles.add(hash);
16346 }
16347 function registerDocument29(targetDocument) {
16348 const runtime = getRuntime29();
16349 runtime.documents.set(
16350 targetDocument,
16351 (runtime.documents.get(targetDocument) ?? 0) + 1
16352 );
16353 for (const [hash, css] of runtime.styles) {
16354 injectStyle29(targetDocument, hash, css);
16355 }
16356 return () => {
16357 const count = runtime.documents.get(targetDocument);
16358 if (count === void 0) {
16359 return;
16360 }
16361 if (count <= 1) {
16362 runtime.documents.delete(targetDocument);
16363 return;
16364 }
16365 runtime.documents.set(targetDocument, count - 1);
16366 };
16367 }
16368 function registerStyle29(hash, css) {
16369 const runtime = getRuntime29();
16370 runtime.styles.set(hash, css);
16371 for (const targetDocument of runtime.documents.keys()) {
16372 injectStyle29(targetDocument, hash, css);
16373 }
16374 }
16375 if (typeof process === "undefined" || true) {
16376 registerStyle29("846edc217c", "._5f4053eba32ce092__list{list-style:none;margin:0;padding:0}._5f4053eba32ce092__list>li{flex-shrink:0}._5f4053eba32ce092__list>li:last-child{flex-shrink:1;min-width:0}.d1978551971a3360__current{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._6d9152063d443376__separator{color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);margin:0 var(--wpds-dimension-gap-sm,8px);user-select:none}");
16377 }
16378 var style_default28 = { "list": "_5f4053eba32ce092__list", "current": "d1978551971a3360__current", "separator": "_6d9152063d443376__separator" };
16379 var Breadcrumbs = ({ items }) => {
16380 if (!items.length) {
16381 return null;
16382 }
16383 const precedingItems = items.slice(0, -1);
16384 const lastItem = items[items.length - 1];
16385 if (true) {
16386 const invalidItem = precedingItems.find((item) => !item.to);
16387 if (invalidItem) {
16388 throw new Error(
16389 `Breadcrumbs: item "${invalidItem.label}" is missing a \`to\` prop. All items except the last one must have a \`to\` prop.`
16390 );
16391 }
16392 }
16393 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("nav", { "aria-label": (0, import_i18n4.__)("Breadcrumbs"), children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
16394 Stack,
16395 {
16396 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("ul", {}),
16397 direction: "row",
16398 align: "center",
16399 className: style_default28.list,
16400 children: [
16401 precedingItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("li", { children: [
16402 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16403 Text,
16404 {
16405 variant: "body-lg",
16406 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16407 Link,
16408 {
16409 tone: "neutral",
16410 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(RouterLink, { to: item.to })
16411 }
16412 ),
16413 children: item.label
16414 }
16415 ),
16416 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16417 Text,
16418 {
16419 variant: "body-lg",
16420 "aria-hidden": "true",
16421 className: style_default28.separator,
16422 children: "/"
16423 }
16424 )
16425 ] }, index2)),
16426 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("li", { children: lastItem.to ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16427 Text,
16428 {
16429 variant: "body-lg",
16430 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16431 Link,
16432 {
16433 tone: "neutral",
16434 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(RouterLink, { to: lastItem.to })
16435 }
16436 ),
16437 children: lastItem.label
16438 }
16439 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16440 Text,
16441 {
16442 variant: "heading-lg",
16443 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("h1", {}),
16444 className: style_default28.current,
16445 children: lastItem.label
16446 }
16447 ) })
16448 ]
16449 }
16450 ) });
16451 };
16452 var breadcrumbs_default = Breadcrumbs;
16453
16454 // packages/admin-ui/build-module/navigable-region/index.mjs
16455 var import_element57 = __toESM(require_element(), 1);
16456 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
16457 var NavigableRegion = (0, import_element57.forwardRef)(
16458 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
16459 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
16460 Tag,
16461 {
16462 ref,
16463 className: clsx_default("admin-ui-navigable-region", className),
16464 "aria-label": ariaLabel,
16465 role: "region",
16466 tabIndex: "-1",
16467 ...props,
16468 children
16469 }
16470 );
16471 }
16472 );
16473 NavigableRegion.displayName = "NavigableRegion";
16474 var navigable_region_default = NavigableRegion;
16475
16476 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
16477 var import_components = __toESM(require_components(), 1);
16478 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");
16479
16480 // packages/admin-ui/build-module/page/header.mjs
16481 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
16482 var STYLE_HASH_ATTRIBUTE30 = "data-wp-hash";
16483 function getRuntime30() {
16484 const globalScope = globalThis;
16485 if (globalScope.__wpStyleRuntime) {
16486 return globalScope.__wpStyleRuntime;
16487 }
16488 globalScope.__wpStyleRuntime = {
16489 documents: /* @__PURE__ */ new Map(),
16490 styles: /* @__PURE__ */ new Map(),
16491 injectedStyles: /* @__PURE__ */ new WeakMap()
16492 };
16493 if (typeof document !== "undefined") {
16494 registerDocument30(document);
16495 }
16496 return globalScope.__wpStyleRuntime;
16497 }
16498 function documentContainsStyleHash30(targetDocument, hash) {
16499 if (!targetDocument.head) {
16500 return false;
16501 }
16502 for (const style of targetDocument.head.querySelectorAll(
16503 `style[${STYLE_HASH_ATTRIBUTE30}]`
16504 )) {
16505 if (style.getAttribute(STYLE_HASH_ATTRIBUTE30) === hash) {
16506 return true;
16507 }
16508 }
16509 return false;
16510 }
16511 function injectStyle30(targetDocument, hash, css) {
16512 if (!targetDocument.head) {
16513 return;
16514 }
16515 const runtime = getRuntime30();
16516 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16517 if (!injectedStyles) {
16518 injectedStyles = /* @__PURE__ */ new Set();
16519 runtime.injectedStyles.set(targetDocument, injectedStyles);
16520 }
16521 if (injectedStyles.has(hash)) {
16522 return;
16523 }
16524 if (documentContainsStyleHash30(targetDocument, hash)) {
16525 injectedStyles.add(hash);
16526 return;
16527 }
16528 const style = targetDocument.createElement("style");
16529 style.setAttribute(STYLE_HASH_ATTRIBUTE30, hash);
16530 style.appendChild(targetDocument.createTextNode(css));
16531 targetDocument.head.appendChild(style);
16532 injectedStyles.add(hash);
16533 }
16534 function registerDocument30(targetDocument) {
16535 const runtime = getRuntime30();
16536 runtime.documents.set(
16537 targetDocument,
16538 (runtime.documents.get(targetDocument) ?? 0) + 1
16539 );
16540 for (const [hash, css] of runtime.styles) {
16541 injectStyle30(targetDocument, hash, css);
16542 }
16543 return () => {
16544 const count = runtime.documents.get(targetDocument);
16545 if (count === void 0) {
16546 return;
16547 }
16548 if (count <= 1) {
16549 runtime.documents.delete(targetDocument);
16550 return;
16551 }
16552 runtime.documents.set(targetDocument, count - 1);
16553 };
16554 }
16555 function registerStyle30(hash, css) {
16556 const runtime = getRuntime30();
16557 runtime.styles.set(hash, css);
16558 for (const targetDocument of runtime.documents.keys()) {
16559 injectStyle30(targetDocument, hash, css);
16560 }
16561 }
16562 if (typeof process === "undefined" || true) {
16563 registerStyle30("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
16564 }
16565 var style_default29 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
16566 function Header3({
16567 headingLevel = 1,
16568 breadcrumbs,
16569 badges,
16570 visual,
16571 title,
16572 subTitle,
16573 actions,
16574 showSidebarToggle = true
16575 }) {
16576 const HeadingTag = `h${headingLevel}`;
16577 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", className: style_default29.header, children: [
16578 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
16579 Stack,
16580 {
16581 className: style_default29["header-content"],
16582 direction: "row",
16583 gap: "sm",
16584 justify: "space-between",
16585 children: [
16586 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
16587 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16588 SidebarToggleSlot,
16589 {
16590 bubblesVirtually: true,
16591 className: style_default29["sidebar-toggle-slot"]
16592 }
16593 ),
16594 visual && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16595 "div",
16596 {
16597 className: style_default29["header-visual"],
16598 "aria-hidden": "true",
16599 children: visual
16600 }
16601 ),
16602 title && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16603 Text,
16604 {
16605 className: style_default29["header-title"],
16606 render: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(HeadingTag, {}),
16607 variant: "heading-lg",
16608 children: title
16609 }
16610 ),
16611 breadcrumbs,
16612 badges
16613 ] }),
16614 actions && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16615 Stack,
16616 {
16617 align: "center",
16618 className: style_default29["header-actions"],
16619 direction: "row",
16620 gap: "sm",
16621 children: actions
16622 }
16623 )
16624 ]
16625 }
16626 ),
16627 subTitle && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16628 Text,
16629 {
16630 render: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", {}),
16631 variant: "body-md",
16632 className: style_default29["header-subtitle"],
16633 children: subTitle
16634 }
16635 )
16636 ] });
16637 }
16638
16639 // packages/admin-ui/build-module/page/index.mjs
16640 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
16641 var STYLE_HASH_ATTRIBUTE31 = "data-wp-hash";
16642 function getRuntime31() {
16643 const globalScope = globalThis;
16644 if (globalScope.__wpStyleRuntime) {
16645 return globalScope.__wpStyleRuntime;
16646 }
16647 globalScope.__wpStyleRuntime = {
16648 documents: /* @__PURE__ */ new Map(),
16649 styles: /* @__PURE__ */ new Map(),
16650 injectedStyles: /* @__PURE__ */ new WeakMap()
16651 };
16652 if (typeof document !== "undefined") {
16653 registerDocument31(document);
16654 }
16655 return globalScope.__wpStyleRuntime;
16656 }
16657 function documentContainsStyleHash31(targetDocument, hash) {
16658 if (!targetDocument.head) {
16659 return false;
16660 }
16661 for (const style of targetDocument.head.querySelectorAll(
16662 `style[${STYLE_HASH_ATTRIBUTE31}]`
16663 )) {
16664 if (style.getAttribute(STYLE_HASH_ATTRIBUTE31) === hash) {
16665 return true;
16666 }
16667 }
16668 return false;
16669 }
16670 function injectStyle31(targetDocument, hash, css) {
16671 if (!targetDocument.head) {
16672 return;
16673 }
16674 const runtime = getRuntime31();
16675 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16676 if (!injectedStyles) {
16677 injectedStyles = /* @__PURE__ */ new Set();
16678 runtime.injectedStyles.set(targetDocument, injectedStyles);
16679 }
16680 if (injectedStyles.has(hash)) {
16681 return;
16682 }
16683 if (documentContainsStyleHash31(targetDocument, hash)) {
16684 injectedStyles.add(hash);
16685 return;
16686 }
16687 const style = targetDocument.createElement("style");
16688 style.setAttribute(STYLE_HASH_ATTRIBUTE31, hash);
16689 style.appendChild(targetDocument.createTextNode(css));
16690 targetDocument.head.appendChild(style);
16691 injectedStyles.add(hash);
16692 }
16693 function registerDocument31(targetDocument) {
16694 const runtime = getRuntime31();
16695 runtime.documents.set(
16696 targetDocument,
16697 (runtime.documents.get(targetDocument) ?? 0) + 1
16698 );
16699 for (const [hash, css] of runtime.styles) {
16700 injectStyle31(targetDocument, hash, css);
16701 }
16702 return () => {
16703 const count = runtime.documents.get(targetDocument);
16704 if (count === void 0) {
16705 return;
16706 }
16707 if (count <= 1) {
16708 runtime.documents.delete(targetDocument);
16709 return;
16710 }
16711 runtime.documents.set(targetDocument, count - 1);
16712 };
16713 }
16714 function registerStyle31(hash, css) {
16715 const runtime = getRuntime31();
16716 runtime.styles.set(hash, css);
16717 for (const targetDocument of runtime.documents.keys()) {
16718 injectStyle31(targetDocument, hash, css);
16719 }
16720 }
16721 if (typeof process === "undefined" || true) {
16722 registerStyle31("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
16723 }
16724 var style_default30 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
16725 function Page({
16726 headingLevel,
16727 breadcrumbs,
16728 badges,
16729 visual,
16730 title,
16731 subTitle,
16732 children,
16733 className,
16734 actions,
16735 ariaLabel,
16736 hasPadding = false,
16737 showSidebarToggle = true
16738 }) {
16739 const classes = clsx_default(style_default30.page, className);
16740 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
16741 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
16742 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16743 Header3,
16744 {
16745 headingLevel,
16746 breadcrumbs,
16747 badges,
16748 visual,
16749 title,
16750 subTitle,
16751 actions,
16752 showSidebarToggle
16753 }
16754 ),
16755 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16756 "div",
16757 {
16758 className: clsx_default(
16759 style_default30.content,
16760 style_default30["has-padding"]
16761 ),
16762 children
16763 }
16764 ) : children
16765 ] });
16766 }
16767 Page.SidebarToggleFill = SidebarToggleFill;
16768 var page_default = Page;
16769
16770 // packages/content-types/build-module/components/layout/index.mjs
16771 var import_components2 = __toESM(require_components(), 1);
16772 var import_i18n5 = __toESM(require_i18n(), 1);
16773 import { useNavigate } from "@wordpress/route";
16774
16775 // packages/content-types/build-module/lock-unlock.mjs
16776 var import_private_apis2 = __toESM(require_private_apis(), 1);
16777 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
16778 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
16779 "@wordpress/content-types"
16780 );
16781
16782 // packages/content-types/build-module/components/layout/index.mjs
16783 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
16784 var { Tabs } = unlock2(import_components2.privateApis);
16785 function Layout({ activeTab, children }) {
16786 const navigate = useNavigate();
16787 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
16788 page_default,
16789 {
16790 ariaLabel: (0, import_i18n5.__)("Content Types"),
16791 className: "content-types-page",
16792 children: [
16793 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16794 Tabs,
16795 {
16796 selectedTabId: activeTab,
16797 onSelect: (tabId) => navigate({ to: `/${tabId}` }),
16798 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "content-types-tabs-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Tabs.TabList, { children: [
16799 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Tabs.Tab, { tabId: "post-types", children: (0, import_i18n5.__)("Post Types") }),
16800 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Tabs.Tab, { tabId: "taxonomies", children: (0, import_i18n5.__)("Taxonomies") })
16801 ] }) })
16802 }
16803 ),
16804 children
16805 ]
16806 }
16807 );
16808 }
16809
16810 // packages/content-types/build-module/post-types/list.mjs
16811 var import_components59 = __toESM(require_components(), 1);
16812
16813 // packages/dataviews/build-module/dataviews/index.mjs
16814 var import_element114 = __toESM(require_element(), 1);
16815 var import_compose15 = __toESM(require_compose(), 1);
16816
16817 // packages/dataviews/build-module/components/dataviews-context/index.mjs
16818 var import_element58 = __toESM(require_element(), 1);
16819
16820 // packages/dataviews/build-module/constants.mjs
16821 var import_i18n6 = __toESM(require_i18n(), 1);
16822 var OPERATOR_IS_ANY = "isAny";
16823 var OPERATOR_IS_NONE = "isNone";
16824 var OPERATOR_IS_ALL = "isAll";
16825 var OPERATOR_IS_NOT_ALL = "isNotAll";
16826 var OPERATOR_BETWEEN = "between";
16827 var OPERATOR_IN_THE_PAST = "inThePast";
16828 var OPERATOR_OVER = "over";
16829 var OPERATOR_IS = "is";
16830 var OPERATOR_IS_NOT = "isNot";
16831 var OPERATOR_LESS_THAN = "lessThan";
16832 var OPERATOR_GREATER_THAN = "greaterThan";
16833 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
16834 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
16835 var OPERATOR_BEFORE = "before";
16836 var OPERATOR_AFTER = "after";
16837 var OPERATOR_BEFORE_INC = "beforeInc";
16838 var OPERATOR_AFTER_INC = "afterInc";
16839 var OPERATOR_CONTAINS = "contains";
16840 var OPERATOR_NOT_CONTAINS = "notContains";
16841 var OPERATOR_STARTS_WITH = "startsWith";
16842 var OPERATOR_ON = "on";
16843 var OPERATOR_NOT_ON = "notOn";
16844 var SORTING_DIRECTIONS = ["asc", "desc"];
16845 var sortArrows = { asc: "↑", desc: "↓" };
16846 var sortValues = { asc: "ascending", desc: "descending" };
16847 var sortLabels = {
16848 asc: (0, import_i18n6.__)("Sort ascending"),
16849 desc: (0, import_i18n6.__)("Sort descending")
16850 };
16851 var sortIcons = {
16852 asc: arrow_up_default,
16853 desc: arrow_down_default
16854 };
16855 var LAYOUT_TABLE = "table";
16856 var LAYOUT_GRID = "grid";
16857 var LAYOUT_LIST = "list";
16858 var LAYOUT_ACTIVITY = "activity";
16859 var LAYOUT_PICKER_GRID = "pickerGrid";
16860 var LAYOUT_PICKER_TABLE = "pickerTable";
16861 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
16862
16863 // packages/dataviews/build-module/components/dataviews-context/index.mjs
16864 var DataViewsContext = (0, import_element58.createContext)({
16865 view: { type: LAYOUT_TABLE },
16866 onChangeView: () => {
16867 },
16868 fields: [],
16869 data: [],
16870 paginationInfo: {
16871 totalItems: 0,
16872 totalPages: 0
16873 },
16874 selection: [],
16875 onChangeSelection: () => {
16876 },
16877 setOpenedFilter: () => {
16878 },
16879 openedFilter: null,
16880 getItemId: (item) => item.id,
16881 isItemClickable: () => true,
16882 renderItemLink: void 0,
16883 containerWidth: 0,
16884 containerRef: (0, import_element58.createRef)(),
16885 resizeObserverRef: () => {
16886 },
16887 defaultLayouts: { list: {}, grid: {}, table: {} },
16888 filters: [],
16889 isShowingFilter: false,
16890 setIsShowingFilter: () => {
16891 },
16892 hasInitiallyLoaded: false,
16893 config: {
16894 perPageSizes: []
16895 },
16896 intersectionObserver: null
16897 });
16898 DataViewsContext.displayName = "DataViewsContext";
16899 var dataviews_context_default = DataViewsContext;
16900
16901 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
16902 var import_i18n27 = __toESM(require_i18n(), 1);
16903
16904 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
16905 var import_i18n14 = __toESM(require_i18n(), 1);
16906 var import_components8 = __toESM(require_components(), 1);
16907 var import_element66 = __toESM(require_element(), 1);
16908 var import_keycodes = __toESM(require_keycodes(), 1);
16909
16910 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
16911 var import_components3 = __toESM(require_components(), 1);
16912 var import_i18n7 = __toESM(require_i18n(), 1);
16913 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
16914 function DataViewsSelectionCheckbox({
16915 selection,
16916 onChangeSelection,
16917 item,
16918 getItemId,
16919 titleField: titleField2,
16920 disabled: disabled2,
16921 ...extraProps
16922 }) {
16923 const id = getItemId(item);
16924 const isInSelectionArray = selection.includes(id);
16925 const checked = !disabled2 && isInSelectionArray;
16926 const selectionLabel = titleField2?.getValue?.({ item }) || (0, import_i18n7.__)("(no title)");
16927 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16928 import_components3.CheckboxControl,
16929 {
16930 className: "dataviews-selection-checkbox",
16931 "aria-label": selectionLabel,
16932 "aria-disabled": disabled2,
16933 checked,
16934 onChange: () => {
16935 if (disabled2) {
16936 return;
16937 }
16938 onChangeSelection(
16939 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
16940 );
16941 },
16942 ...extraProps
16943 }
16944 );
16945 }
16946
16947 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
16948 var import_components4 = __toESM(require_components(), 1);
16949 var import_i18n8 = __toESM(require_i18n(), 1);
16950 var import_element59 = __toESM(require_element(), 1);
16951 var import_data = __toESM(require_data(), 1);
16952 var import_compose3 = __toESM(require_compose(), 1);
16953
16954 // packages/dataviews/build-module/lock-unlock.mjs
16955 var import_private_apis3 = __toESM(require_private_apis(), 1);
16956 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
16957 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
16958 "@wordpress/dataviews"
16959 );
16960
16961 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
16962 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
16963 var { Menu, kebabCase } = unlock3(import_components4.privateApis);
16964 function ButtonTrigger({
16965 action,
16966 onClick,
16967 items,
16968 variant
16969 }) {
16970 const label = typeof action.label === "string" ? action.label : action.label(items);
16971 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16972 import_components4.Button,
16973 {
16974 disabled: !!action.disabled,
16975 accessibleWhenDisabled: true,
16976 size: "compact",
16977 variant,
16978 onClick,
16979 children: label
16980 }
16981 );
16982 }
16983 function MenuItemTrigger({
16984 action,
16985 onClick,
16986 items
16987 }) {
16988 const label = typeof action.label === "string" ? action.label : action.label(items);
16989 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.ItemLabel, { children: label }) });
16990 }
16991 function ActionModal({
16992 action,
16993 items,
16994 closeModal
16995 }) {
16996 const label = typeof action.label === "string" ? action.label : action.label(items);
16997 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
16998 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16999 import_components4.Modal,
17000 {
17001 title: modalHeader || label,
17002 __experimentalHideHeader: !!action.hideModalHeader,
17003 onRequestClose: closeModal,
17004 focusOnMount: action.modalFocusOnMount ?? true,
17005 size: action.modalSize || "medium",
17006 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
17007 action.id
17008 )}`,
17009 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(action.RenderModal, { items, closeModal })
17010 }
17011 );
17012 }
17013 function ActionsMenuGroup({
17014 actions,
17015 item,
17016 registry,
17017 setActiveModalAction
17018 }) {
17019 const { primaryActions, regularActions } = (0, import_element59.useMemo)(() => {
17020 return actions.reduce(
17021 (acc, action) => {
17022 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
17023 return acc;
17024 },
17025 {
17026 primaryActions: [],
17027 regularActions: []
17028 }
17029 );
17030 }, [actions]);
17031 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17032 MenuItemTrigger,
17033 {
17034 action,
17035 onClick: () => {
17036 if ("RenderModal" in action) {
17037 setActiveModalAction(action);
17038 return;
17039 }
17040 action.callback([item], { registry });
17041 },
17042 items: [item]
17043 },
17044 action.id
17045 ));
17046 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu.Group, { children: [
17047 renderActionGroup(primaryActions),
17048 renderActionGroup(regularActions)
17049 ] });
17050 }
17051 function ItemActions({
17052 item,
17053 actions,
17054 isCompact
17055 }) {
17056 const registry = (0, import_data.useRegistry)();
17057 const { primaryActions, eligibleActions } = (0, import_element59.useMemo)(() => {
17058 const _eligibleActions = actions.filter(
17059 (action) => !action.isEligible || action.isEligible(item)
17060 );
17061 const _primaryActions = _eligibleActions.filter(
17062 (action) => action.isPrimary
17063 );
17064 return {
17065 primaryActions: _primaryActions,
17066 eligibleActions: _eligibleActions
17067 };
17068 }, [actions, item]);
17069 const isMobileViewport = (0, import_compose3.useViewportMatch)("medium", "<");
17070 if (isCompact) {
17071 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17072 CompactItemActions,
17073 {
17074 item,
17075 actions: eligibleActions,
17076 isSmall: true,
17077 registry
17078 }
17079 );
17080 }
17081 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
17082 Stack,
17083 {
17084 direction: "row",
17085 justify: "flex-end",
17086 className: "dataviews-item-actions",
17087 style: {
17088 flexShrink: 0,
17089 width: "auto"
17090 },
17091 children: [
17092 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17093 PrimaryActions,
17094 {
17095 item,
17096 actions: primaryActions,
17097 registry
17098 }
17099 ),
17100 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
17101 // there if there are any actions at all.
17102 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17103 CompactItemActions,
17104 {
17105 item,
17106 actions: eligibleActions,
17107 registry
17108 }
17109 )
17110 ]
17111 }
17112 );
17113 }
17114 function CompactItemActions({
17115 item,
17116 actions,
17117 isSmall,
17118 registry
17119 }) {
17120 const [activeModalAction, setActiveModalAction] = (0, import_element59.useState)(
17121 null
17122 );
17123 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
17124 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu, { placement: "bottom-end", children: [
17125 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17126 Menu.TriggerButton,
17127 {
17128 render: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17129 import_components4.Button,
17130 {
17131 size: isSmall ? "small" : "compact",
17132 icon: more_vertical_default,
17133 label: (0, import_i18n8.__)("Actions"),
17134 accessibleWhenDisabled: true,
17135 disabled: !actions.length,
17136 className: "dataviews-all-actions-button"
17137 }
17138 )
17139 }
17140 ),
17141 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17142 ActionsMenuGroup,
17143 {
17144 actions,
17145 item,
17146 registry,
17147 setActiveModalAction
17148 }
17149 ) })
17150 ] }),
17151 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17152 ActionModal,
17153 {
17154 action: activeModalAction,
17155 items: [item],
17156 closeModal: () => setActiveModalAction(null)
17157 }
17158 )
17159 ] });
17160 }
17161 function PrimaryActions({
17162 item,
17163 actions,
17164 registry,
17165 buttonVariant
17166 }) {
17167 const [activeModalAction, setActiveModalAction] = (0, import_element59.useState)(null);
17168 const isMobileViewport = (0, import_compose3.useViewportMatch)("medium", "<");
17169 if (isMobileViewport) {
17170 return null;
17171 }
17172 if (!Array.isArray(actions) || actions.length === 0) {
17173 return null;
17174 }
17175 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
17176 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17177 ButtonTrigger,
17178 {
17179 action,
17180 onClick: () => {
17181 if ("RenderModal" in action) {
17182 setActiveModalAction(action);
17183 return;
17184 }
17185 action.callback([item], { registry });
17186 },
17187 items: [item],
17188 variant: buttonVariant
17189 },
17190 action.id
17191 )),
17192 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17193 ActionModal,
17194 {
17195 action: activeModalAction,
17196 items: [item],
17197 closeModal: () => setActiveModalAction(null)
17198 }
17199 )
17200 ] });
17201 }
17202
17203 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
17204 var import_components5 = __toESM(require_components(), 1);
17205 var import_i18n10 = __toESM(require_i18n(), 1);
17206 var import_element60 = __toESM(require_element(), 1);
17207 var import_data2 = __toESM(require_data(), 1);
17208 var import_compose4 = __toESM(require_compose(), 1);
17209
17210 // packages/dataviews/build-module/utils/get-footer-message.mjs
17211 var import_i18n9 = __toESM(require_i18n(), 1);
17212 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
17213 if (selectionCount > 0) {
17214 return (0, import_i18n9.sprintf)(
17215 /* translators: %d: number of items. */
17216 (0, import_i18n9._n)("%d Item selected", "%d Items selected", selectionCount),
17217 selectionCount
17218 );
17219 }
17220 if (onlyTotalCount || totalItems <= itemsCount) {
17221 return (0, import_i18n9.sprintf)(
17222 /* translators: %d: number of items. */
17223 (0, import_i18n9._n)("%d Item", "%d Items", totalItems),
17224 totalItems
17225 );
17226 }
17227 return (0, import_i18n9.sprintf)(
17228 /* translators: %1$d: number of items. %2$d: total number of items. */
17229 (0, import_i18n9._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
17230 itemsCount,
17231 totalItems
17232 );
17233 }
17234
17235 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
17236 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
17237 function ActionWithModal({
17238 action,
17239 items,
17240 ActionTriggerComponent
17241 }) {
17242 const [isModalOpen, setIsModalOpen] = (0, import_element60.useState)(false);
17243 const actionTriggerProps = {
17244 action,
17245 onClick: () => {
17246 setIsModalOpen(true);
17247 },
17248 items
17249 };
17250 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_jsx_runtime93.Fragment, { children: [
17251 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
17252 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17253 ActionModal,
17254 {
17255 action,
17256 items,
17257 closeModal: () => setIsModalOpen(false)
17258 }
17259 )
17260 ] });
17261 }
17262 function useHasAPossibleBulkAction(actions, item) {
17263 return (0, import_element60.useMemo)(() => {
17264 return actions.some((action) => {
17265 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
17266 });
17267 }, [actions, item]);
17268 }
17269 function useSomeItemHasAPossibleBulkAction(actions, data) {
17270 return (0, import_element60.useMemo)(() => {
17271 return data.some((item) => {
17272 return actions.some((action) => {
17273 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
17274 });
17275 });
17276 }, [actions, data]);
17277 }
17278 function BulkSelectionCheckbox({
17279 selection,
17280 onChangeSelection,
17281 data,
17282 actions,
17283 getItemId,
17284 disableSelectAll = false
17285 }) {
17286 const selectableItems = (0, import_element60.useMemo)(() => {
17287 return data.filter((item) => {
17288 return actions.some(
17289 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
17290 );
17291 });
17292 }, [data, actions]);
17293 const selectedItems = data.filter(
17294 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
17295 );
17296 const hasSelection = selection.length > 0;
17297 const areAllSelected = selectedItems.length === selectableItems.length;
17298 if (disableSelectAll) {
17299 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17300 import_components5.CheckboxControl,
17301 {
17302 className: "dataviews-view-table-selection-checkbox",
17303 checked: hasSelection,
17304 disabled: !hasSelection,
17305 onChange: () => {
17306 onChangeSelection([]);
17307 },
17308 "aria-label": (0, import_i18n10.__)("Deselect all")
17309 }
17310 );
17311 }
17312 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17313 import_components5.CheckboxControl,
17314 {
17315 className: "dataviews-view-table-selection-checkbox",
17316 checked: areAllSelected,
17317 indeterminate: !areAllSelected && !!selectedItems.length,
17318 onChange: () => {
17319 if (areAllSelected) {
17320 onChangeSelection([]);
17321 } else {
17322 onChangeSelection(
17323 selectableItems.map((item) => getItemId(item))
17324 );
17325 }
17326 },
17327 "aria-label": areAllSelected ? (0, import_i18n10.__)("Deselect all") : (0, import_i18n10.__)("Select all")
17328 }
17329 );
17330 }
17331 function ActionTrigger({
17332 action,
17333 onClick,
17334 isBusy,
17335 items
17336 }) {
17337 const label = typeof action.label === "string" ? action.label : action.label(items);
17338 const isMobile = (0, import_compose4.useViewportMatch)("medium", "<");
17339 if (isMobile) {
17340 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17341 import_components5.Button,
17342 {
17343 disabled: isBusy,
17344 accessibleWhenDisabled: true,
17345 label,
17346 icon: action.icon,
17347 size: "compact",
17348 onClick,
17349 isBusy
17350 }
17351 );
17352 }
17353 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17354 import_components5.Button,
17355 {
17356 disabled: isBusy,
17357 accessibleWhenDisabled: true,
17358 size: "compact",
17359 onClick,
17360 isBusy,
17361 children: label
17362 }
17363 );
17364 }
17365 var EMPTY_ARRAY2 = [];
17366 function ActionButton2({
17367 action,
17368 selectedItems,
17369 actionInProgress,
17370 setActionInProgress
17371 }) {
17372 const registry = (0, import_data2.useRegistry)();
17373 const selectedEligibleItems = (0, import_element60.useMemo)(() => {
17374 return selectedItems.filter((item) => {
17375 return !action.isEligible || action.isEligible(item);
17376 });
17377 }, [action, selectedItems]);
17378 if ("RenderModal" in action) {
17379 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17380 ActionWithModal,
17381 {
17382 action,
17383 items: selectedEligibleItems,
17384 ActionTriggerComponent: ActionTrigger
17385 },
17386 action.id
17387 );
17388 }
17389 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17390 ActionTrigger,
17391 {
17392 action,
17393 onClick: async () => {
17394 setActionInProgress(action.id);
17395 await action.callback(selectedItems, {
17396 registry
17397 });
17398 setActionInProgress(null);
17399 },
17400 items: selectedEligibleItems,
17401 isBusy: actionInProgress === action.id
17402 },
17403 action.id
17404 );
17405 }
17406 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
17407 const message2 = getFooterMessage(
17408 selection.length,
17409 data.length,
17410 paginationInfo.totalItems,
17411 isInfiniteScroll
17412 );
17413 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17414 Stack,
17415 {
17416 direction: "row",
17417 className: "dataviews-bulk-actions-footer__container",
17418 gap: "md",
17419 align: "center",
17420 children: [
17421 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17422 BulkSelectionCheckbox,
17423 {
17424 selection,
17425 onChangeSelection,
17426 data,
17427 actions,
17428 getItemId,
17429 disableSelectAll: isInfiniteScroll
17430 }
17431 ),
17432 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
17433 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17434 Stack,
17435 {
17436 direction: "row",
17437 className: "dataviews-bulk-actions-footer__action-buttons",
17438 gap: "xs",
17439 children: [
17440 actionsToShow.map((action) => {
17441 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17442 ActionButton2,
17443 {
17444 action,
17445 selectedItems,
17446 actionInProgress,
17447 setActionInProgress
17448 },
17449 action.id
17450 );
17451 }),
17452 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17453 import_components5.Button,
17454 {
17455 icon: close_small_default,
17456 showTooltip: true,
17457 tooltipPosition: "top",
17458 size: "compact",
17459 label: (0, import_i18n10.__)("Cancel"),
17460 disabled: !!actionInProgress,
17461 accessibleWhenDisabled: false,
17462 onClick: () => {
17463 onChangeSelection(EMPTY_ARRAY2);
17464 }
17465 }
17466 )
17467 ]
17468 }
17469 )
17470 ]
17471 }
17472 );
17473 }
17474 function FooterContent({
17475 selection,
17476 actions,
17477 onChangeSelection,
17478 data,
17479 getItemId,
17480 isInfiniteScroll,
17481 paginationInfo
17482 }) {
17483 const [actionInProgress, setActionInProgress] = (0, import_element60.useState)(
17484 null
17485 );
17486 const footerContentRef = (0, import_element60.useRef)(void 0);
17487 const isMobile = (0, import_compose4.useViewportMatch)("medium", "<");
17488 const bulkActions = (0, import_element60.useMemo)(
17489 () => actions.filter((action) => action.supportsBulk),
17490 [actions]
17491 );
17492 const selectableItems = (0, import_element60.useMemo)(() => {
17493 return data.filter((item) => {
17494 return bulkActions.some(
17495 (action) => !action.isEligible || action.isEligible(item)
17496 );
17497 });
17498 }, [data, bulkActions]);
17499 const selectedItems = (0, import_element60.useMemo)(() => {
17500 return data.filter(
17501 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
17502 );
17503 }, [selection, data, getItemId, selectableItems]);
17504 const actionsToShow = (0, import_element60.useMemo)(
17505 () => actions.filter((action) => {
17506 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
17507 (item) => !action.isEligible || action.isEligible(item)
17508 );
17509 }),
17510 [actions, selectedItems, isMobile]
17511 );
17512 if (!actionInProgress) {
17513 if (footerContentRef.current) {
17514 footerContentRef.current = void 0;
17515 }
17516 return renderFooterContent(
17517 data,
17518 actions,
17519 getItemId,
17520 isInfiniteScroll,
17521 selection,
17522 actionsToShow,
17523 selectedItems,
17524 actionInProgress,
17525 setActionInProgress,
17526 onChangeSelection,
17527 paginationInfo
17528 );
17529 } else if (!footerContentRef.current) {
17530 footerContentRef.current = renderFooterContent(
17531 data,
17532 actions,
17533 getItemId,
17534 isInfiniteScroll,
17535 selection,
17536 actionsToShow,
17537 selectedItems,
17538 actionInProgress,
17539 setActionInProgress,
17540 onChangeSelection,
17541 paginationInfo
17542 );
17543 }
17544 return footerContentRef.current;
17545 }
17546 function BulkActionsFooter() {
17547 const {
17548 data,
17549 selection,
17550 actions = EMPTY_ARRAY2,
17551 onChangeSelection,
17552 getItemId,
17553 paginationInfo,
17554 view
17555 } = (0, import_element60.useContext)(dataviews_context_default);
17556 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17557 FooterContent,
17558 {
17559 selection,
17560 onChangeSelection,
17561 data,
17562 actions,
17563 getItemId,
17564 isInfiniteScroll: !!view.infiniteScrollEnabled,
17565 paginationInfo
17566 }
17567 );
17568 }
17569
17570 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
17571 var import_i18n11 = __toESM(require_i18n(), 1);
17572 var import_components6 = __toESM(require_components(), 1);
17573 var import_element61 = __toESM(require_element(), 1);
17574
17575 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
17576 function getHideableFields(view, fields) {
17577 const togglableFields = [
17578 view?.titleField,
17579 view?.mediaField,
17580 view?.descriptionField
17581 ].filter(Boolean);
17582 return fields.filter(
17583 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
17584 );
17585 }
17586
17587 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
17588 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
17589 var { Menu: Menu2 } = unlock3(import_components6.privateApis);
17590 function WithMenuSeparators({ children }) {
17591 return import_element61.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_element61.Fragment, { children: [
17592 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Separator, {}),
17593 child
17594 ] }, i2));
17595 }
17596 var _HeaderMenu = (0, import_element61.forwardRef)(function HeaderMenu({
17597 fieldId,
17598 view,
17599 fields,
17600 onChangeView,
17601 onHide,
17602 setOpenedFilter,
17603 canMove = true,
17604 canInsertLeft = true,
17605 canInsertRight = true
17606 }, ref) {
17607 const visibleFieldIds = view.fields ?? [];
17608 const index2 = visibleFieldIds?.indexOf(fieldId);
17609 const isSorted = view.sort?.field === fieldId;
17610 let isHidable = false;
17611 let isSortable = false;
17612 let canAddFilter = false;
17613 let operators = [];
17614 const field = fields.find((f2) => f2.id === fieldId);
17615 const { setIsShowingFilter } = (0, import_element61.useContext)(dataviews_context_default);
17616 if (!field) {
17617 return null;
17618 }
17619 isHidable = field.enableHiding !== false;
17620 isSortable = field.enableSorting !== false;
17621 const header = field.header;
17622 operators = !!field.filterBy && field.filterBy?.operators || [];
17623 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
17624 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
17625 return header;
17626 }
17627 const hiddenFields = getHideableFields(view, fields).filter(
17628 (f2) => !visibleFieldIds.includes(f2.id)
17629 );
17630 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
17631 const isRtl = (0, import_i18n11.isRTL)();
17632 return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [
17633 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
17634 Menu2.TriggerButton,
17635 {
17636 render: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17637 import_components6.Button,
17638 {
17639 size: "compact",
17640 className: "dataviews-view-table-header-button",
17641 ref,
17642 variant: "tertiary"
17643 }
17644 ),
17645 children: [
17646 header,
17647 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
17648 ]
17649 }
17650 ),
17651 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(WithMenuSeparators, { children: [
17652 isSortable && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
17653 (direction) => {
17654 const isChecked = view.sort && isSorted && view.sort.direction === direction;
17655 const value = `${fieldId}-${direction}`;
17656 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17657 Menu2.RadioItem,
17658 {
17659 name: "view-table-sorting",
17660 value,
17661 checked: isChecked,
17662 onChange: () => {
17663 onChangeView({
17664 ...view,
17665 sort: {
17666 field: fieldId,
17667 direction
17668 },
17669 showLevels: false
17670 });
17671 },
17672 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
17673 },
17674 value
17675 );
17676 }
17677 ) }),
17678 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17679 Menu2.Item,
17680 {
17681 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: funnel_default }),
17682 onClick: () => {
17683 setOpenedFilter(fieldId);
17684 setIsShowingFilter(true);
17685 onChangeView({
17686 ...view,
17687 page: 1,
17688 filters: [
17689 ...view.filters || [],
17690 {
17691 field: fieldId,
17692 value: void 0,
17693 operator: operators[0]
17694 }
17695 ]
17696 });
17697 },
17698 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Add filter") })
17699 }
17700 ) }),
17701 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2.Group, { children: [
17702 canMove && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17703 Menu2.Item,
17704 {
17705 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: arrow_left_default }),
17706 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
17707 onClick: () => {
17708 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
17709 const newFields = [
17710 ...visibleFieldIds
17711 ];
17712 newFields.splice(index2, 1);
17713 newFields.splice(
17714 targetIndex,
17715 0,
17716 fieldId
17717 );
17718 onChangeView({
17719 ...view,
17720 fields: newFields
17721 });
17722 },
17723 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Move left") })
17724 }
17725 ),
17726 canMove && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17727 Menu2.Item,
17728 {
17729 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: arrow_right_default }),
17730 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
17731 onClick: () => {
17732 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
17733 const newFields = [
17734 ...visibleFieldIds
17735 ];
17736 newFields.splice(index2, 1);
17737 newFields.splice(
17738 targetIndex,
17739 0,
17740 fieldId
17741 );
17742 onChangeView({
17743 ...view,
17744 fields: newFields
17745 });
17746 },
17747 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Move right") })
17748 }
17749 ),
17750 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [
17751 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Insert left") }) }),
17752 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
17753 const insertIndex = isRtl ? index2 + 1 : index2;
17754 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17755 Menu2.Item,
17756 {
17757 onClick: () => {
17758 onChangeView({
17759 ...view,
17760 fields: [
17761 ...visibleFieldIds.slice(
17762 0,
17763 insertIndex
17764 ),
17765 hiddenField.id,
17766 ...visibleFieldIds.slice(
17767 insertIndex
17768 )
17769 ]
17770 });
17771 },
17772 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
17773 },
17774 hiddenField.id
17775 );
17776 }) })
17777 ] }),
17778 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [
17779 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Insert right") }) }),
17780 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
17781 const insertIndex = isRtl ? index2 : index2 + 1;
17782 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17783 Menu2.Item,
17784 {
17785 onClick: () => {
17786 onChangeView({
17787 ...view,
17788 fields: [
17789 ...visibleFieldIds.slice(
17790 0,
17791 insertIndex
17792 ),
17793 hiddenField.id,
17794 ...visibleFieldIds.slice(
17795 insertIndex
17796 )
17797 ]
17798 });
17799 },
17800 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
17801 },
17802 hiddenField.id
17803 );
17804 }) })
17805 ] }),
17806 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17807 Menu2.Item,
17808 {
17809 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: unseen_default }),
17810 onClick: () => {
17811 onHide(field);
17812 onChangeView({
17813 ...view,
17814 fields: visibleFieldIds.filter(
17815 (id) => id !== fieldId
17816 )
17817 });
17818 },
17819 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Hide column") })
17820 }
17821 )
17822 ] })
17823 ] }) })
17824 ] });
17825 });
17826 var ColumnHeaderMenu = _HeaderMenu;
17827 var column_header_menu_default = ColumnHeaderMenu;
17828
17829 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
17830 var import_element62 = __toESM(require_element(), 1);
17831 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
17832 function getClickableItemProps({
17833 item,
17834 isItemClickable,
17835 onClickItem,
17836 className
17837 }) {
17838 if (!isItemClickable(item) || !onClickItem) {
17839 return { className };
17840 }
17841 return {
17842 className: className ? `${className} ${className}--clickable` : void 0,
17843 role: "button",
17844 tabIndex: 0,
17845 onClick: (event) => {
17846 event.stopPropagation();
17847 onClickItem(item);
17848 },
17849 onKeyDown: (event) => {
17850 if (event.key === "Enter" || event.key === "" || event.key === " ") {
17851 event.stopPropagation();
17852 onClickItem(item);
17853 }
17854 }
17855 };
17856 }
17857 function ItemClickWrapper({
17858 item,
17859 isItemClickable,
17860 onClickItem,
17861 renderItemLink,
17862 className,
17863 children,
17864 ...extraProps
17865 }) {
17866 if (!isItemClickable(item)) {
17867 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className, ...extraProps, children });
17868 }
17869 if (renderItemLink) {
17870 const renderedElement = renderItemLink({
17871 item,
17872 className: `${className} ${className}--clickable`,
17873 ...extraProps,
17874 children
17875 });
17876 return (0, import_element62.cloneElement)(renderedElement, {
17877 onClick: (event) => {
17878 event.stopPropagation();
17879 if (renderedElement.props.onClick) {
17880 renderedElement.props.onClick(event);
17881 }
17882 },
17883 onKeyDown: (event) => {
17884 if (event.key === "Enter" || event.key === "" || event.key === " ") {
17885 event.stopPropagation();
17886 if (renderedElement.props.onKeyDown) {
17887 renderedElement.props.onKeyDown(event);
17888 }
17889 }
17890 }
17891 });
17892 }
17893 const clickProps = getClickableItemProps({
17894 item,
17895 isItemClickable,
17896 onClickItem,
17897 className
17898 });
17899 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { ...clickProps, ...extraProps, children });
17900 }
17901
17902 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
17903 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
17904 function ColumnPrimary({
17905 item,
17906 level,
17907 titleField: titleField2,
17908 mediaField,
17909 descriptionField: descriptionField3,
17910 onClickItem,
17911 renderItemLink,
17912 isItemClickable
17913 }) {
17914 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
17915 mediaField && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17916 ItemClickWrapper,
17917 {
17918 item,
17919 isItemClickable,
17920 onClickItem,
17921 renderItemLink,
17922 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
17923 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField2 ? titleField2.getValue?.({ item }) : void 0,
17924 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17925 mediaField.render,
17926 {
17927 item,
17928 field: mediaField,
17929 config: { sizes: "32px" }
17930 }
17931 )
17932 }
17933 ),
17934 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
17935 Stack,
17936 {
17937 direction: "column",
17938 align: "flex-start",
17939 className: "dataviews-view-table__primary-column-content",
17940 children: [
17941 titleField2 && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
17942 ItemClickWrapper,
17943 {
17944 item,
17945 isItemClickable,
17946 onClickItem,
17947 renderItemLink,
17948 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
17949 children: [
17950 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("span", { className: "dataviews-view-table__level", children: [
17951 Array(level).fill("—").join(" "),
17952 " "
17953 ] }),
17954 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(titleField2.render, { item, field: titleField2 })
17955 ]
17956 }
17957 ),
17958 descriptionField3 && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17959 descriptionField3.render,
17960 {
17961 item,
17962 field: descriptionField3
17963 }
17964 )
17965 ]
17966 }
17967 )
17968 ] });
17969 }
17970 var column_primary_default = ColumnPrimary;
17971
17972 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
17973 var import_element63 = __toESM(require_element(), 1);
17974 var import_i18n12 = __toESM(require_i18n(), 1);
17975 var isScrolledToEnd = (element) => {
17976 if ((0, import_i18n12.isRTL)()) {
17977 const scrollLeft = Math.abs(element.scrollLeft);
17978 return scrollLeft <= 1;
17979 }
17980 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
17981 };
17982 function useScrollState({
17983 scrollContainerRef,
17984 enabledHorizontal = false
17985 }) {
17986 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element63.useState)(false);
17987 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element63.useState)(false);
17988 const handleScroll = (0, import_element63.useCallback)(() => {
17989 const scrollContainer = scrollContainerRef.current;
17990 if (!scrollContainer) {
17991 return;
17992 }
17993 if (enabledHorizontal) {
17994 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
17995 }
17996 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
17997 }, [scrollContainerRef, enabledHorizontal]);
17998 (0, import_element63.useEffect)(() => {
17999 if (typeof window === "undefined" || !scrollContainerRef.current) {
18000 return () => {
18001 };
18002 }
18003 const scrollContainer = scrollContainerRef.current;
18004 handleScroll();
18005 scrollContainer.addEventListener("scroll", handleScroll);
18006 window.addEventListener("resize", handleScroll);
18007 return () => {
18008 scrollContainer.removeEventListener("scroll", handleScroll);
18009 window.removeEventListener("resize", handleScroll);
18010 };
18011 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
18012 return { isHorizontalScrollEnd, isVerticallyScrolled };
18013 }
18014
18015 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
18016 function getDataByGroup(data, groupByField) {
18017 return data.reduce((groups, item) => {
18018 const groupName = groupByField.getValue({ item });
18019 if (!groups.has(groupName)) {
18020 groups.set(groupName, []);
18021 }
18022 groups.get(groupName)?.push(item);
18023 return groups;
18024 }, /* @__PURE__ */ new Map());
18025 }
18026
18027 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
18028 var import_components7 = __toESM(require_components(), 1);
18029 var import_i18n13 = __toESM(require_i18n(), 1);
18030 var import_element64 = __toESM(require_element(), 1);
18031 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
18032 function FieldItem({
18033 field,
18034 isVisible: isVisible2,
18035 onToggleVisibility
18036 }) {
18037 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
18038 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.Icon, { icon: check_default }) }),
18039 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
18040 ] }) });
18041 }
18042 function isDefined(item) {
18043 return !!item;
18044 }
18045 function PropertiesSection({
18046 showLabel = true
18047 }) {
18048 const { view, fields, onChangeView } = (0, import_element64.useContext)(dataviews_context_default);
18049 const regularFields = getHideableFields(view, fields);
18050 if (!regularFields?.length) {
18051 return null;
18052 }
18053 const titleField2 = fields.find((f2) => f2.id === view.titleField);
18054 const previewField = fields.find((f2) => f2.id === view.mediaField);
18055 const descriptionField3 = fields.find(
18056 (f2) => f2.id === view.descriptionField
18057 );
18058 const lockedFields = [
18059 {
18060 field: titleField2,
18061 isVisibleFlag: "showTitle"
18062 },
18063 {
18064 field: previewField,
18065 isVisibleFlag: "showMedia"
18066 },
18067 {
18068 field: descriptionField3,
18069 isVisibleFlag: "showDescription"
18070 }
18071 ].filter(({ field }) => isDefined(field));
18072 const visibleFieldIds = view.fields ?? [];
18073 const visibleRegularFieldsCount = regularFields.filter(
18074 (f2) => visibleFieldIds.includes(f2.id)
18075 ).length;
18076 const visibleLockedFields = lockedFields.filter(
18077 ({ isVisibleFlag }) => (
18078 // @ts-expect-error
18079 view[isVisibleFlag] ?? true
18080 )
18081 );
18082 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
18083 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
18084 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
18085 showLabel && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n13.__)("Properties") }),
18086 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18087 Stack,
18088 {
18089 direction: "column",
18090 className: "dataviews-view-config__properties",
18091 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
18092 lockedFields.map(({ field, isVisibleFlag }) => {
18093 const isVisible2 = view[isVisibleFlag] ?? true;
18094 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
18095 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18096 FieldItem,
18097 {
18098 field: fieldToRender,
18099 isVisible: isVisible2,
18100 onToggleVisibility: () => {
18101 onChangeView({
18102 ...view,
18103 [isVisibleFlag]: !isVisible2
18104 });
18105 }
18106 },
18107 field.id
18108 );
18109 }),
18110 regularFields.map((field) => {
18111 const isVisible2 = visibleFieldIds.includes(field.id);
18112 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
18113 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18114 FieldItem,
18115 {
18116 field: fieldToRender,
18117 isVisible: isVisible2,
18118 onToggleVisibility: () => {
18119 onChangeView({
18120 ...view,
18121 fields: isVisible2 ? visibleFieldIds.filter(
18122 (fieldId) => fieldId !== field.id
18123 ) : [...visibleFieldIds, field.id]
18124 });
18125 }
18126 },
18127 field.id
18128 );
18129 })
18130 ] })
18131 }
18132 )
18133 ] });
18134 }
18135
18136 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
18137 var import_element65 = __toESM(require_element(), 1);
18138 function useDelayedLoading(isLoading, options = { delay: 400 }) {
18139 const [showLoader, setShowLoader] = (0, import_element65.useState)(false);
18140 (0, import_element65.useEffect)(() => {
18141 if (!isLoading) {
18142 return;
18143 }
18144 const timeout = setTimeout(() => {
18145 setShowLoader(true);
18146 }, options.delay);
18147 return () => {
18148 clearTimeout(timeout);
18149 setShowLoader(false);
18150 };
18151 }, [isLoading, options.delay]);
18152 return showLoader;
18153 }
18154
18155 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
18156 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
18157 function getEffectiveAlign(explicitAlign, fieldType) {
18158 if (explicitAlign) {
18159 return explicitAlign;
18160 }
18161 if (fieldType === "integer" || fieldType === "number") {
18162 return "end";
18163 }
18164 return void 0;
18165 }
18166 function TableColumnField({
18167 item,
18168 fields,
18169 column,
18170 align
18171 }) {
18172 const field = fields.find((f2) => f2.id === column);
18173 if (!field) {
18174 return null;
18175 }
18176 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
18177 "dataviews-view-table__cell-align-end": align === "end",
18178 "dataviews-view-table__cell-align-center": align === "center"
18179 });
18180 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(field.render, { item, field }) });
18181 }
18182 function TableRow({
18183 hasBulkActions,
18184 item,
18185 level,
18186 actions,
18187 fields,
18188 id,
18189 view,
18190 titleField: titleField2,
18191 mediaField,
18192 descriptionField: descriptionField3,
18193 selection,
18194 getItemId,
18195 isItemClickable,
18196 onClickItem,
18197 renderItemLink,
18198 onChangeSelection,
18199 isActionsColumnSticky,
18200 posinset
18201 }) {
18202 const { paginationInfo } = (0, import_element66.useContext)(dataviews_context_default);
18203 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
18204 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
18205 const {
18206 showTitle = true,
18207 showMedia = true,
18208 showDescription = true,
18209 infiniteScrollEnabled
18210 } = view;
18211 const isTouchDeviceRef = (0, import_element66.useRef)(false);
18212 const columns = view.fields ?? [];
18213 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription;
18214 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
18215 "tr",
18216 {
18217 className: clsx_default("dataviews-view-table__row", {
18218 "is-selected": hasPossibleBulkAction && isSelected2,
18219 "has-bulk-actions": hasPossibleBulkAction
18220 }),
18221 onTouchStart: () => {
18222 isTouchDeviceRef.current = true;
18223 },
18224 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
18225 "aria-posinset": posinset,
18226 role: infiniteScrollEnabled ? "article" : void 0,
18227 onMouseDown: (event) => {
18228 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
18229 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
18230 event?.preventDefault();
18231 }
18232 },
18233 onClick: (event) => {
18234 if (!hasPossibleBulkAction) {
18235 return;
18236 }
18237 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
18238 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
18239 onChangeSelection(
18240 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
18241 );
18242 }
18243 },
18244 children: [
18245 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18246 DataViewsSelectionCheckbox,
18247 {
18248 item,
18249 selection,
18250 onChangeSelection,
18251 getItemId,
18252 titleField: titleField2,
18253 disabled: !hasPossibleBulkAction
18254 }
18255 ) }) }),
18256 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18257 column_primary_default,
18258 {
18259 item,
18260 level,
18261 titleField: showTitle ? titleField2 : void 0,
18262 mediaField: showMedia ? mediaField : void 0,
18263 descriptionField: showDescription ? descriptionField3 : void 0,
18264 isItemClickable,
18265 onClickItem,
18266 renderItemLink
18267 }
18268 ) }),
18269 columns.map((column) => {
18270 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
18271 const field = fields.find((f2) => f2.id === column);
18272 const effectiveAlign = getEffectiveAlign(align, field?.type);
18273 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18274 "td",
18275 {
18276 style: {
18277 width,
18278 maxWidth,
18279 minWidth
18280 },
18281 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18282 TableColumnField,
18283 {
18284 fields,
18285 item,
18286 column,
18287 align: effectiveAlign
18288 }
18289 )
18290 },
18291 column
18292 );
18293 }),
18294 !!actions?.length && // Disable reason: we are not making the element interactive,
18295 // but preventing any click events from bubbling up to the
18296 // table row. This allows us to add a click handler to the row
18297 // itself (to toggle row selection) without erroneously
18298 // intercepting click events from ItemActions.
18299 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18300 "td",
18301 {
18302 className: clsx_default("dataviews-view-table__actions-column", {
18303 "dataviews-view-table__actions-column--sticky": true,
18304 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
18305 }),
18306 onClick: (e2) => e2.stopPropagation(),
18307 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ItemActions, { item, actions })
18308 }
18309 )
18310 ]
18311 }
18312 );
18313 }
18314 function ViewTable({
18315 actions,
18316 data,
18317 fields,
18318 getItemId,
18319 getItemLevel,
18320 isLoading = false,
18321 onChangeView,
18322 onChangeSelection,
18323 selection,
18324 setOpenedFilter,
18325 onClickItem,
18326 isItemClickable,
18327 renderItemLink,
18328 view,
18329 className,
18330 empty
18331 }) {
18332 const { containerRef } = (0, import_element66.useContext)(dataviews_context_default);
18333 const isDelayedLoading = useDelayedLoading(isLoading);
18334 const headerMenuRefs = (0, import_element66.useRef)(/* @__PURE__ */ new Map());
18335 const headerMenuToFocusRef = (0, import_element66.useRef)(void 0);
18336 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element66.useState)();
18337 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element66.useState)(null);
18338 (0, import_element66.useEffect)(() => {
18339 if (headerMenuToFocusRef.current) {
18340 headerMenuToFocusRef.current.focus();
18341 headerMenuToFocusRef.current = void 0;
18342 }
18343 });
18344 const tableNoticeId = (0, import_element66.useId)();
18345 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
18346 scrollContainerRef: containerRef,
18347 enabledHorizontal: !!actions?.length
18348 });
18349 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
18350 if (nextHeaderMenuToFocus) {
18351 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
18352 setNextHeaderMenuToFocus(void 0);
18353 return;
18354 }
18355 const onHide = (field) => {
18356 const hidden = headerMenuRefs.current.get(field.id);
18357 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
18358 setNextHeaderMenuToFocus(fallback?.node);
18359 };
18360 const handleHeaderContextMenu = (event) => {
18361 event.preventDefault();
18362 event.stopPropagation();
18363 const virtualAnchor = {
18364 getBoundingClientRect: () => ({
18365 x: event.clientX,
18366 y: event.clientY,
18367 top: event.clientY,
18368 left: event.clientX,
18369 right: event.clientX,
18370 bottom: event.clientY,
18371 width: 0,
18372 height: 0,
18373 toJSON: () => ({})
18374 })
18375 };
18376 window.requestAnimationFrame(() => {
18377 setContextMenuAnchor(virtualAnchor);
18378 });
18379 };
18380 const hasData = !!data?.length;
18381 const titleField2 = fields.find((field) => field.id === view.titleField);
18382 const mediaField = fields.find((field) => field.id === view.mediaField);
18383 const descriptionField3 = fields.find(
18384 (field) => field.id === view.descriptionField
18385 );
18386 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
18387 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
18388 const { showTitle = true, showMedia = true, showDescription = true } = view;
18389 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription;
18390 const columns = view.fields ?? [];
18391 const headerMenuRef = (column, index2) => (node) => {
18392 if (node) {
18393 headerMenuRefs.current.set(column, {
18394 node,
18395 fallback: columns[index2 > 0 ? index2 - 1 : 1]
18396 });
18397 } else {
18398 headerMenuRefs.current.delete(column);
18399 }
18400 };
18401 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
18402 const isRtl = (0, import_i18n14.isRTL)();
18403 if (!hasData) {
18404 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18405 "div",
18406 {
18407 className: clsx_default("dataviews-no-results", {
18408 "is-refreshing": isDelayedLoading
18409 }),
18410 id: tableNoticeId,
18411 children: empty
18412 }
18413 );
18414 }
18415 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_jsx_runtime98.Fragment, { children: [
18416 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
18417 "table",
18418 {
18419 className: clsx_default("dataviews-view-table", className, {
18420 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
18421 view.layout.density
18422 ),
18423 "has-bulk-actions": hasBulkActions,
18424 "is-refreshing": !isInfiniteScroll && isDelayedLoading
18425 }),
18426 "aria-busy": isLoading,
18427 "aria-describedby": tableNoticeId,
18428 role: isInfiniteScroll ? "feed" : void 0,
18429 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
18430 children: [
18431 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("colgroup", { children: [
18432 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
18433 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
18434 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18435 "col",
18436 {
18437 className: clsx_default(
18438 `dataviews-view-table__col-${column}`,
18439 {
18440 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
18441 }
18442 )
18443 },
18444 `col-${column}`
18445 )),
18446 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-actions" })
18447 ] }),
18448 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18449 import_components8.Popover,
18450 {
18451 anchor: contextMenuAnchor,
18452 onClose: () => setContextMenuAnchor(null),
18453 placement: "bottom-start",
18454 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(PropertiesSection, { showLabel: false })
18455 }
18456 ),
18457 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18458 "thead",
18459 {
18460 className: clsx_default({
18461 "dataviews-view-table__thead--stuck": isVerticallyScrolled
18462 }),
18463 onContextMenu: handleHeaderContextMenu,
18464 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("tr", { className: "dataviews-view-table__row", children: [
18465 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18466 "th",
18467 {
18468 className: "dataviews-view-table__checkbox-column",
18469 scope: "col",
18470 onContextMenu: handleHeaderContextMenu,
18471 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18472 BulkSelectionCheckbox,
18473 {
18474 selection,
18475 onChangeSelection,
18476 data,
18477 actions,
18478 getItemId
18479 }
18480 )
18481 }
18482 ),
18483 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("th", { scope: "col", children: titleField2 && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18484 column_header_menu_default,
18485 {
18486 ref: headerMenuRef(
18487 titleField2.id,
18488 0
18489 ),
18490 fieldId: titleField2.id,
18491 view,
18492 fields,
18493 onChangeView,
18494 onHide,
18495 setOpenedFilter,
18496 canMove: false,
18497 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
18498 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
18499 }
18500 ) }),
18501 columns.map((column, index2) => {
18502 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
18503 const field = fields.find(
18504 (f2) => f2.id === column
18505 );
18506 const effectiveAlign = getEffectiveAlign(
18507 align,
18508 field?.type
18509 );
18510 const canInsertOrMove = view.layout?.enableMoving ?? true;
18511 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18512 "th",
18513 {
18514 style: {
18515 width,
18516 maxWidth,
18517 minWidth,
18518 textAlign: effectiveAlign
18519 },
18520 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
18521 scope: "col",
18522 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18523 column_header_menu_default,
18524 {
18525 ref: headerMenuRef(column, index2),
18526 fieldId: column,
18527 view,
18528 fields,
18529 onChangeView,
18530 onHide,
18531 setOpenedFilter,
18532 canMove: canInsertOrMove,
18533 canInsertLeft: canInsertOrMove,
18534 canInsertRight: canInsertOrMove
18535 }
18536 )
18537 },
18538 column
18539 );
18540 }),
18541 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18542 "th",
18543 {
18544 className: clsx_default(
18545 "dataviews-view-table__actions-column",
18546 {
18547 "dataviews-view-table__actions-column--sticky": true,
18548 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
18549 }
18550 ),
18551 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n14.__)("Actions") })
18552 }
18553 )
18554 ] })
18555 }
18556 ),
18557 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
18558 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("tbody", { children: [
18559 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18560 "td",
18561 {
18562 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
18563 className: "dataviews-view-table__group-header-cell",
18564 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
18565 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
18566 (0, import_i18n14.__)("%1$s: %2$s"),
18567 groupField.label,
18568 groupName
18569 )
18570 }
18571 ) }),
18572 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18573 TableRow,
18574 {
18575 item,
18576 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
18577 hasBulkActions,
18578 actions,
18579 fields,
18580 id: getItemId(item) || index2.toString(),
18581 view,
18582 titleField: titleField2,
18583 mediaField,
18584 descriptionField: descriptionField3,
18585 selection,
18586 getItemId,
18587 onChangeSelection,
18588 onClickItem,
18589 renderItemLink,
18590 isItemClickable,
18591 isActionsColumnSticky: !isHorizontalScrollEnd
18592 },
18593 getItemId(item)
18594 ))
18595 ] }, `group-${groupName}`)
18596 ) : /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18597 TableRow,
18598 {
18599 item,
18600 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
18601 hasBulkActions,
18602 actions,
18603 fields,
18604 id: getItemId(item) || index2.toString(),
18605 view,
18606 titleField: titleField2,
18607 mediaField,
18608 descriptionField: descriptionField3,
18609 selection,
18610 getItemId,
18611 onChangeSelection,
18612 onClickItem,
18613 renderItemLink,
18614 isItemClickable,
18615 isActionsColumnSticky: !isHorizontalScrollEnd,
18616 posinset: isInfiniteScroll ? index2 + 1 : void 0
18617 },
18618 getItemId(item)
18619 )) })
18620 ]
18621 }
18622 ),
18623 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components8.Spinner, {}) }) })
18624 ] });
18625 }
18626 var table_default = ViewTable;
18627
18628 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
18629 var import_components11 = __toESM(require_components(), 1);
18630 var import_i18n17 = __toESM(require_i18n(), 1);
18631
18632 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
18633 var import_components10 = __toESM(require_components(), 1);
18634 var import_i18n16 = __toESM(require_i18n(), 1);
18635 var import_compose5 = __toESM(require_compose(), 1);
18636 var import_keycodes2 = __toESM(require_keycodes(), 1);
18637 var import_element70 = __toESM(require_element(), 1);
18638
18639 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
18640 var import_components9 = __toESM(require_components(), 1);
18641 var import_i18n15 = __toESM(require_i18n(), 1);
18642 var import_element67 = __toESM(require_element(), 1);
18643 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
18644 var imageSizes = [
18645 {
18646 value: 120,
18647 breakpoint: 1
18648 },
18649 {
18650 value: 170,
18651 breakpoint: 1
18652 },
18653 {
18654 value: 230,
18655 breakpoint: 1
18656 },
18657 {
18658 value: 290,
18659 breakpoint: 1112
18660 // at minimum image width, 4 images display at this container size
18661 },
18662 {
18663 value: 350,
18664 breakpoint: 1636
18665 // at minimum image width, 6 images display at this container size
18666 },
18667 {
18668 value: 430,
18669 breakpoint: 588
18670 // at minimum image width, 2 images display at this container size
18671 }
18672 ];
18673 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
18674 function useGridColumns() {
18675 const context = (0, import_element67.useContext)(dataviews_context_default);
18676 const view = context.view;
18677 return (0, import_element67.useMemo)(() => {
18678 const containerWidth = context.containerWidth;
18679 const gap = 32;
18680 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
18681 const columns = Math.floor(
18682 (containerWidth + gap) / (previewSize + gap)
18683 );
18684 return Math.max(1, columns);
18685 }, [context.containerWidth, view.layout?.previewSize]);
18686 }
18687
18688 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
18689 var import_element68 = __toESM(require_element(), 1);
18690 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
18691 var GridItems = (0, import_element68.forwardRef)(({ className, previewSize, ...props }, ref) => {
18692 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
18693 "div",
18694 {
18695 ref,
18696 className: clsx_default("dataviews-view-grid-items", className),
18697 style: {
18698 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
18699 },
18700 ...props
18701 }
18702 );
18703 });
18704
18705 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
18706 var import_element69 = __toESM(require_element(), 1);
18707 function useIntersectionObserver(elementRef, posinset) {
18708 const { intersectionObserver } = (0, import_element69.useContext)(dataviews_context_default);
18709 (0, import_element69.useEffect)(() => {
18710 const element = elementRef.current;
18711 if (!element || posinset === void 0 || !intersectionObserver) {
18712 return;
18713 }
18714 intersectionObserver.observe(element);
18715 return () => {
18716 intersectionObserver.unobserve(element);
18717 };
18718 }, [elementRef, intersectionObserver, posinset]);
18719 }
18720 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
18721 const hasData = !!data?.length;
18722 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
18723 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
18724 }
18725
18726 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
18727 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
18728 var { Badge: WCBadge } = unlock3(import_components10.privateApis);
18729 function chunk(array, size4) {
18730 const chunks = [];
18731 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
18732 chunks.push(array.slice(i2, i2 + size4));
18733 }
18734 return chunks;
18735 }
18736 var GridItem = (0, import_element70.forwardRef)(
18737 function GridItem2({
18738 view,
18739 selection,
18740 onChangeSelection,
18741 onClickItem,
18742 isItemClickable,
18743 renderItemLink,
18744 getItemId,
18745 item,
18746 actions,
18747 mediaField,
18748 titleField: titleField2,
18749 descriptionField: descriptionField3,
18750 regularFields,
18751 badgeFields,
18752 hasBulkActions,
18753 config,
18754 posinset,
18755 setsize,
18756 ...props
18757 }, forwardedRef) {
18758 const {
18759 showTitle = true,
18760 showMedia = true,
18761 showDescription = true
18762 } = view;
18763 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
18764 const id = getItemId(item);
18765 const elementRef = (0, import_element70.useRef)(null);
18766 const setRefs = (0, import_element70.useCallback)(
18767 (node) => {
18768 elementRef.current = node;
18769 if (typeof forwardedRef === "function") {
18770 forwardedRef(node);
18771 } else if (forwardedRef) {
18772 forwardedRef.current = node;
18773 }
18774 },
18775 [forwardedRef]
18776 );
18777 useIntersectionObserver(elementRef, posinset);
18778 const instanceId = (0, import_compose5.useInstanceId)(GridItem2);
18779 const isSelected2 = selection.includes(id);
18780 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
18781 const rendersMediaField = showMedia && mediaField?.render;
18782 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18783 mediaField.render,
18784 {
18785 item,
18786 field: mediaField,
18787 config
18788 }
18789 ) : mediaPlaceholder;
18790 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(titleField2.render, { item, field: titleField2 }) : null;
18791 let mediaA11yProps;
18792 let titleA11yProps;
18793 if (isItemClickable(item) && onClickItem) {
18794 if (renderedTitleField) {
18795 mediaA11yProps = {
18796 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
18797 };
18798 titleA11yProps = {
18799 id: `dataviews-view-grid__title-field-${instanceId}`
18800 };
18801 } else {
18802 mediaA11yProps = {
18803 "aria-label": (0, import_i18n16.__)("Navigate to item")
18804 };
18805 }
18806 }
18807 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
18808 Stack,
18809 {
18810 direction: "column",
18811 ...props,
18812 ref: setRefs,
18813 "aria-setsize": setsize,
18814 "aria-posinset": posinset,
18815 className: clsx_default(
18816 props.className,
18817 "dataviews-view-grid__row__gridcell",
18818 "dataviews-view-grid__card",
18819 {
18820 "is-selected": hasBulkAction && isSelected2
18821 }
18822 ),
18823 onClickCapture: (event) => {
18824 props.onClickCapture?.(event);
18825 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
18826 event.stopPropagation();
18827 event.preventDefault();
18828 if (!hasBulkAction) {
18829 return;
18830 }
18831 onChangeSelection(
18832 isSelected2 ? selection.filter(
18833 (itemId) => id !== itemId
18834 ) : [...selection, id]
18835 );
18836 }
18837 },
18838 children: [
18839 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18840 ItemClickWrapper,
18841 {
18842 item,
18843 isItemClickable,
18844 onClickItem,
18845 renderItemLink,
18846 className: clsx_default("dataviews-view-grid__media", {
18847 "dataviews-view-grid__media--placeholder": !rendersMediaField
18848 }),
18849 ...mediaA11yProps,
18850 children: renderedMediaField
18851 }
18852 ),
18853 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18854 DataViewsSelectionCheckbox,
18855 {
18856 item,
18857 selection,
18858 onChangeSelection,
18859 getItemId,
18860 titleField: titleField2,
18861 disabled: !hasBulkAction
18862 }
18863 ),
18864 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18865 ItemActions,
18866 {
18867 item,
18868 actions,
18869 isCompact: true
18870 }
18871 ) }),
18872 showTitle && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18873 ItemClickWrapper,
18874 {
18875 item,
18876 isItemClickable,
18877 onClickItem,
18878 renderItemLink,
18879 className: "dataviews-view-grid__title-field dataviews-title-field",
18880 ...titleA11yProps,
18881 title: titleField2?.getValueFormatted({
18882 item,
18883 field: titleField2
18884 }) || void 0,
18885 children: renderedTitleField
18886 }
18887 ) }),
18888 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Stack, { direction: "column", gap: "xs", children: [
18889 showDescription && descriptionField3?.render && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18890 descriptionField3.render,
18891 {
18892 item,
18893 field: descriptionField3
18894 }
18895 ),
18896 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18897 Stack,
18898 {
18899 direction: "row",
18900 className: "dataviews-view-grid__badge-fields",
18901 gap: "sm",
18902 wrap: "wrap",
18903 align: "top",
18904 justify: "flex-start",
18905 children: badgeFields.map((field) => {
18906 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18907 WCBadge,
18908 {
18909 className: "dataviews-view-grid__field-value",
18910 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18911 field.render,
18912 {
18913 item,
18914 field
18915 }
18916 )
18917 },
18918 field.id
18919 );
18920 })
18921 }
18922 ),
18923 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18924 Stack,
18925 {
18926 direction: "column",
18927 className: "dataviews-view-grid__fields",
18928 gap: "xs",
18929 children: regularFields.map((field) => {
18930 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18931 import_components10.Flex,
18932 {
18933 className: "dataviews-view-grid__field",
18934 gap: 1,
18935 justify: "flex-start",
18936 expanded: true,
18937 style: { height: "auto" },
18938 direction: "row",
18939 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
18940 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(tooltip_exports.Root, { children: [
18941 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18942 tooltip_exports.Trigger,
18943 {
18944 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components10.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
18945 }
18946 ),
18947 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(tooltip_exports.Popup, { children: field.label })
18948 ] }),
18949 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18950 import_components10.FlexItem,
18951 {
18952 className: "dataviews-view-grid__field-value",
18953 style: { maxHeight: "none" },
18954 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18955 field.render,
18956 {
18957 item,
18958 field
18959 }
18960 )
18961 }
18962 )
18963 ] })
18964 },
18965 field.id
18966 );
18967 })
18968 }
18969 )
18970 ] })
18971 ]
18972 }
18973 );
18974 }
18975 );
18976 function CompositeGrid({
18977 data,
18978 isInfiniteScroll,
18979 className,
18980 inert,
18981 isLoading,
18982 view,
18983 fields,
18984 selection,
18985 onChangeSelection,
18986 onClickItem,
18987 isItemClickable,
18988 renderItemLink,
18989 getItemId,
18990 actions
18991 }) {
18992 const { paginationInfo, resizeObserverRef } = (0, import_element70.useContext)(dataviews_context_default);
18993 const gridColumns = useGridColumns();
18994 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
18995 const titleField2 = fields.find(
18996 (field) => field.id === view?.titleField
18997 );
18998 const mediaField = fields.find(
18999 (field) => field.id === view?.mediaField
19000 );
19001 const descriptionField3 = fields.find(
19002 (field) => field.id === view?.descriptionField
19003 );
19004 const otherFields = view.fields ?? [];
19005 const { regularFields, badgeFields } = otherFields.reduce(
19006 (accumulator, fieldId) => {
19007 const field = fields.find((f2) => f2.id === fieldId);
19008 if (!field) {
19009 return accumulator;
19010 }
19011 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
19012 accumulator[key].push(field);
19013 return accumulator;
19014 },
19015 { regularFields: [], badgeFields: [] }
19016 );
19017 const size4 = "900px";
19018 const totalRows = Math.ceil(data.length / gridColumns);
19019 const placeholdersNeeded = usePlaceholdersNeeded(
19020 data,
19021 isInfiniteScroll,
19022 gridColumns
19023 );
19024 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, {
19025 // Render infinite scroll layout (no rows, feed semantics)
19026 children: [
19027 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
19028 import_components10.Composite,
19029 {
19030 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19031 GridItems,
19032 {
19033 className: clsx_default(
19034 "dataviews-view-grid-infinite-scroll",
19035 className,
19036 {
19037 [`has-${view.layout?.density}-density`]: view.layout?.density && [
19038 "compact",
19039 "comfortable"
19040 ].includes(view.layout.density)
19041 }
19042 ),
19043 previewSize: view.layout?.previewSize,
19044 "aria-busy": isLoading,
19045 ref: resizeObserverRef
19046 }
19047 ),
19048 role: "feed",
19049 focusWrap: true,
19050 inert,
19051 children: [
19052 Array.from({ length: placeholdersNeeded }).map(
19053 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19054 import_components10.Composite.Item,
19055 {
19056 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19057 Stack,
19058 {
19059 ...props,
19060 direction: "column",
19061 role: "article",
19062 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
19063 }
19064 ),
19065 "aria-hidden": true,
19066 tabIndex: -1
19067 },
19068 `placeholder-${index2}`
19069 )
19070 ),
19071 data.map((item) => {
19072 const itemId = getItemId(item);
19073 const stablePosition = item.position;
19074 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19075 import_components10.Composite.Item,
19076 {
19077 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19078 GridItem,
19079 {
19080 ...props,
19081 id: itemId,
19082 role: "article",
19083 view,
19084 selection,
19085 onChangeSelection,
19086 onClickItem,
19087 isItemClickable,
19088 renderItemLink,
19089 getItemId,
19090 item,
19091 actions,
19092 mediaField,
19093 titleField: titleField2,
19094 descriptionField: descriptionField3,
19095 regularFields,
19096 badgeFields,
19097 hasBulkActions,
19098 posinset: stablePosition,
19099 setsize: paginationInfo.totalItems,
19100 config: {
19101 sizes: size4
19102 }
19103 }
19104 )
19105 },
19106 itemId
19107 );
19108 })
19109 ]
19110 }
19111 ),
19112 // Render standard grid layout (with rows, grid semantics)
19113 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19114 import_components10.Composite,
19115 {
19116 role: "grid",
19117 className: clsx_default("dataviews-view-grid", className, {
19118 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
19119 view.layout.density
19120 )
19121 }),
19122 focusWrap: true,
19123 "aria-busy": isLoading,
19124 "aria-rowcount": totalRows,
19125 ref: resizeObserverRef,
19126 inert,
19127 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19128 import_components10.Composite.Row,
19129 {
19130 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19131 "div",
19132 {
19133 role: "row",
19134 "aria-rowindex": i2 + 1,
19135 "aria-label": (0, import_i18n16.sprintf)(
19136 /* translators: %d: The row number in the grid */
19137 (0, import_i18n16.__)("Row %d"),
19138 i2 + 1
19139 ),
19140 className: "dataviews-view-grid__row",
19141 style: {
19142 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
19143 }
19144 }
19145 ),
19146 children: row.map((item) => {
19147 const itemId = getItemId(item);
19148 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19149 import_components10.Composite.Item,
19150 {
19151 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19152 GridItem,
19153 {
19154 ...props,
19155 id: itemId,
19156 role: "gridcell",
19157 view,
19158 selection,
19159 onChangeSelection,
19160 onClickItem,
19161 isItemClickable,
19162 renderItemLink,
19163 getItemId,
19164 item,
19165 actions,
19166 mediaField,
19167 titleField: titleField2,
19168 descriptionField: descriptionField3,
19169 regularFields,
19170 badgeFields,
19171 hasBulkActions,
19172 config: {
19173 sizes: size4
19174 }
19175 }
19176 )
19177 },
19178 itemId
19179 );
19180 })
19181 },
19182 i2
19183 ))
19184 }
19185 )
19186 ]
19187 });
19188 }
19189
19190 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
19191 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
19192 function ViewGrid({
19193 actions,
19194 data,
19195 fields,
19196 getItemId,
19197 isLoading,
19198 onChangeSelection,
19199 onClickItem,
19200 isItemClickable,
19201 renderItemLink,
19202 selection,
19203 view,
19204 className,
19205 empty
19206 }) {
19207 const isDelayedLoading = useDelayedLoading(!!isLoading);
19208 const hasData = !!data?.length;
19209 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
19210 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
19211 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
19212 if (!hasData) {
19213 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19214 "div",
19215 {
19216 className: clsx_default("dataviews-no-results", {
19217 "is-refreshing": isDelayedLoading
19218 }),
19219 children: empty
19220 }
19221 );
19222 }
19223 const gridProps = {
19224 className: clsx_default(className, {
19225 "is-refreshing": !isInfiniteScroll && isDelayedLoading
19226 }),
19227 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
19228 isLoading,
19229 view,
19230 fields,
19231 selection,
19232 onChangeSelection,
19233 onClickItem,
19234 isItemClickable,
19235 renderItemLink,
19236 getItemId,
19237 actions
19238 };
19239 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_jsx_runtime102.Fragment, {
19240 // Render multiple groups.
19241 children: [
19242 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
19243 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(
19244 Stack,
19245 {
19246 direction: "column",
19247 gap: "sm",
19248 children: [
19249 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n17.sprintf)(
19250 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
19251 (0, import_i18n17.__)("%1$s: %2$s"),
19252 groupField.label,
19253 groupName
19254 ) }),
19255 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19256 CompositeGrid,
19257 {
19258 ...gridProps,
19259 data: groupItems,
19260 isInfiniteScroll: false
19261 }
19262 )
19263 ]
19264 },
19265 groupName
19266 )
19267 ) }),
19268 // Render a single grid with all data.
19269 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19270 CompositeGrid,
19271 {
19272 ...gridProps,
19273 data,
19274 isInfiniteScroll: !!isInfiniteScroll
19275 }
19276 ),
19277 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components11.Spinner, {}) })
19278 ]
19279 });
19280 }
19281 var grid_default = ViewGrid;
19282
19283 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
19284 var import_compose6 = __toESM(require_compose(), 1);
19285 var import_components12 = __toESM(require_components(), 1);
19286 var import_element71 = __toESM(require_element(), 1);
19287 var import_i18n18 = __toESM(require_i18n(), 1);
19288 var import_data3 = __toESM(require_data(), 1);
19289 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
19290 var { Menu: Menu3 } = unlock3(import_components12.privateApis);
19291 function generateItemWrapperCompositeId(idPrefix) {
19292 return `${idPrefix}-item-wrapper`;
19293 }
19294 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
19295 return `${idPrefix}-primary-action-${primaryActionId}`;
19296 }
19297 function generateDropdownTriggerCompositeId(idPrefix) {
19298 return `${idPrefix}-dropdown`;
19299 }
19300 function PrimaryActionGridCell({
19301 idPrefix,
19302 primaryAction,
19303 item
19304 }) {
19305 const registry = (0, import_data3.useRegistry)();
19306 const [isModalOpen, setIsModalOpen] = (0, import_element71.useState)(false);
19307 const compositeItemId = generatePrimaryActionCompositeId(
19308 idPrefix,
19309 primaryAction.id
19310 );
19311 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
19312 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19313 import_components12.Composite.Item,
19314 {
19315 id: compositeItemId,
19316 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19317 import_components12.Button,
19318 {
19319 disabled: !!primaryAction.disabled,
19320 accessibleWhenDisabled: true,
19321 text: label,
19322 size: "small",
19323 onClick: () => setIsModalOpen(true)
19324 }
19325 ),
19326 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19327 ActionModal,
19328 {
19329 action: primaryAction,
19330 items: [item],
19331 closeModal: () => setIsModalOpen(false)
19332 }
19333 )
19334 }
19335 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19336 import_components12.Composite.Item,
19337 {
19338 id: compositeItemId,
19339 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19340 import_components12.Button,
19341 {
19342 disabled: !!primaryAction.disabled,
19343 accessibleWhenDisabled: true,
19344 size: "small",
19345 onClick: () => {
19346 primaryAction.callback([item], { registry });
19347 },
19348 children: label
19349 }
19350 )
19351 }
19352 ) }, primaryAction.id);
19353 }
19354 function ListItem({
19355 view,
19356 actions,
19357 idPrefix,
19358 isSelected: isSelected2,
19359 item,
19360 titleField: titleField2,
19361 mediaField,
19362 descriptionField: descriptionField3,
19363 onSelect,
19364 otherFields,
19365 onDropdownTriggerKeyDown,
19366 posinset
19367 }) {
19368 const {
19369 showTitle = true,
19370 showMedia = true,
19371 showDescription = true,
19372 infiniteScrollEnabled
19373 } = view;
19374 const itemRef = (0, import_element71.useRef)(null);
19375 const labelId = `${idPrefix}-label`;
19376 const descriptionId = `${idPrefix}-description`;
19377 const registry = (0, import_data3.useRegistry)();
19378 const [isHovered, setIsHovered] = (0, import_element71.useState)(false);
19379 const [activeModalAction, setActiveModalAction] = (0, import_element71.useState)(
19380 null
19381 );
19382 const handleHover = ({ type }) => {
19383 const isHover = type === "mouseenter";
19384 setIsHovered(isHover);
19385 };
19386 const { paginationInfo } = (0, import_element71.useContext)(dataviews_context_default);
19387 (0, import_element71.useEffect)(() => {
19388 if (isSelected2) {
19389 itemRef.current?.scrollIntoView({
19390 behavior: "auto",
19391 block: "nearest",
19392 inline: "nearest"
19393 });
19394 }
19395 }, [isSelected2]);
19396 const { primaryAction, eligibleActions } = (0, import_element71.useMemo)(() => {
19397 const _eligibleActions = actions.filter(
19398 (action) => !action.isEligible || action.isEligible(item)
19399 );
19400 const _primaryActions = _eligibleActions.filter(
19401 (action) => action.isPrimary
19402 );
19403 return {
19404 primaryAction: _primaryActions[0],
19405 eligibleActions: _eligibleActions
19406 };
19407 }, [actions, item]);
19408 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
19409 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19410 mediaField.render,
19411 {
19412 item,
19413 field: mediaField,
19414 config: { sizes: "52px" }
19415 }
19416 ) }) : null;
19417 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(titleField2.render, { item, field: titleField2 }) : null;
19418 const renderDescription = showDescription && descriptionField3?.render;
19419 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
19420 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19421 Stack,
19422 {
19423 direction: "row",
19424 gap: "md",
19425 className: "dataviews-view-list__item-actions",
19426 children: [
19427 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19428 PrimaryActionGridCell,
19429 {
19430 idPrefix,
19431 primaryAction,
19432 item
19433 }
19434 ),
19435 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { role: "gridcell", children: [
19436 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(Menu3, { placement: "bottom-end", children: [
19437 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19438 Menu3.TriggerButton,
19439 {
19440 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19441 import_components12.Composite.Item,
19442 {
19443 id: generateDropdownTriggerCompositeId(
19444 idPrefix
19445 ),
19446 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19447 import_components12.Button,
19448 {
19449 size: "small",
19450 icon: more_vertical_default,
19451 label: (0, import_i18n18.__)("Actions"),
19452 accessibleWhenDisabled: true,
19453 disabled: !actions.length,
19454 onKeyDown: onDropdownTriggerKeyDown
19455 }
19456 )
19457 }
19458 )
19459 }
19460 ),
19461 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19462 ActionsMenuGroup,
19463 {
19464 actions: eligibleActions,
19465 item,
19466 registry,
19467 setActiveModalAction
19468 }
19469 ) })
19470 ] }),
19471 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19472 ActionModal,
19473 {
19474 action: activeModalAction,
19475 items: [item],
19476 closeModal: () => setActiveModalAction(null)
19477 }
19478 )
19479 ] })
19480 ]
19481 }
19482 );
19483 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19484 import_components12.Composite.Row,
19485 {
19486 ref: itemRef,
19487 render: (
19488 /* aria-posinset breaks Composite.Row if passed to it directly. */
19489 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19490 "div",
19491 {
19492 "aria-posinset": posinset,
19493 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
19494 }
19495 )
19496 ),
19497 role: infiniteScrollEnabled ? "article" : "row",
19498 className: clsx_default({
19499 "is-selected": isSelected2,
19500 "is-hovered": isHovered
19501 }),
19502 onMouseEnter: handleHover,
19503 onMouseLeave: handleHover,
19504 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19505 Stack,
19506 {
19507 direction: "row",
19508 className: "dataviews-view-list__item-wrapper",
19509 children: [
19510 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19511 import_components12.Composite.Item,
19512 {
19513 id: generateItemWrapperCompositeId(idPrefix),
19514 "aria-pressed": isSelected2,
19515 "aria-labelledby": labelId,
19516 "aria-describedby": descriptionId,
19517 className: "dataviews-view-list__item",
19518 onClick: () => onSelect(item)
19519 }
19520 ) }),
19521 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19522 Stack,
19523 {
19524 direction: "row",
19525 gap: "md",
19526 justify: "start",
19527 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
19528 style: { flex: 1, minWidth: 0 },
19529 children: [
19530 renderedMediaField,
19531 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19532 Stack,
19533 {
19534 direction: "column",
19535 gap: "xs",
19536 className: "dataviews-view-list__field-wrapper",
19537 children: [
19538 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(Stack, { direction: "row", align: "center", children: [
19539 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19540 "div",
19541 {
19542 className: "dataviews-title-field dataviews-view-list__title-field",
19543 id: labelId,
19544 children: renderedTitleField
19545 }
19546 ),
19547 usedActions
19548 ] }),
19549 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19550 descriptionField3.render,
19551 {
19552 item,
19553 field: descriptionField3
19554 }
19555 ) }),
19556 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19557 "div",
19558 {
19559 className: "dataviews-view-list__fields",
19560 id: descriptionId,
19561 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19562 "div",
19563 {
19564 className: "dataviews-view-list__field",
19565 children: [
19566 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19567 VisuallyHidden,
19568 {
19569 className: "dataviews-view-list__field-label",
19570 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", {}),
19571 children: field.label
19572 }
19573 ),
19574 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19575 field.render,
19576 {
19577 item,
19578 field
19579 }
19580 ) })
19581 ]
19582 },
19583 field.id
19584 ))
19585 }
19586 )
19587 ]
19588 }
19589 )
19590 ]
19591 }
19592 )
19593 ]
19594 }
19595 )
19596 }
19597 );
19598 }
19599 function isDefined2(item) {
19600 return !!item;
19601 }
19602 function ViewList(props) {
19603 const {
19604 actions,
19605 data,
19606 fields,
19607 getItemId,
19608 isLoading,
19609 onChangeSelection,
19610 selection,
19611 view,
19612 className,
19613 empty
19614 } = props;
19615 const baseId = (0, import_compose6.useInstanceId)(ViewList, "view-list");
19616 const isDelayedLoading = useDelayedLoading(!!isLoading);
19617 const selectedItem = data?.findLast(
19618 (item) => selection.includes(getItemId(item))
19619 );
19620 const titleField2 = fields.find((field) => field.id === view.titleField);
19621 const mediaField = fields.find((field) => field.id === view.mediaField);
19622 const descriptionField3 = fields.find(
19623 (field) => field.id === view.descriptionField
19624 );
19625 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
19626 const onSelect = (item) => onChangeSelection([getItemId(item)]);
19627 const generateCompositeItemIdPrefix = (0, import_element71.useCallback)(
19628 (item) => `${baseId}-${getItemId(item)}`,
19629 [baseId, getItemId]
19630 );
19631 const isActiveCompositeItem = (0, import_element71.useCallback)(
19632 (item, idToCheck) => {
19633 return idToCheck.startsWith(
19634 generateCompositeItemIdPrefix(item)
19635 );
19636 },
19637 [generateCompositeItemIdPrefix]
19638 );
19639 const [activeCompositeId, setActiveCompositeId] = (0, import_element71.useState)(void 0);
19640 const compositeRef = (0, import_element71.useRef)(null);
19641 (0, import_element71.useEffect)(() => {
19642 if (selectedItem) {
19643 setActiveCompositeId(
19644 generateItemWrapperCompositeId(
19645 generateCompositeItemIdPrefix(selectedItem)
19646 )
19647 );
19648 }
19649 }, [selectedItem, generateCompositeItemIdPrefix]);
19650 const activeItemIndex = data.findIndex(
19651 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
19652 );
19653 const previousActiveItemIndex = (0, import_compose6.usePrevious)(activeItemIndex);
19654 const isActiveIdInList = activeItemIndex !== -1;
19655 const selectCompositeItem = (0, import_element71.useCallback)(
19656 (targetIndex, generateCompositeId) => {
19657 const clampedIndex = Math.min(
19658 data.length - 1,
19659 Math.max(0, targetIndex)
19660 );
19661 if (!data[clampedIndex]) {
19662 return;
19663 }
19664 const itemIdPrefix = generateCompositeItemIdPrefix(
19665 data[clampedIndex]
19666 );
19667 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
19668 setActiveCompositeId(targetCompositeItemId);
19669 if (compositeRef.current?.contains(
19670 compositeRef.current.ownerDocument.activeElement
19671 )) {
19672 document.getElementById(targetCompositeItemId)?.focus();
19673 }
19674 },
19675 [data, generateCompositeItemIdPrefix]
19676 );
19677 (0, import_element71.useEffect)(() => {
19678 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
19679 if (!isActiveIdInList && wasActiveIdInList) {
19680 selectCompositeItem(
19681 previousActiveItemIndex,
19682 generateItemWrapperCompositeId
19683 );
19684 }
19685 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
19686 const onDropdownTriggerKeyDown = (0, import_element71.useCallback)(
19687 (event) => {
19688 if (event.key === "ArrowDown") {
19689 event.preventDefault();
19690 selectCompositeItem(
19691 activeItemIndex + 1,
19692 generateDropdownTriggerCompositeId
19693 );
19694 }
19695 if (event.key === "ArrowUp") {
19696 event.preventDefault();
19697 selectCompositeItem(
19698 activeItemIndex - 1,
19699 generateDropdownTriggerCompositeId
19700 );
19701 }
19702 },
19703 [selectCompositeItem, activeItemIndex]
19704 );
19705 const hasData = !!data?.length;
19706 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
19707 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
19708 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
19709 if (!hasData) {
19710 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19711 "div",
19712 {
19713 className: clsx_default("dataviews-no-results", {
19714 "is-refreshing": isDelayedLoading
19715 }),
19716 children: empty
19717 }
19718 );
19719 }
19720 if (hasData && groupField && dataByGroup) {
19721 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19722 import_components12.Composite,
19723 {
19724 ref: compositeRef,
19725 id: `${baseId}`,
19726 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", {}),
19727 className: "dataviews-view-list__group",
19728 role: "grid",
19729 activeId: activeCompositeId,
19730 setActiveId: setActiveCompositeId,
19731 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19732 Stack,
19733 {
19734 direction: "column",
19735 gap: "lg",
19736 className: clsx_default("dataviews-view-list", className),
19737 children: Array.from(dataByGroup.entries()).map(
19738 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19739 Stack,
19740 {
19741 direction: "column",
19742 gap: "sm",
19743 children: [
19744 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
19745 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
19746 (0, import_i18n18.__)("%1$s: %2$s"),
19747 groupField.label,
19748 groupName
19749 ) }),
19750 groupItems.map((item) => {
19751 const id = generateCompositeItemIdPrefix(item);
19752 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19753 ListItem,
19754 {
19755 view,
19756 idPrefix: id,
19757 actions,
19758 item,
19759 isSelected: item === selectedItem,
19760 onSelect,
19761 mediaField,
19762 titleField: titleField2,
19763 descriptionField: descriptionField3,
19764 otherFields,
19765 onDropdownTriggerKeyDown
19766 },
19767 id
19768 );
19769 })
19770 ]
19771 },
19772 groupName
19773 )
19774 )
19775 }
19776 )
19777 }
19778 );
19779 }
19780 return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [
19781 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19782 import_components12.Composite,
19783 {
19784 ref: compositeRef,
19785 id: baseId,
19786 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", {}),
19787 className: clsx_default("dataviews-view-list", className, {
19788 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
19789 view.layout.density
19790 ),
19791 "is-refreshing": !isInfiniteScroll && isDelayedLoading
19792 }),
19793 role: view.infiniteScrollEnabled ? "feed" : "grid",
19794 activeId: activeCompositeId,
19795 setActiveId: setActiveCompositeId,
19796 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
19797 children: data.map((item, index2) => {
19798 const id = generateCompositeItemIdPrefix(item);
19799 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19800 ListItem,
19801 {
19802 view,
19803 idPrefix: id,
19804 actions,
19805 item,
19806 isSelected: item === selectedItem,
19807 onSelect,
19808 mediaField,
19809 titleField: titleField2,
19810 descriptionField: descriptionField3,
19811 otherFields,
19812 onDropdownTriggerKeyDown,
19813 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
19814 },
19815 id
19816 );
19817 })
19818 }
19819 ),
19820 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components12.Spinner, {}) })
19821 ] });
19822 }
19823
19824 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
19825 var import_components13 = __toESM(require_components(), 1);
19826
19827 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
19828 var import_i18n19 = __toESM(require_i18n(), 1);
19829 var import_element72 = __toESM(require_element(), 1);
19830 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
19831 function ActivityGroup({
19832 groupName,
19833 groupData,
19834 groupField,
19835 showLabel = true,
19836 children
19837 }) {
19838 const groupHeader = showLabel ? (0, import_element72.createInterpolateElement)(
19839 // translators: %s: The label of the field e.g. "Status".
19840 (0, import_i18n19.sprintf)((0, import_i18n19.__)("%s: <groupName />"), groupField.label).trim(),
19841 {
19842 groupName: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
19843 groupField.render,
19844 {
19845 item: groupData[0],
19846 field: groupField
19847 }
19848 )
19849 }
19850 ) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(groupField.render, { item: groupData[0], field: groupField });
19851 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
19852 Stack,
19853 {
19854 direction: "column",
19855 className: "dataviews-view-activity__group",
19856 children: [
19857 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
19858 children
19859 ]
19860 },
19861 groupName
19862 );
19863 }
19864
19865 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
19866 var import_element73 = __toESM(require_element(), 1);
19867 var import_data4 = __toESM(require_data(), 1);
19868 var import_compose7 = __toESM(require_compose(), 1);
19869 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
19870 function ActivityItem(props) {
19871 const {
19872 view,
19873 actions,
19874 item,
19875 titleField: titleField2,
19876 mediaField,
19877 descriptionField: descriptionField3,
19878 otherFields,
19879 posinset,
19880 onClickItem,
19881 renderItemLink,
19882 isItemClickable
19883 } = props;
19884 const {
19885 showTitle = true,
19886 showMedia = true,
19887 showDescription = true,
19888 infiniteScrollEnabled
19889 } = view;
19890 const itemRef = (0, import_element73.useRef)(null);
19891 const registry = (0, import_data4.useRegistry)();
19892 const { paginationInfo } = (0, import_element73.useContext)(dataviews_context_default);
19893 const { primaryActions, eligibleActions } = (0, import_element73.useMemo)(() => {
19894 const _eligibleActions = actions.filter(
19895 (action) => !action.isEligible || action.isEligible(item)
19896 );
19897 const _primaryActions = _eligibleActions.filter(
19898 (action) => action.isPrimary
19899 );
19900 return {
19901 primaryActions: _primaryActions,
19902 eligibleActions: _eligibleActions
19903 };
19904 }, [actions, item]);
19905 const isMobileViewport = (0, import_compose7.useViewportMatch)("medium", "<");
19906 const density = view.layout?.density ?? "balanced";
19907 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19908 mediaField.render,
19909 {
19910 item,
19911 field: mediaField,
19912 config: {
19913 sizes: density === "comfortable" ? "32px" : "24px"
19914 }
19915 }
19916 ) : null;
19917 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19918 "span",
19919 {
19920 className: "dataviews-view-activity__item-bullet",
19921 "aria-hidden": "true"
19922 }
19923 ) });
19924 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(titleField2.render, { item, field: titleField2 }) : null;
19925 const verticalGap = (0, import_element73.useMemo)(() => {
19926 switch (density) {
19927 case "comfortable":
19928 return "md";
19929 default:
19930 return "sm";
19931 }
19932 }, [density]);
19933 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19934 "div",
19935 {
19936 ref: itemRef,
19937 role: infiniteScrollEnabled ? "article" : void 0,
19938 "aria-posinset": posinset,
19939 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
19940 className: clsx_default(
19941 "dataviews-view-activity__item",
19942 density === "compact" && "is-compact",
19943 density === "balanced" && "is-balanced",
19944 density === "comfortable" && "is-comfortable"
19945 ),
19946 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
19947 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19948 Stack,
19949 {
19950 direction: "column",
19951 gap: "xs",
19952 align: "center",
19953 className: "dataviews-view-activity__item-type",
19954 children: renderedMediaField
19955 }
19956 ),
19957 /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
19958 Stack,
19959 {
19960 direction: "column",
19961 gap: verticalGap,
19962 align: "flex-start",
19963 className: "dataviews-view-activity__item-content",
19964 children: [
19965 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19966 ItemClickWrapper,
19967 {
19968 item,
19969 isItemClickable,
19970 onClickItem,
19971 renderItemLink,
19972 className: "dataviews-view-activity__item-title",
19973 children: renderedTitleField
19974 }
19975 ),
19976 showDescription && descriptionField3 && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19977 descriptionField3.render,
19978 {
19979 item,
19980 field: descriptionField3
19981 }
19982 ) }),
19983 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
19984 "div",
19985 {
19986 className: "dataviews-view-activity__item-field",
19987 children: [
19988 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19989 VisuallyHidden,
19990 {
19991 className: "dataviews-view-activity__item-field-label",
19992 render: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", {}),
19993 children: field.label
19994 }
19995 ),
19996 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19997 field.render,
19998 {
19999 item,
20000 field
20001 }
20002 ) })
20003 ]
20004 },
20005 field.id
20006 )) }),
20007 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20008 PrimaryActions,
20009 {
20010 item,
20011 actions: primaryActions,
20012 registry,
20013 buttonVariant: "secondary"
20014 }
20015 )
20016 ]
20017 }
20018 ),
20019 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
20020 // there if there are any actions at all.
20021 isMobileViewport && // At the same time, only show the menu if there are actions to show.
20022 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20023 ItemActions,
20024 {
20025 item,
20026 actions: eligibleActions,
20027 isCompact: true
20028 }
20029 ) })
20030 ] })
20031 }
20032 );
20033 }
20034 var activity_item_default = ActivityItem;
20035
20036 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
20037 var import_react14 = __toESM(require_react(), 1);
20038 function isDefined3(item) {
20039 return !!item;
20040 }
20041 function ActivityItems(props) {
20042 const { data, fields, getItemId, view } = props;
20043 const titleField2 = fields.find((field) => field.id === view.titleField);
20044 const mediaField = fields.find((field) => field.id === view.mediaField);
20045 const descriptionField3 = fields.find(
20046 (field) => field.id === view.descriptionField
20047 );
20048 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
20049 return data.map((item, index2) => {
20050 return /* @__PURE__ */ (0, import_react14.createElement)(
20051 activity_item_default,
20052 {
20053 ...props,
20054 key: getItemId(item),
20055 item,
20056 mediaField,
20057 titleField: titleField2,
20058 descriptionField: descriptionField3,
20059 otherFields,
20060 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
20061 }
20062 );
20063 });
20064 }
20065
20066 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
20067 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
20068 function ViewActivity(props) {
20069 const { empty, data, fields, isLoading, view, className } = props;
20070 const isDelayedLoading = useDelayedLoading(!!isLoading);
20071 const hasData = !!data?.length;
20072 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
20073 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
20074 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
20075 if (!hasData) {
20076 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20077 "div",
20078 {
20079 className: clsx_default("dataviews-no-results", {
20080 "is-refreshing": isDelayedLoading
20081 }),
20082 children: empty
20083 }
20084 );
20085 }
20086 const isInert2 = !isInfiniteScroll && !!isLoading;
20087 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
20088 "is-refreshing": !isInfiniteScroll && isDelayedLoading
20089 });
20090 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
20091 if (hasData && groupField && dataByGroup) {
20092 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20093 Stack,
20094 {
20095 direction: "column",
20096 gap: "sm",
20097 className: wrapperClassName,
20098 inert: isInert2 ? "true" : void 0,
20099 children: groupedEntries.map(
20100 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20101 ActivityGroup,
20102 {
20103 groupName,
20104 groupData,
20105 groupField,
20106 showLabel: view.groupBy?.showLabel !== false,
20107 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20108 ActivityItems,
20109 {
20110 ...props,
20111 data: groupData
20112 }
20113 )
20114 },
20115 groupName
20116 )
20117 )
20118 }
20119 );
20120 }
20121 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(import_jsx_runtime106.Fragment, { children: [
20122 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20123 "div",
20124 {
20125 className: wrapperClassName,
20126 role: view.infiniteScrollEnabled ? "feed" : void 0,
20127 inert: isInert2 ? "true" : void 0,
20128 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(ActivityItems, { ...props })
20129 }
20130 ),
20131 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components13.Spinner, {}) })
20132 ] });
20133 }
20134
20135 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
20136 var import_components16 = __toESM(require_components(), 1);
20137 var import_i18n22 = __toESM(require_i18n(), 1);
20138 var import_compose8 = __toESM(require_compose(), 1);
20139 var import_element76 = __toESM(require_element(), 1);
20140
20141 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
20142 var import_components15 = __toESM(require_components(), 1);
20143 var import_data5 = __toESM(require_data(), 1);
20144 var import_element75 = __toESM(require_element(), 1);
20145 var import_i18n21 = __toESM(require_i18n(), 1);
20146
20147 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
20148 var import_components14 = __toESM(require_components(), 1);
20149 var import_element74 = __toESM(require_element(), 1);
20150 var import_i18n20 = __toESM(require_i18n(), 1);
20151 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
20152 function DataViewsPagination() {
20153 const {
20154 view,
20155 onChangeView,
20156 paginationInfo: { totalItems = 0, totalPages }
20157 } = (0, import_element74.useContext)(dataviews_context_default);
20158 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
20159 return null;
20160 }
20161 const currentPage = view.page ?? 1;
20162 const pageSelectOptions = Array.from(Array(totalPages)).map(
20163 (_, i2) => {
20164 const page = i2 + 1;
20165 return {
20166 value: page.toString(),
20167 label: page.toString(),
20168 "aria-label": currentPage === page ? (0, import_i18n20.sprintf)(
20169 // translators: 1: current page number. 2: total number of pages.
20170 (0, import_i18n20.__)("Page %1$d of %2$d"),
20171 currentPage,
20172 totalPages
20173 ) : page.toString()
20174 };
20175 }
20176 );
20177 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
20178 Stack,
20179 {
20180 direction: "row",
20181 className: "dataviews-pagination",
20182 justify: "end",
20183 align: "center",
20184 gap: "xl",
20185 children: [
20186 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20187 Stack,
20188 {
20189 direction: "row",
20190 justify: "flex-start",
20191 align: "center",
20192 gap: "xs",
20193 className: "dataviews-pagination__page-select",
20194 children: (0, import_element74.createInterpolateElement)(
20195 (0, import_i18n20.sprintf)(
20196 // translators: 1: Current page number, 2: Total number of pages.
20197 (0, import_i18n20._x)(
20198 "<div>Page</div>%1$s<div>of %2$d</div>",
20199 "paging"
20200 ),
20201 "<CurrentPage />",
20202 totalPages
20203 ),
20204 {
20205 div: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { "aria-hidden": true }),
20206 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
20207 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20208 import_components14.SelectControl,
20209 {
20210 "aria-label": (0, import_i18n20.__)("Current page"),
20211 value: currentPage.toString(),
20212 options: pageSelectOptions,
20213 onChange: (newValue) => {
20214 onChangeView({
20215 ...view,
20216 page: +newValue
20217 });
20218 },
20219 size: "small",
20220 variant: "minimal"
20221 }
20222 )
20223 }
20224 )
20225 }
20226 ),
20227 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
20228 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20229 import_components14.Button,
20230 {
20231 onClick: () => onChangeView({
20232 ...view,
20233 page: currentPage - 1
20234 }),
20235 disabled: currentPage === 1,
20236 accessibleWhenDisabled: true,
20237 label: (0, import_i18n20.__)("Previous page"),
20238 icon: (0, import_i18n20.isRTL)() ? next_default : previous_default,
20239 showTooltip: true,
20240 size: "compact",
20241 tooltipPosition: "top"
20242 }
20243 ),
20244 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20245 import_components14.Button,
20246 {
20247 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
20248 disabled: currentPage >= totalPages,
20249 accessibleWhenDisabled: true,
20250 label: (0, import_i18n20.__)("Next page"),
20251 icon: (0, import_i18n20.isRTL)() ? previous_default : next_default,
20252 showTooltip: true,
20253 size: "compact",
20254 tooltipPosition: "top"
20255 }
20256 )
20257 ] })
20258 ]
20259 }
20260 );
20261 }
20262 var dataviews_pagination_default = (0, import_element74.memo)(DataViewsPagination);
20263
20264 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
20265 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
20266 function useIsMultiselectPicker(actions) {
20267 return (0, import_element75.useMemo)(() => {
20268 return !!actions?.length && actions?.every((action) => action.supportsBulk);
20269 }, [actions]);
20270 }
20271
20272 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
20273 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
20274 var { Badge: WCBadge2 } = unlock3(import_components16.privateApis);
20275 function GridItem3({
20276 view,
20277 multiselect,
20278 selection,
20279 onChangeSelection,
20280 getItemId,
20281 item,
20282 mediaField,
20283 titleField: titleField2,
20284 descriptionField: descriptionField3,
20285 regularFields,
20286 badgeFields,
20287 config,
20288 posinset,
20289 setsize
20290 }) {
20291 const { showTitle = true, showMedia = true, showDescription = true } = view;
20292 const id = getItemId(item);
20293 const elementRef = (0, import_element76.useRef)(null);
20294 const isSelected2 = selection.includes(id);
20295 useIntersectionObserver(elementRef, posinset);
20296 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20297 mediaField.render,
20298 {
20299 item,
20300 field: mediaField,
20301 config
20302 }
20303 ) : null;
20304 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(titleField2.render, { item, field: titleField2 }) : null;
20305 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
20306 import_components16.Composite.Item,
20307 {
20308 ref: elementRef,
20309 "aria-label": titleField2 ? titleField2.getValue({ item }) || (0, import_i18n22.__)("(no title)") : void 0,
20310 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Stack, { direction: "column", children, ...props }),
20311 role: "option",
20312 "aria-posinset": posinset,
20313 "aria-setsize": setsize,
20314 className: clsx_default("dataviews-view-picker-grid__card", {
20315 "is-selected": isSelected2
20316 }),
20317 "aria-selected": isSelected2,
20318 onClick: () => {
20319 if (isSelected2) {
20320 onChangeSelection(
20321 selection.filter((itemId) => id !== itemId)
20322 );
20323 } else {
20324 const newSelection = multiselect ? [...selection, id] : [id];
20325 onChangeSelection(newSelection);
20326 }
20327 },
20328 children: [
20329 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
20330 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20331 DataViewsSelectionCheckbox,
20332 {
20333 item,
20334 selection,
20335 onChangeSelection,
20336 getItemId,
20337 titleField: titleField2,
20338 disabled: false,
20339 "aria-hidden": true,
20340 tabIndex: -1
20341 }
20342 ),
20343 showTitle && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20344 Stack,
20345 {
20346 direction: "row",
20347 justify: "space-between",
20348 className: "dataviews-view-picker-grid__title-actions",
20349 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
20350 }
20351 ),
20352 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Stack, { direction: "column", gap: "xs", children: [
20353 showDescription && descriptionField3?.render && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20354 descriptionField3.render,
20355 {
20356 item,
20357 field: descriptionField3
20358 }
20359 ),
20360 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20361 Stack,
20362 {
20363 direction: "row",
20364 className: "dataviews-view-picker-grid__badge-fields",
20365 gap: "sm",
20366 wrap: "wrap",
20367 align: "top",
20368 justify: "flex-start",
20369 children: badgeFields.map((field) => {
20370 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20371 WCBadge2,
20372 {
20373 className: "dataviews-view-picker-grid__field-value",
20374 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20375 field.render,
20376 {
20377 item,
20378 field
20379 }
20380 )
20381 },
20382 field.id
20383 );
20384 })
20385 }
20386 ),
20387 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20388 Stack,
20389 {
20390 direction: "column",
20391 className: "dataviews-view-picker-grid__fields",
20392 gap: "xs",
20393 children: regularFields.map((field) => {
20394 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20395 import_components16.Flex,
20396 {
20397 className: "dataviews-view-picker-grid__field",
20398 gap: 1,
20399 justify: "flex-start",
20400 expanded: true,
20401 style: { height: "auto" },
20402 direction: "row",
20403 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
20404 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
20405 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20406 import_components16.FlexItem,
20407 {
20408 className: "dataviews-view-picker-grid__field-value",
20409 style: { maxHeight: "none" },
20410 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20411 field.render,
20412 {
20413 item,
20414 field
20415 }
20416 )
20417 }
20418 )
20419 ] })
20420 },
20421 field.id
20422 );
20423 })
20424 }
20425 )
20426 ] })
20427 ]
20428 },
20429 id
20430 );
20431 }
20432 function GridGroup({
20433 groupName,
20434 groupField,
20435 showLabel = true,
20436 children
20437 }) {
20438 const headerId = (0, import_compose8.useInstanceId)(
20439 GridGroup,
20440 "dataviews-view-picker-grid-group__header"
20441 );
20442 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
20443 Stack,
20444 {
20445 direction: "column",
20446 gap: "sm",
20447 role: "group",
20448 "aria-labelledby": headerId,
20449 children: [
20450 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20451 "h3",
20452 {
20453 className: "dataviews-view-picker-grid-group__header",
20454 id: headerId,
20455 children: showLabel ? (0, import_i18n22.sprintf)(
20456 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
20457 (0, import_i18n22.__)("%1$s: %2$s"),
20458 groupField.label,
20459 groupName
20460 ) : groupName
20461 }
20462 ),
20463 children
20464 ]
20465 },
20466 groupName
20467 );
20468 }
20469 function ViewPickerGrid({
20470 actions,
20471 data,
20472 fields,
20473 getItemId,
20474 isLoading,
20475 onChangeSelection,
20476 selection,
20477 view,
20478 className,
20479 empty
20480 }) {
20481 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element76.useContext)(dataviews_context_default);
20482 const titleField2 = fields.find(
20483 (field) => field.id === view?.titleField
20484 );
20485 const mediaField = fields.find(
20486 (field) => field.id === view?.mediaField
20487 );
20488 const descriptionField3 = fields.find(
20489 (field) => field.id === view?.descriptionField
20490 );
20491 const otherFields = view.fields ?? [];
20492 const { regularFields, badgeFields } = otherFields.reduce(
20493 (accumulator, fieldId) => {
20494 const field = fields.find((f2) => f2.id === fieldId);
20495 if (!field) {
20496 return accumulator;
20497 }
20498 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
20499 accumulator[key].push(field);
20500 return accumulator;
20501 },
20502 { regularFields: [], badgeFields: [] }
20503 );
20504 const hasData = !!data?.length;
20505 const usedPreviewSize = view.layout?.previewSize;
20506 const isMultiselect = useIsMultiselectPicker(actions);
20507 const size4 = "900px";
20508 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
20509 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
20510 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
20511 const currentPage = view?.page ?? 1;
20512 const perPage = view?.perPage ?? 0;
20513 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
20514 const gridColumns = useGridColumns();
20515 const placeholdersNeeded = usePlaceholdersNeeded(
20516 data,
20517 isInfiniteScroll,
20518 gridColumns
20519 );
20520 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, {
20521 // Render multiple groups.
20522 children: [
20523 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20524 import_components16.Composite,
20525 {
20526 virtualFocus: true,
20527 orientation: "horizontal",
20528 role: "listbox",
20529 "aria-multiselectable": isMultiselect,
20530 className: clsx_default(
20531 "dataviews-view-picker-grid",
20532 className,
20533 {
20534 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
20535 view.layout.density
20536 )
20537 }
20538 ),
20539 "aria-label": itemListLabel,
20540 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20541 Stack,
20542 {
20543 direction: "column",
20544 gap: "lg",
20545 children,
20546 ...props
20547 }
20548 ),
20549 children: Array.from(dataByGroup.entries()).map(
20550 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20551 GridGroup,
20552 {
20553 groupName,
20554 groupField,
20555 showLabel: view.groupBy?.showLabel !== false,
20556 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20557 GridItems,
20558 {
20559 previewSize: usedPreviewSize,
20560 style: {
20561 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
20562 },
20563 "aria-busy": isLoading,
20564 ref: resizeObserverRef,
20565 children: groupItems.map((item) => {
20566 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
20567 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20568 GridItem3,
20569 {
20570 view,
20571 multiselect: isMultiselect,
20572 selection,
20573 onChangeSelection,
20574 getItemId,
20575 item,
20576 mediaField,
20577 titleField: titleField2,
20578 descriptionField: descriptionField3,
20579 regularFields,
20580 badgeFields,
20581 config: {
20582 sizes: size4
20583 },
20584 posinset: posInSet,
20585 setsize: setSize
20586 },
20587 getItemId(item)
20588 );
20589 })
20590 }
20591 )
20592 },
20593 groupName
20594 )
20595 )
20596 }
20597 ),
20598 // Render a single grid with all data.
20599 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
20600 import_components16.Composite,
20601 {
20602 render: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20603 GridItems,
20604 {
20605 className: clsx_default(
20606 "dataviews-view-picker-grid",
20607 className,
20608 {
20609 [`has-${view.layout?.density}-density`]: view.layout?.density && [
20610 "compact",
20611 "comfortable"
20612 ].includes(view.layout.density)
20613 }
20614 ),
20615 previewSize: usedPreviewSize,
20616 "aria-busy": isLoading,
20617 ref: resizeObserverRef
20618 }
20619 ),
20620 virtualFocus: true,
20621 orientation: "horizontal",
20622 role: "listbox",
20623 "aria-multiselectable": isMultiselect,
20624 "aria-label": itemListLabel,
20625 children: [
20626 Array.from({ length: placeholdersNeeded }).map(
20627 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20628 import_components16.Composite.Item,
20629 {
20630 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20631 Stack,
20632 {
20633 direction: "column",
20634 children,
20635 ...props
20636 }
20637 ),
20638 role: "option",
20639 "aria-hidden": true,
20640 tabIndex: -1,
20641 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
20642 },
20643 `placeholder-${index2}`
20644 )
20645 ),
20646 data.map((item) => {
20647 const posinset = item.position;
20648 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20649 GridItem3,
20650 {
20651 view,
20652 multiselect: isMultiselect,
20653 selection,
20654 onChangeSelection,
20655 getItemId,
20656 item,
20657 mediaField,
20658 titleField: titleField2,
20659 descriptionField: descriptionField3,
20660 regularFields,
20661 badgeFields,
20662 config: {
20663 sizes: size4
20664 },
20665 posinset,
20666 setsize: setSize
20667 },
20668 getItemId(item)
20669 );
20670 })
20671 ]
20672 }
20673 ),
20674 // Render empty state.
20675 !hasData && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20676 "div",
20677 {
20678 className: clsx_default({
20679 "dataviews-loading": isLoading,
20680 "dataviews-no-results": !isLoading
20681 }),
20682 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.Spinner, {}) }) : empty
20683 }
20684 ),
20685 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.Spinner, {}) })
20686 ]
20687 });
20688 }
20689 var picker_grid_default = ViewPickerGrid;
20690
20691 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
20692 var import_i18n23 = __toESM(require_i18n(), 1);
20693 var import_components17 = __toESM(require_components(), 1);
20694 var import_element77 = __toESM(require_element(), 1);
20695 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
20696 function TableColumnField2({
20697 item,
20698 fields,
20699 column,
20700 align
20701 }) {
20702 const field = fields.find((f2) => f2.id === column);
20703 if (!field) {
20704 return null;
20705 }
20706 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
20707 "dataviews-view-table__cell-align-end": align === "end",
20708 "dataviews-view-table__cell-align-center": align === "center"
20709 });
20710 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(field.render, { item, field }) });
20711 }
20712 function TableRow2({
20713 item,
20714 fields,
20715 id,
20716 view,
20717 titleField: titleField2,
20718 mediaField,
20719 descriptionField: descriptionField3,
20720 selection,
20721 getItemId,
20722 onChangeSelection,
20723 multiselect,
20724 posinset
20725 }) {
20726 const { paginationInfo } = (0, import_element77.useContext)(dataviews_context_default);
20727 const isSelected2 = selection.includes(id);
20728 const [isHovered, setIsHovered] = (0, import_element77.useState)(false);
20729 const elementRef = (0, import_element77.useRef)(null);
20730 useIntersectionObserver(elementRef, posinset);
20731 const {
20732 showTitle = true,
20733 showMedia = true,
20734 showDescription = true,
20735 infiniteScrollEnabled
20736 } = view;
20737 const handleMouseEnter = () => {
20738 setIsHovered(true);
20739 };
20740 const handleMouseLeave = () => {
20741 setIsHovered(false);
20742 };
20743 const columns = view.fields ?? [];
20744 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription;
20745 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20746 import_components17.Composite.Item,
20747 {
20748 ref: elementRef,
20749 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20750 "tr",
20751 {
20752 className: clsx_default("dataviews-view-table__row", {
20753 "is-selected": isSelected2,
20754 "is-hovered": isHovered
20755 }),
20756 onMouseEnter: handleMouseEnter,
20757 onMouseLeave: handleMouseLeave,
20758 children,
20759 ...props
20760 }
20761 ),
20762 "aria-selected": isSelected2,
20763 "aria-setsize": paginationInfo.totalItems || void 0,
20764 "aria-posinset": posinset,
20765 role: infiniteScrollEnabled ? "article" : "option",
20766 onMouseDown: (event) => {
20767 if (event.button !== 0) {
20768 return;
20769 }
20770 event.currentTarget.parentElement?.focus({
20771 preventScroll: true
20772 });
20773 },
20774 onClick: () => {
20775 if (isSelected2) {
20776 onChangeSelection(
20777 selection.filter((itemId) => id !== itemId)
20778 );
20779 } else {
20780 const newSelection = multiselect ? [...selection, id] : [id];
20781 onChangeSelection(newSelection);
20782 }
20783 },
20784 children: [
20785 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20786 "td",
20787 {
20788 className: "dataviews-view-table__checkbox-column",
20789 role: "presentation",
20790 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20791 DataViewsSelectionCheckbox,
20792 {
20793 item,
20794 selection,
20795 onChangeSelection,
20796 getItemId,
20797 titleField: titleField2,
20798 disabled: false,
20799 "aria-hidden": true,
20800 tabIndex: -1
20801 }
20802 ) })
20803 }
20804 ),
20805 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20806 "td",
20807 {
20808 role: "presentation",
20809 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20810 column_primary_default,
20811 {
20812 item,
20813 titleField: showTitle ? titleField2 : void 0,
20814 mediaField: showMedia ? mediaField : void 0,
20815 descriptionField: showDescription ? descriptionField3 : void 0,
20816 isItemClickable: () => false
20817 }
20818 )
20819 }
20820 ),
20821 columns.map((column) => {
20822 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
20823 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20824 "td",
20825 {
20826 style: {
20827 width,
20828 maxWidth,
20829 minWidth
20830 },
20831 role: "presentation",
20832 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20833 TableColumnField2,
20834 {
20835 fields,
20836 item,
20837 column,
20838 align
20839 }
20840 )
20841 },
20842 column
20843 );
20844 })
20845 ]
20846 },
20847 id
20848 );
20849 }
20850 function ViewPickerTable({
20851 actions,
20852 data,
20853 fields,
20854 getItemId,
20855 isLoading = false,
20856 onChangeView,
20857 onChangeSelection,
20858 selection,
20859 setOpenedFilter,
20860 view,
20861 className,
20862 empty
20863 }) {
20864 const headerMenuRefs = (0, import_element77.useRef)(/* @__PURE__ */ new Map());
20865 const headerMenuToFocusRef = (0, import_element77.useRef)(void 0);
20866 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element77.useState)();
20867 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
20868 (0, import_element77.useEffect)(() => {
20869 if (headerMenuToFocusRef.current) {
20870 headerMenuToFocusRef.current.focus();
20871 headerMenuToFocusRef.current = void 0;
20872 }
20873 });
20874 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
20875 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
20876 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
20877 const tableNoticeId = (0, import_element77.useId)();
20878 if (nextHeaderMenuToFocus) {
20879 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
20880 setNextHeaderMenuToFocus(void 0);
20881 return;
20882 }
20883 const onHide = (field) => {
20884 const hidden = headerMenuRefs.current.get(field.id);
20885 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
20886 setNextHeaderMenuToFocus(fallback?.node);
20887 };
20888 const hasData = !!data?.length;
20889 const titleField2 = fields.find((field) => field.id === view.titleField);
20890 const mediaField = fields.find((field) => field.id === view.mediaField);
20891 const descriptionField3 = fields.find(
20892 (field) => field.id === view.descriptionField
20893 );
20894 const { showTitle = true, showMedia = true, showDescription = true } = view;
20895 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription;
20896 const columns = view.fields ?? [];
20897 const headerMenuRef = (column, index2) => (node) => {
20898 if (node) {
20899 headerMenuRefs.current.set(column, {
20900 node,
20901 fallback: columns[index2 > 0 ? index2 - 1 : 1]
20902 });
20903 } else {
20904 headerMenuRefs.current.delete(column);
20905 }
20906 };
20907 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(import_jsx_runtime110.Fragment, { children: [
20908 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20909 "table",
20910 {
20911 className: clsx_default(
20912 "dataviews-view-table",
20913 "dataviews-view-picker-table",
20914 className,
20915 {
20916 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
20917 view.layout.density
20918 )
20919 }
20920 ),
20921 "aria-busy": isLoading,
20922 "aria-describedby": tableNoticeId,
20923 role: isInfiniteScroll ? "feed" : "listbox",
20924 children: [
20925 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20926 "tr",
20927 {
20928 className: "dataviews-view-table__row",
20929 role: "presentation",
20930 children: [
20931 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20932 BulkSelectionCheckbox,
20933 {
20934 selection,
20935 onChangeSelection,
20936 data,
20937 actions,
20938 getItemId,
20939 disableSelectAll: isInfiniteScroll
20940 }
20941 ) }),
20942 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("th", { children: titleField2 && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20943 column_header_menu_default,
20944 {
20945 ref: headerMenuRef(
20946 titleField2.id,
20947 0
20948 ),
20949 fieldId: titleField2.id,
20950 view,
20951 fields,
20952 onChangeView,
20953 onHide,
20954 setOpenedFilter,
20955 canMove: false
20956 }
20957 ) }),
20958 columns.map((column, index2) => {
20959 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
20960 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20961 "th",
20962 {
20963 style: {
20964 width,
20965 maxWidth,
20966 minWidth,
20967 textAlign: align
20968 },
20969 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
20970 scope: "col",
20971 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20972 column_header_menu_default,
20973 {
20974 ref: headerMenuRef(column, index2),
20975 fieldId: column,
20976 view,
20977 fields,
20978 onChangeView,
20979 onHide,
20980 setOpenedFilter,
20981 canMove: view.layout?.enableMoving ?? true
20982 }
20983 )
20984 },
20985 column
20986 );
20987 })
20988 ]
20989 }
20990 ) }),
20991 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
20992 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20993 import_components17.Composite,
20994 {
20995 virtualFocus: true,
20996 orientation: "vertical",
20997 render: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tbody", { role: "group" }),
20998 children: [
20999 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
21000 "tr",
21001 {
21002 className: "dataviews-view-table__group-header-row",
21003 role: "presentation",
21004 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
21005 "td",
21006 {
21007 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
21008 className: "dataviews-view-table__group-header-cell",
21009 role: "presentation",
21010 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n23.sprintf)(
21011 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
21012 (0, import_i18n23.__)("%1$s: %2$s"),
21013 groupField.label,
21014 groupName
21015 )
21016 }
21017 )
21018 }
21019 ),
21020 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
21021 TableRow2,
21022 {
21023 item,
21024 fields,
21025 id: getItemId(item) || index2.toString(),
21026 view,
21027 titleField: titleField2,
21028 mediaField,
21029 descriptionField: descriptionField3,
21030 selection,
21031 getItemId,
21032 onChangeSelection,
21033 multiselect: isMultiselect
21034 },
21035 getItemId(item)
21036 ))
21037 ]
21038 },
21039 `group-${groupName}`
21040 )
21041 ) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
21042 import_components17.Composite,
21043 {
21044 render: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tbody", { role: "presentation" }),
21045 virtualFocus: true,
21046 orientation: "vertical",
21047 children: hasData && data.map((item, index2) => {
21048 const itemId = getItemId(item);
21049 const posinset = item.position;
21050 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
21051 TableRow2,
21052 {
21053 item,
21054 fields,
21055 id: itemId || index2.toString(),
21056 view,
21057 titleField: titleField2,
21058 mediaField,
21059 descriptionField: descriptionField3,
21060 selection,
21061 getItemId,
21062 onChangeSelection,
21063 multiselect: isMultiselect,
21064 posinset
21065 },
21066 itemId
21067 );
21068 })
21069 }
21070 )
21071 ]
21072 }
21073 ),
21074 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
21075 "div",
21076 {
21077 className: clsx_default({
21078 "dataviews-loading": isLoading,
21079 "dataviews-no-results": !hasData && !isLoading
21080 }),
21081 id: tableNoticeId,
21082 children: [
21083 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components17.Spinner, {}) }) : empty),
21084 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components17.Spinner, {}) })
21085 ]
21086 }
21087 )
21088 ] });
21089 }
21090 var picker_table_default = ViewPickerTable;
21091
21092 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
21093 var import_components18 = __toESM(require_components(), 1);
21094 var import_element78 = __toESM(require_element(), 1);
21095 var import_compose9 = __toESM(require_compose(), 1);
21096 var import_i18n24 = __toESM(require_i18n(), 1);
21097 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
21098 function isDefined4(item) {
21099 return !!item;
21100 }
21101 function PickerActivityItem({
21102 view,
21103 multiselect,
21104 selection,
21105 onChangeSelection,
21106 getItemId,
21107 item,
21108 titleField: titleField2,
21109 mediaField,
21110 descriptionField: descriptionField3,
21111 otherFields,
21112 posinset,
21113 setsize
21114 }) {
21115 const elementRef = (0, import_element78.useRef)(null);
21116 useIntersectionObserver(elementRef, posinset);
21117 const { showTitle = true, showMedia = true, showDescription = true } = view;
21118 const id = getItemId(item);
21119 const isSelected2 = selection.includes(id);
21120 const density = view.layout?.density ?? "balanced";
21121 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21122 mediaField.render,
21123 {
21124 item,
21125 field: mediaField,
21126 config: {
21127 sizes: density === "comfortable" ? "32px" : "24px"
21128 }
21129 }
21130 ) : null;
21131 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21132 "span",
21133 {
21134 className: "dataviews-view-picker-activity__item-bullet",
21135 "aria-hidden": "true"
21136 }
21137 ) });
21138 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(titleField2.render, { item, field: titleField2 }) : null;
21139 const renderedDescriptionField = showDescription && descriptionField3?.render ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(descriptionField3.render, { item, field: descriptionField3 }) : null;
21140 const verticalGap = (0, import_element78.useMemo)(() => {
21141 switch (density) {
21142 case "comfortable":
21143 return "md";
21144 default:
21145 return "sm";
21146 }
21147 }, [density]);
21148 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21149 import_components18.Composite.Item,
21150 {
21151 ref: elementRef,
21152 role: "option",
21153 "aria-label": titleField2 ? titleField2.getValue({ item }) || void 0 : void 0,
21154 "aria-posinset": posinset,
21155 "aria-setsize": setsize,
21156 "aria-selected": isSelected2,
21157 className: clsx_default(
21158 "dataviews-view-picker-activity__item",
21159 density === "compact" && "is-compact",
21160 density === "balanced" && "is-balanced",
21161 density === "comfortable" && "is-comfortable",
21162 isSelected2 && "is-selected"
21163 ),
21164 onClick: () => {
21165 if (isSelected2) {
21166 onChangeSelection(
21167 selection.filter((itemId) => id !== itemId)
21168 );
21169 } else {
21170 const newSelection = multiselect ? [...selection, id] : [id];
21171 onChangeSelection(newSelection);
21172 }
21173 },
21174 render: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", {}),
21175 children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
21176 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21177 Stack,
21178 {
21179 direction: "column",
21180 gap: "xs",
21181 align: "center",
21182 className: "dataviews-view-picker-activity__item-type",
21183 children: renderedMediaField
21184 }
21185 ),
21186 /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
21187 Stack,
21188 {
21189 direction: "column",
21190 gap: verticalGap,
21191 align: "flex-start",
21192 className: "dataviews-view-picker-activity__item-content",
21193 children: [
21194 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
21195 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
21196 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
21197 "div",
21198 {
21199 className: "dataviews-view-picker-activity__item-field",
21200 children: [
21201 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21202 VisuallyHidden,
21203 {
21204 render: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", {}),
21205 className: "dataviews-view-picker-activity__item-field-label",
21206 children: field.label
21207 }
21208 ),
21209 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21210 field.render,
21211 {
21212 item,
21213 field
21214 }
21215 ) })
21216 ]
21217 },
21218 field.id
21219 )) })
21220 ]
21221 }
21222 )
21223 ] })
21224 }
21225 );
21226 }
21227 function PickerActivityGroup({
21228 groupName,
21229 groupField,
21230 showLabel = true,
21231 children
21232 }) {
21233 const headerId = (0, import_compose9.useInstanceId)(
21234 PickerActivityGroup,
21235 "dataviews-view-picker-activity-group__header"
21236 );
21237 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
21238 Stack,
21239 {
21240 direction: "column",
21241 role: "group",
21242 "aria-labelledby": headerId,
21243 className: "dataviews-view-picker-activity-group",
21244 children: [
21245 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21246 "h3",
21247 {
21248 className: "dataviews-view-picker-activity-group__header",
21249 id: headerId,
21250 children: showLabel ? (0, import_i18n24.sprintf)(
21251 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
21252 (0, import_i18n24.__)("%1$s: %2$s"),
21253 groupField.label,
21254 groupName
21255 ) : groupName
21256 }
21257 ),
21258 children
21259 ]
21260 }
21261 );
21262 }
21263 function ViewPickerActivity({
21264 data,
21265 fields,
21266 getItemId,
21267 isLoading,
21268 onChangeSelection,
21269 selection,
21270 view,
21271 actions,
21272 className,
21273 empty
21274 }) {
21275 const { itemListLabel, paginationInfo } = (0, import_element78.useContext)(dataviews_context_default);
21276 const isMultiselect = useIsMultiselectPicker(actions);
21277 const titleField2 = fields.find(
21278 (field) => field.id === view?.titleField
21279 );
21280 const mediaField = fields.find(
21281 (field) => field.id === view?.mediaField
21282 );
21283 const descriptionField3 = fields.find(
21284 (field) => field.id === view?.descriptionField
21285 );
21286 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
21287 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
21288 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
21289 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
21290 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
21291 const hasData = !!data?.length;
21292 const isGrouped = !!(groupField && dataByGroup);
21293 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21294 PickerActivityItem,
21295 {
21296 view,
21297 multiselect: isMultiselect,
21298 selection,
21299 onChangeSelection,
21300 getItemId,
21301 item,
21302 titleField: titleField2,
21303 mediaField,
21304 descriptionField: descriptionField3,
21305 otherFields,
21306 posinset: item.position,
21307 setsize
21308 },
21309 getItemId(item)
21310 );
21311 if (!hasData) {
21312 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21313 "div",
21314 {
21315 className: clsx_default({
21316 "dataviews-loading": isLoading,
21317 "dataviews-no-results": !isLoading
21318 }),
21319 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components18.Spinner, {}) }) : empty
21320 }
21321 );
21322 }
21323 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
21324 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21325 import_components18.Composite,
21326 {
21327 virtualFocus: true,
21328 orientation: "vertical",
21329 role: "listbox",
21330 "aria-multiselectable": isMultiselect,
21331 "aria-label": itemListLabel,
21332 "aria-busy": isLoading,
21333 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
21334 className: clsx_default(
21335 "dataviews-view-picker-activity",
21336 className
21337 ),
21338 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
21339 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21340 PickerActivityGroup,
21341 {
21342 groupName,
21343 groupField,
21344 showLabel: view.groupBy?.showLabel !== false,
21345 children: groupItems.map(renderItem)
21346 },
21347 groupName
21348 )
21349 ) : data.map(renderItem)
21350 }
21351 ),
21352 isLoading && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components18.Spinner, {}) })
21353 ] });
21354 }
21355
21356 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
21357 var import_components19 = __toESM(require_components(), 1);
21358 var import_i18n25 = __toESM(require_i18n(), 1);
21359 var import_element79 = __toESM(require_element(), 1);
21360 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
21361 function DensityPicker() {
21362 const context = (0, import_element79.useContext)(dataviews_context_default);
21363 const view = context.view;
21364 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
21365 import_components19.__experimentalToggleGroupControl,
21366 {
21367 size: "__unstable-large",
21368 label: (0, import_i18n25.__)("Density"),
21369 value: view.layout?.density || "balanced",
21370 onChange: (value) => {
21371 context.onChangeView({
21372 ...view,
21373 layout: {
21374 ...view.layout,
21375 density: value
21376 }
21377 });
21378 },
21379 isBlock: true,
21380 children: [
21381 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
21382 import_components19.__experimentalToggleGroupControlOption,
21383 {
21384 value: "comfortable",
21385 label: (0, import_i18n25._x)(
21386 "Comfortable",
21387 "Density option for DataView layout"
21388 )
21389 },
21390 "comfortable"
21391 ),
21392 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
21393 import_components19.__experimentalToggleGroupControlOption,
21394 {
21395 value: "balanced",
21396 label: (0, import_i18n25._x)("Balanced", "Density option for DataView layout")
21397 },
21398 "balanced"
21399 ),
21400 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
21401 import_components19.__experimentalToggleGroupControlOption,
21402 {
21403 value: "compact",
21404 label: (0, import_i18n25._x)("Compact", "Density option for DataView layout")
21405 },
21406 "compact"
21407 )
21408 ]
21409 }
21410 );
21411 }
21412
21413 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
21414 var import_components20 = __toESM(require_components(), 1);
21415 var import_i18n26 = __toESM(require_i18n(), 1);
21416 var import_element80 = __toESM(require_element(), 1);
21417 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
21418 var imageSizes2 = [
21419 {
21420 value: 120,
21421 breakpoint: 1
21422 },
21423 {
21424 value: 170,
21425 breakpoint: 1
21426 },
21427 {
21428 value: 230,
21429 breakpoint: 1
21430 },
21431 {
21432 value: 290,
21433 breakpoint: 1112
21434 // at minimum image width, 4 images display at this container size
21435 },
21436 {
21437 value: 350,
21438 breakpoint: 1636
21439 // at minimum image width, 6 images display at this container size
21440 },
21441 {
21442 value: 430,
21443 breakpoint: 588
21444 // at minimum image width, 2 images display at this container size
21445 }
21446 ];
21447 function PreviewSizePicker() {
21448 const context = (0, import_element80.useContext)(dataviews_context_default);
21449 const view = context.view;
21450 const breakValues = imageSizes2.filter((size4) => {
21451 return context.containerWidth >= size4.breakpoint;
21452 });
21453 const layoutPreviewSize = view.layout?.previewSize ?? 230;
21454 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
21455 const marks = breakValues.map((size4, index2) => {
21456 return {
21457 value: index2
21458 };
21459 });
21460 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
21461 import_components20.RangeControl,
21462 {
21463 __next40pxDefaultSize: true,
21464 showTooltip: false,
21465 label: (0, import_i18n26.__)("Preview size"),
21466 value: previewSizeToUse,
21467 min: 0,
21468 max: breakValues.length - 1,
21469 withInputField: false,
21470 onChange: (value = 0) => {
21471 context.onChangeView({
21472 ...view,
21473 layout: {
21474 ...view.layout,
21475 previewSize: breakValues[value].value
21476 }
21477 });
21478 },
21479 step: 1,
21480 marks
21481 }
21482 );
21483 }
21484
21485 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
21486 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
21487 function GridConfigOptions() {
21488 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_jsx_runtime114.Fragment, { children: [
21489 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(DensityPicker, {}),
21490 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(PreviewSizePicker, {})
21491 ] });
21492 }
21493
21494 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
21495 var VIEW_LAYOUTS = [
21496 {
21497 type: LAYOUT_TABLE,
21498 label: (0, import_i18n27.__)("Table"),
21499 component: table_default,
21500 icon: block_table_default,
21501 viewConfigOptions: DensityPicker
21502 },
21503 {
21504 type: LAYOUT_GRID,
21505 label: (0, import_i18n27.__)("Grid"),
21506 component: grid_default,
21507 icon: category_default,
21508 viewConfigOptions: GridConfigOptions
21509 },
21510 {
21511 type: LAYOUT_LIST,
21512 label: (0, import_i18n27.__)("List"),
21513 component: ViewList,
21514 icon: (0, import_i18n27.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
21515 viewConfigOptions: DensityPicker
21516 },
21517 {
21518 type: LAYOUT_ACTIVITY,
21519 label: (0, import_i18n27.__)("Activity"),
21520 component: ViewActivity,
21521 icon: scheduled_default,
21522 viewConfigOptions: DensityPicker
21523 },
21524 {
21525 type: LAYOUT_PICKER_GRID,
21526 label: (0, import_i18n27.__)("Grid"),
21527 component: picker_grid_default,
21528 icon: category_default,
21529 viewConfigOptions: GridConfigOptions,
21530 isPicker: true
21531 },
21532 {
21533 type: LAYOUT_PICKER_TABLE,
21534 label: (0, import_i18n27.__)("Table"),
21535 component: picker_table_default,
21536 icon: block_table_default,
21537 viewConfigOptions: DensityPicker,
21538 isPicker: true
21539 },
21540 {
21541 type: LAYOUT_PICKER_ACTIVITY,
21542 label: (0, import_i18n27.__)("Activity"),
21543 component: ViewPickerActivity,
21544 icon: scheduled_default,
21545 viewConfigOptions: DensityPicker,
21546 isPicker: true
21547 }
21548 ];
21549
21550 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21551 var import_element88 = __toESM(require_element(), 1);
21552
21553 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21554 var import_components23 = __toESM(require_components(), 1);
21555 var import_i18n30 = __toESM(require_i18n(), 1);
21556 var import_element85 = __toESM(require_element(), 1);
21557
21558 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
21559 var import_react15 = __toESM(require_react(), 1);
21560 var FocusableContext = (0, import_react15.createContext)(true);
21561
21562 // node_modules/@ariakit/utils/dist/index.js
21563 function toArray(arg) {
21564 if (Array.isArray(arg)) return arg;
21565 return typeof arg !== "undefined" ? [arg] : [];
21566 }
21567 function flatten2DArray(array) {
21568 const flattened = [];
21569 for (const row of array) flattened.push(...row);
21570 return flattened;
21571 }
21572 function reverseArray(array) {
21573 return array.slice().reverse();
21574 }
21575 var canUseDOM = checkIsBrowser();
21576 function checkIsBrowser() {
21577 return typeof window !== "undefined" && !!window.document?.createElement;
21578 }
21579 function getDocument(node) {
21580 if (!node) return document;
21581 if ("self" in node) return node.document;
21582 return node.ownerDocument || document;
21583 }
21584 function getActiveElement(node, activeDescendant = false) {
21585 const { activeElement: activeElement2 } = getDocument(node);
21586 if (!activeElement2?.nodeName) return null;
21587 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
21588 if (activeDescendant) {
21589 const id = activeElement2.getAttribute("aria-activedescendant");
21590 if (id) {
21591 const element = getDocument(activeElement2).getElementById(id);
21592 if (element) return element;
21593 }
21594 }
21595 return activeElement2;
21596 }
21597 function contains2(parent, child) {
21598 return parent === child || parent.contains(child);
21599 }
21600 function isElement2(target) {
21601 return target?.nodeType === 1;
21602 }
21603 function isNode2(target) {
21604 return typeof target?.nodeType === "number";
21605 }
21606 function isFrame(element) {
21607 return element.tagName === "IFRAME";
21608 }
21609 function isButton(element) {
21610 const tagName = element.tagName.toLowerCase();
21611 if (tagName === "button") return true;
21612 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
21613 return false;
21614 }
21615 var buttonInputTypes = [
21616 "button",
21617 "color",
21618 "file",
21619 "image",
21620 "reset",
21621 "submit"
21622 ];
21623 function isVisible(element) {
21624 if (typeof element.checkVisibility === "function") return element.checkVisibility();
21625 const htmlElement = element;
21626 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
21627 }
21628 function isTextField(element) {
21629 try {
21630 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
21631 const isTextArea = element.tagName === "TEXTAREA";
21632 return isTextInput || isTextArea || false;
21633 } catch (_error) {
21634 return false;
21635 }
21636 }
21637 function isTextbox(element) {
21638 return element.isContentEditable || isTextField(element);
21639 }
21640 function getTextboxValue(element) {
21641 if (isTextField(element)) return element.value;
21642 if (element.isContentEditable) {
21643 const range = getDocument(element).createRange();
21644 range.selectNodeContents(element);
21645 return range.toString();
21646 }
21647 return "";
21648 }
21649 function getTextboxSelection(element) {
21650 let start = 0;
21651 let end = 0;
21652 if (isTextField(element)) {
21653 start = element.selectionStart || 0;
21654 end = element.selectionEnd || 0;
21655 } else if (element.isContentEditable) {
21656 const selection = getDocument(element).getSelection();
21657 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
21658 const range = selection.getRangeAt(0);
21659 const nextRange = range.cloneRange();
21660 nextRange.selectNodeContents(element);
21661 nextRange.setEnd(range.startContainer, range.startOffset);
21662 start = nextRange.toString().length;
21663 nextRange.setEnd(range.endContainer, range.endOffset);
21664 end = nextRange.toString().length;
21665 }
21666 }
21667 return {
21668 start,
21669 end
21670 };
21671 }
21672 function getPopupRole(element, fallback) {
21673 const allowedPopupRoles = [
21674 "dialog",
21675 "menu",
21676 "listbox",
21677 "tree",
21678 "grid"
21679 ];
21680 const role = element?.getAttribute("role");
21681 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
21682 return fallback;
21683 }
21684 function getScrollingElement(element) {
21685 if (!element) return null;
21686 const isScrollableOverflow = (overflow) => {
21687 if (overflow === "auto") return true;
21688 if (overflow === "scroll") return true;
21689 return false;
21690 };
21691 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
21692 const { overflowY } = getComputedStyle(element);
21693 if (isScrollableOverflow(overflowY)) return element;
21694 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
21695 const { overflowX } = getComputedStyle(element);
21696 if (isScrollableOverflow(overflowX)) return element;
21697 }
21698 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
21699 }
21700 function setSelectionRange(element, ...args) {
21701 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
21702 }
21703 function sortBasedOnDOMPosition(items, getElement) {
21704 const pairs = items.map((item, index2) => [index2, item]);
21705 let isOrderDifferent = false;
21706 pairs.sort(([indexA, a2], [indexB, b2]) => {
21707 const elementA = getElement(a2);
21708 const elementB = getElement(b2);
21709 if (elementA === elementB) return 0;
21710 if (!elementA || !elementB) return 0;
21711 if (isElementPreceding(elementA, elementB)) {
21712 if (indexA > indexB) isOrderDifferent = true;
21713 return -1;
21714 }
21715 if (indexA < indexB) isOrderDifferent = true;
21716 return 1;
21717 });
21718 if (isOrderDifferent) return pairs.map(([_, item]) => item);
21719 return items;
21720 }
21721 function isElementPreceding(a2, b2) {
21722 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
21723 }
21724 function isTouchDevice() {
21725 return canUseDOM && !!navigator.maxTouchPoints;
21726 }
21727 function isApple() {
21728 if (!canUseDOM) return false;
21729 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
21730 }
21731 function isSafari2() {
21732 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
21733 }
21734 function isFirefox2() {
21735 return canUseDOM && /firefox\//i.test(navigator.userAgent);
21736 }
21737 function isPortalEvent(event) {
21738 const { currentTarget, target } = event;
21739 if (!currentTarget) return false;
21740 if (!isNode2(target)) return true;
21741 return !contains2(currentTarget, target);
21742 }
21743 function isSelfTarget(event) {
21744 return event.target === event.currentTarget;
21745 }
21746 function isOpeningInNewTab(event) {
21747 const element = event.currentTarget;
21748 if (!element) return false;
21749 const isAppleDevice = isApple();
21750 if (isAppleDevice && !event.metaKey) return false;
21751 if (!isAppleDevice && !event.ctrlKey) return false;
21752 const tagName = element.tagName.toLowerCase();
21753 if (tagName === "a") return true;
21754 if (tagName === "button" && element.type === "submit") return true;
21755 if (tagName === "input" && element.type === "submit") return true;
21756 return false;
21757 }
21758 function isDownloading(event) {
21759 const element = event.currentTarget;
21760 if (!element) return false;
21761 const tagName = element.tagName.toLowerCase();
21762 if (!event.altKey) return false;
21763 if (tagName === "a") return true;
21764 if (tagName === "button" && element.type === "submit") return true;
21765 if (tagName === "input" && element.type === "submit") return true;
21766 return false;
21767 }
21768 function fireBlurEvent(element, eventInit) {
21769 const event = new FocusEvent("blur", eventInit);
21770 const defaultAllowed = element.dispatchEvent(event);
21771 const bubbleInit = {
21772 ...eventInit,
21773 bubbles: true
21774 };
21775 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
21776 return defaultAllowed;
21777 }
21778 function fireKeyboardEvent(element, type, eventInit) {
21779 const event = new KeyboardEvent(type, eventInit);
21780 return element.dispatchEvent(event);
21781 }
21782 function fireClickEvent(element, eventInit) {
21783 const event = new MouseEvent("click", eventInit);
21784 return element.dispatchEvent(event);
21785 }
21786 function isFocusEventOutside(event, container) {
21787 const containerElement = container || event.currentTarget;
21788 const relatedTarget = event.relatedTarget;
21789 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
21790 }
21791 function queueBeforeEvent(element, type, callback, timeout) {
21792 const createTimer = (callback2) => {
21793 if (timeout) {
21794 const timerId2 = setTimeout(callback2, timeout);
21795 return () => clearTimeout(timerId2);
21796 }
21797 const timerId = requestAnimationFrame(callback2);
21798 return () => cancelAnimationFrame(timerId);
21799 };
21800 const cancelTimer = createTimer(() => {
21801 element.removeEventListener(type, callSync, true);
21802 callback();
21803 });
21804 const callSync = () => {
21805 cancelTimer();
21806 callback();
21807 };
21808 element.addEventListener(type, callSync, {
21809 once: true,
21810 capture: true
21811 });
21812 return cancelTimer;
21813 }
21814 function addGlobalEventListener(type, listener, options, scope = window) {
21815 const children = [];
21816 try {
21817 scope.document.addEventListener(type, listener, options);
21818 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
21819 } catch {
21820 }
21821 const removeEventListener = () => {
21822 try {
21823 scope.document.removeEventListener(type, listener, options);
21824 } catch {
21825 }
21826 for (const remove of children) remove();
21827 };
21828 return removeEventListener;
21829 }
21830 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'])";
21831 function isFocusable(element) {
21832 if (!element.matches(selector)) return false;
21833 if (!isVisible(element)) return false;
21834 if (element.closest("[inert]")) return false;
21835 return true;
21836 }
21837 function hasFocus(element) {
21838 const activeElement2 = getActiveElement(element);
21839 if (!activeElement2) return false;
21840 if (activeElement2 === element) return true;
21841 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
21842 if (!activeDescendant) return false;
21843 return activeDescendant === element.id;
21844 }
21845 function hasFocusWithin(element) {
21846 const activeElement2 = getActiveElement(element);
21847 if (!activeElement2) return false;
21848 if (contains2(element, activeElement2)) return true;
21849 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
21850 if (!activeDescendant) return false;
21851 if (!("id" in element)) return false;
21852 if (activeDescendant === element.id) return true;
21853 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
21854 }
21855 function focusIntoView(element, options) {
21856 if (!("scrollIntoView" in element)) element.focus();
21857 else {
21858 element.focus({ preventScroll: true });
21859 element.scrollIntoView({
21860 block: "nearest",
21861 inline: "nearest",
21862 ...options
21863 });
21864 }
21865 }
21866 function noop4(..._) {
21867 }
21868 function hasOwnProperty(object, prop) {
21869 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
21870 return Object.prototype.hasOwnProperty.call(object, prop);
21871 }
21872 function chain(...fns) {
21873 return (...args) => {
21874 for (const fn of fns) if (typeof fn === "function") fn(...args);
21875 };
21876 }
21877 function normalizeString(str) {
21878 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
21879 }
21880 function omit(object, keys) {
21881 const result = { ...object };
21882 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
21883 return result;
21884 }
21885 function pick(object, paths) {
21886 const result = {};
21887 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
21888 return result;
21889 }
21890 function identity(value) {
21891 return value;
21892 }
21893 function invariant(condition, message2) {
21894 if (condition) return;
21895 if (typeof message2 !== "string") throw new Error("Invariant failed");
21896 throw new Error(message2);
21897 }
21898 function getKeys(obj) {
21899 return Object.keys(obj);
21900 }
21901 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
21902 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
21903 if (result == null) return false;
21904 return !result;
21905 }
21906 function disabledFromProps(props) {
21907 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
21908 }
21909 function removeUndefinedValues(obj) {
21910 const result = {};
21911 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
21912 return result;
21913 }
21914 function defaultValue(...values) {
21915 for (const value of values) if (value !== void 0) return value;
21916 }
21917 function createUndoCallback(callback) {
21918 return async () => {
21919 const redo = await callback?.();
21920 return createUndoCallback(async () => {
21921 await redo?.();
21922 return callback;
21923 });
21924 };
21925 }
21926 var UndoManager = createUndoManager();
21927 function createUndoManager({ limit = 100 } = {}) {
21928 const undoStack = [];
21929 let redoStack = [];
21930 let currentGroup = null;
21931 const canUndo = () => undoStack.length > 0;
21932 const canRedo = () => redoStack.length > 0;
21933 const undo = async () => {
21934 if (!canUndo()) return;
21935 currentGroup = null;
21936 redoStack.push(await undoStack.pop()?.());
21937 };
21938 const redo = async () => {
21939 if (!canRedo()) return;
21940 currentGroup = null;
21941 undoStack.push(await redoStack.pop()?.());
21942 };
21943 const execute = async (callback, group) => {
21944 if (!callback) return;
21945 while (undoStack.length > limit) undoStack.shift();
21946 const sameGroup = group === currentGroup;
21947 currentGroup = group ?? null;
21948 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
21949 const undoCallback = await callback();
21950 if (!undoCallback) return;
21951 redoStack = [];
21952 const currentUndo = undoStack[nextIndex];
21953 undoStack[nextIndex] = createUndoCallback(async () => {
21954 await undoCallback?.();
21955 const currentRedo = await currentUndo?.();
21956 return async () => {
21957 await currentRedo?.();
21958 await callback?.();
21959 };
21960 });
21961 };
21962 return {
21963 canUndo,
21964 canRedo,
21965 undo,
21966 redo,
21967 execute
21968 };
21969 }
21970
21971 // node_modules/@ariakit/react-utils/dist/index.js
21972 var React82 = __toESM(require_react(), 1);
21973 var import_react16 = __toESM(require_react(), 1);
21974 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
21975 function setRef(ref, value) {
21976 if (typeof ref === "function") ref(value);
21977 else if (ref) ref.current = value;
21978 }
21979 function isValidElementWithRef(element) {
21980 if (!element) return false;
21981 if (!(0, import_react16.isValidElement)(element)) return false;
21982 if ("ref" in element.props) return true;
21983 if ("ref" in element) return true;
21984 return false;
21985 }
21986 function getRefProperty(element) {
21987 if (!isValidElementWithRef(element)) return null;
21988 return { ...element.props }.ref || element.ref;
21989 }
21990 function mergeProps2(base, overrides) {
21991 const props = { ...base };
21992 for (const key in overrides) {
21993 if (!hasOwnProperty(overrides, key)) continue;
21994 if (key === "className") {
21995 const prop = "className";
21996 const baseClass = base[prop];
21997 const overrideClass = overrides[prop];
21998 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
21999 else props[prop] = overrideClass || baseClass;
22000 continue;
22001 }
22002 if (key === "style") {
22003 const prop = "style";
22004 props[prop] = base[prop] ? {
22005 ...base[prop],
22006 ...overrides[prop]
22007 } : overrides[prop];
22008 continue;
22009 }
22010 const overrideValue = overrides[key];
22011 if (key.startsWith("on")) {
22012 if (typeof overrideValue !== "function") continue;
22013 const baseValue = base[key];
22014 if (typeof baseValue === "function") {
22015 props[key] = (...args) => {
22016 overrideValue(...args);
22017 baseValue(...args);
22018 };
22019 continue;
22020 }
22021 }
22022 props[key] = overrideValue;
22023 }
22024 return props;
22025 }
22026 var _React = { ...React82 };
22027 var useReactId = _React.useId;
22028 var useReactDeferredValue = _React.useDeferredValue;
22029 var useReactInsertionEffect = _React.useInsertionEffect;
22030 var useSafeLayoutEffect = canUseDOM ? import_react16.useLayoutEffect : import_react16.useEffect;
22031 function useInitialValue(value) {
22032 const [initialValue] = (0, import_react16.useState)(value);
22033 return initialValue;
22034 }
22035 function useLiveRef(value) {
22036 const ref = (0, import_react16.useRef)(value);
22037 useSafeLayoutEffect(() => {
22038 ref.current = value;
22039 });
22040 return ref;
22041 }
22042 function useEvent(callback) {
22043 const ref = (0, import_react16.useRef)(() => {
22044 throw new Error("Cannot call an event handler while rendering.");
22045 });
22046 if (useReactInsertionEffect) useReactInsertionEffect(() => {
22047 ref.current = callback;
22048 });
22049 else ref.current = callback;
22050 return (0, import_react16.useCallback)((...args) => ref.current?.(...args), []);
22051 }
22052 function useTransactionState(callback) {
22053 const [state, setState] = (0, import_react16.useState)(null);
22054 useSafeLayoutEffect(() => {
22055 if (state == null) return;
22056 if (!callback) return;
22057 let prevState = null;
22058 callback((prev) => {
22059 prevState = prev;
22060 return state;
22061 });
22062 return () => {
22063 callback(prevState);
22064 };
22065 }, [state, callback]);
22066 return [state, setState];
22067 }
22068 function useMergeRefs3(...refs) {
22069 return (0, import_react16.useMemo)(() => {
22070 if (!refs.some(Boolean)) return;
22071 return (value) => {
22072 for (const ref of refs) setRef(ref, value);
22073 };
22074 }, refs);
22075 }
22076 function useId5(defaultId) {
22077 if (useReactId) {
22078 const reactId = useReactId();
22079 if (defaultId) return defaultId;
22080 return reactId;
22081 }
22082 const [id, setId] = (0, import_react16.useState)(defaultId);
22083 useSafeLayoutEffect(() => {
22084 if (defaultId || id) return;
22085 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
22086 }, [defaultId, id]);
22087 return defaultId || id;
22088 }
22089 function useTagName(refOrElement, type) {
22090 const stringOrUndefined = (type2) => {
22091 if (typeof type2 !== "string") return;
22092 return type2;
22093 };
22094 const [tagName, setTagName] = (0, import_react16.useState)(() => stringOrUndefined(type));
22095 useSafeLayoutEffect(() => {
22096 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
22097 }, [refOrElement, type]);
22098 return tagName;
22099 }
22100 function useAttribute(refOrElement, attributeName, defaultValue2) {
22101 const initialValue = useInitialValue(defaultValue2);
22102 const [attribute, setAttribute] = (0, import_react16.useState)(initialValue);
22103 (0, import_react16.useEffect)(() => {
22104 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
22105 if (!element) return;
22106 const callback = () => {
22107 const value = element.getAttribute(attributeName);
22108 setAttribute(value == null ? initialValue : value);
22109 };
22110 const observer = new MutationObserver(callback);
22111 observer.observe(element, { attributeFilter: [attributeName] });
22112 callback();
22113 return () => observer.disconnect();
22114 }, [
22115 refOrElement,
22116 attributeName,
22117 initialValue
22118 ]);
22119 return attribute;
22120 }
22121 function useUpdateEffect(effect, deps) {
22122 const mounted = (0, import_react16.useRef)(false);
22123 (0, import_react16.useEffect)(() => {
22124 if (mounted.current) return effect();
22125 mounted.current = true;
22126 }, deps);
22127 (0, import_react16.useEffect)(() => () => {
22128 mounted.current = false;
22129 }, []);
22130 }
22131 function useUpdateLayoutEffect(effect, deps) {
22132 const mounted = (0, import_react16.useRef)(false);
22133 useSafeLayoutEffect(() => {
22134 if (mounted.current) return effect();
22135 mounted.current = true;
22136 }, deps);
22137 useSafeLayoutEffect(() => () => {
22138 mounted.current = false;
22139 }, []);
22140 }
22141 function useForceUpdate() {
22142 return (0, import_react16.useReducer)(() => [], []);
22143 }
22144 function useBooleanEvent(booleanOrCallback) {
22145 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
22146 }
22147 function useWrapElement(props, callback, deps = []) {
22148 const wrapElement = (0, import_react16.useCallback)((element) => {
22149 if (props.wrapElement) element = props.wrapElement(element);
22150 return callback(element);
22151 }, [...deps, props.wrapElement]);
22152 return {
22153 ...props,
22154 wrapElement
22155 };
22156 }
22157 function useMetadataProps(props, key, value) {
22158 const parent = props.onLoadedMetadataCapture;
22159 const onLoadedMetadataCapture = (0, import_react16.useMemo)(() => {
22160 return Object.assign(() => {
22161 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
22162 }, [
22163 parent,
22164 key,
22165 value
22166 ]);
22167 return [parent?.[key], { onLoadedMetadataCapture }];
22168 }
22169 var hasInstalledGlobalEventListeners = false;
22170 function useIsMouseMoving() {
22171 (0, import_react16.useEffect)(() => {
22172 if (hasInstalledGlobalEventListeners) return;
22173 addGlobalEventListener("mousemove", setMouseMoving, true);
22174 addGlobalEventListener("mousedown", resetMouseMoving, true);
22175 addGlobalEventListener("mouseup", resetMouseMoving, true);
22176 addGlobalEventListener("keydown", resetMouseMoving, true);
22177 addGlobalEventListener("scroll", resetMouseMoving, true);
22178 hasInstalledGlobalEventListeners = true;
22179 }, []);
22180 return useEvent(() => mouseMoving);
22181 }
22182 var mouseMoving = false;
22183 var previousScreenX = 0;
22184 var previousScreenY = 0;
22185 function hasMouseMovement(event) {
22186 const movementX = event.movementX || event.screenX - previousScreenX;
22187 const movementY = event.movementY || event.screenY - previousScreenY;
22188 previousScreenX = event.screenX;
22189 previousScreenY = event.screenY;
22190 return movementX || movementY || false;
22191 }
22192 function setMouseMoving(event) {
22193 if (!hasMouseMovement(event)) return;
22194 mouseMoving = true;
22195 }
22196 function resetMouseMoving() {
22197 mouseMoving = false;
22198 }
22199 function forwardRef70(render4) {
22200 const Role = React82.forwardRef((props, ref) => render4({
22201 ...props,
22202 ref
22203 }));
22204 Role.displayName = render4.displayName || render4.name;
22205 return Role;
22206 }
22207 function memo3(Component, propsAreEqual) {
22208 return React82.memo(Component, propsAreEqual);
22209 }
22210 function createElement3(Type, props) {
22211 const { wrapElement, render: render4, ...rest } = props;
22212 const mergedRef = useMergeRefs3(props.ref, getRefProperty(render4));
22213 let element;
22214 if (React82.isValidElement(render4)) {
22215 const renderProps = {
22216 ...render4.props,
22217 ref: mergedRef
22218 };
22219 element = React82.cloneElement(render4, mergeProps2(rest, renderProps));
22220 } else if (render4) element = render4(rest);
22221 else element = /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(Type, { ...rest });
22222 if (wrapElement) return wrapElement(element);
22223 return element;
22224 }
22225 function createHook(useProps) {
22226 const useRole = (props = {}) => {
22227 return useProps(props);
22228 };
22229 useRole.displayName = useProps.name;
22230 return useRole;
22231 }
22232 function createStoreContext(providers = [], scopedProviders = []) {
22233 const context = React82.createContext(void 0);
22234 const scopedContext = React82.createContext(void 0);
22235 const useContext53 = () => React82.useContext(context);
22236 const useScopedContext = (onlyScoped = false) => {
22237 const scoped = React82.useContext(scopedContext);
22238 const store = useContext53();
22239 if (onlyScoped) return scoped;
22240 return scoped || store;
22241 };
22242 const useProviderContext = () => {
22243 const scoped = React82.useContext(scopedContext);
22244 const store = useContext53();
22245 if (scoped && scoped === store) return;
22246 return store;
22247 };
22248 const ContextProvider = (props) => {
22249 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(Provider2, {
22250 ...props,
22251 children
22252 }), /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(context.Provider, { ...props }));
22253 };
22254 const ScopedContextProvider = (props) => {
22255 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(ContextProvider, {
22256 ...props,
22257 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(Provider2, {
22258 ...props,
22259 children
22260 }), /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(scopedContext.Provider, { ...props }))
22261 });
22262 };
22263 return {
22264 context,
22265 scopedContext,
22266 useContext: useContext53,
22267 useScopedContext,
22268 useProviderContext,
22269 ContextProvider,
22270 ScopedContextProvider
22271 };
22272 }
22273
22274 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
22275 var import_react17 = __toESM(require_react(), 1);
22276 var TagName = "div";
22277 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
22278 var isSafariBrowser = isSafari2();
22279 var alwaysFocusVisibleInputTypes = [
22280 "text",
22281 "search",
22282 "url",
22283 "tel",
22284 "email",
22285 "password",
22286 "number",
22287 "date",
22288 "month",
22289 "week",
22290 "time",
22291 "datetime",
22292 "datetime-local"
22293 ];
22294 function isAlwaysFocusVisible(element) {
22295 const { tagName, readOnly, type } = element;
22296 if (tagName === "TEXTAREA" && !readOnly) return true;
22297 if (tagName === "SELECT" && !readOnly) return true;
22298 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
22299 if (element.isContentEditable) return true;
22300 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
22301 return false;
22302 }
22303 function isNativeTabbable(tagName) {
22304 if (!tagName) return true;
22305 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
22306 }
22307 function supportsDisabledAttribute(tagName) {
22308 if (!tagName) return true;
22309 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
22310 }
22311 var buttonInputTypes2 = [
22312 "button",
22313 "color",
22314 "file",
22315 "image",
22316 "reset",
22317 "submit"
22318 ];
22319 function needsSafariTabIndex(tagName, inputType) {
22320 if (tagName === "button") return true;
22321 if (tagName === "input" && inputType) {
22322 if (inputType === "checkbox" || inputType === "radio") return true;
22323 return buttonInputTypes2.includes(inputType);
22324 }
22325 return false;
22326 }
22327 function isNativeSubmitControl(element) {
22328 if (element.tagName === "BUTTON") {
22329 const { type } = element;
22330 return type === "submit";
22331 }
22332 if (element.tagName === "INPUT") {
22333 const { type } = element;
22334 return type === "submit" || type === "image";
22335 }
22336 return false;
22337 }
22338 function getTabIndex4({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
22339 if (!focusable2) return tabIndexProp;
22340 if (trulyDisabled) {
22341 if (nativeTabbable && !supportsDisabled) return -1;
22342 return;
22343 }
22344 if (nativeTabbable) {
22345 if (safariTabIndex && tabIndexProp == null) return 0;
22346 return tabIndexProp;
22347 }
22348 return tabIndexProp ?? 0;
22349 }
22350 function useDisableEvent(onEvent, disabled2) {
22351 return useEvent((event) => {
22352 onEvent?.(event);
22353 if (event.defaultPrevented) return;
22354 if (disabled2) {
22355 event.stopPropagation();
22356 event.preventDefault();
22357 }
22358 });
22359 }
22360 var hasInstalledGlobalEventListeners2 = false;
22361 var isKeyboardModality = true;
22362 function onGlobalMouseDown(event) {
22363 const target = event.target;
22364 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
22365 }
22366 function onGlobalKeyDown(event) {
22367 if (event.metaKey) return;
22368 if (event.ctrlKey) return;
22369 if (event.altKey) return;
22370 isKeyboardModality = true;
22371 }
22372 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
22373 const ref = (0, import_react17.useRef)(null);
22374 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
22375 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
22376 (0, import_react17.useEffect)(() => {
22377 if (!focusable2) return;
22378 if (hasInstalledGlobalEventListeners2) return;
22379 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
22380 addGlobalEventListener("keydown", onGlobalKeyDown, true);
22381 hasInstalledGlobalEventListeners2 = true;
22382 }, [focusable2]);
22383 const disabled2 = focusable2 && disabledFromProps(props);
22384 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
22385 const [focusVisible, setFocusVisible] = (0, import_react17.useState)(false);
22386 const focusVisibleRef = (0, import_react17.useRef)(false);
22387 const nativeSubmitObserverCleanupRef = (0, import_react17.useRef)(null);
22388 const cleanupFocusVisible = useEvent((element) => {
22389 nativeSubmitObserverCleanupRef.current?.();
22390 nativeSubmitObserverCleanupRef.current = null;
22391 focusVisibleRef.current = false;
22392 element?.removeAttribute("data-focus-visible");
22393 });
22394 (0, import_react17.useEffect)(() => {
22395 if (!focusable2) return;
22396 if (!trulyDisabled) return;
22397 cleanupFocusVisible(ref.current);
22398 if (focusVisible) setFocusVisible(false);
22399 }, [
22400 focusable2,
22401 trulyDisabled,
22402 focusVisible,
22403 cleanupFocusVisible
22404 ]);
22405 (0, import_react17.useEffect)(() => {
22406 if (!focusable2) return;
22407 if (!focusVisible) return;
22408 const element = ref.current;
22409 if (!element) return;
22410 if (typeof IntersectionObserver === "undefined") return;
22411 const observer = new IntersectionObserver(() => {
22412 if (!isFocusable(element)) {
22413 focusVisibleRef.current = false;
22414 setFocusVisible(false);
22415 }
22416 });
22417 observer.observe(element);
22418 return () => observer.disconnect();
22419 }, [focusable2, focusVisible]);
22420 (0, import_react17.useEffect)(() => {
22421 return () => nativeSubmitObserverCleanupRef.current?.();
22422 }, []);
22423 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
22424 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
22425 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
22426 const handleFocusVisible = (event, currentTarget) => {
22427 if (currentTarget) event.currentTarget = currentTarget;
22428 if (!focusable2) return;
22429 const element = event.currentTarget;
22430 if (!element) return;
22431 if (!hasFocus(element)) return;
22432 onFocusVisible?.(event);
22433 if (event.defaultPrevented) return;
22434 element.dataset.focusVisible = "true";
22435 focusVisibleRef.current = true;
22436 if (isNativeSubmitControl(element)) {
22437 nativeSubmitObserverCleanupRef.current?.();
22438 nativeSubmitObserverCleanupRef.current = null;
22439 if (typeof IntersectionObserver !== "undefined") {
22440 const observer = new IntersectionObserver(() => {
22441 if (isFocusable(element)) return;
22442 cleanupFocusVisible(element);
22443 });
22444 observer.observe(element);
22445 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
22446 }
22447 return;
22448 }
22449 setFocusVisible(true);
22450 };
22451 const onKeyDownCaptureProp = props.onKeyDownCapture;
22452 const onKeyDownCapture = useEvent((event) => {
22453 onKeyDownCaptureProp?.(event);
22454 if (event.defaultPrevented) return;
22455 if (!focusable2) return;
22456 if (focusVisible) return;
22457 if (focusVisibleRef.current) return;
22458 if (event.metaKey) return;
22459 if (event.altKey) return;
22460 if (event.ctrlKey) return;
22461 if (!isSelfTarget(event)) return;
22462 const element = event.currentTarget;
22463 const applyFocusVisible = () => handleFocusVisible(event, element);
22464 queueBeforeEvent(element, "focusout", applyFocusVisible);
22465 });
22466 const onFocusCaptureProp = props.onFocusCapture;
22467 const onFocusCapture = useEvent((event) => {
22468 onFocusCaptureProp?.(event);
22469 if (event.defaultPrevented) return;
22470 if (!focusable2) return;
22471 if (!isSelfTarget(event)) {
22472 setFocusVisible(false);
22473 return;
22474 }
22475 const element = event.currentTarget;
22476 const applyFocusVisible = () => handleFocusVisible(event, element);
22477 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
22478 else setFocusVisible(false);
22479 });
22480 const onBlurProp = props.onBlur;
22481 const onBlur = useEvent((event) => {
22482 onBlurProp?.(event);
22483 if (!focusable2) return;
22484 if (!isFocusEventOutside(event)) return;
22485 cleanupFocusVisible(event.currentTarget);
22486 setFocusVisible(false);
22487 });
22488 const autoFocusOnShow = (0, import_react17.useContext)(FocusableContext);
22489 const autoFocusRef = useEvent((element) => {
22490 if (!focusable2) return;
22491 if (!autoFocus) return;
22492 if (!element) return;
22493 if (!autoFocusOnShow) return;
22494 queueMicrotask(() => {
22495 if (hasFocus(element)) return;
22496 if (!isFocusable(element)) return;
22497 element.focus();
22498 });
22499 });
22500 const tagName = useTagName(ref);
22501 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
22502 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
22503 const [safariTabIndex, setSafariTabIndex] = (0, import_react17.useState)(false);
22504 if (isSafariBrowser) (0, import_react17.useEffect)(() => {
22505 if (!focusable2) return;
22506 const element = ref.current;
22507 if (!element) return;
22508 const tag = element.tagName.toLowerCase();
22509 const type = element.type;
22510 setSafariTabIndex(needsSafariTabIndex(tag, type));
22511 }, [focusable2]);
22512 const styleProp = props.style;
22513 const style = (0, import_react17.useMemo)(() => {
22514 if (trulyDisabled) return {
22515 pointerEvents: "none",
22516 ...styleProp
22517 };
22518 return styleProp;
22519 }, [trulyDisabled, styleProp]);
22520 props = {
22521 "data-focus-visible": focusable2 && focusVisible || void 0,
22522 "data-autofocus": autoFocus || void 0,
22523 "aria-disabled": disabled2 || void 0,
22524 ...props,
22525 ...metadataProps,
22526 ref: useMergeRefs3(ref, autoFocusRef, props.ref),
22527 style,
22528 tabIndex: getTabIndex4({
22529 focusable: focusable2,
22530 trulyDisabled,
22531 nativeTabbable,
22532 supportsDisabled,
22533 safariTabIndex,
22534 tabIndexProp: props.tabIndex
22535 }),
22536 disabled: supportsDisabled && trulyDisabled ? true : void 0,
22537 contentEditable: disabled2 ? void 0 : props.contentEditable,
22538 onKeyPressCapture,
22539 onClickCapture,
22540 onMouseDownCapture,
22541 onKeyDownCapture,
22542 onFocusCapture,
22543 onBlur
22544 };
22545 return removeUndefinedValues(props);
22546 });
22547 var Focusable = forwardRef70(function Focusable2(props) {
22548 return createElement3(TagName, useFocusable(props));
22549 });
22550
22551 // node_modules/@ariakit/react-components/dist/command/command.js
22552 var import_react18 = __toESM(require_react(), 1);
22553 var TagName2 = "button";
22554 function isNativeClick(event) {
22555 if (!event.isTrusted) return false;
22556 const element = event.currentTarget;
22557 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
22558 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
22559 return false;
22560 }
22561 var symbol = /* @__PURE__ */ Symbol("command");
22562 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
22563 const ref = (0, import_react18.useRef)(null);
22564 const [isNativeButton, setIsNativeButton] = (0, import_react18.useState)(false);
22565 (0, import_react18.useEffect)(() => {
22566 if (!ref.current) return;
22567 setIsNativeButton(isButton(ref.current));
22568 }, []);
22569 const [active, setActive] = (0, import_react18.useState)(false);
22570 const activeRef = (0, import_react18.useRef)(false);
22571 const disabled2 = disabledFromProps(props);
22572 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
22573 const onKeyDownProp = props.onKeyDown;
22574 const onKeyDown = useEvent((event) => {
22575 onKeyDownProp?.(event);
22576 const element = event.currentTarget;
22577 if (event.defaultPrevented) return;
22578 if (isDuplicate) return;
22579 if (disabled2) return;
22580 if (!isSelfTarget(event)) return;
22581 if (isTextField(element)) return;
22582 if (element.isContentEditable) return;
22583 const isEnter = clickOnEnter && event.key === "Enter";
22584 const isSpace = clickOnSpace && event.key === " ";
22585 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
22586 const shouldPreventSpace = event.key === " " && !clickOnSpace;
22587 if (shouldPreventEnter || shouldPreventSpace) {
22588 event.preventDefault();
22589 return;
22590 }
22591 if (isEnter || isSpace) {
22592 const nativeClick = isNativeClick(event);
22593 if (isEnter) {
22594 if (!nativeClick) {
22595 event.preventDefault();
22596 const { view, ...eventInit } = event;
22597 const click = () => fireClickEvent(element, eventInit);
22598 if (isFirefox2()) queueBeforeEvent(element, "keyup", click);
22599 else queueMicrotask(click);
22600 }
22601 } else if (isSpace) {
22602 activeRef.current = true;
22603 if (!nativeClick) {
22604 event.preventDefault();
22605 setActive(true);
22606 }
22607 }
22608 }
22609 });
22610 const onKeyUpProp = props.onKeyUp;
22611 const onKeyUp = useEvent((event) => {
22612 onKeyUpProp?.(event);
22613 if (event.defaultPrevented) return;
22614 if (isDuplicate) return;
22615 if (disabled2) return;
22616 if (event.metaKey) return;
22617 const isSpace = clickOnSpace && event.key === " ";
22618 if (activeRef.current && isSpace) {
22619 activeRef.current = false;
22620 if (!isNativeClick(event)) {
22621 event.preventDefault();
22622 setActive(false);
22623 const element = event.currentTarget;
22624 const { view, ...eventInit } = event;
22625 queueMicrotask(() => fireClickEvent(element, eventInit));
22626 }
22627 }
22628 });
22629 props = {
22630 "data-active": active || void 0,
22631 type: isNativeButton ? "button" : void 0,
22632 ...metadataProps,
22633 ...props,
22634 ref: useMergeRefs3(ref, props.ref),
22635 onKeyDown,
22636 onKeyUp
22637 };
22638 props = useFocusable(props);
22639 return props;
22640 });
22641 var Command = forwardRef70(function Command2(props) {
22642 return createElement3(TagName2, useCommand(props));
22643 });
22644
22645 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
22646 var ctx = createStoreContext();
22647 var useCollectionContext = ctx.useContext;
22648 var useCollectionScopedContext = ctx.useScopedContext;
22649 var useCollectionProviderContext = ctx.useProviderContext;
22650 var CollectionContextProvider = ctx.ContextProvider;
22651 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
22652
22653 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
22654 var import_react19 = __toESM(require_react(), 1);
22655 var TagName3 = "div";
22656 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
22657 const context = useCollectionContext();
22658 store = store || context;
22659 const id = useId5(props.id);
22660 const ref = (0, import_react19.useRef)(element);
22661 (0, import_react19.useEffect)(() => {
22662 const element2 = ref.current;
22663 if (!id) return;
22664 if (!element2) return;
22665 if (!shouldRegisterItem) return;
22666 const item = getItem({
22667 id,
22668 element: element2
22669 });
22670 return store?.renderItem(item);
22671 }, [
22672 id,
22673 shouldRegisterItem,
22674 getItem,
22675 store
22676 ]);
22677 props = {
22678 ...props,
22679 ref: useMergeRefs3(ref, props.ref)
22680 };
22681 return removeUndefinedValues(props);
22682 });
22683 var CollectionItem = forwardRef70(function CollectionItem2(props) {
22684 return createElement3(TagName3, useCollectionItem(props));
22685 });
22686
22687 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
22688 var import_react20 = __toESM(require_react(), 1);
22689 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
22690 var useCompositeContext = ctx2.useContext;
22691 var useCompositeScopedContext = ctx2.useScopedContext;
22692 var useCompositeProviderContext = ctx2.useProviderContext;
22693 var CompositeContextProvider = ctx2.ContextProvider;
22694 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
22695 var CompositeItemContext = (0, import_react20.createContext)(void 0);
22696 var CompositeRowContext = (0, import_react20.createContext)(void 0);
22697
22698 // node_modules/@ariakit/react-components/dist/composite/utils.js
22699 function findFirstEnabledItem(items, excludeId) {
22700 return items.find((item) => {
22701 if (excludeId) return !item.disabled && item.id !== excludeId;
22702 return !item.disabled;
22703 });
22704 }
22705 function getEnabledItem(store, id) {
22706 if (!id) return null;
22707 return store.item(id) || null;
22708 }
22709 function groupItemsByRows(items) {
22710 const rows = [];
22711 for (const item of items) {
22712 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
22713 if (row) row.push(item);
22714 else rows.push([item]);
22715 }
22716 return rows;
22717 }
22718 function selectTextField(element, collapseToEnd = false) {
22719 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
22720 else if (element.isContentEditable) {
22721 const selection = getDocument(element).getSelection();
22722 selection?.selectAllChildren(element);
22723 if (collapseToEnd) selection?.collapseToEnd();
22724 }
22725 }
22726 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
22727 function focusSilently(element) {
22728 element[FOCUS_SILENTLY] = true;
22729 element.focus({ preventScroll: true });
22730 }
22731 function silentlyFocused(element) {
22732 const isSilentlyFocused = element[FOCUS_SILENTLY];
22733 delete element[FOCUS_SILENTLY];
22734 return isSilentlyFocused;
22735 }
22736 function isItem(store, element, exclude) {
22737 if (!element) return false;
22738 if (element === exclude) return false;
22739 const item = store.item(element.id);
22740 if (!item) return false;
22741 if (exclude && item.element === exclude) return false;
22742 return true;
22743 }
22744
22745 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
22746 var import_react21 = __toESM(require_react(), 1);
22747 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
22748
22749 // node_modules/@ariakit/store/dist/index.js
22750 function getInternal(store, key) {
22751 const internals = store.__unstableInternals;
22752 invariant(internals, "Invalid store");
22753 return internals[key];
22754 }
22755 function hasUpdatedKey(keys, updatedKey) {
22756 if (!keys) return true;
22757 for (const currentKey of keys) if (updatedKey instanceof Set) {
22758 if (updatedKey.has(currentKey)) return true;
22759 } else if (currentKey === updatedKey) return true;
22760 return false;
22761 }
22762 function addKeyedListener(map, keys, listener) {
22763 if (!keys) return;
22764 for (const key of keys) {
22765 let listeners = map.get(key);
22766 if (!listeners) {
22767 listeners = /* @__PURE__ */ new Set();
22768 map.set(key, listeners);
22769 }
22770 listeners.add(listener);
22771 }
22772 }
22773 function deleteKeyedListener(map, keys, listener) {
22774 if (!map) return;
22775 if (!keys) return;
22776 for (const key of keys) {
22777 const listeners = map.get(key);
22778 if (!listeners) continue;
22779 listeners.delete(listener);
22780 if (!listeners.size) map.delete(key);
22781 }
22782 }
22783 function createStore(initialState, ...stores) {
22784 let state = initialState;
22785 let prevStateBatch = state;
22786 let destroy = noop4;
22787 let batchPending = false;
22788 let inDispatch = false;
22789 let updatedKeys = /* @__PURE__ */ new Set();
22790 const instances = /* @__PURE__ */ new Set();
22791 const setups = /* @__PURE__ */ new Set();
22792 const syncListenerGroup = {
22793 listeners: /* @__PURE__ */ new Set(),
22794 disposables: /* @__PURE__ */ new Map(),
22795 listenerKeys: /* @__PURE__ */ new WeakMap()
22796 };
22797 const batchListenerGroup = {
22798 listeners: /* @__PURE__ */ new Set(),
22799 disposables: /* @__PURE__ */ new Map(),
22800 listenerKeys: /* @__PURE__ */ new WeakMap()
22801 };
22802 const storeSetup = (callback) => {
22803 setups.add(callback);
22804 return () => setups.delete(callback);
22805 };
22806 const storeInit = () => {
22807 const initializedInstances = instances.size;
22808 const instance = /* @__PURE__ */ Symbol();
22809 instances.add(instance);
22810 const maybeDestroy = () => {
22811 instances.delete(instance);
22812 if (instances.size) return;
22813 destroy();
22814 };
22815 if (initializedInstances) return maybeDestroy;
22816 const stateKeys = getKeys(state);
22817 const desyncs = [];
22818 for (const store of stores) {
22819 const storeState = store?.getState?.();
22820 if (!storeState) continue;
22821 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
22822 if (!keys.length) continue;
22823 if (stores.length === 1 || keys.length === stateKeys.length) {
22824 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
22825 setState(key, state2[key], true);
22826 }));
22827 continue;
22828 }
22829 let didSyncInitialState = false;
22830 desyncs.push(sync(store, keys, (state2, prevState) => {
22831 for (const key of keys) {
22832 if (didSyncInitialState && state2[key] === prevState[key]) continue;
22833 setState(key, state2[key], true);
22834 }
22835 didSyncInitialState = true;
22836 }));
22837 }
22838 const teardowns = [];
22839 for (const setup2 of setups) teardowns.push(setup2());
22840 const cleanups = stores.map(init);
22841 destroy = chain(...desyncs, ...teardowns, ...cleanups);
22842 return maybeDestroy;
22843 };
22844 const deleteListenerIndexes = (group, listener, keys) => {
22845 if (keys === void 0) return;
22846 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
22847 else group.allKeysListeners?.delete(listener);
22848 };
22849 const registerListener = (keys, listener, group = syncListenerGroup) => {
22850 const listenerKeysValue = keys ? [...keys] : null;
22851 if (group.listeners.has(listener)) deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
22852 group.listeners.add(listener);
22853 if (listenerKeysValue) {
22854 group.listenersByKey ??= /* @__PURE__ */ new Map();
22855 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
22856 } else {
22857 group.allKeysListeners ??= /* @__PURE__ */ new Set();
22858 group.allKeysListeners.add(listener);
22859 }
22860 group.listenerKeys.set(listener, listenerKeysValue);
22861 return () => {
22862 group.disposables.get(listener)?.();
22863 group.disposables.delete(listener);
22864 const currentKeys = group.listenerKeys.get(listener);
22865 deleteListenerIndexes(group, listener, listenerKeysValue);
22866 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
22867 group.listenerKeys.delete(listener);
22868 group.listeners.delete(listener);
22869 };
22870 };
22871 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
22872 const reconcileInitialCleanup = (group, listener, cleanup) => {
22873 if (cleanup) group.disposables.set(listener, cleanup);
22874 else group.disposables.delete(listener);
22875 };
22876 const storeSync = (keys, listener) => {
22877 reconcileInitialCleanup(syncListenerGroup, listener, listener(state, state));
22878 return registerListener(keys, listener);
22879 };
22880 const storeBatch = (keys, listener) => {
22881 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
22882 reconcileInitialCleanup(batchListenerGroup, listener, listener(state, prevStateBatch));
22883 return registerListener(keys, listener, batchListenerGroup);
22884 };
22885 const storePick = (keys) => createStore(pick(state, keys), finalStore);
22886 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
22887 const getState = () => state;
22888 const runListeners = (group, prevState, updatedKey) => {
22889 const { disposables } = group;
22890 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
22891 const keyedListeners = group.listenersByKey?.get(updatedKey);
22892 if (!keyedListeners) return;
22893 for (const listener of keyedListeners) {
22894 const cleanup = disposables.size ? disposables.get(listener) : void 0;
22895 if (cleanup) cleanup();
22896 const result = listener(state, prevState);
22897 if (result) disposables.set(listener, result);
22898 else if (cleanup) disposables.delete(listener);
22899 }
22900 return;
22901 }
22902 const allKeysListeners = group.allKeysListeners;
22903 for (const listener of group.listeners) {
22904 if (!allKeysListeners?.has(listener)) {
22905 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
22906 }
22907 const cleanup = disposables.size ? disposables.get(listener) : void 0;
22908 if (cleanup) cleanup();
22909 const result = listener(state, prevState);
22910 if (result) disposables.set(listener, result);
22911 else if (cleanup) disposables.delete(listener);
22912 }
22913 };
22914 const setState = (key, value, fromStores = false) => {
22915 if (!hasOwnProperty(state, key)) return;
22916 const currentValue = state[key];
22917 const nextValue = typeof value === "function" ? value(currentValue) : value;
22918 if (nextValue === currentValue) return;
22919 if (!fromStores && stores.length) for (const store of stores) store?.setState?.(key, nextValue);
22920 const prevState = state;
22921 state = {
22922 ...state,
22923 [key]: nextValue
22924 };
22925 const wasInDispatch = inDispatch;
22926 inDispatch = true;
22927 try {
22928 runListeners(syncListenerGroup, prevState, key);
22929 } finally {
22930 inDispatch = wasInDispatch;
22931 }
22932 if (!batchListenerGroup.listeners.size) {
22933 if (!inDispatch) prevStateBatch = state;
22934 return;
22935 }
22936 updatedKeys.add(key);
22937 if (batchPending) return;
22938 batchPending = true;
22939 queueMicrotask(() => {
22940 batchPending = false;
22941 const snapshot = state;
22942 const updatedKeysSnapshot = updatedKeys;
22943 updatedKeys = /* @__PURE__ */ new Set();
22944 const prevStateBatchBefore = prevStateBatch;
22945 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
22946 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
22947 });
22948 };
22949 const finalStore = {
22950 getState,
22951 setState,
22952 __unstableInternals: {
22953 setup: storeSetup,
22954 init: storeInit,
22955 subscribe: storeSubscribe,
22956 sync: storeSync,
22957 batch: storeBatch,
22958 pick: storePick,
22959 omit: storeOmit
22960 }
22961 };
22962 return finalStore;
22963 }
22964 function setup(store, ...args) {
22965 if (!store) return;
22966 return getInternal(store, "setup")(...args);
22967 }
22968 function init(store, ...args) {
22969 if (!store) return;
22970 return getInternal(store, "init")(...args);
22971 }
22972 function subscribe(store, ...args) {
22973 if (!store) return;
22974 return getInternal(store, "subscribe")(...args);
22975 }
22976 function sync(store, ...args) {
22977 if (!store) return;
22978 return getInternal(store, "sync")(...args);
22979 }
22980 function batch(store, ...args) {
22981 if (!store) return;
22982 return getInternal(store, "batch")(...args);
22983 }
22984 function omit2(store, ...args) {
22985 if (!store) return;
22986 return getInternal(store, "omit")(...args);
22987 }
22988 function pick2(store, ...args) {
22989 if (!store) return;
22990 return getInternal(store, "pick")(...args);
22991 }
22992 function mergeStore(...stores) {
22993 const initialState = {};
22994 for (const store2 of stores) {
22995 const nextState = store2?.getState?.();
22996 if (nextState) Object.assign(initialState, nextState);
22997 }
22998 const store = createStore(initialState, ...stores);
22999 return Object.assign({}, ...stores, store);
23000 }
23001 function throwOnConflictingProps(props, store) {
23002 if (false) return;
23003 if (!store) return;
23004 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
23005 const stateKey = key.replace("default", "");
23006 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
23007 });
23008 if (!defaultKeys.length) return;
23009 const storeState = store.getState();
23010 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
23011 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
23012
23013 const store = useSelectStore();
23014 <SelectProvider store={store} defaultValue="Apple" />
23015 ^ ^
23016
23017 Instead, pass the default state to the topmost store:
23018
23019 const store = useSelectStore({ defaultValue: "Apple" });
23020 <SelectProvider store={store} />
23021
23022 See https://github.com/ariakit/ariakit/pull/2745 for more details.
23023
23024 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
23025 `);
23026 }
23027
23028 // node_modules/@ariakit/react-store/dist/index.js
23029 var React83 = __toESM(require_react(), 1);
23030 var import_shim2 = __toESM(require_shim(), 1);
23031 var noopSubscribe = () => () => {
23032 };
23033 function useStoreState(store, keyOrSelector = identity) {
23034 const storeSubscribe = React83.useCallback((callback) => {
23035 if (!store) return noopSubscribe();
23036 return subscribe(store, null, callback);
23037 }, [store]);
23038 const getSnapshot = () => {
23039 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
23040 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
23041 const state = store?.getState();
23042 if (selector2) return selector2(state);
23043 if (!state) return;
23044 if (!key) return;
23045 if (!hasOwnProperty(state, key)) return;
23046 return state[key];
23047 };
23048 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
23049 }
23050 function useStoreStateObject(store, object) {
23051 const objRef = React83.useRef({});
23052 const storeSubscribe = React83.useCallback((callback) => {
23053 if (!store) return noopSubscribe();
23054 return subscribe(store, null, callback);
23055 }, [store]);
23056 const getSnapshot = () => {
23057 const state = store?.getState();
23058 let updated = false;
23059 const obj = objRef.current;
23060 for (const prop in object) {
23061 const keyOrSelector = object[prop];
23062 if (typeof keyOrSelector === "function") {
23063 const value = keyOrSelector(state);
23064 if (value !== obj[prop]) {
23065 obj[prop] = value;
23066 updated = true;
23067 }
23068 }
23069 if (typeof keyOrSelector === "string") {
23070 if (!state) continue;
23071 if (!hasOwnProperty(state, keyOrSelector)) continue;
23072 const value = state[keyOrSelector];
23073 if (value !== obj[prop]) {
23074 obj[prop] = value;
23075 updated = true;
23076 }
23077 }
23078 }
23079 if (updated) objRef.current = { ...obj };
23080 return objRef.current;
23081 };
23082 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
23083 }
23084 function useStoreProps(store, props, key, setKey) {
23085 const value = hasOwnProperty(props, key) ? props[key] : void 0;
23086 const propsRef = useLiveRef({
23087 value,
23088 setValue: setKey ? props[setKey] : void 0
23089 });
23090 useSafeLayoutEffect(() => {
23091 return sync(store, [key], (state, prev) => {
23092 const { value: value2, setValue } = propsRef.current;
23093 if (!setValue) return;
23094 if (state[key] === prev[key]) return;
23095 if (state[key] === value2) return;
23096 setValue(state[key]);
23097 });
23098 }, [store, key]);
23099 useSafeLayoutEffect(() => {
23100 if (value === void 0) return;
23101 store.setState(key, value);
23102 return batch(store, [key], () => {
23103 if (value === void 0) return;
23104 store.setState(key, value);
23105 });
23106 });
23107 }
23108 function useStore2(createStore2, props) {
23109 const [store, setStore] = React83.useState(() => createStore2(props));
23110 useSafeLayoutEffect(() => init(store), [store]);
23111 const useState55 = React83.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
23112 return [React83.useMemo(() => ({
23113 ...store,
23114 useState: useState55
23115 }), [store, useState55]), useEvent(() => {
23116 setStore((store2) => createStore2({
23117 ...props,
23118 ...store2.getState()
23119 }));
23120 })];
23121 }
23122
23123 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
23124 var TagName4 = "button";
23125 function isEditableElement(element) {
23126 if (isTextbox(element)) return true;
23127 return element.tagName === "INPUT" && !isButton(element);
23128 }
23129 function getNextPageOffset(scrollingElement, pageUp = false) {
23130 const height = scrollingElement.clientHeight;
23131 const { top } = scrollingElement.getBoundingClientRect();
23132 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
23133 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
23134 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
23135 return pageOffset;
23136 }
23137 function getItemOffset(itemElement, pageUp = false) {
23138 const { top } = itemElement.getBoundingClientRect();
23139 if (pageUp) return top + itemElement.clientHeight;
23140 return top;
23141 }
23142 function findNextPageItemId(element, store, next, pageUp = false) {
23143 if (!store) return;
23144 if (!next) return;
23145 const { renderedItems } = store.getState();
23146 const scrollingElement = getScrollingElement(element);
23147 if (!scrollingElement) return;
23148 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
23149 let id;
23150 let prevDifference;
23151 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
23152 const previousId = id;
23153 id = next(i2);
23154 if (!id) break;
23155 if (id === previousId) continue;
23156 const itemElement = getEnabledItem(store, id)?.element;
23157 if (!itemElement) continue;
23158 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
23159 const absDifference = Math.abs(difference);
23160 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
23161 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
23162 break;
23163 }
23164 prevDifference = absDifference;
23165 }
23166 return id;
23167 }
23168 function targetIsAnotherItem(event, store) {
23169 if (isSelfTarget(event)) return false;
23170 return isItem(store, event.target);
23171 }
23172 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable4 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
23173 const context = useCompositeScopedContext();
23174 store = store || context;
23175 const id = useId5(props.id);
23176 const ref = (0, import_react21.useRef)(null);
23177 const row = (0, import_react21.useContext)(CompositeRowContext);
23178 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
23179 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable: isTabbable2 } = useStoreStateObject(store, {
23180 rowId(state) {
23181 if (rowIdProp) return rowIdProp;
23182 if (!state) return;
23183 if (!row?.baseElement) return;
23184 if (row.baseElement !== state.baseElement) return;
23185 return row.id;
23186 },
23187 baseElement(state) {
23188 return state?.baseElement || void 0;
23189 },
23190 isActiveItem(state) {
23191 return !!state && state.activeId === id;
23192 },
23193 ariaSetSize(state) {
23194 if (ariaSetSizeProp != null) return ariaSetSizeProp;
23195 if (!state) return;
23196 if (!row?.ariaSetSize) return;
23197 if (row.baseElement !== state.baseElement) return;
23198 return row.ariaSetSize;
23199 },
23200 ariaPosInSet(state) {
23201 if (ariaPosInSetProp != null) return ariaPosInSetProp;
23202 if (!state) return;
23203 if (!row?.ariaPosInSet) return;
23204 if (row.baseElement !== state.baseElement) return;
23205 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId);
23206 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
23207 },
23208 isTabbable(state) {
23209 if (!state?.renderedItems.length) return true;
23210 if (state.virtualFocus) return false;
23211 if (tabbable4) return true;
23212 if (state.activeId === null) return false;
23213 const item = store?.item(state.activeId);
23214 if (item?.disabled) return true;
23215 if (!item?.element) return true;
23216 return state.activeId === id;
23217 }
23218 });
23219 const getItem = (0, import_react21.useCallback)((item) => {
23220 const nextItem = {
23221 ...item,
23222 id: id || item.id,
23223 rowId,
23224 disabled: trulyDisabled,
23225 children: item.element?.textContent
23226 };
23227 if (getItemProp) return getItemProp(nextItem);
23228 return nextItem;
23229 }, [
23230 id,
23231 rowId,
23232 trulyDisabled,
23233 getItemProp
23234 ]);
23235 const onFocusProp = props.onFocus;
23236 const hasFocusedComposite = (0, import_react21.useRef)(false);
23237 const onFocus = useEvent((event) => {
23238 onFocusProp?.(event);
23239 if (event.defaultPrevented) return;
23240 if (isPortalEvent(event)) return;
23241 if (!id) return;
23242 if (!store) return;
23243 if (targetIsAnotherItem(event, store)) return;
23244 const { virtualFocus, baseElement: baseElement2 } = store.getState();
23245 store.setActiveId(id);
23246 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
23247 if (!virtualFocus) return;
23248 if (!isSelfTarget(event)) return;
23249 if (isEditableElement(event.currentTarget)) return;
23250 if (!baseElement2?.isConnected) return;
23251 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) event.currentTarget.scrollIntoView({
23252 block: "nearest",
23253 inline: "nearest"
23254 });
23255 hasFocusedComposite.current = true;
23256 if (event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget)) focusSilently(baseElement2);
23257 else baseElement2.focus();
23258 });
23259 const onBlurCaptureProp = props.onBlurCapture;
23260 const onBlurCapture = useEvent((event) => {
23261 onBlurCaptureProp?.(event);
23262 if (event.defaultPrevented) return;
23263 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
23264 hasFocusedComposite.current = false;
23265 event.preventDefault();
23266 event.stopPropagation();
23267 }
23268 });
23269 const onKeyDownProp = props.onKeyDown;
23270 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
23271 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
23272 const onKeyDown = useEvent((event) => {
23273 onKeyDownProp?.(event);
23274 if (event.defaultPrevented) return;
23275 if (!isSelfTarget(event)) return;
23276 if (!store) return;
23277 const { currentTarget } = event;
23278 const state = store.getState();
23279 const isGrid2 = !!store.item(id)?.rowId;
23280 const isVertical = state.orientation !== "horizontal";
23281 const isHorizontal = state.orientation !== "vertical";
23282 const canHomeEnd = () => {
23283 if (isGrid2) return true;
23284 if (isHorizontal) return true;
23285 if (!state.baseElement) return true;
23286 if (!isTextField(state.baseElement)) return true;
23287 return false;
23288 };
23289 const action = {
23290 ArrowUp: (isGrid2 || isVertical) && store.up,
23291 ArrowRight: (isGrid2 || isHorizontal) && store.next,
23292 ArrowDown: (isGrid2 || isVertical) && store.down,
23293 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
23294 Home: () => {
23295 if (!canHomeEnd()) return;
23296 if (!isGrid2 || event.ctrlKey) return store?.first();
23297 return store?.previous(-1);
23298 },
23299 End: () => {
23300 if (!canHomeEnd()) return;
23301 if (!isGrid2 || event.ctrlKey) return store?.last();
23302 return store?.next(-1);
23303 },
23304 PageUp: () => {
23305 return findNextPageItemId(currentTarget, store, store?.up, true);
23306 },
23307 PageDown: () => {
23308 return findNextPageItemId(currentTarget, store, store?.down);
23309 }
23310 }[event.key];
23311 if (action) {
23312 if (isTextbox(currentTarget)) {
23313 const selection = getTextboxSelection(currentTarget);
23314 const isLeft = isHorizontal && event.key === "ArrowLeft";
23315 const isRight = isHorizontal && event.key === "ArrowRight";
23316 const isUp = isVertical && event.key === "ArrowUp";
23317 const isDown = isVertical && event.key === "ArrowDown";
23318 if (isRight || isDown) {
23319 const { length: valueLength } = getTextboxValue(currentTarget);
23320 if (selection.end !== valueLength) return;
23321 } else if ((isLeft || isUp) && selection.start !== 0) return;
23322 }
23323 const nextId = action();
23324 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
23325 if (!moveOnKeyPressProp(event)) return;
23326 event.preventDefault();
23327 store.move(nextId);
23328 }
23329 }
23330 });
23331 const providerValue = (0, import_react21.useMemo)(() => ({
23332 id,
23333 baseElement
23334 }), [id, baseElement]);
23335 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(CompositeItemContext.Provider, {
23336 value: providerValue,
23337 children: element
23338 }), [providerValue]);
23339 props = {
23340 "data-active-item": isActiveItem || void 0,
23341 ...props,
23342 id,
23343 ref: useMergeRefs3(ref, props.ref),
23344 tabIndex: isTabbable2 ? props.tabIndex : -1,
23345 onFocus,
23346 onBlurCapture,
23347 onKeyDown
23348 };
23349 props = useCommand(props);
23350 props = useCollectionItem({
23351 store,
23352 ...props,
23353 getItem,
23354 shouldRegisterItem: id ? props.shouldRegisterItem : false
23355 });
23356 return removeUndefinedValues({
23357 ...props,
23358 "aria-setsize": ariaSetSize,
23359 "aria-posinset": ariaPosInSet
23360 });
23361 });
23362 var CompositeItem = memo3(forwardRef70(function CompositeItem2(props) {
23363 return createElement3(TagName4, useCompositeItem(props));
23364 }));
23365
23366 // node_modules/@ariakit/react-components/dist/composite/composite.js
23367 var import_react22 = __toESM(require_react(), 1);
23368 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
23369 var TagName5 = "div";
23370 function isGrid(items) {
23371 return items.some((item) => !!item.rowId);
23372 }
23373 function isPrintableKey(event) {
23374 const target = event.target;
23375 if (target && !isTextField(target)) return false;
23376 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
23377 }
23378 function isModifierKey(event) {
23379 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
23380 }
23381 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
23382 return useEvent((event) => {
23383 onKeyboardEvent?.(event);
23384 if (event.defaultPrevented) return;
23385 if (event.isPropagationStopped()) return;
23386 if (!isSelfTarget(event)) return;
23387 if (isModifierKey(event)) return;
23388 if (isPrintableKey(event)) return;
23389 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
23390 if (!activeElement2) return;
23391 const { view, ...eventInit } = event;
23392 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
23393 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
23394 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
23395 });
23396 }
23397 function findFirstEnabledItemInTheLastRow(items) {
23398 return findFirstEnabledItem(flatten2DArray(reverseArray(groupItemsByRows(items))));
23399 }
23400 function withBaseScrollPreserved(store, callback) {
23401 const { virtualFocus, baseElement } = store.getState();
23402 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
23403 callback();
23404 return;
23405 }
23406 const savedScrollLeft = baseElement.scrollLeft;
23407 const savedScrollTop = baseElement.scrollTop;
23408 callback();
23409 baseElement.scrollLeft = savedScrollLeft;
23410 baseElement.scrollTop = savedScrollTop;
23411 }
23412 function useScheduleFocus(store) {
23413 const [scheduled, setScheduled] = (0, import_react22.useState)(false);
23414 const schedule = (0, import_react22.useCallback)(() => setScheduled(true), []);
23415 const activeItem = useStoreState(store, (state) => getEnabledItem(store, state.activeId));
23416 (0, import_react22.useEffect)(() => {
23417 const activeElement2 = activeItem?.element;
23418 if (!scheduled) return;
23419 if (!activeElement2) return;
23420 setScheduled(false);
23421 withBaseScrollPreserved(store, () => {
23422 activeElement2.focus({ preventScroll: true });
23423 });
23424 }, [
23425 store,
23426 activeItem,
23427 scheduled
23428 ]);
23429 return schedule;
23430 }
23431 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
23432 const context = useCompositeProviderContext();
23433 store = store || context;
23434 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
23435 const ref = (0, import_react22.useRef)(null);
23436 const previousElementRef = (0, import_react22.useRef)(null);
23437 const scheduleFocus = useScheduleFocus(store);
23438 const moves = useStoreState(store, "moves");
23439 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
23440 (0, import_react22.useEffect)(() => {
23441 if (!store) return;
23442 if (!moves) return;
23443 if (!composite) return;
23444 if (!focusOnMove) return;
23445 const { activeId: activeId2 } = store.getState();
23446 const itemElement = getEnabledItem(store, activeId2)?.element;
23447 if (!itemElement) return;
23448 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
23449 }, [
23450 store,
23451 moves,
23452 composite,
23453 focusOnMove
23454 ]);
23455 useSafeLayoutEffect(() => {
23456 if (!store) return;
23457 if (!moves) return;
23458 if (!composite) return;
23459 const { baseElement, activeId: activeId2 } = store.getState();
23460 if (!(activeId2 === null)) return;
23461 if (!baseElement) return;
23462 const previousElement = previousElementRef.current;
23463 previousElementRef.current = null;
23464 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
23465 if (!hasFocus(baseElement)) baseElement.focus();
23466 }, [
23467 store,
23468 moves,
23469 composite
23470 ]);
23471 const activeId = useStoreState(store, "activeId");
23472 const virtualFocus = useStoreState(store, "virtualFocus");
23473 useSafeLayoutEffect(() => {
23474 if (!store) return;
23475 if (!composite) return;
23476 if (!virtualFocus) return;
23477 const previousElement = previousElementRef.current;
23478 previousElementRef.current = null;
23479 if (!previousElement) return;
23480 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
23481 if (relatedTarget === previousElement) return;
23482 fireBlurEvent(previousElement, { relatedTarget });
23483 }, [
23484 store,
23485 activeId,
23486 virtualFocus,
23487 composite
23488 ]);
23489 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
23490 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
23491 const onFocusCaptureProp = props.onFocusCapture;
23492 const onFocusCapture = useEvent((event) => {
23493 onFocusCaptureProp?.(event);
23494 if (event.defaultPrevented) return;
23495 if (!store) return;
23496 const { virtualFocus: virtualFocus2 } = store.getState();
23497 if (!virtualFocus2) return;
23498 const previousActiveElement = event.relatedTarget;
23499 const isSilentlyFocused = silentlyFocused(event.currentTarget);
23500 if (isSelfTarget(event) && isSilentlyFocused) {
23501 event.stopPropagation();
23502 previousElementRef.current = previousActiveElement;
23503 }
23504 });
23505 const onFocusProp = props.onFocus;
23506 const onFocus = useEvent((event) => {
23507 onFocusProp?.(event);
23508 if (event.defaultPrevented) return;
23509 if (!composite) return;
23510 if (!store) return;
23511 const { relatedTarget } = event;
23512 const { virtualFocus: virtualFocus2 } = store.getState();
23513 if (virtualFocus2) {
23514 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
23515 } else if (isSelfTarget(event)) store.setActiveId(null);
23516 });
23517 const onBlurCaptureProp = props.onBlurCapture;
23518 const onBlurCapture = useEvent((event) => {
23519 onBlurCaptureProp?.(event);
23520 if (event.defaultPrevented) return;
23521 if (!store) return;
23522 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
23523 if (!virtualFocus2) return;
23524 const activeElement2 = getEnabledItem(store, activeId2)?.element;
23525 const nextActiveElement = event.relatedTarget;
23526 const nextActiveElementIsItem = isItem(store, nextActiveElement);
23527 const previousElement = previousElementRef.current;
23528 previousElementRef.current = null;
23529 if (isSelfTarget(event) && nextActiveElementIsItem) {
23530 if (nextActiveElement === activeElement2) {
23531 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
23532 } else if (activeElement2) fireBlurEvent(activeElement2, event);
23533 else if (previousElement) fireBlurEvent(previousElement, event);
23534 event.stopPropagation();
23535 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
23536 });
23537 const onKeyDownProp = props.onKeyDown;
23538 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
23539 const onKeyDown = useEvent((event) => {
23540 onKeyDownProp?.(event);
23541 if (event.nativeEvent.isComposing) return;
23542 if (event.defaultPrevented) return;
23543 if (!store) return;
23544 if (!isSelfTarget(event)) return;
23545 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
23546 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
23547 const isVertical = orientation !== "horizontal";
23548 const isHorizontal = orientation !== "vertical";
23549 const grid = isGrid(renderedItems);
23550 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
23551 const up = () => {
23552 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
23553 return store?.last();
23554 };
23555 const action = {
23556 ArrowUp: (grid || isVertical) && up,
23557 ArrowRight: (grid || isHorizontal) && store.first,
23558 ArrowDown: (grid || isVertical) && store.first,
23559 ArrowLeft: (grid || isHorizontal) && store.last,
23560 Home: store.first,
23561 End: store.last,
23562 PageUp: store.first,
23563 PageDown: store.last
23564 }[event.key];
23565 if (action) {
23566 const id = action();
23567 if (id !== void 0) {
23568 if (!moveOnKeyPressProp(event)) return;
23569 event.preventDefault();
23570 store.move(id);
23571 }
23572 }
23573 });
23574 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(CompositeScopedContextProvider, {
23575 value: store,
23576 children: element
23577 }), [store]);
23578 props = {
23579 "aria-activedescendant": useStoreState(store, (state) => {
23580 if (!store) return;
23581 if (!composite) return;
23582 if (!state.virtualFocus) return;
23583 return getEnabledItem(store, state.activeId)?.id;
23584 }),
23585 ...props,
23586 ref: useMergeRefs3(ref, setBaseElement, props.ref),
23587 onKeyDownCapture,
23588 onKeyUpCapture,
23589 onFocusCapture,
23590 onFocus,
23591 onBlurCapture,
23592 onKeyDown
23593 };
23594 props = useFocusable({
23595 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
23596 ...props
23597 });
23598 return props;
23599 });
23600 var Composite6 = forwardRef70(function Composite7(props) {
23601 return createElement3(TagName5, useComposite(props));
23602 });
23603
23604 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
23605 var ctx3 = createStoreContext();
23606 var useDisclosureContext = ctx3.useContext;
23607 var useDisclosureScopedContext = ctx3.useScopedContext;
23608 var useDisclosureProviderContext = ctx3.useProviderContext;
23609 var DisclosureContextProvider = ctx3.ContextProvider;
23610 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
23611
23612 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
23613 var import_react23 = __toESM(require_react(), 1);
23614 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
23615 var useDialogContext = ctx4.useContext;
23616 var useDialogScopedContext = ctx4.useScopedContext;
23617 var useDialogProviderContext = ctx4.useProviderContext;
23618 var DialogContextProvider = ctx4.ContextProvider;
23619 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
23620 var DialogHeadingContext = (0, import_react23.createContext)(void 0);
23621 var DialogDescriptionContext = (0, import_react23.createContext)(void 0);
23622
23623 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
23624 var import_react24 = __toESM(require_react(), 1);
23625 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
23626 var import_react_dom4 = __toESM(require_react_dom(), 1);
23627 var TagName6 = "div";
23628 function afterTimeout(timeoutMs, cb) {
23629 const timeoutId = setTimeout(cb, timeoutMs);
23630 return () => clearTimeout(timeoutId);
23631 }
23632 function afterPaint(cb) {
23633 let raf = requestAnimationFrame(() => {
23634 raf = requestAnimationFrame(cb);
23635 });
23636 return () => cancelAnimationFrame(raf);
23637 }
23638 function parseCSSTime(...times) {
23639 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
23640 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
23641 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
23642 if (currentTime > longestTime) return currentTime;
23643 return longestTime;
23644 }, 0);
23645 }
23646 function isHidden3(mounted, hidden, alwaysVisible) {
23647 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
23648 }
23649 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
23650 const context = useDisclosureProviderContext();
23651 store = store || context;
23652 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
23653 const ref = (0, import_react24.useRef)(null);
23654 const id = useId5(props.id);
23655 const [transition, setTransition] = (0, import_react24.useState)(null);
23656 const open = useStoreState(store, "open");
23657 const mounted = useStoreState(store, "mounted");
23658 const animated = useStoreState(store, "animated");
23659 const contentElement = useStoreState(store, "contentElement");
23660 const otherElement = useStoreState(store.disclosure, "contentElement");
23661 const hasClosedRef = (0, import_react24.useRef)(false);
23662 useSafeLayoutEffect(() => {
23663 if (!ref.current) return;
23664 store?.setContentElement(ref.current);
23665 }, [store]);
23666 useSafeLayoutEffect(() => {
23667 let previousAnimated;
23668 store?.setState("animated", (animated2) => {
23669 previousAnimated = animated2;
23670 return true;
23671 });
23672 return () => {
23673 if (previousAnimated === void 0) return;
23674 store?.setState("animated", previousAnimated);
23675 };
23676 }, [store]);
23677 useSafeLayoutEffect(() => {
23678 if (!animated) {
23679 if (!open) {
23680 hasClosedRef.current = true;
23681 setTransition(null);
23682 } else if (hasClosedRef.current) {
23683 hasClosedRef.current = false;
23684 setTransition("enter");
23685 }
23686 return;
23687 }
23688 if (!contentElement?.isConnected) {
23689 setTransition(null);
23690 return;
23691 }
23692 return afterPaint(() => {
23693 setTransition(open ? "enter" : mounted ? "leave" : null);
23694 });
23695 }, [
23696 animated,
23697 contentElement,
23698 open,
23699 mounted
23700 ]);
23701 useSafeLayoutEffect(() => {
23702 if (!store) return;
23703 if (!animated) return;
23704 if (!transition) return;
23705 if (!contentElement) return;
23706 const stopAnimation = () => store?.setState("animating", false);
23707 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
23708 if (transition === "leave" && open) return;
23709 if (transition === "enter" && !open) return;
23710 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
23711 const { transitionDuration, animationDuration, transitionDelay, animationDelay } = getComputedStyle(contentElement);
23712 const { transitionDuration: transitionDuration2 = "0", animationDuration: animationDuration2 = "0", transitionDelay: transitionDelay2 = "0", animationDelay: animationDelay2 = "0" } = otherElement ? getComputedStyle(otherElement) : {};
23713 const timeout = parseCSSTime(transitionDelay, animationDelay, transitionDelay2, animationDelay2) + parseCSSTime(transitionDuration, animationDuration, transitionDuration2, animationDuration2);
23714 if (!timeout) {
23715 if (transition === "enter") store.setState("animated", false);
23716 stopAnimation();
23717 return;
23718 }
23719 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
23720 }, [
23721 store,
23722 animated,
23723 contentElement,
23724 otherElement,
23725 open,
23726 transition
23727 ]);
23728 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DialogScopedContextProvider, {
23729 value: store,
23730 children: element
23731 }), [store]);
23732 const hidden = isHidden3(mounted, props.hidden, alwaysVisible);
23733 const styleProp = props.style;
23734 const style = (0, import_react24.useMemo)(() => {
23735 if (hidden) return {
23736 ...styleProp,
23737 display: "none"
23738 };
23739 return styleProp;
23740 }, [hidden, styleProp]);
23741 props = {
23742 "data-open": open || void 0,
23743 "data-enter": transition === "enter" || void 0,
23744 "data-leave": transition === "leave" || void 0,
23745 hidden,
23746 ...props,
23747 id,
23748 ref: useMergeRefs3(id ? store.setContentElement : null, ref, props.ref),
23749 style
23750 };
23751 return removeUndefinedValues(props);
23752 });
23753 var DisclosureContentImpl = forwardRef70(function DisclosureContentImpl2(props) {
23754 return createElement3(TagName6, useDisclosureContent(props));
23755 });
23756 var DisclosureContent = forwardRef70(function DisclosureContent2({ unmountOnHide, ...props }) {
23757 const context = useDisclosureProviderContext();
23758 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
23759 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DisclosureContentImpl, { ...props });
23760 });
23761
23762 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
23763 function createDisclosureStore(props = {}) {
23764 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
23765 throwOnConflictingProps(props, store);
23766 const syncState = store?.getState();
23767 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
23768 const animated = defaultValue(props.animated, syncState?.animated, false);
23769 const disclosure = createStore({
23770 open,
23771 animated,
23772 animating: !!animated && open,
23773 mounted: open,
23774 contentElement: defaultValue(syncState?.contentElement, null),
23775 disclosureElement: defaultValue(syncState?.disclosureElement, null)
23776 }, store);
23777 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
23778 if (state.animated) return;
23779 disclosure.setState("animating", false);
23780 }));
23781 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
23782 if (!disclosure.getState().animated) return;
23783 disclosure.setState("animating", true);
23784 }));
23785 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
23786 disclosure.setState("mounted", state.open || state.animating);
23787 }));
23788 return {
23789 ...disclosure,
23790 disclosure: props.disclosure,
23791 setOpen: (value) => disclosure.setState("open", value),
23792 show: () => disclosure.setState("open", true),
23793 hide: () => disclosure.setState("open", false),
23794 toggle: () => disclosure.setState("open", (open2) => !open2),
23795 stopAnimation: () => disclosure.setState("animating", false),
23796 setContentElement: (value) => disclosure.setState("contentElement", value),
23797 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
23798 };
23799 }
23800
23801 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
23802 function useDisclosureStoreProps(store, update2, props) {
23803 useUpdateEffect(update2, [props.store, props.disclosure]);
23804 useStoreProps(store, props, "open", "setOpen");
23805 useStoreProps(store, props, "mounted", "setMounted");
23806 useStoreProps(store, props, "animated");
23807 return Object.assign(store, { disclosure: props.disclosure });
23808 }
23809
23810 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
23811 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
23812 var usePopoverContext = ctx5.useContext;
23813 var usePopoverScopedContext = ctx5.useScopedContext;
23814 var usePopoverProviderContext = ctx5.useProviderContext;
23815 var PopoverContextProvider = ctx5.ContextProvider;
23816 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
23817
23818 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
23819 var import_react25 = __toESM(require_react(), 1);
23820 var ComboboxListRoleContext = (0, import_react25.createContext)(void 0);
23821 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
23822 var useComboboxContext = ctx6.useContext;
23823 var useComboboxScopedContext = ctx6.useScopedContext;
23824 var useComboboxProviderContext = ctx6.useProviderContext;
23825 var ComboboxContextProvider = ctx6.ContextProvider;
23826 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
23827 var ComboboxItemValueContext = (0, import_react25.createContext)(void 0);
23828 var ComboboxItemCheckedContext = (0, import_react25.createContext)(false);
23829
23830 // node_modules/@ariakit/components/dist/collection/collection-store.js
23831 function getCommonParent(items) {
23832 const firstItem = items.find((item) => !!item.element);
23833 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
23834 let parentElement = firstItem?.element?.parentElement;
23835 if (!lastElement) return getDocument(parentElement).body;
23836 while (parentElement) {
23837 if (parentElement.contains(lastElement)) return parentElement;
23838 parentElement = parentElement.parentElement;
23839 }
23840 return getDocument(parentElement).body;
23841 }
23842 function getPrivateStore(store) {
23843 return store?.__unstablePrivateStore;
23844 }
23845 function createCollectionStore(props = {}) {
23846 throwOnConflictingProps(props, props.store);
23847 const syncState = props.store?.getState();
23848 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
23849 const itemsMap = new Map(items.map((item) => [item.id, item]));
23850 const initialState = {
23851 items,
23852 renderedItems: defaultValue(syncState?.renderedItems, [])
23853 };
23854 const syncPrivateStore = getPrivateStore(props.store);
23855 const privateStore = createStore({
23856 items,
23857 renderedItems: initialState.renderedItems
23858 }, syncPrivateStore);
23859 const collection = createStore(initialState, props.store);
23860 const sortItems = (renderedItems) => {
23861 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
23862 privateStore.setState("renderedItems", sortedItems);
23863 collection.setState("renderedItems", sortedItems);
23864 };
23865 setup(collection, () => init(privateStore));
23866 setup(privateStore, () => {
23867 return batch(privateStore, ["items"], (state) => {
23868 collection.setState("items", state.items);
23869 });
23870 });
23871 setup(privateStore, () => {
23872 return batch(privateStore, ["renderedItems"], (state) => {
23873 let firstRun = true;
23874 let raf = requestAnimationFrame(() => {
23875 const { renderedItems } = collection.getState();
23876 if (state.renderedItems === renderedItems) return;
23877 sortItems(state.renderedItems);
23878 });
23879 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
23880 const ioCallback = () => {
23881 if (firstRun) {
23882 firstRun = false;
23883 return;
23884 }
23885 cancelAnimationFrame(raf);
23886 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
23887 };
23888 const root = getCommonParent(state.renderedItems);
23889 const observer = new IntersectionObserver(ioCallback, { root });
23890 for (const item of state.renderedItems) {
23891 if (!item.element) continue;
23892 observer.observe(item.element);
23893 }
23894 return () => {
23895 cancelAnimationFrame(raf);
23896 observer.disconnect();
23897 };
23898 });
23899 });
23900 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
23901 let prevItem;
23902 setItems((items2) => {
23903 const index2 = items2.findIndex(({ id }) => id === item.id);
23904 const nextItems = items2.slice();
23905 if (index2 !== -1) {
23906 prevItem = items2[index2];
23907 const nextItem = {
23908 ...prevItem,
23909 ...item
23910 };
23911 nextItems[index2] = nextItem;
23912 itemsMap.set(item.id, nextItem);
23913 } else {
23914 nextItems.push(item);
23915 itemsMap.set(item.id, item);
23916 }
23917 return nextItems;
23918 });
23919 const unmergeItem = () => {
23920 setItems((items2) => {
23921 if (!prevItem) {
23922 if (canDeleteFromMap) itemsMap.delete(item.id);
23923 return items2.filter(({ id }) => id !== item.id);
23924 }
23925 const index2 = items2.findIndex(({ id }) => id === item.id);
23926 if (index2 === -1) return items2;
23927 const nextItems = items2.slice();
23928 nextItems[index2] = prevItem;
23929 itemsMap.set(item.id, prevItem);
23930 return nextItems;
23931 });
23932 };
23933 return unmergeItem;
23934 };
23935 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
23936 return {
23937 ...collection,
23938 registerItem,
23939 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
23940 item: (id) => {
23941 if (!id) return null;
23942 let item = itemsMap.get(id);
23943 if (!item) {
23944 const { items: items2 } = privateStore.getState();
23945 item = items2.find((item2) => item2.id === id);
23946 if (item) itemsMap.set(id, item);
23947 }
23948 return item || null;
23949 },
23950 __unstablePrivateStore: privateStore
23951 };
23952 }
23953
23954 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
23955 function useCollectionStoreProps(store, update2, props) {
23956 useUpdateEffect(update2, [props.store]);
23957 useStoreProps(store, props, "items", "setItems");
23958 return store;
23959 }
23960
23961 // node_modules/@ariakit/components/dist/composite/composite-store.js
23962 var NULL_ITEM = { id: null };
23963 function findFirstEnabledItem2(items, excludeId) {
23964 return items.find((item) => {
23965 if (excludeId) return !item.disabled && item.id !== excludeId;
23966 return !item.disabled;
23967 });
23968 }
23969 function getEnabledItems(items, excludeId) {
23970 return items.filter((item) => {
23971 if (excludeId) return !item.disabled && item.id !== excludeId;
23972 return !item.disabled;
23973 });
23974 }
23975 function getItemsInRow(items, rowId) {
23976 return items.filter((item) => item.rowId === rowId);
23977 }
23978 function flipItems(items, activeId, shouldInsertNullItem = false) {
23979 const index2 = items.findIndex((item) => item.id === activeId);
23980 return [
23981 ...items.slice(index2 + 1),
23982 ...shouldInsertNullItem ? [NULL_ITEM] : [],
23983 ...items.slice(0, index2)
23984 ];
23985 }
23986 function groupItemsByRows2(items) {
23987 const rows = [];
23988 for (const item of items) {
23989 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
23990 if (row) row.push(item);
23991 else rows.push([item]);
23992 }
23993 return rows;
23994 }
23995 function getMaxRowLength(array) {
23996 let maxLength = 0;
23997 for (const { length } of array) if (length > maxLength) maxLength = length;
23998 return maxLength;
23999 }
24000 function createEmptyItem(rowId) {
24001 return {
24002 id: "__EMPTY_ITEM__",
24003 disabled: true,
24004 rowId
24005 };
24006 }
24007 function normalizeRows(rows, activeId, focusShift) {
24008 const maxLength = getMaxRowLength(rows);
24009 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
24010 const item = row[i2];
24011 if (!item || focusShift && item.disabled) {
24012 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
24013 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
24014 }
24015 }
24016 return rows;
24017 }
24018 function verticalizeItems(items) {
24019 const rows = groupItemsByRows2(items);
24020 const maxLength = getMaxRowLength(rows);
24021 const verticalized = [];
24022 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
24023 const item = row[i2];
24024 if (item) verticalized.push({
24025 ...item,
24026 rowId: item.rowId ? `${i2}` : void 0
24027 });
24028 }
24029 return verticalized;
24030 }
24031 function createCompositeStore(props = {}) {
24032 const syncState = props.store?.getState();
24033 const collection = createCollectionStore(props);
24034 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
24035 const composite = createStore({
24036 ...collection.getState(),
24037 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
24038 activeId,
24039 baseElement: defaultValue(syncState?.baseElement, null),
24040 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
24041 moves: defaultValue(syncState?.moves, 0),
24042 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
24043 rtl: defaultValue(props.rtl, syncState?.rtl, false),
24044 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
24045 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
24046 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
24047 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
24048 }, collection, props.store);
24049 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
24050 composite.setState("activeId", (activeId2) => {
24051 if (activeId2 !== void 0) return activeId2;
24052 return findFirstEnabledItem2(state.renderedItems)?.id;
24053 });
24054 }));
24055 const getNextId = (direction = "next", options = {}) => {
24056 const defaultState = composite.getState();
24057 const { skip = 0, activeId: activeId2 = defaultState.activeId, focusShift = defaultState.focusShift, focusLoop = defaultState.focusLoop, focusWrap = defaultState.focusWrap, includesBaseElement = defaultState.includesBaseElement, renderedItems = defaultState.renderedItems, rtl = defaultState.rtl } = options;
24058 const isVerticalDirection = direction === "up" || direction === "down";
24059 const isNextDirection = direction === "next" || direction === "down";
24060 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
24061 const canShift = focusShift && !skip;
24062 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift));
24063 items = canReverse ? reverseArray(items) : items;
24064 items = isVerticalDirection ? verticalizeItems(items) : items;
24065 if (activeId2 == null) return findFirstEnabledItem2(items)?.id;
24066 const activeItem = items.find((item) => item.id === activeId2);
24067 if (!activeItem) return findFirstEnabledItem2(items)?.id;
24068 const isGrid2 = items.some((item) => item.rowId);
24069 const activeIndex = items.indexOf(activeItem);
24070 const nextItems = items.slice(activeIndex + 1);
24071 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
24072 if (skip) {
24073 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
24074 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
24075 }
24076 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
24077 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
24078 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
24079 if (canLoop) return findFirstEnabledItem2(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
24080 if (canWrap) {
24081 const nextItem2 = findFirstEnabledItem2(hasNullItem ? nextItemsInRow : nextItems, activeId2);
24082 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
24083 }
24084 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
24085 if (!nextItem && hasNullItem) return null;
24086 return nextItem?.id;
24087 };
24088 return {
24089 ...collection,
24090 ...composite,
24091 setBaseElement: (element) => composite.setState("baseElement", element),
24092 setActiveId: (id) => composite.setState("activeId", id),
24093 move: (id) => {
24094 if (id === void 0) return;
24095 composite.setState("activeId", id);
24096 composite.setState("moves", (moves) => moves + 1);
24097 },
24098 first: () => findFirstEnabledItem2(composite.getState().renderedItems)?.id,
24099 last: () => findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))?.id,
24100 next: (options) => {
24101 if (options !== void 0 && typeof options === "number") options = { skip: options };
24102 return getNextId("next", options);
24103 },
24104 previous: (options) => {
24105 if (options !== void 0 && typeof options === "number") options = { skip: options };
24106 return getNextId("previous", options);
24107 },
24108 down: (options) => {
24109 if (options !== void 0 && typeof options === "number") options = { skip: options };
24110 return getNextId("down", options);
24111 },
24112 up: (options) => {
24113 if (options !== void 0 && typeof options === "number") options = { skip: options };
24114 return getNextId("up", options);
24115 }
24116 };
24117 }
24118
24119 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
24120 function useCompositeStoreOptions(props) {
24121 return {
24122 id: useId5(props.id),
24123 ...props
24124 };
24125 }
24126 function useCompositeStoreProps(store, update2, props) {
24127 store = useCollectionStoreProps(store, update2, props);
24128 useStoreProps(store, props, "activeId", "setActiveId");
24129 useStoreProps(store, props, "includesBaseElement");
24130 useStoreProps(store, props, "virtualFocus");
24131 useStoreProps(store, props, "orientation");
24132 useStoreProps(store, props, "rtl");
24133 useStoreProps(store, props, "focusLoop");
24134 useStoreProps(store, props, "focusWrap");
24135 useStoreProps(store, props, "focusShift");
24136 return store;
24137 }
24138
24139 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
24140 function createDialogStore(props = {}) {
24141 return createDisclosureStore(props);
24142 }
24143
24144 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
24145 function useDialogStoreProps(store, update2, props) {
24146 return useDisclosureStoreProps(store, update2, props);
24147 }
24148
24149 // node_modules/@ariakit/components/dist/popover/popover-store.js
24150 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
24151 const store = mergeStore(props.store, omit2(otherPopover, [
24152 "arrowElement",
24153 "anchorElement",
24154 "contentElement",
24155 "popoverElement",
24156 "disclosureElement"
24157 ]));
24158 throwOnConflictingProps(props, store);
24159 const syncState = store?.getState();
24160 const dialog = createDialogStore({
24161 ...props,
24162 store
24163 });
24164 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
24165 const popover = createStore({
24166 ...dialog.getState(),
24167 placement,
24168 currentPlacement: placement,
24169 anchorElement: defaultValue(syncState?.anchorElement, null),
24170 popoverElement: defaultValue(syncState?.popoverElement, null),
24171 arrowElement: defaultValue(syncState?.arrowElement, null),
24172 rendered: /* @__PURE__ */ Symbol("rendered")
24173 }, dialog, store);
24174 return {
24175 ...dialog,
24176 ...popover,
24177 setAnchorElement: (element) => popover.setState("anchorElement", element),
24178 setPopoverElement: (element) => popover.setState("popoverElement", element),
24179 setArrowElement: (element) => popover.setState("arrowElement", element),
24180 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
24181 };
24182 }
24183
24184 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
24185 function usePopoverStoreProps(store, update2, props) {
24186 useUpdateEffect(update2, [props.popover]);
24187 useStoreProps(store, props, "placement");
24188 return useDialogStoreProps(store, update2, props);
24189 }
24190
24191 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
24192 var TagName7 = "div";
24193 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
24194 const context = usePopoverProviderContext();
24195 store = store || context;
24196 props = {
24197 ...props,
24198 ref: useMergeRefs3(store?.setAnchorElement, props.ref)
24199 };
24200 return props;
24201 });
24202 var PopoverAnchor = forwardRef70(function PopoverAnchor2(props) {
24203 return createElement3(TagName7, usePopoverAnchor(props));
24204 });
24205
24206 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
24207 var import_react26 = __toESM(require_react(), 1);
24208 var TagName8 = "div";
24209 function hoveringInside(event) {
24210 const nextElement = event.relatedTarget;
24211 if (!isElement2(nextElement)) return false;
24212 return contains2(event.currentTarget, nextElement);
24213 }
24214 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
24215 function movingToAnotherItem(event) {
24216 const { relatedTarget } = event;
24217 if (!isElement2(relatedTarget)) return false;
24218 let dest = relatedTarget;
24219 do {
24220 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
24221 dest = dest.parentElement;
24222 } while (dest);
24223 return false;
24224 }
24225 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
24226 const context = useCompositeScopedContext();
24227 store = store || context;
24228 invariant(store, "CompositeHover must be wrapped in a Composite component.");
24229 const isMouseMoving = useIsMouseMoving();
24230 const onMouseMoveProp = props.onMouseMove;
24231 const focusOnHoverProp = useBooleanEvent(focusOnHover);
24232 const onMouseMove = useEvent((event) => {
24233 onMouseMoveProp?.(event);
24234 if (event.defaultPrevented) return;
24235 if (!isMouseMoving()) return;
24236 if (!focusOnHoverProp(event)) return;
24237 if (!hasFocusWithin(event.currentTarget)) {
24238 const baseElement = store?.getState().baseElement;
24239 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
24240 }
24241 store?.setActiveId(event.currentTarget.id);
24242 });
24243 const onMouseLeaveProp = props.onMouseLeave;
24244 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
24245 const onMouseLeave = useEvent((event) => {
24246 onMouseLeaveProp?.(event);
24247 if (event.defaultPrevented) return;
24248 if (!isMouseMoving()) return;
24249 if (hoveringInside(event)) return;
24250 if (movingToAnotherItem(event)) return;
24251 if (!focusOnHoverProp(event)) return;
24252 if (!blurOnHoverEndProp(event)) return;
24253 store?.setActiveId(null);
24254 store?.getState().baseElement?.focus();
24255 });
24256 const ref = (0, import_react26.useCallback)((element) => {
24257 if (!element) return;
24258 element[symbol2] = true;
24259 }, []);
24260 props = {
24261 ...props,
24262 ref: useMergeRefs3(ref, props.ref),
24263 onMouseMove,
24264 onMouseLeave
24265 };
24266 return removeUndefinedValues(props);
24267 });
24268 var CompositeHover = memo3(forwardRef70(function CompositeHover2(props) {
24269 return createElement3(TagName8, useCompositeHover(props));
24270 }));
24271
24272 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
24273 var import_react27 = __toESM(require_react(), 1);
24274 var TagName9 = "input";
24275 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
24276 if (!autoSelect) return false;
24277 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
24278 }
24279 function hasCompletionString(value, activeValue) {
24280 if (!activeValue) return false;
24281 if (value == null) return false;
24282 value = normalizeString(value);
24283 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
24284 }
24285 function isInputEvent(event) {
24286 return event.type === "input";
24287 }
24288 function isAriaAutoCompleteValue(value) {
24289 return value === "inline" || value === "list" || value === "both" || value === "none";
24290 }
24291 function getDefaultAutoSelectId(items) {
24292 return items.find((item) => {
24293 if (item.disabled) return false;
24294 return item.element?.getAttribute("role") !== "tab";
24295 })?.id;
24296 }
24297 var useCombobox = createHook(function useCombobox2({ store, focusable: focusable2 = true, autoSelect: autoSelectProp = false, getAutoSelectId, setValueOnChange, showMinLength = 0, showOnChange, showOnMouseDown, showOnClick = showOnMouseDown, showOnKeyDown, showOnKeyPress = showOnKeyDown, blurActiveItemOnClick, setValueOnClick = true, moveOnKeyPress = true, autoComplete = "list", ...props }) {
24298 const context = useComboboxProviderContext();
24299 store = store || context;
24300 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
24301 const ref = (0, import_react27.useRef)(null);
24302 const [valueUpdated, forceValueUpdate] = useForceUpdate();
24303 const canAutoSelectRef = (0, import_react27.useRef)(false);
24304 const composingRef = (0, import_react27.useRef)(false);
24305 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
24306 const inline4 = autoComplete === "inline" || autoComplete === "both";
24307 const [canInline, setCanInline] = (0, import_react27.useState)(inline4);
24308 useUpdateLayoutEffect(() => {
24309 if (!inline4) return;
24310 setCanInline(true);
24311 }, [inline4]);
24312 const storeValue = useStoreState(store, "value");
24313 const prevSelectedValueRef = (0, import_react27.useRef)(void 0);
24314 (0, import_react27.useEffect)(() => {
24315 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
24316 prevSelectedValueRef.current = prev.selectedValue;
24317 });
24318 }, [store]);
24319 const inlineActiveValue = useStoreState(store, (state) => {
24320 if (!inline4) return;
24321 if (!canInline) return;
24322 if (state.activeValue && Array.isArray(state.selectedValue)) {
24323 if (state.selectedValue.includes(state.activeValue)) return;
24324 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
24325 }
24326 return state.activeValue;
24327 });
24328 const items = useStoreState(store, "renderedItems");
24329 const open = useStoreState(store, "open");
24330 const contentElement = useStoreState(store, "contentElement");
24331 const value = (0, import_react27.useMemo)(() => {
24332 if (!inline4) return storeValue;
24333 if (!canInline) return storeValue;
24334 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
24335 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
24336 return storeValue;
24337 }
24338 return inlineActiveValue || storeValue;
24339 }, [
24340 inline4,
24341 canInline,
24342 items,
24343 inlineActiveValue,
24344 autoSelect,
24345 storeValue
24346 ]);
24347 (0, import_react27.useEffect)(() => {
24348 const element = ref.current;
24349 if (!element) return;
24350 const onCompositeItemMove = () => setCanInline(true);
24351 element.addEventListener("combobox-item-move", onCompositeItemMove);
24352 return () => {
24353 element.removeEventListener("combobox-item-move", onCompositeItemMove);
24354 };
24355 }, []);
24356 (0, import_react27.useEffect)(() => {
24357 if (!inline4) return;
24358 if (!canInline) return;
24359 if (!inlineActiveValue) return;
24360 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
24361 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
24362 let cleanup = noop4;
24363 queueMicrotask(() => {
24364 const element = ref.current;
24365 if (!element) return;
24366 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
24367 const nextStart = storeValue.length;
24368 const nextEnd = inlineActiveValue.length;
24369 setSelectionRange(element, nextStart, nextEnd);
24370 cleanup = () => {
24371 if (!hasFocus(element)) return;
24372 const { start, end } = getTextboxSelection(element);
24373 if (start !== nextStart) return;
24374 if (end !== nextEnd) return;
24375 setSelectionRange(element, prevStart, prevEnd);
24376 };
24377 });
24378 return () => cleanup();
24379 }, [
24380 valueUpdated,
24381 inline4,
24382 canInline,
24383 inlineActiveValue,
24384 items,
24385 autoSelect,
24386 storeValue
24387 ]);
24388 const scrollingElementRef = (0, import_react27.useRef)(null);
24389 const getAutoSelectIdProp = useEvent(getAutoSelectId);
24390 const autoSelectIdRef = (0, import_react27.useRef)(null);
24391 const autoSelectMovedRef = (0, import_react27.useRef)(void 0);
24392 const userScrolledRef = (0, import_react27.useRef)(false);
24393 const isAutoScrollingRef = (0, import_react27.useRef)(false);
24394 (0, import_react27.useEffect)(() => {
24395 if (!open) return;
24396 if (!contentElement) return;
24397 const scrollingElement = getScrollingElement(contentElement);
24398 if (!scrollingElement) return;
24399 scrollingElementRef.current = scrollingElement;
24400 const onUserScroll = () => {
24401 canAutoSelectRef.current = false;
24402 userScrolledRef.current = true;
24403 };
24404 const onScroll = () => {
24405 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
24406 if (!store) return;
24407 if (!canAutoSelectRef.current) return;
24408 const { activeId } = store.getState();
24409 if (activeId === null) return;
24410 if (activeId === autoSelectIdRef.current) return;
24411 canAutoSelectRef.current = false;
24412 };
24413 const options = {
24414 passive: true,
24415 capture: true
24416 };
24417 scrollingElement.addEventListener("wheel", onUserScroll, options);
24418 scrollingElement.addEventListener("touchmove", onUserScroll, options);
24419 scrollingElement.addEventListener("scroll", onScroll, options);
24420 return () => {
24421 scrollingElement.removeEventListener("wheel", onUserScroll, true);
24422 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
24423 scrollingElement.removeEventListener("scroll", onScroll, true);
24424 };
24425 }, [
24426 open,
24427 contentElement,
24428 store
24429 ]);
24430 useSafeLayoutEffect(() => {
24431 userScrolledRef.current = false;
24432 if (!storeValue) return;
24433 if (composingRef.current) return;
24434 canAutoSelectRef.current = true;
24435 }, [storeValue]);
24436 useSafeLayoutEffect(() => {
24437 if (autoSelect !== "always" && open) return;
24438 canAutoSelectRef.current = open;
24439 }, [autoSelect, open]);
24440 useSafeLayoutEffect(() => {
24441 if (open) return;
24442 autoSelectMovedRef.current = void 0;
24443 }, [open]);
24444 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
24445 useUpdateEffect(() => {
24446 const canAutoSelect = canAutoSelectRef.current;
24447 if (!store) return;
24448 if (!open) return;
24449 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
24450 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
24451 if (baseElement && !hasFocus(baseElement)) return;
24452 if (contentElement2?.hasAttribute("data-placing")) {
24453 const observer = new MutationObserver(forceValueUpdate);
24454 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
24455 return () => observer.disconnect();
24456 }
24457 if (autoSelect && canAutoSelect) {
24458 const userAutoSelectId = getAutoSelectIdProp(items);
24459 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
24460 autoSelectIdRef.current = autoSelectId;
24461 const nextActiveId = autoSelectId ?? null;
24462 const nextActiveValue = store.item(nextActiveId)?.value;
24463 const moved = autoSelectMovedRef.current;
24464 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
24465 autoSelectMovedRef.current = {
24466 id: nextActiveId,
24467 value: nextActiveValue
24468 };
24469 store.move(nextActiveId);
24470 } else store.setState("activeValue", nextActiveValue);
24471 } else {
24472 const element = store.item(activeId || store.first())?.element;
24473 if (element && "scrollIntoView" in element) {
24474 isAutoScrollingRef.current = true;
24475 element.scrollIntoView({
24476 block: "nearest",
24477 inline: "nearest"
24478 });
24479 requestAnimationFrame(() => {
24480 isAutoScrollingRef.current = false;
24481 });
24482 }
24483 }
24484 }, [
24485 store,
24486 open,
24487 valueUpdated,
24488 storeValue,
24489 autoSelect,
24490 resetValueOnSelect,
24491 getAutoSelectIdProp,
24492 items
24493 ]);
24494 (0, import_react27.useEffect)(() => {
24495 if (!inline4) return;
24496 const combobox = ref.current;
24497 if (!combobox) return;
24498 const elements = [combobox, contentElement].filter((value2) => !!value2);
24499 const onBlur2 = (event) => {
24500 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
24501 };
24502 for (const element of elements) element.addEventListener("focusout", onBlur2);
24503 return () => {
24504 for (const element of elements) element.removeEventListener("focusout", onBlur2);
24505 };
24506 }, [
24507 inline4,
24508 contentElement,
24509 store,
24510 value
24511 ]);
24512 const canShow = (event) => {
24513 return event.currentTarget.value.length >= showMinLength;
24514 };
24515 const onChangeProp = props.onChange;
24516 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
24517 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
24518 const onChange = useEvent((event) => {
24519 onChangeProp?.(event);
24520 if (event.defaultPrevented) return;
24521 if (!store) return;
24522 const currentTarget = event.currentTarget;
24523 const { value: value2, selectionStart, selectionEnd } = currentTarget;
24524 const nativeEvent = event.nativeEvent;
24525 canAutoSelectRef.current = true;
24526 if (isInputEvent(nativeEvent)) {
24527 if (nativeEvent.isComposing) {
24528 canAutoSelectRef.current = false;
24529 composingRef.current = true;
24530 }
24531 if (inline4) {
24532 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
24533 const caretAtEnd = selectionStart === value2.length;
24534 setCanInline(textInserted && caretAtEnd);
24535 }
24536 }
24537 if (setValueOnChangeProp(event)) {
24538 const isSameValue = value2 === store.getState().value;
24539 store.setValue(value2);
24540 queueMicrotask(() => {
24541 setSelectionRange(currentTarget, selectionStart, selectionEnd);
24542 });
24543 if (inline4 && autoSelect && isSameValue) forceValueUpdate();
24544 }
24545 if (showOnChangeProp(event)) store.show();
24546 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
24547 });
24548 const onCompositionEndProp = props.onCompositionEnd;
24549 const onCompositionEnd = useEvent((event) => {
24550 canAutoSelectRef.current = true;
24551 composingRef.current = false;
24552 onCompositionEndProp?.(event);
24553 if (event.defaultPrevented) return;
24554 if (!autoSelect) return;
24555 forceValueUpdate();
24556 });
24557 const onMouseDownProp = props.onMouseDown;
24558 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
24559 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
24560 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
24561 const onMouseDown = useEvent((event) => {
24562 onMouseDownProp?.(event);
24563 if (event.defaultPrevented) return;
24564 if (event.button) return;
24565 if (event.ctrlKey) return;
24566 if (!store) return;
24567 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
24568 if (setValueOnClickProp(event)) store.setValue(value);
24569 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
24570 });
24571 const onKeyDownProp = props.onKeyDown;
24572 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
24573 const onKeyDown = useEvent((event) => {
24574 onKeyDownProp?.(event);
24575 if (!event.repeat) canAutoSelectRef.current = false;
24576 if (event.defaultPrevented) return;
24577 if (!store) return;
24578 const { open: open2 } = store.getState();
24579 if (open2 && event.key === "Enter") {
24580 event.preventDefault();
24581 return;
24582 }
24583 if (event.ctrlKey) return;
24584 if (event.altKey) return;
24585 if (event.shiftKey) return;
24586 if (event.metaKey) return;
24587 if (open2) return;
24588 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
24589 if (showOnKeyPressProp(event)) {
24590 event.preventDefault();
24591 store.show();
24592 }
24593 }
24594 });
24595 const onBlurProp = props.onBlur;
24596 const onBlur = useEvent((event) => {
24597 canAutoSelectRef.current = false;
24598 onBlurProp?.(event);
24599 if (event.defaultPrevented) return;
24600 });
24601 const id = useId5(props.id);
24602 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
24603 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
24604 props = {
24605 role: "combobox",
24606 "aria-autocomplete": ariaAutoComplete,
24607 "aria-haspopup": getPopupRole(contentElement, "listbox"),
24608 "aria-expanded": open,
24609 "aria-controls": contentElement?.id,
24610 "data-active-item": isActiveItem || void 0,
24611 value,
24612 ...props,
24613 id,
24614 ref: useMergeRefs3(ref, props.ref),
24615 onChange,
24616 onCompositionEnd,
24617 onMouseDown,
24618 onKeyDown,
24619 onBlur
24620 };
24621 props = useComposite({
24622 store,
24623 focusable: focusable2,
24624 ...props,
24625 moveOnKeyPress: (event) => {
24626 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
24627 if (inline4) setCanInline(true);
24628 return true;
24629 }
24630 });
24631 props = usePopoverAnchor({
24632 store,
24633 ...props
24634 });
24635 return {
24636 autoComplete: "off",
24637 ...props
24638 };
24639 });
24640 var Combobox = forwardRef70(function Combobox2(props) {
24641 return createElement3(TagName9, useCombobox(props));
24642 });
24643
24644 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
24645 var import_react28 = __toESM(require_react(), 1);
24646 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
24647 var TagName10 = "div";
24648 function isSelected(storeValue, itemValue) {
24649 if (itemValue == null) return;
24650 if (storeValue == null) return false;
24651 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
24652 return storeValue === itemValue;
24653 }
24654 function getItemRole(popupRole) {
24655 return {
24656 menu: "menuitem",
24657 listbox: "option",
24658 tree: "treeitem"
24659 }[popupRole] ?? "option";
24660 }
24661 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
24662 const context = useComboboxScopedContext();
24663 store = store || context;
24664 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
24665 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
24666 resetValueOnSelectState: "resetValueOnSelect",
24667 multiSelectable(state) {
24668 return Array.isArray(state.selectedValue);
24669 },
24670 selected(state) {
24671 return isSelected(state.selectedValue, value);
24672 }
24673 });
24674 const getItem = (0, import_react28.useCallback)((item) => {
24675 const nextItem = {
24676 ...item,
24677 value
24678 };
24679 if (getItemProp) return getItemProp(nextItem);
24680 return nextItem;
24681 }, [value, getItemProp]);
24682 setValueOnClick = setValueOnClick ?? !multiSelectable;
24683 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
24684 const onClickProp = props.onClick;
24685 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
24686 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
24687 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
24688 const hideOnClickProp = useBooleanEvent(hideOnClick);
24689 const onClick = useEvent((event) => {
24690 onClickProp?.(event);
24691 if (event.defaultPrevented) return;
24692 if (isDownloading(event)) return;
24693 if (isOpeningInNewTab(event)) return;
24694 if (value != null) {
24695 if (selectValueOnClickProp(event)) {
24696 if (resetValueOnSelectProp(event)) store?.resetValue();
24697 store?.setSelectedValue((prevValue) => {
24698 if (!Array.isArray(prevValue)) return value;
24699 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
24700 return [...prevValue, value];
24701 });
24702 }
24703 if (setValueOnClickProp(event)) store?.setValue(value);
24704 }
24705 if (hideOnClickProp(event)) store?.hide();
24706 });
24707 const onKeyDownProp = props.onKeyDown;
24708 const onKeyDown = useEvent((event) => {
24709 onKeyDownProp?.(event);
24710 if (event.defaultPrevented) return;
24711 const baseElement = store?.getState().baseElement;
24712 if (!baseElement) return;
24713 if (hasFocus(baseElement)) return;
24714 if (event.key.length === 1 || event.key === "Backspace" || event.key === "Delete") {
24715 queueMicrotask(() => baseElement.focus());
24716 if (isTextField(baseElement)) store?.setValue(baseElement.value);
24717 }
24718 });
24719 if (multiSelectable && selected != null) props = {
24720 "aria-selected": selected,
24721 ...props
24722 };
24723 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(ComboboxItemValueContext.Provider, {
24724 value,
24725 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(ComboboxItemCheckedContext.Provider, {
24726 value: selected ?? false,
24727 children: element
24728 })
24729 }), [value, selected]);
24730 props = {
24731 role: getItemRole((0, import_react28.useContext)(ComboboxListRoleContext)),
24732 children: value,
24733 ...props,
24734 onClick,
24735 onKeyDown
24736 };
24737 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
24738 props = useCompositeItem({
24739 store,
24740 ...props,
24741 getItem,
24742 moveOnKeyPress: (event) => {
24743 if (!moveOnKeyPressProp(event)) return false;
24744 const moveEvent = new Event("combobox-item-move");
24745 store?.getState().baseElement?.dispatchEvent(moveEvent);
24746 return true;
24747 }
24748 });
24749 props = useCompositeHover({
24750 store,
24751 focusOnHover,
24752 ...props
24753 });
24754 return props;
24755 });
24756 var ComboboxItem = memo3(forwardRef70(function ComboboxItem2(props) {
24757 return createElement3(TagName10, useComboboxItem(props));
24758 }));
24759
24760 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
24761 var import_react29 = __toESM(require_react(), 1);
24762 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
24763 var TagName11 = "span";
24764 function normalizeValue(value) {
24765 return normalizeString(value).toLowerCase();
24766 }
24767 function getOffsets(string, values) {
24768 const offsets = [];
24769 for (const value of values) {
24770 let pos = 0;
24771 const length = value.length;
24772 while (string.indexOf(value, pos) !== -1) {
24773 const index2 = string.indexOf(value, pos);
24774 if (index2 !== -1) offsets.push([index2, length]);
24775 pos = index2 + 1;
24776 }
24777 }
24778 return offsets;
24779 }
24780 function filterOverlappingOffsets(offsets) {
24781 return offsets.filter(([offset4, length], i2, arr) => {
24782 return !arr.some(([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length);
24783 });
24784 }
24785 function sortOffsets(offsets) {
24786 return offsets.sort(([a2], [b2]) => a2 - b2);
24787 }
24788 function splitValue(itemValue, userValue) {
24789 if (!itemValue) return itemValue;
24790 if (!userValue) return itemValue;
24791 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
24792 const parts = [];
24793 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("span", {
24794 "data-autocomplete-value": autocomplete ? "" : void 0,
24795 "data-user-value": autocomplete ? void 0 : "",
24796 children: value
24797 }, parts.length);
24798 const offsets = sortOffsets(filterOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
24799 const firstEntry = offsets[0];
24800 if (!firstEntry) {
24801 parts.push(span(itemValue, true));
24802 return parts;
24803 }
24804 const [firstOffset] = firstEntry;
24805 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
24806 const value = itemValue.slice(offset4, offset4 + length);
24807 const nextOffset = offsets[i2 + 1]?.[0];
24808 return [value, itemValue.slice(offset4 + length, nextOffset)];
24809 })].forEach((value, i2) => {
24810 if (!value) return;
24811 parts.push(span(value, i2 % 2 === 0));
24812 });
24813 return parts;
24814 }
24815 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
24816 const context = useComboboxScopedContext();
24817 store = store || context;
24818 const itemContext = (0, import_react29.useContext)(ComboboxItemValueContext);
24819 const itemValue = value ?? itemContext;
24820 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
24821 props = {
24822 children: (0, import_react29.useMemo)(() => {
24823 if (!itemValue) return;
24824 if (!inputValue) return itemValue;
24825 return splitValue(itemValue, inputValue);
24826 }, [itemValue, inputValue]),
24827 ...props
24828 };
24829 return removeUndefinedValues(props);
24830 });
24831 var ComboboxItemValue = forwardRef70(function ComboboxItemValue2(props) {
24832 return createElement3(TagName11, useComboboxItemValue(props));
24833 });
24834
24835 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
24836 var TagName12 = "label";
24837 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
24838 const context = useComboboxProviderContext();
24839 store = store || context;
24840 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
24841 props = {
24842 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
24843 ...props
24844 };
24845 return removeUndefinedValues(props);
24846 });
24847 var ComboboxLabel = memo3(forwardRef70(function ComboboxLabel2(props) {
24848 return createElement3(TagName12, useComboboxLabel(props));
24849 }));
24850
24851 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
24852 var import_react30 = __toESM(require_react(), 1);
24853 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
24854 var TagName13 = "div";
24855 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
24856 const scopedContext = useComboboxScopedContext(true);
24857 const context = useComboboxContext();
24858 store = store || context;
24859 const scopedContextSameStore = !!store && store === scopedContext;
24860 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
24861 const ref = (0, import_react30.useRef)(null);
24862 const id = useId5(props.id);
24863 const mounted = useStoreState(store, "mounted");
24864 const hidden = isHidden3(mounted, props.hidden, alwaysVisible);
24865 const style = hidden ? {
24866 ...props.style,
24867 display: "none"
24868 } : props.style;
24869 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
24870 const role = useAttribute(ref, "role", props.role);
24871 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
24872 const [hasListboxInside, setHasListboxInside] = (0, import_react30.useState)(false);
24873 const contentElement = useStoreState(store, "contentElement");
24874 useSafeLayoutEffect(() => {
24875 if (!mounted) return;
24876 const element = ref.current;
24877 if (!element) return;
24878 if (contentElement !== element) return;
24879 const callback = () => {
24880 setHasListboxInside(!!element.querySelector("[role='listbox']"));
24881 };
24882 const observer = new MutationObserver(callback);
24883 observer.observe(element, {
24884 subtree: true,
24885 childList: true,
24886 attributeFilter: ["role"]
24887 });
24888 callback();
24889 return () => observer.disconnect();
24890 }, [mounted, contentElement]);
24891 if (!hasListboxInside) props = {
24892 role: "listbox",
24893 "aria-multiselectable": ariaMultiSelectable,
24894 ...props
24895 };
24896 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ComboboxScopedContextProvider, {
24897 value: store,
24898 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ComboboxListRoleContext.Provider, {
24899 value: role,
24900 children: element
24901 })
24902 }), [store, role]);
24903 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
24904 props = {
24905 hidden,
24906 ...props,
24907 id,
24908 ref: useMergeRefs3(setContentElement, ref, props.ref),
24909 style
24910 };
24911 return removeUndefinedValues(props);
24912 });
24913 var ComboboxList = forwardRef70(function ComboboxList2(props) {
24914 return createElement3(TagName13, useComboboxList(props));
24915 });
24916
24917 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
24918 var import_react31 = __toESM(require_react(), 1);
24919 var TagValueContext = (0, import_react31.createContext)(null);
24920 var TagRemoveIdContext = (0, import_react31.createContext)(null);
24921 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
24922 var useTagContext = ctx7.useContext;
24923 var useTagScopedContext = ctx7.useScopedContext;
24924 var useTagProviderContext = ctx7.useProviderContext;
24925 var TagContextProvider = ctx7.ContextProvider;
24926 var TagScopedContextProvider = ctx7.ScopedContextProvider;
24927
24928 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
24929 var isTouchSafari = isSafari2() && isTouchDevice();
24930 function createComboboxStore({ tag, ...props } = {}) {
24931 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
24932 throwOnConflictingProps(props, store);
24933 const tagState = tag?.getState();
24934 const syncState = store?.getState();
24935 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
24936 const composite = createCompositeStore({
24937 ...props,
24938 activeId,
24939 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
24940 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
24941 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
24942 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
24943 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
24944 });
24945 const popover = createPopoverStore({
24946 ...props,
24947 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
24948 });
24949 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
24950 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
24951 const multiSelectable = Array.isArray(selectedValue);
24952 const initialState = {
24953 ...composite.getState(),
24954 ...popover.getState(),
24955 value,
24956 selectedValue,
24957 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
24958 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
24959 activeValue: syncState?.activeValue
24960 };
24961 const combobox = createStore(initialState, composite, popover, store);
24962 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
24963 combobox.setState("virtualFocus", false);
24964 }));
24965 setup(combobox, () => {
24966 if (!tag) return;
24967 return chain(sync(combobox, ["selectedValue"], (state) => {
24968 if (!Array.isArray(state.selectedValue)) return;
24969 tag.setValues(state.selectedValue);
24970 }), sync(tag, ["values"], (state) => {
24971 combobox.setState("selectedValue", state.values);
24972 }));
24973 });
24974 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
24975 if (!state.resetValueOnHide) return;
24976 if (state.mounted) return;
24977 combobox.setState("value", value);
24978 }));
24979 setup(combobox, () => sync(combobox, ["open"], (state) => {
24980 if (state.open) return;
24981 combobox.setState("activeId", activeId);
24982 combobox.setState("moves", 0);
24983 }));
24984 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
24985 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
24986 }));
24987 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
24988 if (state.moves === prev.moves) return;
24989 const { activeId: activeId2 } = combobox.getState();
24990 const activeItem = composite.item(activeId2);
24991 combobox.setState("activeValue", activeItem?.value);
24992 }));
24993 return {
24994 ...popover,
24995 ...composite,
24996 ...combobox,
24997 tag,
24998 setValue: (value2) => combobox.setState("value", value2),
24999 resetValue: () => combobox.setState("value", initialState.value),
25000 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
25001 };
25002 }
25003
25004 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
25005 function useComboboxStoreOptions(props) {
25006 const tag = useTagContext();
25007 props = {
25008 ...props,
25009 tag: props.tag !== void 0 ? props.tag : tag
25010 };
25011 return useCompositeStoreOptions(props);
25012 }
25013 function useComboboxStoreProps(store, update2, props) {
25014 useUpdateEffect(update2, [props.tag]);
25015 useStoreProps(store, props, "value", "setValue");
25016 useStoreProps(store, props, "selectedValue", "setSelectedValue");
25017 useStoreProps(store, props, "resetValueOnHide");
25018 useStoreProps(store, props, "resetValueOnSelect");
25019 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
25020 }
25021 function useComboboxStore(props = {}) {
25022 props = useComboboxStoreOptions(props);
25023 const [store, update2] = useStore2(createComboboxStore, props);
25024 return useComboboxStoreProps(store, update2, props);
25025 }
25026
25027 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
25028 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
25029 function ComboboxProvider(props = {}) {
25030 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(ComboboxContextProvider, {
25031 value: useComboboxStore(props),
25032 children: props.children
25033 });
25034 }
25035
25036 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
25037 var import_remove_accents = __toESM(require_remove_accents(), 1);
25038 var import_compose10 = __toESM(require_compose(), 1);
25039 var import_i18n28 = __toESM(require_i18n(), 1);
25040 var import_element82 = __toESM(require_element(), 1);
25041 var import_components21 = __toESM(require_components(), 1);
25042
25043 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
25044 var EMPTY_ARRAY3 = [];
25045 var getCurrentValue = (filterDefinition, currentFilter) => {
25046 if (filterDefinition.singleSelection) {
25047 return currentFilter?.value;
25048 }
25049 if (Array.isArray(currentFilter?.value)) {
25050 return currentFilter.value;
25051 }
25052 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
25053 return [currentFilter.value];
25054 }
25055 return EMPTY_ARRAY3;
25056 };
25057
25058 // packages/dataviews/build-module/hooks/use-elements.mjs
25059 var import_element81 = __toESM(require_element(), 1);
25060 var EMPTY_ARRAY4 = [];
25061 function useElements({
25062 elements,
25063 getElements
25064 }) {
25065 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
25066 const [records, setRecords] = (0, import_element81.useState)(staticElements);
25067 const [isLoading, setIsLoading] = (0, import_element81.useState)(false);
25068 (0, import_element81.useEffect)(() => {
25069 if (!getElements) {
25070 setRecords(staticElements);
25071 return;
25072 }
25073 let cancelled = false;
25074 setIsLoading(true);
25075 getElements().then((fetchedElements) => {
25076 if (!cancelled) {
25077 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
25078 setRecords(dynamicElements);
25079 }
25080 }).catch(() => {
25081 if (!cancelled) {
25082 setRecords(staticElements);
25083 }
25084 }).finally(() => {
25085 if (!cancelled) {
25086 setIsLoading(false);
25087 }
25088 });
25089 return () => {
25090 cancelled = true;
25091 };
25092 }, [getElements, staticElements]);
25093 return {
25094 elements: records,
25095 isLoading
25096 };
25097 }
25098
25099 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
25100 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
25101 function normalizeSearchInput(input = "") {
25102 return (0, import_remove_accents.default)(input.trim().toLowerCase());
25103 }
25104 var getNewValue = (filterDefinition, currentFilter, value) => {
25105 if (filterDefinition.singleSelection) {
25106 return value;
25107 }
25108 if (Array.isArray(currentFilter?.value)) {
25109 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
25110 }
25111 return [value];
25112 };
25113 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
25114 return `${prefix}-${filterElementValue}`;
25115 }
25116 var MultiSelectionOption = ({ selected }) => {
25117 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25118 "span",
25119 {
25120 className: clsx_default(
25121 "dataviews-filters__search-widget-listitem-multi-selection",
25122 { "is-selected": selected }
25123 ),
25124 children: selected && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components21.Icon, { icon: check_default })
25125 }
25126 );
25127 };
25128 var SingleSelectionOption = ({ selected }) => {
25129 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25130 "span",
25131 {
25132 className: clsx_default(
25133 "dataviews-filters__search-widget-listitem-single-selection",
25134 { "is-selected": selected }
25135 )
25136 }
25137 );
25138 };
25139 function ListBox({ view, filter, onChangeView }) {
25140 const baseId = (0, import_compose10.useInstanceId)(ListBox, "dataviews-filter-list-box");
25141 const [activeCompositeId, setActiveCompositeId] = (0, import_element82.useState)(
25142 // When there are one or less operators, the first item is set as active
25143 // (by setting the initial `activeId` to `undefined`).
25144 // With 2 or more operators, the focus is moved on the operators control
25145 // (by setting the initial `activeId` to `null`), meaning that there won't
25146 // be an active item initially. Focus is then managed via the
25147 // `onFocusVisible` callback.
25148 filter.operators?.length === 1 ? void 0 : null
25149 );
25150 const currentFilter = view.filters?.find(
25151 (f2) => f2.field === filter.field
25152 );
25153 const currentValue = getCurrentValue(filter, currentFilter);
25154 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25155 import_components21.Composite,
25156 {
25157 virtualFocus: true,
25158 focusLoop: true,
25159 activeId: activeCompositeId,
25160 setActiveId: setActiveCompositeId,
25161 role: "listbox",
25162 className: "dataviews-filters__search-widget-listbox",
25163 "aria-label": (0, import_i18n28.sprintf)(
25164 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
25165 (0, import_i18n28.__)("List of: %1$s"),
25166 filter.name
25167 ),
25168 onFocusVisible: () => {
25169 if (!activeCompositeId && filter.elements.length) {
25170 setActiveCompositeId(
25171 generateFilterElementCompositeItemId(
25172 baseId,
25173 filter.elements[0].value
25174 )
25175 );
25176 }
25177 },
25178 render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components21.Composite.Typeahead, {}),
25179 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
25180 import_components21.Composite.Hover,
25181 {
25182 render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25183 import_components21.Composite.Item,
25184 {
25185 id: generateFilterElementCompositeItemId(
25186 baseId,
25187 element.value
25188 ),
25189 render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25190 "div",
25191 {
25192 "aria-label": element.label,
25193 role: "option",
25194 className: "dataviews-filters__search-widget-listitem"
25195 }
25196 ),
25197 onClick: () => {
25198 const newFilters = currentFilter ? [
25199 ...(view.filters ?? []).map(
25200 (_filter) => {
25201 if (_filter.field === filter.field) {
25202 return {
25203 ..._filter,
25204 operator: currentFilter.operator || filter.operators[0],
25205 value: getNewValue(
25206 filter,
25207 currentFilter,
25208 element.value
25209 )
25210 };
25211 }
25212 return _filter;
25213 }
25214 )
25215 ] : [
25216 ...view.filters ?? [],
25217 {
25218 field: filter.field,
25219 operator: filter.operators[0],
25220 value: getNewValue(
25221 filter,
25222 currentFilter,
25223 element.value
25224 )
25225 }
25226 ];
25227 onChangeView({
25228 ...view,
25229 page: 1,
25230 filters: newFilters
25231 });
25232 }
25233 }
25234 ),
25235 children: [
25236 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25237 SingleSelectionOption,
25238 {
25239 selected: currentValue === element.value
25240 }
25241 ),
25242 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25243 MultiSelectionOption,
25244 {
25245 selected: currentValue.includes(element.value)
25246 }
25247 ),
25248 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25249 "span",
25250 {
25251 className: "dataviews-filters__search-widget-listitem-value",
25252 title: element.label,
25253 children: element.label
25254 }
25255 )
25256 ]
25257 },
25258 element.value
25259 ))
25260 }
25261 );
25262 }
25263 function ComboboxList22({ view, filter, onChangeView }) {
25264 const [searchValue, setSearchValue] = (0, import_element82.useState)("");
25265 const deferredSearchValue = (0, import_element82.useDeferredValue)(searchValue);
25266 const currentFilter = view.filters?.find(
25267 (_filter) => _filter.field === filter.field
25268 );
25269 const currentValue = getCurrentValue(filter, currentFilter);
25270 const matches2 = (0, import_element82.useMemo)(() => {
25271 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
25272 return filter.elements.filter(
25273 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
25274 );
25275 }, [filter.elements, deferredSearchValue]);
25276 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
25277 ComboboxProvider,
25278 {
25279 selectedValue: currentValue,
25280 setSelectedValue: (value) => {
25281 const newFilters = currentFilter ? [
25282 ...(view.filters ?? []).map((_filter) => {
25283 if (_filter.field === filter.field) {
25284 return {
25285 ..._filter,
25286 operator: currentFilter.operator || filter.operators[0],
25287 value
25288 };
25289 }
25290 return _filter;
25291 })
25292 ] : [
25293 ...view.filters ?? [],
25294 {
25295 field: filter.field,
25296 operator: filter.operators[0],
25297 value
25298 }
25299 ];
25300 onChangeView({
25301 ...view,
25302 page: 1,
25303 filters: newFilters
25304 });
25305 },
25306 setValue: setSearchValue,
25307 children: [
25308 /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
25309 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ComboboxLabel, {}), children: (0, import_i18n28.__)("Search items") }),
25310 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25311 Combobox,
25312 {
25313 autoSelect: "always",
25314 placeholder: (0, import_i18n28.__)("Search"),
25315 className: "dataviews-filters__search-widget-filter-combobox__input"
25316 }
25317 ),
25318 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components21.Icon, { icon: search_default }) })
25319 ] }),
25320 /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
25321 ComboboxList,
25322 {
25323 className: "dataviews-filters__search-widget-filter-combobox-list",
25324 alwaysVisible: true,
25325 children: [
25326 matches2.map((element) => {
25327 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
25328 ComboboxItem,
25329 {
25330 resetValueOnSelect: false,
25331 value: element.value,
25332 className: "dataviews-filters__search-widget-listitem",
25333 hideOnClick: false,
25334 setValueOnClick: false,
25335 focusOnHover: true,
25336 children: [
25337 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25338 SingleSelectionOption,
25339 {
25340 selected: currentValue === element.value
25341 }
25342 ),
25343 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25344 MultiSelectionOption,
25345 {
25346 selected: currentValue.includes(
25347 element.value
25348 )
25349 }
25350 ),
25351 /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
25352 "span",
25353 {
25354 className: "dataviews-filters__search-widget-listitem-value",
25355 title: element.label,
25356 children: [
25357 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25358 ComboboxItemValue,
25359 {
25360 className: "dataviews-filters__search-widget-filter-combobox-item-value",
25361 value: element.label
25362 }
25363 ),
25364 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
25365 ]
25366 }
25367 )
25368 ]
25369 },
25370 element.value
25371 );
25372 }),
25373 !matches2.length && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { children: (0, import_i18n28.__)("No results found") })
25374 ]
25375 }
25376 )
25377 ]
25378 }
25379 );
25380 }
25381 function SearchWidget(props) {
25382 const { elements, isLoading } = useElements({
25383 elements: props.filter.elements,
25384 getElements: props.filter.getElements
25385 });
25386 if (isLoading) {
25387 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components21.Spinner, {}) });
25388 }
25389 if (elements.length === 0) {
25390 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n28.__)("No elements found") });
25391 }
25392 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
25393 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
25394 }
25395
25396 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
25397 var import_es6 = __toESM(require_es6(), 1);
25398 var import_compose11 = __toESM(require_compose(), 1);
25399 var import_element83 = __toESM(require_element(), 1);
25400 var import_components22 = __toESM(require_components(), 1);
25401 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
25402 function InputWidget({
25403 filter,
25404 view,
25405 onChangeView,
25406 fields
25407 }) {
25408 const currentFilter = view.filters?.find(
25409 (f2) => f2.field === filter.field
25410 );
25411 const currentValue = getCurrentValue(filter, currentFilter);
25412 const field = (0, import_element83.useMemo)(() => {
25413 const currentField = fields.find((f2) => f2.id === filter.field);
25414 if (currentField) {
25415 return {
25416 ...currentField,
25417 // Deactivate validation for filters.
25418 isValid: {},
25419 // Filter controls are always enabled.
25420 isDisabled: () => false,
25421 // Filter controls are always visible.
25422 isVisible: () => true,
25423 // Configure getValue/setValue as if Item was a plain object.
25424 getValue: ({ item }) => item[currentField.id],
25425 setValue: ({ value }) => ({
25426 [currentField.id]: value
25427 })
25428 };
25429 }
25430 return currentField;
25431 }, [fields, filter.field]);
25432 const data = (0, import_element83.useMemo)(() => {
25433 return (view.filters ?? []).reduce(
25434 (acc, activeFilter) => {
25435 acc[activeFilter.field] = activeFilter.value;
25436 return acc;
25437 },
25438 {}
25439 );
25440 }, [view.filters]);
25441 const handleChange = (0, import_compose11.useEvent)((updatedData) => {
25442 if (!field || !currentFilter) {
25443 return;
25444 }
25445 const nextValue = field.getValue({ item: updatedData });
25446 if ((0, import_es6.default)(nextValue, currentValue)) {
25447 return;
25448 }
25449 onChangeView({
25450 ...view,
25451 filters: (view.filters ?? []).map(
25452 (_filter) => _filter.field === filter.field ? {
25453 ..._filter,
25454 operator: currentFilter.operator || filter.operators[0],
25455 // Consider empty strings as undefined:
25456 //
25457 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
25458 // - empty string as value means "search empty string": returns only the records that have an empty string as value
25459 //
25460 // In practice, this means the filter will not be able to find an empty string as the value.
25461 value: nextValue === "" ? void 0 : nextValue
25462 } : _filter
25463 )
25464 });
25465 });
25466 if (!field || !field.Edit || !currentFilter) {
25467 return null;
25468 }
25469 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
25470 import_components22.Flex,
25471 {
25472 className: "dataviews-filters__user-input-widget",
25473 gap: 2.5,
25474 direction: "column",
25475 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
25476 field.Edit,
25477 {
25478 hideLabelFromVision: true,
25479 data,
25480 field,
25481 operator: currentFilter.operator,
25482 onChange: handleChange
25483 }
25484 )
25485 }
25486 );
25487 }
25488
25489 // node_modules/date-fns/constants.js
25490 var daysInYear = 365.2425;
25491 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
25492 var minTime = -maxTime;
25493 var millisecondsInWeek = 6048e5;
25494 var millisecondsInDay = 864e5;
25495 var secondsInHour = 3600;
25496 var secondsInDay = secondsInHour * 24;
25497 var secondsInWeek = secondsInDay * 7;
25498 var secondsInYear = secondsInDay * daysInYear;
25499 var secondsInMonth = secondsInYear / 12;
25500 var secondsInQuarter = secondsInMonth * 3;
25501 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
25502
25503 // node_modules/date-fns/constructFrom.js
25504 function constructFrom(date, value) {
25505 if (typeof date === "function") return date(value);
25506 if (date && typeof date === "object" && constructFromSymbol in date)
25507 return date[constructFromSymbol](value);
25508 if (date instanceof Date) return new date.constructor(value);
25509 return new Date(value);
25510 }
25511
25512 // node_modules/date-fns/toDate.js
25513 function toDate(argument, context) {
25514 return constructFrom(context || argument, argument);
25515 }
25516
25517 // node_modules/date-fns/addDays.js
25518 function addDays(date, amount, options) {
25519 const _date = toDate(date, options?.in);
25520 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
25521 if (!amount) return _date;
25522 _date.setDate(_date.getDate() + amount);
25523 return _date;
25524 }
25525
25526 // node_modules/date-fns/addMonths.js
25527 function addMonths(date, amount, options) {
25528 const _date = toDate(date, options?.in);
25529 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
25530 if (!amount) {
25531 return _date;
25532 }
25533 const dayOfMonth = _date.getDate();
25534 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
25535 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
25536 const daysInMonth = endOfDesiredMonth.getDate();
25537 if (dayOfMonth >= daysInMonth) {
25538 return endOfDesiredMonth;
25539 } else {
25540 _date.setFullYear(
25541 endOfDesiredMonth.getFullYear(),
25542 endOfDesiredMonth.getMonth(),
25543 dayOfMonth
25544 );
25545 return _date;
25546 }
25547 }
25548
25549 // node_modules/date-fns/_lib/defaultOptions.js
25550 var defaultOptions = {};
25551 function getDefaultOptions() {
25552 return defaultOptions;
25553 }
25554
25555 // node_modules/date-fns/startOfWeek.js
25556 function startOfWeek(date, options) {
25557 const defaultOptions2 = getDefaultOptions();
25558 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
25559 const _date = toDate(date, options?.in);
25560 const day = _date.getDay();
25561 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
25562 _date.setDate(_date.getDate() - diff);
25563 _date.setHours(0, 0, 0, 0);
25564 return _date;
25565 }
25566
25567 // node_modules/date-fns/startOfISOWeek.js
25568 function startOfISOWeek(date, options) {
25569 return startOfWeek(date, { ...options, weekStartsOn: 1 });
25570 }
25571
25572 // node_modules/date-fns/getISOWeekYear.js
25573 function getISOWeekYear(date, options) {
25574 const _date = toDate(date, options?.in);
25575 const year = _date.getFullYear();
25576 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
25577 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
25578 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
25579 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
25580 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
25581 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
25582 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
25583 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
25584 if (_date.getTime() >= startOfNextYear.getTime()) {
25585 return year + 1;
25586 } else if (_date.getTime() >= startOfThisYear.getTime()) {
25587 return year;
25588 } else {
25589 return year - 1;
25590 }
25591 }
25592
25593 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
25594 function getTimezoneOffsetInMilliseconds(date) {
25595 const _date = toDate(date);
25596 const utcDate = new Date(
25597 Date.UTC(
25598 _date.getFullYear(),
25599 _date.getMonth(),
25600 _date.getDate(),
25601 _date.getHours(),
25602 _date.getMinutes(),
25603 _date.getSeconds(),
25604 _date.getMilliseconds()
25605 )
25606 );
25607 utcDate.setUTCFullYear(_date.getFullYear());
25608 return +date - +utcDate;
25609 }
25610
25611 // node_modules/date-fns/_lib/normalizeDates.js
25612 function normalizeDates(context, ...dates) {
25613 const normalize = constructFrom.bind(
25614 null,
25615 context || dates.find((date) => typeof date === "object")
25616 );
25617 return dates.map(normalize);
25618 }
25619
25620 // node_modules/date-fns/startOfDay.js
25621 function startOfDay(date, options) {
25622 const _date = toDate(date, options?.in);
25623 _date.setHours(0, 0, 0, 0);
25624 return _date;
25625 }
25626
25627 // node_modules/date-fns/differenceInCalendarDays.js
25628 function differenceInCalendarDays(laterDate, earlierDate, options) {
25629 const [laterDate_, earlierDate_] = normalizeDates(
25630 options?.in,
25631 laterDate,
25632 earlierDate
25633 );
25634 const laterStartOfDay = startOfDay(laterDate_);
25635 const earlierStartOfDay = startOfDay(earlierDate_);
25636 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
25637 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
25638 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
25639 }
25640
25641 // node_modules/date-fns/startOfISOWeekYear.js
25642 function startOfISOWeekYear(date, options) {
25643 const year = getISOWeekYear(date, options);
25644 const fourthOfJanuary = constructFrom(options?.in || date, 0);
25645 fourthOfJanuary.setFullYear(year, 0, 4);
25646 fourthOfJanuary.setHours(0, 0, 0, 0);
25647 return startOfISOWeek(fourthOfJanuary);
25648 }
25649
25650 // node_modules/date-fns/addWeeks.js
25651 function addWeeks(date, amount, options) {
25652 return addDays(date, amount * 7, options);
25653 }
25654
25655 // node_modules/date-fns/addYears.js
25656 function addYears(date, amount, options) {
25657 return addMonths(date, amount * 12, options);
25658 }
25659
25660 // node_modules/date-fns/isDate.js
25661 function isDate(value) {
25662 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
25663 }
25664
25665 // node_modules/date-fns/isValid.js
25666 function isValid(date) {
25667 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
25668 }
25669
25670 // node_modules/date-fns/startOfMonth.js
25671 function startOfMonth(date, options) {
25672 const _date = toDate(date, options?.in);
25673 _date.setDate(1);
25674 _date.setHours(0, 0, 0, 0);
25675 return _date;
25676 }
25677
25678 // node_modules/date-fns/startOfYear.js
25679 function startOfYear(date, options) {
25680 const date_ = toDate(date, options?.in);
25681 date_.setFullYear(date_.getFullYear(), 0, 1);
25682 date_.setHours(0, 0, 0, 0);
25683 return date_;
25684 }
25685
25686 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
25687 var formatDistanceLocale = {
25688 lessThanXSeconds: {
25689 one: "less than a second",
25690 other: "less than {{count}} seconds"
25691 },
25692 xSeconds: {
25693 one: "1 second",
25694 other: "{{count}} seconds"
25695 },
25696 halfAMinute: "half a minute",
25697 lessThanXMinutes: {
25698 one: "less than a minute",
25699 other: "less than {{count}} minutes"
25700 },
25701 xMinutes: {
25702 one: "1 minute",
25703 other: "{{count}} minutes"
25704 },
25705 aboutXHours: {
25706 one: "about 1 hour",
25707 other: "about {{count}} hours"
25708 },
25709 xHours: {
25710 one: "1 hour",
25711 other: "{{count}} hours"
25712 },
25713 xDays: {
25714 one: "1 day",
25715 other: "{{count}} days"
25716 },
25717 aboutXWeeks: {
25718 one: "about 1 week",
25719 other: "about {{count}} weeks"
25720 },
25721 xWeeks: {
25722 one: "1 week",
25723 other: "{{count}} weeks"
25724 },
25725 aboutXMonths: {
25726 one: "about 1 month",
25727 other: "about {{count}} months"
25728 },
25729 xMonths: {
25730 one: "1 month",
25731 other: "{{count}} months"
25732 },
25733 aboutXYears: {
25734 one: "about 1 year",
25735 other: "about {{count}} years"
25736 },
25737 xYears: {
25738 one: "1 year",
25739 other: "{{count}} years"
25740 },
25741 overXYears: {
25742 one: "over 1 year",
25743 other: "over {{count}} years"
25744 },
25745 almostXYears: {
25746 one: "almost 1 year",
25747 other: "almost {{count}} years"
25748 }
25749 };
25750 var formatDistance = (token, count, options) => {
25751 let result;
25752 const tokenValue = formatDistanceLocale[token];
25753 if (typeof tokenValue === "string") {
25754 result = tokenValue;
25755 } else if (count === 1) {
25756 result = tokenValue.one;
25757 } else {
25758 result = tokenValue.other.replace("{{count}}", count.toString());
25759 }
25760 if (options?.addSuffix) {
25761 if (options.comparison && options.comparison > 0) {
25762 return "in " + result;
25763 } else {
25764 return result + " ago";
25765 }
25766 }
25767 return result;
25768 };
25769
25770 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
25771 function buildFormatLongFn(args) {
25772 return (options = {}) => {
25773 const width = options.width ? String(options.width) : args.defaultWidth;
25774 const format6 = args.formats[width] || args.formats[args.defaultWidth];
25775 return format6;
25776 };
25777 }
25778
25779 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
25780 var dateFormats = {
25781 full: "EEEE, MMMM do, y",
25782 long: "MMMM do, y",
25783 medium: "MMM d, y",
25784 short: "MM/dd/yyyy"
25785 };
25786 var timeFormats = {
25787 full: "h:mm:ss a zzzz",
25788 long: "h:mm:ss a z",
25789 medium: "h:mm:ss a",
25790 short: "h:mm a"
25791 };
25792 var dateTimeFormats = {
25793 full: "{{date}} 'at' {{time}}",
25794 long: "{{date}} 'at' {{time}}",
25795 medium: "{{date}}, {{time}}",
25796 short: "{{date}}, {{time}}"
25797 };
25798 var formatLong = {
25799 date: buildFormatLongFn({
25800 formats: dateFormats,
25801 defaultWidth: "full"
25802 }),
25803 time: buildFormatLongFn({
25804 formats: timeFormats,
25805 defaultWidth: "full"
25806 }),
25807 dateTime: buildFormatLongFn({
25808 formats: dateTimeFormats,
25809 defaultWidth: "full"
25810 })
25811 };
25812
25813 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
25814 var formatRelativeLocale = {
25815 lastWeek: "'last' eeee 'at' p",
25816 yesterday: "'yesterday at' p",
25817 today: "'today at' p",
25818 tomorrow: "'tomorrow at' p",
25819 nextWeek: "eeee 'at' p",
25820 other: "P"
25821 };
25822 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
25823
25824 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
25825 function buildLocalizeFn(args) {
25826 return (value, options) => {
25827 const context = options?.context ? String(options.context) : "standalone";
25828 let valuesArray;
25829 if (context === "formatting" && args.formattingValues) {
25830 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
25831 const width = options?.width ? String(options.width) : defaultWidth;
25832 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
25833 } else {
25834 const defaultWidth = args.defaultWidth;
25835 const width = options?.width ? String(options.width) : args.defaultWidth;
25836 valuesArray = args.values[width] || args.values[defaultWidth];
25837 }
25838 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
25839 return valuesArray[index2];
25840 };
25841 }
25842
25843 // node_modules/date-fns/locale/en-US/_lib/localize.js
25844 var eraValues = {
25845 narrow: ["B", "A"],
25846 abbreviated: ["BC", "AD"],
25847 wide: ["Before Christ", "Anno Domini"]
25848 };
25849 var quarterValues = {
25850 narrow: ["1", "2", "3", "4"],
25851 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
25852 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
25853 };
25854 var monthValues = {
25855 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
25856 abbreviated: [
25857 "Jan",
25858 "Feb",
25859 "Mar",
25860 "Apr",
25861 "May",
25862 "Jun",
25863 "Jul",
25864 "Aug",
25865 "Sep",
25866 "Oct",
25867 "Nov",
25868 "Dec"
25869 ],
25870 wide: [
25871 "January",
25872 "February",
25873 "March",
25874 "April",
25875 "May",
25876 "June",
25877 "July",
25878 "August",
25879 "September",
25880 "October",
25881 "November",
25882 "December"
25883 ]
25884 };
25885 var dayValues = {
25886 narrow: ["S", "M", "T", "W", "T", "F", "S"],
25887 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
25888 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
25889 wide: [
25890 "Sunday",
25891 "Monday",
25892 "Tuesday",
25893 "Wednesday",
25894 "Thursday",
25895 "Friday",
25896 "Saturday"
25897 ]
25898 };
25899 var dayPeriodValues = {
25900 narrow: {
25901 am: "a",
25902 pm: "p",
25903 midnight: "mi",
25904 noon: "n",
25905 morning: "morning",
25906 afternoon: "afternoon",
25907 evening: "evening",
25908 night: "night"
25909 },
25910 abbreviated: {
25911 am: "AM",
25912 pm: "PM",
25913 midnight: "midnight",
25914 noon: "noon",
25915 morning: "morning",
25916 afternoon: "afternoon",
25917 evening: "evening",
25918 night: "night"
25919 },
25920 wide: {
25921 am: "a.m.",
25922 pm: "p.m.",
25923 midnight: "midnight",
25924 noon: "noon",
25925 morning: "morning",
25926 afternoon: "afternoon",
25927 evening: "evening",
25928 night: "night"
25929 }
25930 };
25931 var formattingDayPeriodValues = {
25932 narrow: {
25933 am: "a",
25934 pm: "p",
25935 midnight: "mi",
25936 noon: "n",
25937 morning: "in the morning",
25938 afternoon: "in the afternoon",
25939 evening: "in the evening",
25940 night: "at night"
25941 },
25942 abbreviated: {
25943 am: "AM",
25944 pm: "PM",
25945 midnight: "midnight",
25946 noon: "noon",
25947 morning: "in the morning",
25948 afternoon: "in the afternoon",
25949 evening: "in the evening",
25950 night: "at night"
25951 },
25952 wide: {
25953 am: "a.m.",
25954 pm: "p.m.",
25955 midnight: "midnight",
25956 noon: "noon",
25957 morning: "in the morning",
25958 afternoon: "in the afternoon",
25959 evening: "in the evening",
25960 night: "at night"
25961 }
25962 };
25963 var ordinalNumber = (dirtyNumber, _options) => {
25964 const number = Number(dirtyNumber);
25965 const rem100 = number % 100;
25966 if (rem100 > 20 || rem100 < 10) {
25967 switch (rem100 % 10) {
25968 case 1:
25969 return number + "st";
25970 case 2:
25971 return number + "nd";
25972 case 3:
25973 return number + "rd";
25974 }
25975 }
25976 return number + "th";
25977 };
25978 var localize = {
25979 ordinalNumber,
25980 era: buildLocalizeFn({
25981 values: eraValues,
25982 defaultWidth: "wide"
25983 }),
25984 quarter: buildLocalizeFn({
25985 values: quarterValues,
25986 defaultWidth: "wide",
25987 argumentCallback: (quarter) => quarter - 1
25988 }),
25989 month: buildLocalizeFn({
25990 values: monthValues,
25991 defaultWidth: "wide"
25992 }),
25993 day: buildLocalizeFn({
25994 values: dayValues,
25995 defaultWidth: "wide"
25996 }),
25997 dayPeriod: buildLocalizeFn({
25998 values: dayPeriodValues,
25999 defaultWidth: "wide",
26000 formattingValues: formattingDayPeriodValues,
26001 defaultFormattingWidth: "wide"
26002 })
26003 };
26004
26005 // node_modules/date-fns/locale/_lib/buildMatchFn.js
26006 function buildMatchFn(args) {
26007 return (string, options = {}) => {
26008 const width = options.width;
26009 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
26010 const matchResult = string.match(matchPattern);
26011 if (!matchResult) {
26012 return null;
26013 }
26014 const matchedString = matchResult[0];
26015 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
26016 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
26017 // [TODO] -- I challenge you to fix the type
26018 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
26019 );
26020 let value;
26021 value = args.valueCallback ? args.valueCallback(key) : key;
26022 value = options.valueCallback ? (
26023 // [TODO] -- I challenge you to fix the type
26024 options.valueCallback(value)
26025 ) : value;
26026 const rest = string.slice(matchedString.length);
26027 return { value, rest };
26028 };
26029 }
26030 function findKey(object, predicate) {
26031 for (const key in object) {
26032 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
26033 return key;
26034 }
26035 }
26036 return void 0;
26037 }
26038 function findIndex(array, predicate) {
26039 for (let key = 0; key < array.length; key++) {
26040 if (predicate(array[key])) {
26041 return key;
26042 }
26043 }
26044 return void 0;
26045 }
26046
26047 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
26048 function buildMatchPatternFn(args) {
26049 return (string, options = {}) => {
26050 const matchResult = string.match(args.matchPattern);
26051 if (!matchResult) return null;
26052 const matchedString = matchResult[0];
26053 const parseResult = string.match(args.parsePattern);
26054 if (!parseResult) return null;
26055 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
26056 value = options.valueCallback ? options.valueCallback(value) : value;
26057 const rest = string.slice(matchedString.length);
26058 return { value, rest };
26059 };
26060 }
26061
26062 // node_modules/date-fns/locale/en-US/_lib/match.js
26063 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
26064 var parseOrdinalNumberPattern = /\d+/i;
26065 var matchEraPatterns = {
26066 narrow: /^(b|a)/i,
26067 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
26068 wide: /^(before christ|before common era|anno domini|common era)/i
26069 };
26070 var parseEraPatterns = {
26071 any: [/^b/i, /^(a|c)/i]
26072 };
26073 var matchQuarterPatterns = {
26074 narrow: /^[1234]/i,
26075 abbreviated: /^q[1234]/i,
26076 wide: /^[1234](th|st|nd|rd)? quarter/i
26077 };
26078 var parseQuarterPatterns = {
26079 any: [/1/i, /2/i, /3/i, /4/i]
26080 };
26081 var matchMonthPatterns = {
26082 narrow: /^[jfmasond]/i,
26083 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
26084 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
26085 };
26086 var parseMonthPatterns = {
26087 narrow: [
26088 /^j/i,
26089 /^f/i,
26090 /^m/i,
26091 /^a/i,
26092 /^m/i,
26093 /^j/i,
26094 /^j/i,
26095 /^a/i,
26096 /^s/i,
26097 /^o/i,
26098 /^n/i,
26099 /^d/i
26100 ],
26101 any: [
26102 /^ja/i,
26103 /^f/i,
26104 /^mar/i,
26105 /^ap/i,
26106 /^may/i,
26107 /^jun/i,
26108 /^jul/i,
26109 /^au/i,
26110 /^s/i,
26111 /^o/i,
26112 /^n/i,
26113 /^d/i
26114 ]
26115 };
26116 var matchDayPatterns = {
26117 narrow: /^[smtwf]/i,
26118 short: /^(su|mo|tu|we|th|fr|sa)/i,
26119 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
26120 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
26121 };
26122 var parseDayPatterns = {
26123 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
26124 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
26125 };
26126 var matchDayPeriodPatterns = {
26127 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
26128 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
26129 };
26130 var parseDayPeriodPatterns = {
26131 any: {
26132 am: /^a/i,
26133 pm: /^p/i,
26134 midnight: /^mi/i,
26135 noon: /^no/i,
26136 morning: /morning/i,
26137 afternoon: /afternoon/i,
26138 evening: /evening/i,
26139 night: /night/i
26140 }
26141 };
26142 var match = {
26143 ordinalNumber: buildMatchPatternFn({
26144 matchPattern: matchOrdinalNumberPattern,
26145 parsePattern: parseOrdinalNumberPattern,
26146 valueCallback: (value) => parseInt(value, 10)
26147 }),
26148 era: buildMatchFn({
26149 matchPatterns: matchEraPatterns,
26150 defaultMatchWidth: "wide",
26151 parsePatterns: parseEraPatterns,
26152 defaultParseWidth: "any"
26153 }),
26154 quarter: buildMatchFn({
26155 matchPatterns: matchQuarterPatterns,
26156 defaultMatchWidth: "wide",
26157 parsePatterns: parseQuarterPatterns,
26158 defaultParseWidth: "any",
26159 valueCallback: (index2) => index2 + 1
26160 }),
26161 month: buildMatchFn({
26162 matchPatterns: matchMonthPatterns,
26163 defaultMatchWidth: "wide",
26164 parsePatterns: parseMonthPatterns,
26165 defaultParseWidth: "any"
26166 }),
26167 day: buildMatchFn({
26168 matchPatterns: matchDayPatterns,
26169 defaultMatchWidth: "wide",
26170 parsePatterns: parseDayPatterns,
26171 defaultParseWidth: "any"
26172 }),
26173 dayPeriod: buildMatchFn({
26174 matchPatterns: matchDayPeriodPatterns,
26175 defaultMatchWidth: "any",
26176 parsePatterns: parseDayPeriodPatterns,
26177 defaultParseWidth: "any"
26178 })
26179 };
26180
26181 // node_modules/date-fns/locale/en-US.js
26182 var enUS = {
26183 code: "en-US",
26184 formatDistance,
26185 formatLong,
26186 formatRelative,
26187 localize,
26188 match,
26189 options: {
26190 weekStartsOn: 0,
26191 firstWeekContainsDate: 1
26192 }
26193 };
26194
26195 // node_modules/date-fns/getDayOfYear.js
26196 function getDayOfYear(date, options) {
26197 const _date = toDate(date, options?.in);
26198 const diff = differenceInCalendarDays(_date, startOfYear(_date));
26199 const dayOfYear = diff + 1;
26200 return dayOfYear;
26201 }
26202
26203 // node_modules/date-fns/getISOWeek.js
26204 function getISOWeek(date, options) {
26205 const _date = toDate(date, options?.in);
26206 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
26207 return Math.round(diff / millisecondsInWeek) + 1;
26208 }
26209
26210 // node_modules/date-fns/getWeekYear.js
26211 function getWeekYear(date, options) {
26212 const _date = toDate(date, options?.in);
26213 const year = _date.getFullYear();
26214 const defaultOptions2 = getDefaultOptions();
26215 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
26216 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
26217 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
26218 firstWeekOfNextYear.setHours(0, 0, 0, 0);
26219 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
26220 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
26221 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
26222 firstWeekOfThisYear.setHours(0, 0, 0, 0);
26223 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
26224 if (+_date >= +startOfNextYear) {
26225 return year + 1;
26226 } else if (+_date >= +startOfThisYear) {
26227 return year;
26228 } else {
26229 return year - 1;
26230 }
26231 }
26232
26233 // node_modules/date-fns/startOfWeekYear.js
26234 function startOfWeekYear(date, options) {
26235 const defaultOptions2 = getDefaultOptions();
26236 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
26237 const year = getWeekYear(date, options);
26238 const firstWeek = constructFrom(options?.in || date, 0);
26239 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
26240 firstWeek.setHours(0, 0, 0, 0);
26241 const _date = startOfWeek(firstWeek, options);
26242 return _date;
26243 }
26244
26245 // node_modules/date-fns/getWeek.js
26246 function getWeek(date, options) {
26247 const _date = toDate(date, options?.in);
26248 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
26249 return Math.round(diff / millisecondsInWeek) + 1;
26250 }
26251
26252 // node_modules/date-fns/_lib/addLeadingZeros.js
26253 function addLeadingZeros(number, targetLength) {
26254 const sign = number < 0 ? "-" : "";
26255 const output = Math.abs(number).toString().padStart(targetLength, "0");
26256 return sign + output;
26257 }
26258
26259 // node_modules/date-fns/_lib/format/lightFormatters.js
26260 var lightFormatters = {
26261 // Year
26262 y(date, token) {
26263 const signedYear = date.getFullYear();
26264 const year = signedYear > 0 ? signedYear : 1 - signedYear;
26265 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
26266 },
26267 // Month
26268 M(date, token) {
26269 const month = date.getMonth();
26270 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
26271 },
26272 // Day of the month
26273 d(date, token) {
26274 return addLeadingZeros(date.getDate(), token.length);
26275 },
26276 // AM or PM
26277 a(date, token) {
26278 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
26279 switch (token) {
26280 case "a":
26281 case "aa":
26282 return dayPeriodEnumValue.toUpperCase();
26283 case "aaa":
26284 return dayPeriodEnumValue;
26285 case "aaaaa":
26286 return dayPeriodEnumValue[0];
26287 case "aaaa":
26288 default:
26289 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
26290 }
26291 },
26292 // Hour [1-12]
26293 h(date, token) {
26294 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
26295 },
26296 // Hour [0-23]
26297 H(date, token) {
26298 return addLeadingZeros(date.getHours(), token.length);
26299 },
26300 // Minute
26301 m(date, token) {
26302 return addLeadingZeros(date.getMinutes(), token.length);
26303 },
26304 // Second
26305 s(date, token) {
26306 return addLeadingZeros(date.getSeconds(), token.length);
26307 },
26308 // Fraction of second
26309 S(date, token) {
26310 const numberOfDigits = token.length;
26311 const milliseconds = date.getMilliseconds();
26312 const fractionalSeconds = Math.trunc(
26313 milliseconds * Math.pow(10, numberOfDigits - 3)
26314 );
26315 return addLeadingZeros(fractionalSeconds, token.length);
26316 }
26317 };
26318
26319 // node_modules/date-fns/_lib/format/formatters.js
26320 var dayPeriodEnum = {
26321 am: "am",
26322 pm: "pm",
26323 midnight: "midnight",
26324 noon: "noon",
26325 morning: "morning",
26326 afternoon: "afternoon",
26327 evening: "evening",
26328 night: "night"
26329 };
26330 var formatters = {
26331 // Era
26332 G: function(date, token, localize2) {
26333 const era = date.getFullYear() > 0 ? 1 : 0;
26334 switch (token) {
26335 // AD, BC
26336 case "G":
26337 case "GG":
26338 case "GGG":
26339 return localize2.era(era, { width: "abbreviated" });
26340 // A, B
26341 case "GGGGG":
26342 return localize2.era(era, { width: "narrow" });
26343 // Anno Domini, Before Christ
26344 case "GGGG":
26345 default:
26346 return localize2.era(era, { width: "wide" });
26347 }
26348 },
26349 // Year
26350 y: function(date, token, localize2) {
26351 if (token === "yo") {
26352 const signedYear = date.getFullYear();
26353 const year = signedYear > 0 ? signedYear : 1 - signedYear;
26354 return localize2.ordinalNumber(year, { unit: "year" });
26355 }
26356 return lightFormatters.y(date, token);
26357 },
26358 // Local week-numbering year
26359 Y: function(date, token, localize2, options) {
26360 const signedWeekYear = getWeekYear(date, options);
26361 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
26362 if (token === "YY") {
26363 const twoDigitYear = weekYear % 100;
26364 return addLeadingZeros(twoDigitYear, 2);
26365 }
26366 if (token === "Yo") {
26367 return localize2.ordinalNumber(weekYear, { unit: "year" });
26368 }
26369 return addLeadingZeros(weekYear, token.length);
26370 },
26371 // ISO week-numbering year
26372 R: function(date, token) {
26373 const isoWeekYear = getISOWeekYear(date);
26374 return addLeadingZeros(isoWeekYear, token.length);
26375 },
26376 // Extended year. This is a single number designating the year of this calendar system.
26377 // The main difference between `y` and `u` localizers are B.C. years:
26378 // | Year | `y` | `u` |
26379 // |------|-----|-----|
26380 // | AC 1 | 1 | 1 |
26381 // | BC 1 | 1 | 0 |
26382 // | BC 2 | 2 | -1 |
26383 // Also `yy` always returns the last two digits of a year,
26384 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
26385 u: function(date, token) {
26386 const year = date.getFullYear();
26387 return addLeadingZeros(year, token.length);
26388 },
26389 // Quarter
26390 Q: function(date, token, localize2) {
26391 const quarter = Math.ceil((date.getMonth() + 1) / 3);
26392 switch (token) {
26393 // 1, 2, 3, 4
26394 case "Q":
26395 return String(quarter);
26396 // 01, 02, 03, 04
26397 case "QQ":
26398 return addLeadingZeros(quarter, 2);
26399 // 1st, 2nd, 3rd, 4th
26400 case "Qo":
26401 return localize2.ordinalNumber(quarter, { unit: "quarter" });
26402 // Q1, Q2, Q3, Q4
26403 case "QQQ":
26404 return localize2.quarter(quarter, {
26405 width: "abbreviated",
26406 context: "formatting"
26407 });
26408 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
26409 case "QQQQQ":
26410 return localize2.quarter(quarter, {
26411 width: "narrow",
26412 context: "formatting"
26413 });
26414 // 1st quarter, 2nd quarter, ...
26415 case "QQQQ":
26416 default:
26417 return localize2.quarter(quarter, {
26418 width: "wide",
26419 context: "formatting"
26420 });
26421 }
26422 },
26423 // Stand-alone quarter
26424 q: function(date, token, localize2) {
26425 const quarter = Math.ceil((date.getMonth() + 1) / 3);
26426 switch (token) {
26427 // 1, 2, 3, 4
26428 case "q":
26429 return String(quarter);
26430 // 01, 02, 03, 04
26431 case "qq":
26432 return addLeadingZeros(quarter, 2);
26433 // 1st, 2nd, 3rd, 4th
26434 case "qo":
26435 return localize2.ordinalNumber(quarter, { unit: "quarter" });
26436 // Q1, Q2, Q3, Q4
26437 case "qqq":
26438 return localize2.quarter(quarter, {
26439 width: "abbreviated",
26440 context: "standalone"
26441 });
26442 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
26443 case "qqqqq":
26444 return localize2.quarter(quarter, {
26445 width: "narrow",
26446 context: "standalone"
26447 });
26448 // 1st quarter, 2nd quarter, ...
26449 case "qqqq":
26450 default:
26451 return localize2.quarter(quarter, {
26452 width: "wide",
26453 context: "standalone"
26454 });
26455 }
26456 },
26457 // Month
26458 M: function(date, token, localize2) {
26459 const month = date.getMonth();
26460 switch (token) {
26461 case "M":
26462 case "MM":
26463 return lightFormatters.M(date, token);
26464 // 1st, 2nd, ..., 12th
26465 case "Mo":
26466 return localize2.ordinalNumber(month + 1, { unit: "month" });
26467 // Jan, Feb, ..., Dec
26468 case "MMM":
26469 return localize2.month(month, {
26470 width: "abbreviated",
26471 context: "formatting"
26472 });
26473 // J, F, ..., D
26474 case "MMMMM":
26475 return localize2.month(month, {
26476 width: "narrow",
26477 context: "formatting"
26478 });
26479 // January, February, ..., December
26480 case "MMMM":
26481 default:
26482 return localize2.month(month, { width: "wide", context: "formatting" });
26483 }
26484 },
26485 // Stand-alone month
26486 L: function(date, token, localize2) {
26487 const month = date.getMonth();
26488 switch (token) {
26489 // 1, 2, ..., 12
26490 case "L":
26491 return String(month + 1);
26492 // 01, 02, ..., 12
26493 case "LL":
26494 return addLeadingZeros(month + 1, 2);
26495 // 1st, 2nd, ..., 12th
26496 case "Lo":
26497 return localize2.ordinalNumber(month + 1, { unit: "month" });
26498 // Jan, Feb, ..., Dec
26499 case "LLL":
26500 return localize2.month(month, {
26501 width: "abbreviated",
26502 context: "standalone"
26503 });
26504 // J, F, ..., D
26505 case "LLLLL":
26506 return localize2.month(month, {
26507 width: "narrow",
26508 context: "standalone"
26509 });
26510 // January, February, ..., December
26511 case "LLLL":
26512 default:
26513 return localize2.month(month, { width: "wide", context: "standalone" });
26514 }
26515 },
26516 // Local week of year
26517 w: function(date, token, localize2, options) {
26518 const week = getWeek(date, options);
26519 if (token === "wo") {
26520 return localize2.ordinalNumber(week, { unit: "week" });
26521 }
26522 return addLeadingZeros(week, token.length);
26523 },
26524 // ISO week of year
26525 I: function(date, token, localize2) {
26526 const isoWeek = getISOWeek(date);
26527 if (token === "Io") {
26528 return localize2.ordinalNumber(isoWeek, { unit: "week" });
26529 }
26530 return addLeadingZeros(isoWeek, token.length);
26531 },
26532 // Day of the month
26533 d: function(date, token, localize2) {
26534 if (token === "do") {
26535 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
26536 }
26537 return lightFormatters.d(date, token);
26538 },
26539 // Day of year
26540 D: function(date, token, localize2) {
26541 const dayOfYear = getDayOfYear(date);
26542 if (token === "Do") {
26543 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
26544 }
26545 return addLeadingZeros(dayOfYear, token.length);
26546 },
26547 // Day of week
26548 E: function(date, token, localize2) {
26549 const dayOfWeek = date.getDay();
26550 switch (token) {
26551 // Tue
26552 case "E":
26553 case "EE":
26554 case "EEE":
26555 return localize2.day(dayOfWeek, {
26556 width: "abbreviated",
26557 context: "formatting"
26558 });
26559 // T
26560 case "EEEEE":
26561 return localize2.day(dayOfWeek, {
26562 width: "narrow",
26563 context: "formatting"
26564 });
26565 // Tu
26566 case "EEEEEE":
26567 return localize2.day(dayOfWeek, {
26568 width: "short",
26569 context: "formatting"
26570 });
26571 // Tuesday
26572 case "EEEE":
26573 default:
26574 return localize2.day(dayOfWeek, {
26575 width: "wide",
26576 context: "formatting"
26577 });
26578 }
26579 },
26580 // Local day of week
26581 e: function(date, token, localize2, options) {
26582 const dayOfWeek = date.getDay();
26583 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
26584 switch (token) {
26585 // Numerical value (Nth day of week with current locale or weekStartsOn)
26586 case "e":
26587 return String(localDayOfWeek);
26588 // Padded numerical value
26589 case "ee":
26590 return addLeadingZeros(localDayOfWeek, 2);
26591 // 1st, 2nd, ..., 7th
26592 case "eo":
26593 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
26594 case "eee":
26595 return localize2.day(dayOfWeek, {
26596 width: "abbreviated",
26597 context: "formatting"
26598 });
26599 // T
26600 case "eeeee":
26601 return localize2.day(dayOfWeek, {
26602 width: "narrow",
26603 context: "formatting"
26604 });
26605 // Tu
26606 case "eeeeee":
26607 return localize2.day(dayOfWeek, {
26608 width: "short",
26609 context: "formatting"
26610 });
26611 // Tuesday
26612 case "eeee":
26613 default:
26614 return localize2.day(dayOfWeek, {
26615 width: "wide",
26616 context: "formatting"
26617 });
26618 }
26619 },
26620 // Stand-alone local day of week
26621 c: function(date, token, localize2, options) {
26622 const dayOfWeek = date.getDay();
26623 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
26624 switch (token) {
26625 // Numerical value (same as in `e`)
26626 case "c":
26627 return String(localDayOfWeek);
26628 // Padded numerical value
26629 case "cc":
26630 return addLeadingZeros(localDayOfWeek, token.length);
26631 // 1st, 2nd, ..., 7th
26632 case "co":
26633 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
26634 case "ccc":
26635 return localize2.day(dayOfWeek, {
26636 width: "abbreviated",
26637 context: "standalone"
26638 });
26639 // T
26640 case "ccccc":
26641 return localize2.day(dayOfWeek, {
26642 width: "narrow",
26643 context: "standalone"
26644 });
26645 // Tu
26646 case "cccccc":
26647 return localize2.day(dayOfWeek, {
26648 width: "short",
26649 context: "standalone"
26650 });
26651 // Tuesday
26652 case "cccc":
26653 default:
26654 return localize2.day(dayOfWeek, {
26655 width: "wide",
26656 context: "standalone"
26657 });
26658 }
26659 },
26660 // ISO day of week
26661 i: function(date, token, localize2) {
26662 const dayOfWeek = date.getDay();
26663 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
26664 switch (token) {
26665 // 2
26666 case "i":
26667 return String(isoDayOfWeek);
26668 // 02
26669 case "ii":
26670 return addLeadingZeros(isoDayOfWeek, token.length);
26671 // 2nd
26672 case "io":
26673 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
26674 // Tue
26675 case "iii":
26676 return localize2.day(dayOfWeek, {
26677 width: "abbreviated",
26678 context: "formatting"
26679 });
26680 // T
26681 case "iiiii":
26682 return localize2.day(dayOfWeek, {
26683 width: "narrow",
26684 context: "formatting"
26685 });
26686 // Tu
26687 case "iiiiii":
26688 return localize2.day(dayOfWeek, {
26689 width: "short",
26690 context: "formatting"
26691 });
26692 // Tuesday
26693 case "iiii":
26694 default:
26695 return localize2.day(dayOfWeek, {
26696 width: "wide",
26697 context: "formatting"
26698 });
26699 }
26700 },
26701 // AM or PM
26702 a: function(date, token, localize2) {
26703 const hours = date.getHours();
26704 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
26705 switch (token) {
26706 case "a":
26707 case "aa":
26708 return localize2.dayPeriod(dayPeriodEnumValue, {
26709 width: "abbreviated",
26710 context: "formatting"
26711 });
26712 case "aaa":
26713 return localize2.dayPeriod(dayPeriodEnumValue, {
26714 width: "abbreviated",
26715 context: "formatting"
26716 }).toLowerCase();
26717 case "aaaaa":
26718 return localize2.dayPeriod(dayPeriodEnumValue, {
26719 width: "narrow",
26720 context: "formatting"
26721 });
26722 case "aaaa":
26723 default:
26724 return localize2.dayPeriod(dayPeriodEnumValue, {
26725 width: "wide",
26726 context: "formatting"
26727 });
26728 }
26729 },
26730 // AM, PM, midnight, noon
26731 b: function(date, token, localize2) {
26732 const hours = date.getHours();
26733 let dayPeriodEnumValue;
26734 if (hours === 12) {
26735 dayPeriodEnumValue = dayPeriodEnum.noon;
26736 } else if (hours === 0) {
26737 dayPeriodEnumValue = dayPeriodEnum.midnight;
26738 } else {
26739 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
26740 }
26741 switch (token) {
26742 case "b":
26743 case "bb":
26744 return localize2.dayPeriod(dayPeriodEnumValue, {
26745 width: "abbreviated",
26746 context: "formatting"
26747 });
26748 case "bbb":
26749 return localize2.dayPeriod(dayPeriodEnumValue, {
26750 width: "abbreviated",
26751 context: "formatting"
26752 }).toLowerCase();
26753 case "bbbbb":
26754 return localize2.dayPeriod(dayPeriodEnumValue, {
26755 width: "narrow",
26756 context: "formatting"
26757 });
26758 case "bbbb":
26759 default:
26760 return localize2.dayPeriod(dayPeriodEnumValue, {
26761 width: "wide",
26762 context: "formatting"
26763 });
26764 }
26765 },
26766 // in the morning, in the afternoon, in the evening, at night
26767 B: function(date, token, localize2) {
26768 const hours = date.getHours();
26769 let dayPeriodEnumValue;
26770 if (hours >= 17) {
26771 dayPeriodEnumValue = dayPeriodEnum.evening;
26772 } else if (hours >= 12) {
26773 dayPeriodEnumValue = dayPeriodEnum.afternoon;
26774 } else if (hours >= 4) {
26775 dayPeriodEnumValue = dayPeriodEnum.morning;
26776 } else {
26777 dayPeriodEnumValue = dayPeriodEnum.night;
26778 }
26779 switch (token) {
26780 case "B":
26781 case "BB":
26782 case "BBB":
26783 return localize2.dayPeriod(dayPeriodEnumValue, {
26784 width: "abbreviated",
26785 context: "formatting"
26786 });
26787 case "BBBBB":
26788 return localize2.dayPeriod(dayPeriodEnumValue, {
26789 width: "narrow",
26790 context: "formatting"
26791 });
26792 case "BBBB":
26793 default:
26794 return localize2.dayPeriod(dayPeriodEnumValue, {
26795 width: "wide",
26796 context: "formatting"
26797 });
26798 }
26799 },
26800 // Hour [1-12]
26801 h: function(date, token, localize2) {
26802 if (token === "ho") {
26803 let hours = date.getHours() % 12;
26804 if (hours === 0) hours = 12;
26805 return localize2.ordinalNumber(hours, { unit: "hour" });
26806 }
26807 return lightFormatters.h(date, token);
26808 },
26809 // Hour [0-23]
26810 H: function(date, token, localize2) {
26811 if (token === "Ho") {
26812 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
26813 }
26814 return lightFormatters.H(date, token);
26815 },
26816 // Hour [0-11]
26817 K: function(date, token, localize2) {
26818 const hours = date.getHours() % 12;
26819 if (token === "Ko") {
26820 return localize2.ordinalNumber(hours, { unit: "hour" });
26821 }
26822 return addLeadingZeros(hours, token.length);
26823 },
26824 // Hour [1-24]
26825 k: function(date, token, localize2) {
26826 let hours = date.getHours();
26827 if (hours === 0) hours = 24;
26828 if (token === "ko") {
26829 return localize2.ordinalNumber(hours, { unit: "hour" });
26830 }
26831 return addLeadingZeros(hours, token.length);
26832 },
26833 // Minute
26834 m: function(date, token, localize2) {
26835 if (token === "mo") {
26836 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
26837 }
26838 return lightFormatters.m(date, token);
26839 },
26840 // Second
26841 s: function(date, token, localize2) {
26842 if (token === "so") {
26843 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
26844 }
26845 return lightFormatters.s(date, token);
26846 },
26847 // Fraction of second
26848 S: function(date, token) {
26849 return lightFormatters.S(date, token);
26850 },
26851 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
26852 X: function(date, token, _localize) {
26853 const timezoneOffset = date.getTimezoneOffset();
26854 if (timezoneOffset === 0) {
26855 return "Z";
26856 }
26857 switch (token) {
26858 // Hours and optional minutes
26859 case "X":
26860 return formatTimezoneWithOptionalMinutes(timezoneOffset);
26861 // Hours, minutes and optional seconds without `:` delimiter
26862 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26863 // so this token always has the same output as `XX`
26864 case "XXXX":
26865 case "XX":
26866 return formatTimezone(timezoneOffset);
26867 // Hours, minutes and optional seconds with `:` delimiter
26868 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26869 // so this token always has the same output as `XXX`
26870 case "XXXXX":
26871 case "XXX":
26872 // Hours and minutes with `:` delimiter
26873 default:
26874 return formatTimezone(timezoneOffset, ":");
26875 }
26876 },
26877 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
26878 x: function(date, token, _localize) {
26879 const timezoneOffset = date.getTimezoneOffset();
26880 switch (token) {
26881 // Hours and optional minutes
26882 case "x":
26883 return formatTimezoneWithOptionalMinutes(timezoneOffset);
26884 // Hours, minutes and optional seconds without `:` delimiter
26885 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26886 // so this token always has the same output as `xx`
26887 case "xxxx":
26888 case "xx":
26889 return formatTimezone(timezoneOffset);
26890 // Hours, minutes and optional seconds with `:` delimiter
26891 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26892 // so this token always has the same output as `xxx`
26893 case "xxxxx":
26894 case "xxx":
26895 // Hours and minutes with `:` delimiter
26896 default:
26897 return formatTimezone(timezoneOffset, ":");
26898 }
26899 },
26900 // Timezone (GMT)
26901 O: function(date, token, _localize) {
26902 const timezoneOffset = date.getTimezoneOffset();
26903 switch (token) {
26904 // Short
26905 case "O":
26906 case "OO":
26907 case "OOO":
26908 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
26909 // Long
26910 case "OOOO":
26911 default:
26912 return "GMT" + formatTimezone(timezoneOffset, ":");
26913 }
26914 },
26915 // Timezone (specific non-location)
26916 z: function(date, token, _localize) {
26917 const timezoneOffset = date.getTimezoneOffset();
26918 switch (token) {
26919 // Short
26920 case "z":
26921 case "zz":
26922 case "zzz":
26923 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
26924 // Long
26925 case "zzzz":
26926 default:
26927 return "GMT" + formatTimezone(timezoneOffset, ":");
26928 }
26929 },
26930 // Seconds timestamp
26931 t: function(date, token, _localize) {
26932 const timestamp = Math.trunc(+date / 1e3);
26933 return addLeadingZeros(timestamp, token.length);
26934 },
26935 // Milliseconds timestamp
26936 T: function(date, token, _localize) {
26937 return addLeadingZeros(+date, token.length);
26938 }
26939 };
26940 function formatTimezoneShort(offset4, delimiter = "") {
26941 const sign = offset4 > 0 ? "-" : "+";
26942 const absOffset = Math.abs(offset4);
26943 const hours = Math.trunc(absOffset / 60);
26944 const minutes = absOffset % 60;
26945 if (minutes === 0) {
26946 return sign + String(hours);
26947 }
26948 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
26949 }
26950 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
26951 if (offset4 % 60 === 0) {
26952 const sign = offset4 > 0 ? "-" : "+";
26953 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
26954 }
26955 return formatTimezone(offset4, delimiter);
26956 }
26957 function formatTimezone(offset4, delimiter = "") {
26958 const sign = offset4 > 0 ? "-" : "+";
26959 const absOffset = Math.abs(offset4);
26960 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
26961 const minutes = addLeadingZeros(absOffset % 60, 2);
26962 return sign + hours + delimiter + minutes;
26963 }
26964
26965 // node_modules/date-fns/_lib/format/longFormatters.js
26966 var dateLongFormatter = (pattern, formatLong2) => {
26967 switch (pattern) {
26968 case "P":
26969 return formatLong2.date({ width: "short" });
26970 case "PP":
26971 return formatLong2.date({ width: "medium" });
26972 case "PPP":
26973 return formatLong2.date({ width: "long" });
26974 case "PPPP":
26975 default:
26976 return formatLong2.date({ width: "full" });
26977 }
26978 };
26979 var timeLongFormatter = (pattern, formatLong2) => {
26980 switch (pattern) {
26981 case "p":
26982 return formatLong2.time({ width: "short" });
26983 case "pp":
26984 return formatLong2.time({ width: "medium" });
26985 case "ppp":
26986 return formatLong2.time({ width: "long" });
26987 case "pppp":
26988 default:
26989 return formatLong2.time({ width: "full" });
26990 }
26991 };
26992 var dateTimeLongFormatter = (pattern, formatLong2) => {
26993 const matchResult = pattern.match(/(P+)(p+)?/) || [];
26994 const datePattern = matchResult[1];
26995 const timePattern = matchResult[2];
26996 if (!timePattern) {
26997 return dateLongFormatter(pattern, formatLong2);
26998 }
26999 let dateTimeFormat;
27000 switch (datePattern) {
27001 case "P":
27002 dateTimeFormat = formatLong2.dateTime({ width: "short" });
27003 break;
27004 case "PP":
27005 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
27006 break;
27007 case "PPP":
27008 dateTimeFormat = formatLong2.dateTime({ width: "long" });
27009 break;
27010 case "PPPP":
27011 default:
27012 dateTimeFormat = formatLong2.dateTime({ width: "full" });
27013 break;
27014 }
27015 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
27016 };
27017 var longFormatters = {
27018 p: timeLongFormatter,
27019 P: dateTimeLongFormatter
27020 };
27021
27022 // node_modules/date-fns/_lib/protectedTokens.js
27023 var dayOfYearTokenRE = /^D+$/;
27024 var weekYearTokenRE = /^Y+$/;
27025 var throwTokens = ["D", "DD", "YY", "YYYY"];
27026 function isProtectedDayOfYearToken(token) {
27027 return dayOfYearTokenRE.test(token);
27028 }
27029 function isProtectedWeekYearToken(token) {
27030 return weekYearTokenRE.test(token);
27031 }
27032 function warnOrThrowProtectedError(token, format6, input) {
27033 const _message = message(token, format6, input);
27034 console.warn(_message);
27035 if (throwTokens.includes(token)) throw new RangeError(_message);
27036 }
27037 function message(token, format6, input) {
27038 const subject = token[0] === "Y" ? "years" : "days of the month";
27039 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`;
27040 }
27041
27042 // node_modules/date-fns/format.js
27043 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
27044 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
27045 var escapedStringRegExp = /^'([^]*?)'?$/;
27046 var doubleQuoteRegExp = /''/g;
27047 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
27048 function format(date, formatStr, options) {
27049 const defaultOptions2 = getDefaultOptions();
27050 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
27051 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
27052 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
27053 const originalDate = toDate(date, options?.in);
27054 if (!isValid(originalDate)) {
27055 throw new RangeError("Invalid time value");
27056 }
27057 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
27058 const firstCharacter = substring[0];
27059 if (firstCharacter === "p" || firstCharacter === "P") {
27060 const longFormatter = longFormatters[firstCharacter];
27061 return longFormatter(substring, locale.formatLong);
27062 }
27063 return substring;
27064 }).join("").match(formattingTokensRegExp).map((substring) => {
27065 if (substring === "''") {
27066 return { isToken: false, value: "'" };
27067 }
27068 const firstCharacter = substring[0];
27069 if (firstCharacter === "'") {
27070 return { isToken: false, value: cleanEscapedString(substring) };
27071 }
27072 if (formatters[firstCharacter]) {
27073 return { isToken: true, value: substring };
27074 }
27075 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
27076 throw new RangeError(
27077 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
27078 );
27079 }
27080 return { isToken: false, value: substring };
27081 });
27082 if (locale.localize.preprocessor) {
27083 parts = locale.localize.preprocessor(originalDate, parts);
27084 }
27085 const formatterOptions = {
27086 firstWeekContainsDate,
27087 weekStartsOn,
27088 locale
27089 };
27090 return parts.map((part) => {
27091 if (!part.isToken) return part.value;
27092 const token = part.value;
27093 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
27094 warnOrThrowProtectedError(token, formatStr, String(date));
27095 }
27096 const formatter = formatters[token[0]];
27097 return formatter(originalDate, token, locale.localize, formatterOptions);
27098 }).join("");
27099 }
27100 function cleanEscapedString(input) {
27101 const matched = input.match(escapedStringRegExp);
27102 if (!matched) {
27103 return input;
27104 }
27105 return matched[1].replace(doubleQuoteRegExp, "'");
27106 }
27107
27108 // node_modules/date-fns/subDays.js
27109 function subDays(date, amount, options) {
27110 return addDays(date, -amount, options);
27111 }
27112
27113 // node_modules/date-fns/subMonths.js
27114 function subMonths(date, amount, options) {
27115 return addMonths(date, -amount, options);
27116 }
27117
27118 // node_modules/date-fns/subWeeks.js
27119 function subWeeks(date, amount, options) {
27120 return addWeeks(date, -amount, options);
27121 }
27122
27123 // node_modules/date-fns/subYears.js
27124 function subYears(date, amount, options) {
27125 return addYears(date, -amount, options);
27126 }
27127
27128 // packages/dataviews/build-module/utils/operators.mjs
27129 var import_i18n29 = __toESM(require_i18n(), 1);
27130 var import_element84 = __toESM(require_element(), 1);
27131 var import_date = __toESM(require_date(), 1);
27132 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
27133 var filterTextWrappers = {
27134 Name: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
27135 Value: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
27136 };
27137 function getRelativeDate(value, unit) {
27138 switch (unit) {
27139 case "days":
27140 return subDays(/* @__PURE__ */ new Date(), value);
27141 case "weeks":
27142 return subWeeks(/* @__PURE__ */ new Date(), value);
27143 case "months":
27144 return subMonths(/* @__PURE__ */ new Date(), value);
27145 case "years":
27146 return subYears(/* @__PURE__ */ new Date(), value);
27147 default:
27148 return /* @__PURE__ */ new Date();
27149 }
27150 }
27151 var isNoneOperatorDefinition = {
27152 /* translators: DataViews operator name */
27153 label: (0, import_i18n29.__)("Is none of"),
27154 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27155 (0, import_i18n29.sprintf)(
27156 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
27157 (0, import_i18n29.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
27158 filter.name,
27159 activeElements.map((element) => element.label).join(", ")
27160 ),
27161 filterTextWrappers
27162 ),
27163 filter: ((item, field, filterValue) => {
27164 if (!filterValue?.length) {
27165 return true;
27166 }
27167 const fieldValue = field.getValue({ item });
27168 if (Array.isArray(fieldValue)) {
27169 return !filterValue.some(
27170 (fv) => fieldValue.includes(fv)
27171 );
27172 } else if (typeof fieldValue === "string") {
27173 return !filterValue.includes(fieldValue);
27174 }
27175 return false;
27176 }),
27177 selection: "multi"
27178 };
27179 var OPERATORS = [
27180 {
27181 name: OPERATOR_IS_ANY,
27182 /* translators: DataViews operator name */
27183 label: (0, import_i18n29.__)("Includes"),
27184 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27185 (0, import_i18n29.sprintf)(
27186 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
27187 (0, import_i18n29.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
27188 filter.name,
27189 activeElements.map((element) => element.label).join(", ")
27190 ),
27191 filterTextWrappers
27192 ),
27193 filter(item, field, filterValue) {
27194 if (!filterValue?.length) {
27195 return true;
27196 }
27197 const fieldValue = field.getValue({ item });
27198 if (Array.isArray(fieldValue)) {
27199 return filterValue.some(
27200 (fv) => fieldValue.includes(fv)
27201 );
27202 } else if (typeof fieldValue === "string") {
27203 return filterValue.includes(fieldValue);
27204 }
27205 return false;
27206 },
27207 selection: "multi"
27208 },
27209 {
27210 name: OPERATOR_IS_NONE,
27211 ...isNoneOperatorDefinition
27212 },
27213 {
27214 name: OPERATOR_IS_ALL,
27215 /* translators: DataViews operator name */
27216 label: (0, import_i18n29.__)("Includes all"),
27217 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27218 (0, import_i18n29.sprintf)(
27219 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
27220 (0, import_i18n29.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
27221 filter.name,
27222 activeElements.map((element) => element.label).join(", ")
27223 ),
27224 filterTextWrappers
27225 ),
27226 filter(item, field, filterValue) {
27227 if (!filterValue?.length) {
27228 return true;
27229 }
27230 return filterValue.every((value) => {
27231 return field.getValue({ item })?.includes(value);
27232 });
27233 },
27234 selection: "multi"
27235 },
27236 {
27237 name: OPERATOR_IS_NOT_ALL,
27238 ...isNoneOperatorDefinition
27239 },
27240 {
27241 name: OPERATOR_BETWEEN,
27242 /* translators: DataViews operator name */
27243 label: (0, import_i18n29.__)("Between (inc)"),
27244 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27245 (0, import_i18n29.sprintf)(
27246 /* 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". */
27247 (0, import_i18n29.__)(
27248 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
27249 ),
27250 filter.name,
27251 activeElements[0].label[0],
27252 activeElements[0].label[1]
27253 ),
27254 filterTextWrappers
27255 ),
27256 filter(item, field, filterValue) {
27257 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
27258 return true;
27259 }
27260 const fieldValue = field.getValue({ item });
27261 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
27262 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
27263 }
27264 return false;
27265 },
27266 selection: "custom"
27267 },
27268 {
27269 name: OPERATOR_IN_THE_PAST,
27270 /* translators: DataViews operator name */
27271 label: (0, import_i18n29.__)("In the past"),
27272 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27273 (0, import_i18n29.sprintf)(
27274 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
27275 (0, import_i18n29.__)(
27276 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
27277 ),
27278 filter.name,
27279 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
27280 ),
27281 filterTextWrappers
27282 ),
27283 filter(item, field, filterValue) {
27284 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
27285 return true;
27286 }
27287 const targetDate = getRelativeDate(
27288 filterValue.value,
27289 filterValue.unit
27290 );
27291 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
27292 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
27293 },
27294 selection: "custom"
27295 },
27296 {
27297 name: OPERATOR_OVER,
27298 /* translators: DataViews operator name */
27299 label: (0, import_i18n29.__)("Over"),
27300 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27301 (0, import_i18n29.sprintf)(
27302 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
27303 (0, import_i18n29.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
27304 filter.name,
27305 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
27306 ),
27307 filterTextWrappers
27308 ),
27309 filter(item, field, filterValue) {
27310 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
27311 return true;
27312 }
27313 const targetDate = getRelativeDate(
27314 filterValue.value,
27315 filterValue.unit
27316 );
27317 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
27318 return fieldValue < targetDate;
27319 },
27320 selection: "custom"
27321 },
27322 {
27323 name: OPERATOR_IS,
27324 /* translators: DataViews operator name */
27325 label: (0, import_i18n29.__)("Is"),
27326 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27327 (0, import_i18n29.sprintf)(
27328 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
27329 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
27330 filter.name,
27331 activeElements[0].label
27332 ),
27333 filterTextWrappers
27334 ),
27335 filter(item, field, filterValue) {
27336 return filterValue === field.getValue({ item }) || filterValue === void 0;
27337 },
27338 selection: "single"
27339 },
27340 {
27341 name: OPERATOR_IS_NOT,
27342 /* translators: DataViews operator name */
27343 label: (0, import_i18n29.__)("Is not"),
27344 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27345 (0, import_i18n29.sprintf)(
27346 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
27347 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
27348 filter.name,
27349 activeElements[0].label
27350 ),
27351 filterTextWrappers
27352 ),
27353 filter(item, field, filterValue) {
27354 return filterValue !== field.getValue({ item });
27355 },
27356 selection: "single"
27357 },
27358 {
27359 name: OPERATOR_LESS_THAN,
27360 /* translators: DataViews operator name */
27361 label: (0, import_i18n29.__)("Less than"),
27362 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27363 (0, import_i18n29.sprintf)(
27364 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
27365 (0, import_i18n29.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
27366 filter.name,
27367 activeElements[0].label
27368 ),
27369 filterTextWrappers
27370 ),
27371 filter(item, field, filterValue) {
27372 if (filterValue === void 0) {
27373 return true;
27374 }
27375 const fieldValue = field.getValue({ item });
27376 return fieldValue < filterValue;
27377 },
27378 selection: "single"
27379 },
27380 {
27381 name: OPERATOR_GREATER_THAN,
27382 /* translators: DataViews operator name */
27383 label: (0, import_i18n29.__)("Greater than"),
27384 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27385 (0, import_i18n29.sprintf)(
27386 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
27387 (0, import_i18n29.__)(
27388 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
27389 ),
27390 filter.name,
27391 activeElements[0].label
27392 ),
27393 filterTextWrappers
27394 ),
27395 filter(item, field, filterValue) {
27396 if (filterValue === void 0) {
27397 return true;
27398 }
27399 const fieldValue = field.getValue({ item });
27400 return fieldValue > filterValue;
27401 },
27402 selection: "single"
27403 },
27404 {
27405 name: OPERATOR_LESS_THAN_OR_EQUAL,
27406 /* translators: DataViews operator name */
27407 label: (0, import_i18n29.__)("Less than or equal"),
27408 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27409 (0, import_i18n29.sprintf)(
27410 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
27411 (0, import_i18n29.__)(
27412 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
27413 ),
27414 filter.name,
27415 activeElements[0].label
27416 ),
27417 filterTextWrappers
27418 ),
27419 filter(item, field, filterValue) {
27420 if (filterValue === void 0) {
27421 return true;
27422 }
27423 const fieldValue = field.getValue({ item });
27424 return fieldValue <= filterValue;
27425 },
27426 selection: "single"
27427 },
27428 {
27429 name: OPERATOR_GREATER_THAN_OR_EQUAL,
27430 /* translators: DataViews operator name */
27431 label: (0, import_i18n29.__)("Greater than or equal"),
27432 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27433 (0, import_i18n29.sprintf)(
27434 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
27435 (0, import_i18n29.__)(
27436 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
27437 ),
27438 filter.name,
27439 activeElements[0].label
27440 ),
27441 filterTextWrappers
27442 ),
27443 filter(item, field, filterValue) {
27444 if (filterValue === void 0) {
27445 return true;
27446 }
27447 const fieldValue = field.getValue({ item });
27448 return fieldValue >= filterValue;
27449 },
27450 selection: "single"
27451 },
27452 {
27453 name: OPERATOR_BEFORE,
27454 /* translators: DataViews operator name */
27455 label: (0, import_i18n29.__)("Before"),
27456 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27457 (0, import_i18n29.sprintf)(
27458 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
27459 (0, import_i18n29.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
27460 filter.name,
27461 activeElements[0].label
27462 ),
27463 filterTextWrappers
27464 ),
27465 filter(item, field, filterValue) {
27466 if (filterValue === void 0) {
27467 return true;
27468 }
27469 const filterDate = (0, import_date.getDate)(filterValue);
27470 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27471 return fieldDate < filterDate;
27472 },
27473 selection: "single"
27474 },
27475 {
27476 name: OPERATOR_AFTER,
27477 /* translators: DataViews operator name */
27478 label: (0, import_i18n29.__)("After"),
27479 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27480 (0, import_i18n29.sprintf)(
27481 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
27482 (0, import_i18n29.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
27483 filter.name,
27484 activeElements[0].label
27485 ),
27486 filterTextWrappers
27487 ),
27488 filter(item, field, filterValue) {
27489 if (filterValue === void 0) {
27490 return true;
27491 }
27492 const filterDate = (0, import_date.getDate)(filterValue);
27493 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27494 return fieldDate > filterDate;
27495 },
27496 selection: "single"
27497 },
27498 {
27499 name: OPERATOR_BEFORE_INC,
27500 /* translators: DataViews operator name */
27501 label: (0, import_i18n29.__)("Before (inc)"),
27502 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27503 (0, import_i18n29.sprintf)(
27504 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
27505 (0, import_i18n29.__)(
27506 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
27507 ),
27508 filter.name,
27509 activeElements[0].label
27510 ),
27511 filterTextWrappers
27512 ),
27513 filter(item, field, filterValue) {
27514 if (filterValue === void 0) {
27515 return true;
27516 }
27517 const filterDate = (0, import_date.getDate)(filterValue);
27518 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27519 return fieldDate <= filterDate;
27520 },
27521 selection: "single"
27522 },
27523 {
27524 name: OPERATOR_AFTER_INC,
27525 /* translators: DataViews operator name */
27526 label: (0, import_i18n29.__)("After (inc)"),
27527 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27528 (0, import_i18n29.sprintf)(
27529 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
27530 (0, import_i18n29.__)(
27531 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
27532 ),
27533 filter.name,
27534 activeElements[0].label
27535 ),
27536 filterTextWrappers
27537 ),
27538 filter(item, field, filterValue) {
27539 if (filterValue === void 0) {
27540 return true;
27541 }
27542 const filterDate = (0, import_date.getDate)(filterValue);
27543 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27544 return fieldDate >= filterDate;
27545 },
27546 selection: "single"
27547 },
27548 {
27549 name: OPERATOR_CONTAINS,
27550 /* translators: DataViews operator name */
27551 label: (0, import_i18n29.__)("Contains"),
27552 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27553 (0, import_i18n29.sprintf)(
27554 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
27555 (0, import_i18n29.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
27556 filter.name,
27557 activeElements[0].label
27558 ),
27559 filterTextWrappers
27560 ),
27561 filter(item, field, filterValue) {
27562 if (filterValue === void 0) {
27563 return true;
27564 }
27565 const fieldValue = field.getValue({ item });
27566 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
27567 },
27568 selection: "single"
27569 },
27570 {
27571 name: OPERATOR_NOT_CONTAINS,
27572 /* translators: DataViews operator name */
27573 label: (0, import_i18n29.__)("Doesn't contain"),
27574 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27575 (0, import_i18n29.sprintf)(
27576 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
27577 (0, import_i18n29.__)(
27578 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
27579 ),
27580 filter.name,
27581 activeElements[0].label
27582 ),
27583 filterTextWrappers
27584 ),
27585 filter(item, field, filterValue) {
27586 if (filterValue === void 0) {
27587 return true;
27588 }
27589 const fieldValue = field.getValue({ item });
27590 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
27591 },
27592 selection: "single"
27593 },
27594 {
27595 name: OPERATOR_STARTS_WITH,
27596 /* translators: DataViews operator name */
27597 label: (0, import_i18n29.__)("Starts with"),
27598 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27599 (0, import_i18n29.sprintf)(
27600 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
27601 (0, import_i18n29.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
27602 filter.name,
27603 activeElements[0].label
27604 ),
27605 filterTextWrappers
27606 ),
27607 filter(item, field, filterValue) {
27608 if (filterValue === void 0) {
27609 return true;
27610 }
27611 const fieldValue = field.getValue({ item });
27612 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
27613 },
27614 selection: "single"
27615 },
27616 {
27617 name: OPERATOR_ON,
27618 /* translators: DataViews operator name */
27619 label: (0, import_i18n29.__)("On"),
27620 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27621 (0, import_i18n29.sprintf)(
27622 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
27623 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
27624 filter.name,
27625 activeElements[0].label
27626 ),
27627 filterTextWrappers
27628 ),
27629 filter(item, field, filterValue) {
27630 if (filterValue === void 0) {
27631 return true;
27632 }
27633 const filterDate = (0, import_date.getDate)(filterValue);
27634 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27635 return filterDate.getTime() === fieldDate.getTime();
27636 },
27637 selection: "single"
27638 },
27639 {
27640 name: OPERATOR_NOT_ON,
27641 /* translators: DataViews operator name */
27642 label: (0, import_i18n29.__)("Not on"),
27643 filterText: (filter, activeElements) => (0, import_element84.createInterpolateElement)(
27644 (0, import_i18n29.sprintf)(
27645 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
27646 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
27647 filter.name,
27648 activeElements[0].label
27649 ),
27650 filterTextWrappers
27651 ),
27652 filter(item, field, filterValue) {
27653 if (filterValue === void 0) {
27654 return true;
27655 }
27656 const filterDate = (0, import_date.getDate)(filterValue);
27657 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27658 return filterDate.getTime() !== fieldDate.getTime();
27659 },
27660 selection: "single"
27661 }
27662 ];
27663 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
27664 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
27665 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
27666 (op) => op.name === name
27667 );
27668 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
27669
27670 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
27671 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
27672 var ENTER = "Enter";
27673 var SPACE = " ";
27674 var FilterText = ({
27675 activeElements,
27676 filterInView,
27677 filter
27678 }) => {
27679 if (activeElements === void 0 || activeElements.length === 0) {
27680 return filter.name;
27681 }
27682 const operator = getOperatorByName(filterInView?.operator);
27683 if (operator !== void 0) {
27684 return operator.filterText(filter, activeElements);
27685 }
27686 return (0, import_i18n30.sprintf)(
27687 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
27688 (0, import_i18n30.__)("Unknown status for %1$s"),
27689 filter.name
27690 );
27691 };
27692 function OperatorSelector({
27693 filter,
27694 view,
27695 onChangeView
27696 }) {
27697 const operatorOptions = filter.operators?.map((operator) => ({
27698 value: operator,
27699 label: getOperatorByName(operator)?.label || operator
27700 }));
27701 const currentFilter = view.filters?.find(
27702 (_filter) => _filter.field === filter.field
27703 );
27704 const value = currentFilter?.operator || filter.operators[0];
27705 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(
27706 Stack,
27707 {
27708 direction: "row",
27709 gap: "sm",
27710 justify: "flex-start",
27711 className: "dataviews-filters__summary-operators-container",
27712 align: "center",
27713 children: [
27714 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_components23.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
27715 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27716 import_components23.SelectControl,
27717 {
27718 className: "dataviews-filters__summary-operators-filter-select",
27719 label: (0, import_i18n30.__)("Conditions"),
27720 value,
27721 options: operatorOptions,
27722 onChange: (newValue) => {
27723 const newOperator = newValue;
27724 const currentOperator = currentFilter?.operator;
27725 const newFilters = currentFilter ? [
27726 ...(view.filters ?? []).map(
27727 (_filter) => {
27728 if (_filter.field === filter.field) {
27729 const currentOpSelectionModel = getOperatorByName(
27730 currentOperator
27731 )?.selection;
27732 const newOpSelectionModel = getOperatorByName(
27733 newOperator
27734 )?.selection;
27735 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
27736 currentOpSelectionModel,
27737 newOpSelectionModel
27738 ].includes("custom");
27739 return {
27740 ..._filter,
27741 value: shouldResetValue ? void 0 : _filter.value,
27742 operator: newOperator
27743 };
27744 }
27745 return _filter;
27746 }
27747 )
27748 ] : [
27749 ...view.filters ?? [],
27750 {
27751 field: filter.field,
27752 operator: newOperator,
27753 value: void 0
27754 }
27755 ];
27756 onChangeView({
27757 ...view,
27758 page: 1,
27759 filters: newFilters
27760 });
27761 },
27762 size: "small",
27763 variant: "minimal",
27764 hideLabelFromVision: true
27765 }
27766 )
27767 ]
27768 }
27769 );
27770 }
27771 function Filter({
27772 addFilterRef,
27773 openedFilter,
27774 fields,
27775 ...commonProps
27776 }) {
27777 const toggleRef = (0, import_element85.useRef)(null);
27778 const { filter, view, onChangeView } = commonProps;
27779 const filterInView = view.filters?.find(
27780 (f2) => f2.field === filter.field
27781 );
27782 let activeElements = [];
27783 const field = (0, import_element85.useMemo)(() => {
27784 const currentField = fields.find((f2) => f2.id === filter.field);
27785 if (currentField) {
27786 return {
27787 ...currentField,
27788 // Configure getValue as if Item was a plain object.
27789 // See related input-widget.tsx
27790 getValue: ({ item }) => item[currentField.id]
27791 };
27792 }
27793 return currentField;
27794 }, [fields, filter.field]);
27795 const { elements } = useElements({
27796 elements: filter.elements,
27797 getElements: filter.getElements
27798 });
27799 if (elements.length > 0) {
27800 activeElements = elements.filter((element) => {
27801 if (filter.singleSelection) {
27802 return element.value === filterInView?.value;
27803 }
27804 return filterInView?.value?.includes(element.value);
27805 });
27806 } else if (Array.isArray(filterInView?.value)) {
27807 const label = filterInView.value.map((v2) => {
27808 const formattedValue = field?.getValueFormatted({
27809 item: { [field.id]: v2 },
27810 field
27811 });
27812 return formattedValue || String(v2);
27813 });
27814 activeElements = [
27815 {
27816 value: filterInView.value,
27817 // @ts-ignore
27818 label
27819 }
27820 ];
27821 } else if (typeof filterInView?.value === "object") {
27822 activeElements = [
27823 { value: filterInView.value, label: filterInView.value }
27824 ];
27825 } else if (filterInView?.value !== void 0) {
27826 const label = field !== void 0 ? field.getValueFormatted({
27827 item: { [field.id]: filterInView.value },
27828 field
27829 }) : String(filterInView.value);
27830 activeElements = [
27831 {
27832 value: filterInView.value,
27833 label
27834 }
27835 ];
27836 }
27837 const isPrimary = filter.isPrimary;
27838 const isLocked = filterInView?.isLocked;
27839 const hasValues = !isLocked && filterInView?.value !== void 0;
27840 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
27841 const resetOrRemoveLabel = isPrimary ? (0, import_i18n30.__)("Reset") : (0, import_i18n30.__)("Remove");
27842 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27843 import_components23.Dropdown,
27844 {
27845 defaultOpen: openedFilter === filter.field,
27846 contentClassName: "dataviews-filters__summary-popover",
27847 popoverProps: { placement: "bottom-start", role: "dialog" },
27848 onClose: () => {
27849 toggleRef.current?.focus();
27850 },
27851 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
27852 /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(tooltip_exports.Root, { children: [
27853 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27854 tooltip_exports.Trigger,
27855 {
27856 render: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27857 "div",
27858 {
27859 className: clsx_default(
27860 "dataviews-filters__summary-chip",
27861 {
27862 "has-reset": canResetOrRemove,
27863 "has-values": hasValues,
27864 "is-not-clickable": isLocked
27865 }
27866 ),
27867 role: "button",
27868 tabIndex: isLocked ? -1 : 0,
27869 onClick: () => {
27870 if (!isLocked) {
27871 onToggle();
27872 }
27873 },
27874 onKeyDown: (event) => {
27875 if (!isLocked && [ENTER, SPACE].includes(
27876 event.key
27877 )) {
27878 onToggle();
27879 event.preventDefault();
27880 }
27881 },
27882 "aria-disabled": isLocked,
27883 "aria-pressed": isOpen,
27884 "aria-expanded": isOpen,
27885 ref: toggleRef,
27886 children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27887 FilterText,
27888 {
27889 activeElements,
27890 filterInView,
27891 filter
27892 }
27893 )
27894 }
27895 )
27896 }
27897 ),
27898 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(tooltip_exports.Popup, { children: (0, import_i18n30.sprintf)(
27899 /* translators: 1: Filter name. */
27900 (0, import_i18n30.__)("Filter by: %1$s"),
27901 filter.name.toLowerCase()
27902 ) })
27903 ] }),
27904 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(tooltip_exports.Root, { children: [
27905 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27906 tooltip_exports.Trigger,
27907 {
27908 render: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27909 "button",
27910 {
27911 className: clsx_default(
27912 "dataviews-filters__summary-chip-remove",
27913 { "has-values": hasValues }
27914 ),
27915 "aria-label": resetOrRemoveLabel,
27916 onClick: () => {
27917 onChangeView({
27918 ...view,
27919 page: 1,
27920 filters: view.filters?.filter(
27921 (_filter) => _filter.field !== filter.field
27922 )
27923 });
27924 if (!isPrimary) {
27925 addFilterRef.current?.focus();
27926 } else {
27927 toggleRef.current?.focus();
27928 }
27929 },
27930 children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_components23.Icon, { icon: close_small_default })
27931 }
27932 )
27933 }
27934 ),
27935 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
27936 ] })
27937 ] }),
27938 renderContent: () => {
27939 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
27940 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(OperatorSelector, { ...commonProps }),
27941 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27942 SearchWidget,
27943 {
27944 ...commonProps,
27945 filter: {
27946 ...commonProps.filter,
27947 elements
27948 }
27949 }
27950 ) : /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(InputWidget, { ...commonProps, fields })
27951 ] });
27952 }
27953 }
27954 );
27955 }
27956
27957 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
27958 var import_components24 = __toESM(require_components(), 1);
27959 var import_i18n31 = __toESM(require_i18n(), 1);
27960 var import_element86 = __toESM(require_element(), 1);
27961 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
27962 var { Menu: Menu4 } = unlock3(import_components24.privateApis);
27963 function AddFilterMenu({
27964 filters,
27965 view,
27966 onChangeView,
27967 setOpenedFilter,
27968 triggerProps
27969 }) {
27970 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
27971 return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(Menu4, { children: [
27972 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu4.TriggerButton, { ...triggerProps }),
27973 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
27974 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
27975 Menu4.Item,
27976 {
27977 onClick: () => {
27978 setOpenedFilter(filter.field);
27979 onChangeView({
27980 ...view,
27981 page: 1,
27982 filters: [
27983 ...view.filters || [],
27984 {
27985 field: filter.field,
27986 value: void 0,
27987 operator: filter.operators[0]
27988 }
27989 ]
27990 });
27991 },
27992 children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Menu4.ItemLabel, { children: filter.name })
27993 },
27994 filter.field
27995 );
27996 }) })
27997 ] });
27998 }
27999 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
28000 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
28001 return null;
28002 }
28003 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
28004 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
28005 AddFilterMenu,
28006 {
28007 triggerProps: {
28008 render: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
28009 import_components24.Button,
28010 {
28011 accessibleWhenDisabled: true,
28012 size: "compact",
28013 className: "dataviews-filters-button",
28014 variant: "tertiary",
28015 disabled: !inactiveFilters.length,
28016 ref
28017 }
28018 ),
28019 children: (0, import_i18n31.__)("Add filter")
28020 },
28021 ...{ filters, view, onChangeView, setOpenedFilter }
28022 }
28023 );
28024 }
28025 var add_filter_default = (0, import_element86.forwardRef)(AddFilter);
28026
28027 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
28028 var import_components25 = __toESM(require_components(), 1);
28029 var import_i18n32 = __toESM(require_i18n(), 1);
28030 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
28031 function ResetFilter({
28032 filters,
28033 view,
28034 onChangeView
28035 }) {
28036 const isPrimary = (field) => filters.some(
28037 (_filter) => _filter.field === field && _filter.isPrimary
28038 );
28039 const isDisabled = !view.search && !view.filters?.some(
28040 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
28041 );
28042 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28043 import_components25.Button,
28044 {
28045 disabled: isDisabled,
28046 accessibleWhenDisabled: true,
28047 size: "compact",
28048 variant: "tertiary",
28049 className: "dataviews-filters__reset-button",
28050 onClick: () => {
28051 onChangeView({
28052 ...view,
28053 page: 1,
28054 search: "",
28055 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
28056 });
28057 },
28058 children: (0, import_i18n32.__)("Reset")
28059 }
28060 );
28061 }
28062
28063 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
28064 var import_element87 = __toESM(require_element(), 1);
28065 function useFilters(fields, view) {
28066 return (0, import_element87.useMemo)(() => {
28067 const filters = [];
28068 fields.forEach((field) => {
28069 if (field.filterBy === false || !field.hasElements && !field.Edit) {
28070 return;
28071 }
28072 const operators = field.filterBy.operators;
28073 const isPrimary = !!field.filterBy?.isPrimary;
28074 const isLocked = view.filters?.some(
28075 (f2) => f2.field === field.id && !!f2.isLocked
28076 ) ?? false;
28077 filters.push({
28078 field: field.id,
28079 name: field.label,
28080 elements: field.elements,
28081 getElements: field.getElements,
28082 hasElements: field.hasElements,
28083 singleSelection: operators.some(
28084 (op) => isSingleSelectionOperator(op)
28085 ),
28086 operators,
28087 isVisible: isLocked || isPrimary || !!view.filters?.some(
28088 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
28089 ),
28090 isPrimary,
28091 isLocked
28092 });
28093 });
28094 filters.sort((a2, b2) => {
28095 if (a2.isLocked && !b2.isLocked) {
28096 return -1;
28097 }
28098 if (!a2.isLocked && b2.isLocked) {
28099 return 1;
28100 }
28101 if (a2.isPrimary && !b2.isPrimary) {
28102 return -1;
28103 }
28104 if (!a2.isPrimary && b2.isPrimary) {
28105 return 1;
28106 }
28107 return a2.name.localeCompare(b2.name);
28108 });
28109 return filters;
28110 }, [fields, view]);
28111 }
28112 var use_filters_default = useFilters;
28113
28114 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
28115 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
28116 function Filters({ className }) {
28117 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element88.useContext)(dataviews_context_default);
28118 const addFilterRef = (0, import_element88.useRef)(null);
28119 const filters = use_filters_default(fields, view);
28120 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28121 add_filter_default,
28122 {
28123 filters,
28124 view,
28125 onChangeView,
28126 ref: addFilterRef,
28127 setOpenedFilter
28128 },
28129 "add-filter"
28130 );
28131 const visibleFilters = filters.filter((filter) => filter.isVisible);
28132 if (visibleFilters.length === 0) {
28133 return null;
28134 }
28135 const filterComponents = [
28136 ...visibleFilters.map((filter) => {
28137 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28138 Filter,
28139 {
28140 filter,
28141 view,
28142 fields,
28143 onChangeView,
28144 addFilterRef,
28145 openedFilter
28146 },
28147 filter.field
28148 );
28149 }),
28150 addFilter
28151 ];
28152 filterComponents.push(
28153 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28154 ResetFilter,
28155 {
28156 filters,
28157 view,
28158 onChangeView
28159 },
28160 "reset-filters"
28161 )
28162 );
28163 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28164 Stack,
28165 {
28166 direction: "row",
28167 justify: "flex-start",
28168 gap: "sm",
28169 style: { width: "fit-content" },
28170 wrap: "wrap",
28171 className,
28172 children: filterComponents
28173 }
28174 );
28175 }
28176 var filters_default = (0, import_element88.memo)(Filters);
28177
28178 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
28179 var import_element89 = __toESM(require_element(), 1);
28180 var import_components26 = __toESM(require_components(), 1);
28181 var import_i18n33 = __toESM(require_i18n(), 1);
28182 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
28183 function FiltersToggle() {
28184 const {
28185 filters,
28186 view,
28187 onChangeView,
28188 setOpenedFilter,
28189 isShowingFilter,
28190 setIsShowingFilter
28191 } = (0, import_element89.useContext)(dataviews_context_default);
28192 const buttonRef = (0, import_element89.useRef)(null);
28193 const onChangeViewWithFilterVisibility = (0, import_element89.useCallback)(
28194 (_view) => {
28195 onChangeView(_view);
28196 setIsShowingFilter(true);
28197 },
28198 [onChangeView, setIsShowingFilter]
28199 );
28200 if (filters.length === 0) {
28201 return null;
28202 }
28203 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
28204 const addFilterButtonProps = {
28205 label: (0, import_i18n33.__)("Add filter"),
28206 "aria-expanded": false,
28207 isPressed: false
28208 };
28209 const toggleFiltersButtonProps = {
28210 label: (0, import_i18n33._x)("Filter", "verb"),
28211 "aria-expanded": isShowingFilter,
28212 isPressed: isShowingFilter,
28213 onClick: () => {
28214 if (!isShowingFilter) {
28215 setOpenedFilter(null);
28216 }
28217 setIsShowingFilter(!isShowingFilter);
28218 }
28219 };
28220 const hasPrimaryOrLockedFilters = filters.some(
28221 (filter) => filter.isPrimary || filter.isLocked
28222 );
28223 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28224 import_components26.Button,
28225 {
28226 ref: buttonRef,
28227 className: "dataviews-filters__visibility-toggle",
28228 size: "compact",
28229 icon: funnel_default,
28230 disabled: hasPrimaryOrLockedFilters,
28231 accessibleWhenDisabled: true,
28232 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
28233 }
28234 );
28235 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28236 AddFilterMenu,
28237 {
28238 filters,
28239 view,
28240 onChangeView: onChangeViewWithFilterVisibility,
28241 setOpenedFilter,
28242 triggerProps: { render: buttonComponent }
28243 }
28244 ) : /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28245 FilterVisibilityToggle,
28246 {
28247 buttonRef,
28248 filtersCount: view.filters?.length,
28249 children: buttonComponent
28250 }
28251 ) });
28252 }
28253 function FilterVisibilityToggle({
28254 buttonRef,
28255 filtersCount,
28256 children
28257 }) {
28258 (0, import_element89.useEffect)(
28259 () => () => {
28260 buttonRef.current?.focus();
28261 },
28262 [buttonRef]
28263 );
28264 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [
28265 children,
28266 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
28267 ] });
28268 }
28269 var toggle_default = FiltersToggle;
28270
28271 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
28272 var import_element90 = __toESM(require_element(), 1);
28273 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
28274 function FiltersToggled(props) {
28275 const { isShowingFilter } = (0, import_element90.useContext)(dataviews_context_default);
28276 if (!isShowingFilter) {
28277 return null;
28278 }
28279 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(filters_default, { ...props });
28280 }
28281 var filters_toggled_default = FiltersToggled;
28282
28283 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
28284 var import_element91 = __toESM(require_element(), 1);
28285 var import_components27 = __toESM(require_components(), 1);
28286 var import_i18n34 = __toESM(require_i18n(), 1);
28287 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
28288 function DataViewsLayout({ className }) {
28289 const {
28290 actions = [],
28291 data,
28292 fields,
28293 getItemId,
28294 getItemLevel,
28295 hasInitiallyLoaded,
28296 isLoading,
28297 view,
28298 onChangeView,
28299 selection,
28300 onChangeSelection,
28301 setOpenedFilter,
28302 onClickItem,
28303 isItemClickable,
28304 renderItemLink,
28305 defaultLayouts: defaultLayouts3,
28306 containerRef,
28307 empty = /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("p", { children: (0, import_i18n34.__)("No results") })
28308 } = (0, import_element91.useContext)(dataviews_context_default);
28309 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
28310 delay: 200
28311 });
28312 if (!hasInitiallyLoaded) {
28313 if (!isDelayedInitialLoading) {
28314 return null;
28315 }
28316 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components27.Spinner, {}) }) });
28317 }
28318 const ViewComponent = VIEW_LAYOUTS.find(
28319 (v2) => v2.type === view.type && defaultLayouts3[v2.type]
28320 )?.component;
28321 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28322 ViewComponent,
28323 {
28324 className,
28325 actions,
28326 data,
28327 fields,
28328 getItemId,
28329 getItemLevel,
28330 isLoading,
28331 onChangeView,
28332 onChangeSelection,
28333 selection,
28334 setOpenedFilter,
28335 onClickItem,
28336 renderItemLink,
28337 isItemClickable,
28338 view,
28339 empty
28340 }
28341 ) });
28342 }
28343
28344 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
28345 var import_element92 = __toESM(require_element(), 1);
28346 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
28347 var EMPTY_ARRAY5 = [];
28348 function DataViewsFooter() {
28349 const {
28350 view,
28351 paginationInfo: { totalItems = 0, totalPages },
28352 data,
28353 actions = EMPTY_ARRAY5,
28354 isLoading,
28355 hasInitiallyLoaded
28356 } = (0, import_element92.useContext)(dataviews_context_default);
28357 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
28358 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
28359 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
28360 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
28361 return null;
28362 }
28363 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28364 "div",
28365 {
28366 className: "dataviews-footer",
28367 inert: isRefreshing ? "true" : void 0,
28368 children: /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(
28369 Stack,
28370 {
28371 direction: "row",
28372 justify: "end",
28373 align: "center",
28374 className: clsx_default("dataviews-footer__content", {
28375 "is-refreshing": isDelayedRefreshing
28376 }),
28377 gap: "sm",
28378 children: [
28379 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(BulkActionsFooter, {}),
28380 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(dataviews_pagination_default, {})
28381 ]
28382 }
28383 )
28384 }
28385 );
28386 }
28387
28388 // packages/dataviews/build-module/components/dataviews-search/index.mjs
28389 var import_i18n35 = __toESM(require_i18n(), 1);
28390 var import_element93 = __toESM(require_element(), 1);
28391 var import_components28 = __toESM(require_components(), 1);
28392 var import_compose12 = __toESM(require_compose(), 1);
28393 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
28394 var DataViewsSearch = (0, import_element93.memo)(function Search({ label }) {
28395 const { view, onChangeView } = (0, import_element93.useContext)(dataviews_context_default);
28396 const [search, setSearch, debouncedSearch] = (0, import_compose12.useDebouncedInput)(
28397 view.search
28398 );
28399 (0, import_element93.useEffect)(() => {
28400 if (view.search !== debouncedSearch) {
28401 setSearch(view.search ?? "");
28402 }
28403 }, [view.search, setSearch]);
28404 const onChangeViewRef = (0, import_element93.useRef)(onChangeView);
28405 const viewRef = (0, import_element93.useRef)(view);
28406 (0, import_element93.useEffect)(() => {
28407 onChangeViewRef.current = onChangeView;
28408 viewRef.current = view;
28409 }, [onChangeView, view]);
28410 (0, import_element93.useEffect)(() => {
28411 if (debouncedSearch !== viewRef.current?.search) {
28412 onChangeViewRef.current({
28413 ...viewRef.current,
28414 page: view.page ? 1 : void 0,
28415 startPosition: view.startPosition ? 1 : void 0,
28416 search: debouncedSearch
28417 });
28418 }
28419 }, [debouncedSearch]);
28420 const searchLabel = label || (0, import_i18n35.__)("Search");
28421 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28422 import_components28.SearchControl,
28423 {
28424 className: "dataviews-search",
28425 onChange: setSearch,
28426 value: search,
28427 label: searchLabel,
28428 placeholder: searchLabel,
28429 size: "compact"
28430 }
28431 );
28432 });
28433 var dataviews_search_default = DataViewsSearch;
28434
28435 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
28436 var import_components29 = __toESM(require_components(), 1);
28437 var import_i18n36 = __toESM(require_i18n(), 1);
28438 var import_element94 = __toESM(require_element(), 1);
28439 var import_warning = __toESM(require_warning(), 1);
28440 var import_compose13 = __toESM(require_compose(), 1);
28441 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
28442 var { Menu: Menu5 } = unlock3(import_components29.privateApis);
28443 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
28444 className: "dataviews-config__popover",
28445 placement: "bottom-end",
28446 offset: 9
28447 };
28448 function ViewTypeMenu() {
28449 const { view, onChangeView, defaultLayouts: defaultLayouts3 } = (0, import_element94.useContext)(dataviews_context_default);
28450 const availableLayouts = Object.keys(defaultLayouts3);
28451 if (availableLayouts.length <= 1) {
28452 return null;
28453 }
28454 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
28455 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(Menu5, { children: [
28456 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28457 Menu5.TriggerButton,
28458 {
28459 render: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28460 import_components29.Button,
28461 {
28462 size: "compact",
28463 icon: activeView?.icon,
28464 label: (0, import_i18n36.__)("Layout")
28465 }
28466 )
28467 }
28468 ),
28469 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
28470 const config = VIEW_LAYOUTS.find(
28471 (v2) => v2.type === layout
28472 );
28473 if (!config) {
28474 return null;
28475 }
28476 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28477 Menu5.RadioItem,
28478 {
28479 value: layout,
28480 name: "view-actions-available-view",
28481 checked: layout === view.type,
28482 hideOnClick: true,
28483 onChange: (e2) => {
28484 switch (e2.target.value) {
28485 case "list":
28486 case "grid":
28487 case "table":
28488 case "pickerGrid":
28489 case "pickerTable":
28490 case "pickerActivity":
28491 case "activity":
28492 const viewWithoutLayout = { ...view };
28493 if ("layout" in viewWithoutLayout) {
28494 delete viewWithoutLayout.layout;
28495 }
28496 return onChangeView({
28497 ...viewWithoutLayout,
28498 type: e2.target.value,
28499 ...defaultLayouts3[e2.target.value]
28500 });
28501 }
28502 (0, import_warning.default)("Invalid dataview");
28503 },
28504 children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Menu5.ItemLabel, { children: config.label })
28505 },
28506 layout
28507 );
28508 }) })
28509 ] });
28510 }
28511 function SortFieldControl() {
28512 const { view, fields, onChangeView } = (0, import_element94.useContext)(dataviews_context_default);
28513 const orderOptions = (0, import_element94.useMemo)(() => {
28514 const sortableFields = fields.filter(
28515 (field) => field.enableSorting !== false
28516 );
28517 return sortableFields.map((field) => {
28518 return {
28519 label: field.label,
28520 value: field.id
28521 };
28522 });
28523 }, [fields]);
28524 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28525 import_components29.SelectControl,
28526 {
28527 __next40pxDefaultSize: true,
28528 label: (0, import_i18n36.__)("Sort by"),
28529 value: view.sort?.field,
28530 options: orderOptions,
28531 onChange: (value) => {
28532 onChangeView({
28533 ...view,
28534 sort: {
28535 direction: view?.sort?.direction || "desc",
28536 field: value
28537 },
28538 showLevels: false
28539 });
28540 }
28541 }
28542 );
28543 }
28544 function SortDirectionControl() {
28545 const { view, fields, onChangeView } = (0, import_element94.useContext)(dataviews_context_default);
28546 const sortableFields = fields.filter(
28547 (field) => field.enableSorting !== false
28548 );
28549 if (sortableFields.length === 0) {
28550 return null;
28551 }
28552 let value = view.sort?.direction;
28553 if (!value && view.sort?.field) {
28554 value = "desc";
28555 }
28556 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28557 import_components29.__experimentalToggleGroupControl,
28558 {
28559 className: "dataviews-view-config__sort-direction",
28560 __next40pxDefaultSize: true,
28561 isBlock: true,
28562 label: (0, import_i18n36.__)("Order"),
28563 value,
28564 onChange: (newDirection) => {
28565 if (newDirection === "asc" || newDirection === "desc") {
28566 onChangeView({
28567 ...view,
28568 sort: {
28569 direction: newDirection,
28570 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
28571 fields.find(
28572 (field) => field.enableSorting !== false
28573 )?.id || ""
28574 },
28575 showLevels: false
28576 });
28577 return;
28578 }
28579 (0, import_warning.default)("Invalid direction");
28580 },
28581 children: SORTING_DIRECTIONS.map((direction) => {
28582 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28583 import_components29.__experimentalToggleGroupControlOptionIcon,
28584 {
28585 value: direction,
28586 icon: sortIcons[direction],
28587 label: sortLabels[direction]
28588 },
28589 direction
28590 );
28591 })
28592 }
28593 );
28594 }
28595 function ItemsPerPageControl() {
28596 const { view, config, onChangeView } = (0, import_element94.useContext)(dataviews_context_default);
28597 const { infiniteScrollEnabled } = view;
28598 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
28599 return null;
28600 }
28601 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28602 import_components29.__experimentalToggleGroupControl,
28603 {
28604 __next40pxDefaultSize: true,
28605 isBlock: true,
28606 label: (0, import_i18n36.__)("Items per page"),
28607 value: view.perPage || 10,
28608 disabled: !view?.sort?.field,
28609 onChange: (newItemsPerPage) => {
28610 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
28611 onChangeView({
28612 ...view,
28613 perPage: newItemsPerPageNumber,
28614 page: 1
28615 });
28616 },
28617 children: config.perPageSizes.map((value) => {
28618 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28619 import_components29.__experimentalToggleGroupControlOption,
28620 {
28621 value,
28622 label: value.toString()
28623 },
28624 value
28625 );
28626 })
28627 }
28628 );
28629 }
28630 function ResetViewButton() {
28631 const { onReset } = (0, import_element94.useContext)(dataviews_context_default);
28632 if (onReset === void 0) {
28633 return null;
28634 }
28635 const isDisabled = onReset === false;
28636 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28637 import_components29.Button,
28638 {
28639 variant: "tertiary",
28640 size: "compact",
28641 disabled: isDisabled,
28642 accessibleWhenDisabled: true,
28643 className: "dataviews-view-config__reset-button",
28644 onClick: () => {
28645 if (typeof onReset === "function") {
28646 onReset();
28647 }
28648 },
28649 children: (0, import_i18n36.__)("Reset view")
28650 }
28651 );
28652 }
28653 function DataviewsViewConfigDropdown() {
28654 const { view, onReset } = (0, import_element94.useContext)(dataviews_context_default);
28655 const popoverId = (0, import_compose13.useInstanceId)(
28656 _DataViewsViewConfig,
28657 "dataviews-view-config-dropdown"
28658 );
28659 const activeLayout = VIEW_LAYOUTS.find(
28660 (layout) => layout.type === view.type
28661 );
28662 const isModified = typeof onReset === "function";
28663 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28664 import_components29.Dropdown,
28665 {
28666 expandOnMobile: true,
28667 popoverProps: {
28668 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
28669 id: popoverId
28670 },
28671 renderToggle: ({ onToggle, isOpen }) => {
28672 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
28673 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28674 import_components29.Button,
28675 {
28676 size: "compact",
28677 icon: cog_default,
28678 label: (0, import_i18n36._x)(
28679 "View options",
28680 "View is used as a noun"
28681 ),
28682 onClick: onToggle,
28683 "aria-expanded": isOpen ? "true" : "false",
28684 "aria-controls": popoverId
28685 }
28686 ),
28687 isModified && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
28688 ] });
28689 },
28690 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28691 import_components29.__experimentalDropdownContentWrapper,
28692 {
28693 paddingSize: "medium",
28694 className: "dataviews-config__popover-content-wrapper",
28695 children: /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
28696 Stack,
28697 {
28698 direction: "column",
28699 className: "dataviews-view-config",
28700 gap: "xl",
28701 children: [
28702 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
28703 Stack,
28704 {
28705 direction: "row",
28706 justify: "space-between",
28707 align: "center",
28708 className: "dataviews-view-config__header",
28709 children: [
28710 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28711 import_components29.__experimentalHeading,
28712 {
28713 level: 2,
28714 className: "dataviews-settings-section__title",
28715 children: (0, import_i18n36.__)("Appearance")
28716 }
28717 ),
28718 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(ResetViewButton, {})
28719 ]
28720 }
28721 ),
28722 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(Stack, { direction: "column", gap: "lg", children: [
28723 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
28724 Stack,
28725 {
28726 direction: "row",
28727 gap: "sm",
28728 className: "dataviews-view-config__sort-controls",
28729 children: [
28730 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(SortFieldControl, {}),
28731 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(SortDirectionControl, {})
28732 ]
28733 }
28734 ),
28735 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(activeLayout.viewConfigOptions, {}),
28736 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(ItemsPerPageControl, {}),
28737 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(PropertiesSection, {})
28738 ] })
28739 ]
28740 }
28741 )
28742 }
28743 )
28744 }
28745 );
28746 }
28747 function _DataViewsViewConfig() {
28748 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [
28749 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(ViewTypeMenu, {}),
28750 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(DataviewsViewConfigDropdown, {})
28751 ] });
28752 }
28753 var DataViewsViewConfig = (0, import_element94.memo)(_DataViewsViewConfig);
28754 var dataviews_view_config_default = DataViewsViewConfig;
28755
28756 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
28757 var import_components30 = __toESM(require_components(), 1);
28758 var import_element95 = __toESM(require_element(), 1);
28759
28760 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
28761 function getCustomValidity(isValid2, validity) {
28762 let customValidity;
28763 if (isValid2?.required && validity?.required) {
28764 customValidity = validity?.required?.message ? validity.required : void 0;
28765 } else if (isValid2?.pattern && validity?.pattern) {
28766 customValidity = validity.pattern;
28767 } else if (isValid2?.min && validity?.min) {
28768 customValidity = validity.min;
28769 } else if (isValid2?.max && validity?.max) {
28770 customValidity = validity.max;
28771 } else if (isValid2?.minLength && validity?.minLength) {
28772 customValidity = validity.minLength;
28773 } else if (isValid2?.maxLength && validity?.maxLength) {
28774 customValidity = validity.maxLength;
28775 } else if (isValid2?.elements && validity?.elements) {
28776 customValidity = validity.elements;
28777 } else if (validity?.custom) {
28778 customValidity = validity.custom;
28779 }
28780 return customValidity;
28781 }
28782
28783 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
28784 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
28785 var { ValidatedCheckboxControl } = unlock3(import_components30.privateApis);
28786 function Checkbox({
28787 field,
28788 onChange,
28789 data,
28790 hideLabelFromVision,
28791 markWhenOptional,
28792 validity
28793 }) {
28794 const { getValue, setValue, label, description, isValid: isValid2 } = field;
28795 const disabled2 = field.isDisabled({ item: data, field });
28796 const onChangeControl = (0, import_element95.useCallback)(() => {
28797 onChange(
28798 setValue({ item: data, value: !getValue({ item: data }) })
28799 );
28800 }, [data, getValue, onChange, setValue]);
28801 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
28802 ValidatedCheckboxControl,
28803 {
28804 required: !!field.isValid?.required,
28805 markWhenOptional,
28806 customValidity: getCustomValidity(isValid2, validity),
28807 hidden: hideLabelFromVision,
28808 label,
28809 help: description,
28810 checked: getValue({ item: data }),
28811 onChange: onChangeControl,
28812 disabled: disabled2
28813 }
28814 );
28815 }
28816
28817 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
28818 var import_components31 = __toESM(require_components(), 1);
28819 var import_element96 = __toESM(require_element(), 1);
28820 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
28821 var { ValidatedComboboxControl } = unlock3(import_components31.privateApis);
28822 function Combobox3({
28823 data,
28824 field,
28825 onChange,
28826 hideLabelFromVision,
28827 validity
28828 }) {
28829 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
28830 const value = getValue({ item: data }) ?? "";
28831 const onChangeControl = (0, import_element96.useCallback)(
28832 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
28833 [data, onChange, setValue]
28834 );
28835 const { elements, isLoading } = useElements({
28836 elements: field.elements,
28837 getElements: field.getElements
28838 });
28839 if (isLoading) {
28840 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components31.Spinner, {});
28841 }
28842 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28843 ValidatedComboboxControl,
28844 {
28845 required: !!field.isValid?.required,
28846 customValidity: getCustomValidity(isValid2, validity),
28847 label,
28848 value,
28849 help: description,
28850 placeholder,
28851 options: elements,
28852 onChange: onChangeControl,
28853 hideLabelFromVision,
28854 allowReset: true,
28855 expandOnFocus: true
28856 }
28857 );
28858 }
28859
28860 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
28861 var import_components33 = __toESM(require_components(), 1);
28862 var import_element99 = __toESM(require_element(), 1);
28863 var import_i18n38 = __toESM(require_i18n(), 1);
28864 var import_date3 = __toESM(require_date(), 1);
28865
28866 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
28867 var import_components32 = __toESM(require_components(), 1);
28868 var import_element97 = __toESM(require_element(), 1);
28869 var import_i18n37 = __toESM(require_i18n(), 1);
28870 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
28871 var TIME_UNITS_OPTIONS = {
28872 [OPERATOR_IN_THE_PAST]: [
28873 { value: "days", label: (0, import_i18n37.__)("Days") },
28874 { value: "weeks", label: (0, import_i18n37.__)("Weeks") },
28875 { value: "months", label: (0, import_i18n37.__)("Months") },
28876 { value: "years", label: (0, import_i18n37.__)("Years") }
28877 ],
28878 [OPERATOR_OVER]: [
28879 { value: "days", label: (0, import_i18n37.__)("Days ago") },
28880 { value: "weeks", label: (0, import_i18n37.__)("Weeks ago") },
28881 { value: "months", label: (0, import_i18n37.__)("Months ago") },
28882 { value: "years", label: (0, import_i18n37.__)("Years ago") }
28883 ]
28884 };
28885 function RelativeDateControl({
28886 className,
28887 data,
28888 field,
28889 onChange,
28890 hideLabelFromVision,
28891 operator
28892 }) {
28893 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
28894 const { id, label, description, getValue, setValue } = field;
28895 const disabled2 = field.isDisabled({ item: data, field });
28896 const fieldValue = getValue({ item: data });
28897 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
28898 const onChangeValue = (0, import_element97.useCallback)(
28899 (newValue) => onChange(
28900 setValue({
28901 item: data,
28902 value: { value: Number(newValue), unit }
28903 })
28904 ),
28905 [onChange, setValue, data, unit]
28906 );
28907 const onChangeUnit = (0, import_element97.useCallback)(
28908 (newUnit) => onChange(
28909 setValue({
28910 item: data,
28911 value: { value: relValue, unit: newUnit }
28912 })
28913 ),
28914 [onChange, setValue, data, relValue]
28915 );
28916 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
28917 import_components32.BaseControl,
28918 {
28919 id,
28920 className: clsx_default(className, "dataviews-controls__relative-date"),
28921 label,
28922 hideLabelFromVision,
28923 help: description,
28924 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(Stack, { direction: "row", gap: "sm", children: [
28925 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
28926 import_components32.__experimentalNumberControl,
28927 {
28928 __next40pxDefaultSize: true,
28929 className: "dataviews-controls__relative-date-number",
28930 spinControls: "none",
28931 min: 1,
28932 step: 1,
28933 value: relValue,
28934 onChange: onChangeValue,
28935 disabled: disabled2
28936 }
28937 ),
28938 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
28939 import_components32.SelectControl,
28940 {
28941 className: "dataviews-controls__relative-date-unit",
28942 __next40pxDefaultSize: true,
28943 label: (0, import_i18n37.__)("Unit"),
28944 value: unit,
28945 options,
28946 onChange: onChangeUnit,
28947 hideLabelFromVision: true,
28948 disabled: disabled2
28949 }
28950 )
28951 ] })
28952 }
28953 );
28954 }
28955
28956 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
28957 var import_element98 = __toESM(require_element(), 1);
28958 function useDisabledDateMatchers(isValid2, parseDateFn) {
28959 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
28960 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
28961 const disabledMatchers = (0, import_element98.useMemo)(() => {
28962 const matchers = [];
28963 if (minConstraint) {
28964 const minDate = parseDateFn(minConstraint);
28965 if (minDate) {
28966 matchers.push({ before: minDate });
28967 }
28968 }
28969 if (maxConstraint) {
28970 const maxDate = parseDateFn(maxConstraint);
28971 if (maxDate) {
28972 matchers.push({ after: maxDate });
28973 }
28974 }
28975 return matchers.length > 0 ? matchers : void 0;
28976 }, [minConstraint, maxConstraint, parseDateFn]);
28977 return { minConstraint, maxConstraint, disabledMatchers };
28978 }
28979
28980 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
28981 var import_date2 = __toESM(require_date(), 1);
28982 function parseDateTime(dateTimeString) {
28983 if (!dateTimeString) {
28984 return null;
28985 }
28986 const parsed = (0, import_date2.getDate)(dateTimeString);
28987 return parsed && isValid(parsed) ? parsed : null;
28988 }
28989
28990 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
28991 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
28992 var { DateCalendar, ValidatedInputControl } = unlock3(import_components33.privateApis);
28993 var formatDateTime = (value) => {
28994 if (!value) {
28995 return "";
28996 }
28997 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
28998 };
28999 function CalendarDateTimeControl({
29000 data,
29001 field,
29002 onChange,
29003 hideLabelFromVision,
29004 markWhenOptional,
29005 validity,
29006 config
29007 }) {
29008 const { compact } = config || {};
29009 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
29010 const disabled2 = field.isDisabled({ item: data, field });
29011 const fieldValue = getValue({ item: data });
29012 const value = typeof fieldValue === "string" ? fieldValue : void 0;
29013 const [calendarMonth, setCalendarMonth] = (0, import_element99.useState)(() => {
29014 const parsedDate = parseDateTime(value);
29015 return parsedDate || /* @__PURE__ */ new Date();
29016 });
29017 const inputControlRef = (0, import_element99.useRef)(null);
29018 const validationTimeoutRef = (0, import_element99.useRef)(void 0);
29019 const previousFocusRef = (0, import_element99.useRef)(null);
29020 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
29021 const onChangeCallback = (0, import_element99.useCallback)(
29022 (newValue) => onChange(setValue({ item: data, value: newValue })),
29023 [data, onChange, setValue]
29024 );
29025 (0, import_element99.useEffect)(() => {
29026 return () => {
29027 if (validationTimeoutRef.current) {
29028 clearTimeout(validationTimeoutRef.current);
29029 }
29030 };
29031 }, []);
29032 const onSelectDate = (0, import_element99.useCallback)(
29033 (newDate) => {
29034 let dateTimeValue;
29035 if (newDate) {
29036 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
29037 let wpTime;
29038 if (value) {
29039 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
29040 } else {
29041 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
29042 }
29043 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
29044 dateTimeValue = finalDateTime.toISOString();
29045 onChangeCallback(dateTimeValue);
29046 if (validationTimeoutRef.current) {
29047 clearTimeout(validationTimeoutRef.current);
29048 }
29049 } else {
29050 onChangeCallback(void 0);
29051 }
29052 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
29053 validationTimeoutRef.current = setTimeout(() => {
29054 if (inputControlRef.current) {
29055 inputControlRef.current.focus();
29056 inputControlRef.current.blur();
29057 onChangeCallback(dateTimeValue);
29058 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
29059 previousFocusRef.current.focus();
29060 }
29061 }
29062 }, 0);
29063 },
29064 [onChangeCallback, value]
29065 );
29066 const handleManualDateTimeChange = (0, import_element99.useCallback)(
29067 (newValue) => {
29068 if (newValue) {
29069 const dateTime = (0, import_date3.getDate)(newValue);
29070 onChangeCallback(dateTime.toISOString());
29071 const parsedDate = parseDateTime(dateTime.toISOString());
29072 if (parsedDate) {
29073 setCalendarMonth(parsedDate);
29074 }
29075 } else {
29076 onChangeCallback(void 0);
29077 }
29078 },
29079 [onChangeCallback]
29080 );
29081 const { format: fieldFormat } = field;
29082 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
29083 const {
29084 timezone: { string: timezoneString }
29085 } = (0, import_date3.getSettings)();
29086 let displayLabel = label;
29087 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
29088 displayLabel = `${label} (${(0, import_i18n38.__)("Required")})`;
29089 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
29090 displayLabel = `${label} (${(0, import_i18n38.__)("Optional")})`;
29091 }
29092 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29093 import_components33.BaseControl,
29094 {
29095 id,
29096 label: displayLabel,
29097 help: description,
29098 hideLabelFromVision,
29099 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(Stack, { direction: "column", gap: "lg", children: [
29100 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29101 ValidatedInputControl,
29102 {
29103 ref: inputControlRef,
29104 __next40pxDefaultSize: true,
29105 required: !!isValid2?.required,
29106 customValidity: getCustomValidity(isValid2, validity),
29107 type: "datetime-local",
29108 label: (0, import_i18n38.__)("Date time"),
29109 hideLabelFromVision: true,
29110 value: formatDateTime(value),
29111 onChange: handleManualDateTimeChange,
29112 disabled: disabled2,
29113 min: minConstraint ? formatDateTime(minConstraint) : void 0,
29114 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
29115 }
29116 ),
29117 !compact && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29118 DateCalendar,
29119 {
29120 style: { width: "100%" },
29121 selected: value ? parseDateTime(value) || void 0 : void 0,
29122 onSelect: onSelectDate,
29123 month: calendarMonth,
29124 onMonthChange: setCalendarMonth,
29125 timeZone: timezoneString || void 0,
29126 weekStartsOn,
29127 disabled: disabled2 || disabledMatchers
29128 }
29129 )
29130 ] })
29131 }
29132 );
29133 }
29134 function DateTime({
29135 data,
29136 field,
29137 onChange,
29138 hideLabelFromVision,
29139 markWhenOptional,
29140 operator,
29141 validity,
29142 config
29143 }) {
29144 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
29145 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29146 RelativeDateControl,
29147 {
29148 className: "dataviews-controls__datetime",
29149 data,
29150 field,
29151 onChange,
29152 hideLabelFromVision,
29153 operator
29154 }
29155 );
29156 }
29157 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29158 CalendarDateTimeControl,
29159 {
29160 data,
29161 field,
29162 onChange,
29163 hideLabelFromVision,
29164 markWhenOptional,
29165 validity,
29166 config
29167 }
29168 );
29169 }
29170
29171 // packages/dataviews/build-module/components/dataform-controls/date.mjs
29172 var import_components34 = __toESM(require_components(), 1);
29173 var import_element100 = __toESM(require_element(), 1);
29174 var import_i18n39 = __toESM(require_i18n(), 1);
29175 var import_date4 = __toESM(require_date(), 1);
29176 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
29177 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components34.privateApis);
29178 var DATE_PRESETS = [
29179 {
29180 id: "today",
29181 label: (0, import_i18n39.__)("Today"),
29182 getValue: () => (0, import_date4.getDate)(null)
29183 },
29184 {
29185 id: "yesterday",
29186 label: (0, import_i18n39.__)("Yesterday"),
29187 getValue: () => {
29188 const today = (0, import_date4.getDate)(null);
29189 return subDays(today, 1);
29190 }
29191 },
29192 {
29193 id: "past-week",
29194 label: (0, import_i18n39.__)("Past week"),
29195 getValue: () => {
29196 const today = (0, import_date4.getDate)(null);
29197 return subDays(today, 7);
29198 }
29199 },
29200 {
29201 id: "past-month",
29202 label: (0, import_i18n39.__)("Past month"),
29203 getValue: () => {
29204 const today = (0, import_date4.getDate)(null);
29205 return subMonths(today, 1);
29206 }
29207 }
29208 ];
29209 var DATE_RANGE_PRESETS = [
29210 {
29211 id: "last-7-days",
29212 label: (0, import_i18n39.__)("Last 7 days"),
29213 getValue: () => {
29214 const today = (0, import_date4.getDate)(null);
29215 return [subDays(today, 7), today];
29216 }
29217 },
29218 {
29219 id: "last-30-days",
29220 label: (0, import_i18n39.__)("Last 30 days"),
29221 getValue: () => {
29222 const today = (0, import_date4.getDate)(null);
29223 return [subDays(today, 30), today];
29224 }
29225 },
29226 {
29227 id: "month-to-date",
29228 label: (0, import_i18n39.__)("Month to date"),
29229 getValue: () => {
29230 const today = (0, import_date4.getDate)(null);
29231 return [startOfMonth(today), today];
29232 }
29233 },
29234 {
29235 id: "last-year",
29236 label: (0, import_i18n39.__)("Last year"),
29237 getValue: () => {
29238 const today = (0, import_date4.getDate)(null);
29239 return [subYears(today, 1), today];
29240 }
29241 },
29242 {
29243 id: "year-to-date",
29244 label: (0, import_i18n39.__)("Year to date"),
29245 getValue: () => {
29246 const today = (0, import_date4.getDate)(null);
29247 return [startOfYear(today), today];
29248 }
29249 }
29250 ];
29251 var parseDate = (dateString) => {
29252 if (!dateString) {
29253 return null;
29254 }
29255 const parsed = (0, import_date4.getDate)(dateString);
29256 return parsed && isValid(parsed) ? parsed : null;
29257 };
29258 var formatDate = (date) => {
29259 if (!date) {
29260 return "";
29261 }
29262 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
29263 };
29264 function ValidatedDateControl({
29265 field,
29266 validity,
29267 inputRefs,
29268 isTouched,
29269 setIsTouched,
29270 children
29271 }) {
29272 const { isValid: isValid2 } = field;
29273 const [customValidity, setCustomValidity] = (0, import_element100.useState)(void 0);
29274 const validateRefs = (0, import_element100.useCallback)(() => {
29275 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29276 for (const ref of refs) {
29277 const input = ref.current;
29278 if (input && !input.validity.valid) {
29279 setCustomValidity({
29280 type: "invalid",
29281 message: input.validationMessage
29282 });
29283 return;
29284 }
29285 }
29286 setCustomValidity(void 0);
29287 }, [inputRefs]);
29288 (0, import_element100.useEffect)(() => {
29289 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29290 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
29291 for (const ref of refs) {
29292 const input = ref.current;
29293 if (input) {
29294 input.setCustomValidity(
29295 result?.type === "invalid" && result.message ? result.message : ""
29296 );
29297 }
29298 }
29299 }, [inputRefs, isValid2, validity]);
29300 (0, import_element100.useEffect)(() => {
29301 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29302 const handleInvalid = (event) => {
29303 event.preventDefault();
29304 setIsTouched(true);
29305 };
29306 for (const ref of refs) {
29307 ref.current?.addEventListener("invalid", handleInvalid);
29308 }
29309 return () => {
29310 for (const ref of refs) {
29311 ref.current?.removeEventListener("invalid", handleInvalid);
29312 }
29313 };
29314 }, [inputRefs, setIsTouched]);
29315 (0, import_element100.useEffect)(() => {
29316 if (!isTouched) {
29317 return;
29318 }
29319 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
29320 if (result) {
29321 setCustomValidity(result);
29322 } else {
29323 validateRefs();
29324 }
29325 }, [isTouched, isValid2, validity, validateRefs]);
29326 const onBlur = (event) => {
29327 if (isTouched) {
29328 return;
29329 }
29330 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
29331 setIsTouched(true);
29332 }
29333 };
29334 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { onBlur, children: [
29335 children,
29336 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
29337 "p",
29338 {
29339 className: clsx_default(
29340 "components-validated-control__indicator",
29341 customValidity.type === "invalid" ? "is-invalid" : void 0
29342 ),
29343 children: [
29344 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29345 import_components34.Icon,
29346 {
29347 className: "components-validated-control__indicator-icon",
29348 icon: error_default,
29349 size: 16,
29350 fill: "currentColor"
29351 }
29352 ),
29353 customValidity.message
29354 ]
29355 }
29356 ) })
29357 ] });
29358 }
29359 function CalendarDateControl({
29360 data,
29361 field,
29362 onChange,
29363 hideLabelFromVision,
29364 markWhenOptional,
29365 validity
29366 }) {
29367 const {
29368 id,
29369 label,
29370 description,
29371 setValue,
29372 getValue,
29373 isValid: isValid2,
29374 format: fieldFormat
29375 } = field;
29376 const disabled2 = field.isDisabled({ item: data, field });
29377 const [selectedPresetId, setSelectedPresetId] = (0, import_element100.useState)(
29378 null
29379 );
29380 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
29381 const fieldValue = getValue({ item: data });
29382 const value = typeof fieldValue === "string" ? fieldValue : void 0;
29383 const [calendarMonth, setCalendarMonth] = (0, import_element100.useState)(() => {
29384 const parsedDate = parseDate(value);
29385 return parsedDate || /* @__PURE__ */ new Date();
29386 });
29387 const [isTouched, setIsTouched] = (0, import_element100.useState)(false);
29388 const validityTargetRef = (0, import_element100.useRef)(null);
29389 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
29390 const onChangeCallback = (0, import_element100.useCallback)(
29391 (newValue) => onChange(setValue({ item: data, value: newValue })),
29392 [data, onChange, setValue]
29393 );
29394 const onSelectDate = (0, import_element100.useCallback)(
29395 (newDate) => {
29396 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
29397 onChangeCallback(dateValue);
29398 setSelectedPresetId(null);
29399 setIsTouched(true);
29400 },
29401 [onChangeCallback]
29402 );
29403 const handlePresetClick = (0, import_element100.useCallback)(
29404 (preset) => {
29405 const presetDate = preset.getValue();
29406 const dateValue = formatDate(presetDate);
29407 setCalendarMonth(presetDate);
29408 onChangeCallback(dateValue);
29409 setSelectedPresetId(preset.id);
29410 setIsTouched(true);
29411 },
29412 [onChangeCallback]
29413 );
29414 const handleManualDateChange = (0, import_element100.useCallback)(
29415 (newValue) => {
29416 onChangeCallback(newValue);
29417 if (newValue) {
29418 const parsedDate = parseDate(newValue);
29419 if (parsedDate) {
29420 setCalendarMonth(parsedDate);
29421 }
29422 }
29423 setSelectedPresetId(null);
29424 setIsTouched(true);
29425 },
29426 [onChangeCallback]
29427 );
29428 const {
29429 timezone: { string: timezoneString }
29430 } = (0, import_date4.getSettings)();
29431 let displayLabel = label;
29432 if (isValid2?.required && !markWhenOptional) {
29433 displayLabel = `${label} (${(0, import_i18n39.__)("Required")})`;
29434 } else if (!isValid2?.required && markWhenOptional) {
29435 displayLabel = `${label} (${(0, import_i18n39.__)("Optional")})`;
29436 }
29437 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29438 ValidatedDateControl,
29439 {
29440 field,
29441 validity,
29442 inputRefs: validityTargetRef,
29443 isTouched,
29444 setIsTouched,
29445 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29446 import_components34.BaseControl,
29447 {
29448 id,
29449 className: "dataviews-controls__date",
29450 label: displayLabel,
29451 help: description,
29452 hideLabelFromVision,
29453 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(Stack, { direction: "column", gap: "lg", children: [
29454 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
29455 Stack,
29456 {
29457 direction: "row",
29458 gap: "sm",
29459 wrap: "wrap",
29460 justify: "flex-start",
29461 children: [
29462 DATE_PRESETS.map((preset) => {
29463 const isSelected2 = selectedPresetId === preset.id;
29464 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29465 import_components34.Button,
29466 {
29467 className: "dataviews-controls__date-preset",
29468 variant: "tertiary",
29469 isPressed: isSelected2,
29470 size: "small",
29471 disabled: disabled2,
29472 accessibleWhenDisabled: true,
29473 onClick: () => handlePresetClick(preset),
29474 children: preset.label
29475 },
29476 preset.id
29477 );
29478 }),
29479 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29480 import_components34.Button,
29481 {
29482 className: "dataviews-controls__date-preset",
29483 variant: "tertiary",
29484 isPressed: !selectedPresetId,
29485 size: "small",
29486 disabled: !!selectedPresetId || disabled2,
29487 accessibleWhenDisabled: true,
29488 children: (0, import_i18n39.__)("Custom")
29489 }
29490 )
29491 ]
29492 }
29493 ),
29494 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29495 import_components34.__experimentalInputControl,
29496 {
29497 __next40pxDefaultSize: true,
29498 ref: validityTargetRef,
29499 type: "date",
29500 label: (0, import_i18n39.__)("Date"),
29501 hideLabelFromVision: true,
29502 value,
29503 onChange: handleManualDateChange,
29504 required: !!field.isValid?.required,
29505 disabled: disabled2,
29506 min: minConstraint,
29507 max: maxConstraint
29508 }
29509 ),
29510 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29511 DateCalendar2,
29512 {
29513 style: { width: "100%" },
29514 selected: value ? parseDate(value) || void 0 : void 0,
29515 onSelect: onSelectDate,
29516 month: calendarMonth,
29517 onMonthChange: setCalendarMonth,
29518 timeZone: timezoneString || void 0,
29519 weekStartsOn,
29520 disabled: disabled2 || disabledMatchers,
29521 disableNavigation: disabled2
29522 }
29523 )
29524 ] })
29525 }
29526 )
29527 }
29528 );
29529 }
29530 function CalendarDateRangeControl({
29531 data,
29532 field,
29533 onChange,
29534 hideLabelFromVision,
29535 markWhenOptional,
29536 validity
29537 }) {
29538 const {
29539 id,
29540 label,
29541 description,
29542 getValue,
29543 setValue,
29544 isValid: isValid2,
29545 format: fieldFormat
29546 } = field;
29547 const disabled2 = field.isDisabled({ item: data, field });
29548 let value;
29549 const fieldValue = getValue({ item: data });
29550 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
29551 value = fieldValue;
29552 }
29553 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
29554 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
29555 const onChangeCallback = (0, import_element100.useCallback)(
29556 (newValue) => {
29557 onChange(
29558 setValue({
29559 item: data,
29560 value: newValue
29561 })
29562 );
29563 },
29564 [data, onChange, setValue]
29565 );
29566 const [selectedPresetId, setSelectedPresetId] = (0, import_element100.useState)(
29567 null
29568 );
29569 const selectedRange = (0, import_element100.useMemo)(() => {
29570 if (!value) {
29571 return { from: void 0, to: void 0 };
29572 }
29573 const [from, to] = value;
29574 return {
29575 from: parseDate(from) || void 0,
29576 to: parseDate(to) || void 0
29577 };
29578 }, [value]);
29579 const [calendarMonth, setCalendarMonth] = (0, import_element100.useState)(() => {
29580 return selectedRange.from || /* @__PURE__ */ new Date();
29581 });
29582 const [isTouched, setIsTouched] = (0, import_element100.useState)(false);
29583 const fromInputRef = (0, import_element100.useRef)(null);
29584 const toInputRef = (0, import_element100.useRef)(null);
29585 const updateDateRange = (0, import_element100.useCallback)(
29586 (fromDate, toDate2) => {
29587 if (fromDate && toDate2) {
29588 onChangeCallback([
29589 formatDate(fromDate),
29590 formatDate(toDate2)
29591 ]);
29592 } else if (!fromDate && !toDate2) {
29593 onChangeCallback(void 0);
29594 }
29595 },
29596 [onChangeCallback]
29597 );
29598 const onSelectCalendarRange = (0, import_element100.useCallback)(
29599 (newRange) => {
29600 updateDateRange(newRange?.from, newRange?.to);
29601 setSelectedPresetId(null);
29602 setIsTouched(true);
29603 },
29604 [updateDateRange]
29605 );
29606 const handlePresetClick = (0, import_element100.useCallback)(
29607 (preset) => {
29608 const [startDate, endDate] = preset.getValue();
29609 setCalendarMonth(startDate);
29610 updateDateRange(startDate, endDate);
29611 setSelectedPresetId(preset.id);
29612 setIsTouched(true);
29613 },
29614 [updateDateRange]
29615 );
29616 const handleManualDateChange = (0, import_element100.useCallback)(
29617 (fromOrTo, newValue) => {
29618 const [currentFrom, currentTo] = value || [
29619 void 0,
29620 void 0
29621 ];
29622 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
29623 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
29624 updateDateRange(updatedFrom, updatedTo);
29625 if (newValue) {
29626 const parsedDate = parseDate(newValue);
29627 if (parsedDate) {
29628 setCalendarMonth(parsedDate);
29629 }
29630 }
29631 setSelectedPresetId(null);
29632 setIsTouched(true);
29633 },
29634 [value, updateDateRange]
29635 );
29636 const { timezone } = (0, import_date4.getSettings)();
29637 let displayLabel = label;
29638 if (field.isValid?.required && !markWhenOptional) {
29639 displayLabel = `${label} (${(0, import_i18n39.__)("Required")})`;
29640 } else if (!field.isValid?.required && markWhenOptional) {
29641 displayLabel = `${label} (${(0, import_i18n39.__)("Optional")})`;
29642 }
29643 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29644 ValidatedDateControl,
29645 {
29646 field,
29647 validity,
29648 inputRefs: [fromInputRef, toInputRef],
29649 isTouched,
29650 setIsTouched,
29651 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29652 import_components34.BaseControl,
29653 {
29654 id,
29655 className: "dataviews-controls__date",
29656 label: displayLabel,
29657 help: description,
29658 hideLabelFromVision,
29659 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(Stack, { direction: "column", gap: "lg", children: [
29660 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
29661 Stack,
29662 {
29663 direction: "row",
29664 gap: "sm",
29665 wrap: "wrap",
29666 justify: "flex-start",
29667 children: [
29668 DATE_RANGE_PRESETS.map((preset) => {
29669 const isSelected2 = selectedPresetId === preset.id;
29670 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29671 import_components34.Button,
29672 {
29673 className: "dataviews-controls__date-preset",
29674 variant: "tertiary",
29675 isPressed: isSelected2,
29676 size: "small",
29677 disabled: disabled2,
29678 accessibleWhenDisabled: true,
29679 onClick: () => handlePresetClick(preset),
29680 children: preset.label
29681 },
29682 preset.id
29683 );
29684 }),
29685 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29686 import_components34.Button,
29687 {
29688 className: "dataviews-controls__date-preset",
29689 variant: "tertiary",
29690 isPressed: !selectedPresetId,
29691 size: "small",
29692 accessibleWhenDisabled: true,
29693 disabled: !!selectedPresetId || disabled2,
29694 children: (0, import_i18n39.__)("Custom")
29695 }
29696 )
29697 ]
29698 }
29699 ),
29700 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
29701 Stack,
29702 {
29703 direction: "row",
29704 gap: "sm",
29705 justify: "space-between",
29706 className: "dataviews-controls__date-range-inputs",
29707 children: [
29708 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29709 import_components34.__experimentalInputControl,
29710 {
29711 __next40pxDefaultSize: true,
29712 ref: fromInputRef,
29713 type: "date",
29714 label: (0, import_i18n39.__)("From"),
29715 hideLabelFromVision: true,
29716 value: value?.[0],
29717 onChange: (newValue) => handleManualDateChange("from", newValue),
29718 required: !!field.isValid?.required,
29719 disabled: disabled2,
29720 min: minConstraint,
29721 max: maxConstraint
29722 }
29723 ),
29724 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29725 import_components34.__experimentalInputControl,
29726 {
29727 __next40pxDefaultSize: true,
29728 ref: toInputRef,
29729 type: "date",
29730 label: (0, import_i18n39.__)("To"),
29731 hideLabelFromVision: true,
29732 value: value?.[1],
29733 onChange: (newValue) => handleManualDateChange("to", newValue),
29734 required: !!field.isValid?.required,
29735 disabled: disabled2,
29736 min: minConstraint,
29737 max: maxConstraint
29738 }
29739 )
29740 ]
29741 }
29742 ),
29743 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29744 DateRangeCalendar,
29745 {
29746 style: { width: "100%" },
29747 selected: selectedRange,
29748 onSelect: onSelectCalendarRange,
29749 month: calendarMonth,
29750 onMonthChange: setCalendarMonth,
29751 timeZone: timezone.string || void 0,
29752 weekStartsOn,
29753 disabled: disabled2 || disabledMatchers
29754 }
29755 )
29756 ] })
29757 }
29758 )
29759 }
29760 );
29761 }
29762 function DateControl({
29763 data,
29764 field,
29765 onChange,
29766 hideLabelFromVision,
29767 markWhenOptional,
29768 operator,
29769 validity
29770 }) {
29771 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
29772 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29773 RelativeDateControl,
29774 {
29775 className: "dataviews-controls__date",
29776 data,
29777 field,
29778 onChange,
29779 hideLabelFromVision,
29780 operator
29781 }
29782 );
29783 }
29784 if (operator === OPERATOR_BETWEEN) {
29785 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29786 CalendarDateRangeControl,
29787 {
29788 data,
29789 field,
29790 onChange,
29791 hideLabelFromVision,
29792 markWhenOptional,
29793 validity
29794 }
29795 );
29796 }
29797 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29798 CalendarDateControl,
29799 {
29800 data,
29801 field,
29802 onChange,
29803 hideLabelFromVision,
29804 markWhenOptional,
29805 validity
29806 }
29807 );
29808 }
29809
29810 // packages/dataviews/build-module/components/dataform-controls/select.mjs
29811 var import_components35 = __toESM(require_components(), 1);
29812 var import_element101 = __toESM(require_element(), 1);
29813 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
29814 var { ValidatedSelectControl } = unlock3(import_components35.privateApis);
29815 function Select({
29816 data,
29817 field,
29818 onChange,
29819 hideLabelFromVision,
29820 markWhenOptional,
29821 validity
29822 }) {
29823 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
29824 const disabled2 = field.isDisabled({ item: data, field });
29825 const isMultiple = type === "array";
29826 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
29827 const onChangeControl = (0, import_element101.useCallback)(
29828 (newValue) => onChange(setValue({ item: data, value: newValue })),
29829 [data, onChange, setValue]
29830 );
29831 const { elements, isLoading } = useElements({
29832 elements: field.elements,
29833 getElements: field.getElements
29834 });
29835 if (isLoading) {
29836 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components35.Spinner, {});
29837 }
29838 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29839 ValidatedSelectControl,
29840 {
29841 required: !!field.isValid?.required,
29842 markWhenOptional,
29843 customValidity: getCustomValidity(isValid2, validity),
29844 label,
29845 value,
29846 help: description,
29847 options: elements,
29848 onChange: onChangeControl,
29849 __next40pxDefaultSize: true,
29850 hideLabelFromVision,
29851 multiple: isMultiple,
29852 disabled: disabled2
29853 }
29854 );
29855 }
29856
29857 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
29858 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
29859 var ELEMENTS_THRESHOLD = 10;
29860 function AdaptiveSelect(props) {
29861 const { field } = props;
29862 const { elements } = useElements({
29863 elements: field.elements,
29864 getElements: field.getElements
29865 });
29866 if (elements.length >= ELEMENTS_THRESHOLD) {
29867 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Combobox3, { ...props });
29868 }
29869 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(Select, { ...props });
29870 }
29871
29872 // packages/dataviews/build-module/components/dataform-controls/email.mjs
29873 var import_components37 = __toESM(require_components(), 1);
29874
29875 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
29876 var import_components36 = __toESM(require_components(), 1);
29877 var import_element102 = __toESM(require_element(), 1);
29878 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
29879 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components36.privateApis);
29880 function ValidatedText({
29881 data,
29882 field,
29883 onChange,
29884 hideLabelFromVision,
29885 markWhenOptional,
29886 type,
29887 prefix,
29888 suffix,
29889 validity
29890 }) {
29891 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
29892 const value = getValue({ item: data });
29893 const disabled2 = field.isDisabled({ item: data, field });
29894 const onChangeControl = (0, import_element102.useCallback)(
29895 (newValue) => onChange(
29896 setValue({
29897 item: data,
29898 value: newValue
29899 })
29900 ),
29901 [data, setValue, onChange]
29902 );
29903 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
29904 ValidatedInputControl2,
29905 {
29906 required: !!isValid2.required,
29907 markWhenOptional,
29908 customValidity: getCustomValidity(isValid2, validity),
29909 label,
29910 placeholder,
29911 value: value ?? "",
29912 help: description,
29913 onChange: onChangeControl,
29914 hideLabelFromVision,
29915 type,
29916 prefix,
29917 suffix,
29918 disabled: disabled2,
29919 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
29920 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
29921 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
29922 __next40pxDefaultSize: true
29923 }
29924 );
29925 }
29926
29927 // packages/dataviews/build-module/components/dataform-controls/email.mjs
29928 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
29929 function Email({
29930 data,
29931 field,
29932 onChange,
29933 hideLabelFromVision,
29934 markWhenOptional,
29935 validity
29936 }) {
29937 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
29938 ValidatedText,
29939 {
29940 ...{
29941 data,
29942 field,
29943 onChange,
29944 hideLabelFromVision,
29945 markWhenOptional,
29946 validity,
29947 type: "email",
29948 prefix: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components37.Icon, { icon: envelope_default }) })
29949 }
29950 }
29951 );
29952 }
29953
29954 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
29955 var import_components38 = __toESM(require_components(), 1);
29956 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
29957 function Telephone({
29958 data,
29959 field,
29960 onChange,
29961 hideLabelFromVision,
29962 markWhenOptional,
29963 validity
29964 }) {
29965 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
29966 ValidatedText,
29967 {
29968 ...{
29969 data,
29970 field,
29971 onChange,
29972 hideLabelFromVision,
29973 markWhenOptional,
29974 validity,
29975 type: "tel",
29976 prefix: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components38.Icon, { icon: mobile_default }) })
29977 }
29978 }
29979 );
29980 }
29981
29982 // packages/dataviews/build-module/components/dataform-controls/url.mjs
29983 var import_components39 = __toESM(require_components(), 1);
29984 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
29985 function Url({
29986 data,
29987 field,
29988 onChange,
29989 hideLabelFromVision,
29990 markWhenOptional,
29991 validity
29992 }) {
29993 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
29994 ValidatedText,
29995 {
29996 ...{
29997 data,
29998 field,
29999 onChange,
30000 hideLabelFromVision,
30001 markWhenOptional,
30002 validity,
30003 type: "url",
30004 prefix: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(import_components39.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(import_components39.Icon, { icon: link_default }) })
30005 }
30006 }
30007 );
30008 }
30009
30010 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
30011 var import_components40 = __toESM(require_components(), 1);
30012 var import_element103 = __toESM(require_element(), 1);
30013 var import_i18n40 = __toESM(require_i18n(), 1);
30014 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
30015 var { ValidatedNumberControl } = unlock3(import_components40.privateApis);
30016 function toNumberOrEmpty(value) {
30017 if (value === "" || value === void 0) {
30018 return "";
30019 }
30020 const number = Number(value);
30021 return Number.isFinite(number) ? number : "";
30022 }
30023 function BetweenControls({
30024 value,
30025 onChange,
30026 hideLabelFromVision,
30027 step
30028 }) {
30029 const [min2 = "", max2 = ""] = value;
30030 const onChangeMin = (0, import_element103.useCallback)(
30031 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
30032 [onChange, max2]
30033 );
30034 const onChangeMax = (0, import_element103.useCallback)(
30035 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
30036 [onChange, min2]
30037 );
30038 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30039 import_components40.BaseControl,
30040 {
30041 help: (0, import_i18n40.__)("The max. value must be greater than the min. value."),
30042 children: /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_components40.Flex, { direction: "row", gap: 4, children: [
30043 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30044 import_components40.__experimentalNumberControl,
30045 {
30046 label: (0, import_i18n40.__)("Min."),
30047 value: min2,
30048 max: max2 ? Number(max2) - step : void 0,
30049 onChange: onChangeMin,
30050 __next40pxDefaultSize: true,
30051 hideLabelFromVision,
30052 step
30053 }
30054 ),
30055 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30056 import_components40.__experimentalNumberControl,
30057 {
30058 label: (0, import_i18n40.__)("Max."),
30059 value: max2,
30060 min: min2 ? Number(min2) + step : void 0,
30061 onChange: onChangeMax,
30062 __next40pxDefaultSize: true,
30063 hideLabelFromVision,
30064 step
30065 }
30066 )
30067 ] })
30068 }
30069 );
30070 }
30071 function ValidatedNumber({
30072 data,
30073 field,
30074 onChange,
30075 hideLabelFromVision,
30076 markWhenOptional,
30077 operator,
30078 validity
30079 }) {
30080 const decimals = field.format?.decimals ?? 0;
30081 const step = Math.pow(10, Math.abs(decimals) * -1);
30082 const { label, description, getValue, setValue, isValid: isValid2 } = field;
30083 const value = getValue({ item: data }) ?? "";
30084 const disabled2 = field.isDisabled({ item: data, field });
30085 const onChangeControl = (0, import_element103.useCallback)(
30086 (newValue) => {
30087 onChange(
30088 setValue({
30089 item: data,
30090 // Do not convert an empty string or undefined to a number,
30091 // otherwise there's a mismatch between the UI control (empty)
30092 // and the data relied by onChange (0).
30093 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
30094 })
30095 );
30096 },
30097 [data, onChange, setValue]
30098 );
30099 const onChangeBetweenControls = (0, import_element103.useCallback)(
30100 (newValue) => {
30101 onChange(
30102 setValue({
30103 item: data,
30104 value: newValue
30105 })
30106 );
30107 },
30108 [data, onChange, setValue]
30109 );
30110 if (operator === OPERATOR_BETWEEN) {
30111 let valueBetween = ["", ""];
30112 if (Array.isArray(value) && value.length === 2 && value.every(
30113 (element) => typeof element === "number" || element === ""
30114 )) {
30115 valueBetween = value;
30116 }
30117 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30118 BetweenControls,
30119 {
30120 value: valueBetween,
30121 onChange: onChangeBetweenControls,
30122 hideLabelFromVision,
30123 step
30124 }
30125 );
30126 }
30127 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30128 ValidatedNumberControl,
30129 {
30130 required: !!isValid2.required,
30131 markWhenOptional,
30132 customValidity: getCustomValidity(isValid2, validity),
30133 label,
30134 help: description,
30135 value,
30136 onChange: onChangeControl,
30137 __next40pxDefaultSize: true,
30138 hideLabelFromVision,
30139 step,
30140 min: isValid2.min ? isValid2.min.constraint : void 0,
30141 max: isValid2.max ? isValid2.max.constraint : void 0,
30142 disabled: disabled2
30143 }
30144 );
30145 }
30146
30147 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
30148 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
30149 function Integer(props) {
30150 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(ValidatedNumber, { ...props });
30151 }
30152
30153 // packages/dataviews/build-module/components/dataform-controls/number.mjs
30154 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
30155 function Number2(props) {
30156 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(ValidatedNumber, { ...props });
30157 }
30158
30159 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
30160 var import_components41 = __toESM(require_components(), 1);
30161 var import_element104 = __toESM(require_element(), 1);
30162 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
30163 var { ValidatedRadioControl } = unlock3(import_components41.privateApis);
30164 function Radio({
30165 data,
30166 field,
30167 onChange,
30168 hideLabelFromVision,
30169 markWhenOptional,
30170 validity
30171 }) {
30172 const { label, description, getValue, setValue, isValid: isValid2 } = field;
30173 const disabled2 = field.isDisabled({ item: data, field });
30174 const { elements, isLoading } = useElements({
30175 elements: field.elements,
30176 getElements: field.getElements
30177 });
30178 const value = getValue({ item: data });
30179 const onChangeControl = (0, import_element104.useCallback)(
30180 (newValue) => onChange(setValue({ item: data, value: newValue })),
30181 [data, onChange, setValue]
30182 );
30183 if (isLoading) {
30184 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components41.Spinner, {});
30185 }
30186 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30187 ValidatedRadioControl,
30188 {
30189 required: !!field.isValid?.required,
30190 markWhenOptional,
30191 customValidity: getCustomValidity(isValid2, validity),
30192 label,
30193 help: description,
30194 onChange: onChangeControl,
30195 options: elements,
30196 selected: value,
30197 hideLabelFromVision,
30198 disabled: disabled2
30199 }
30200 );
30201 }
30202
30203 // packages/dataviews/build-module/components/dataform-controls/text.mjs
30204 var import_element105 = __toESM(require_element(), 1);
30205 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1);
30206 function Text3({
30207 data,
30208 field,
30209 onChange,
30210 hideLabelFromVision,
30211 markWhenOptional,
30212 config,
30213 validity
30214 }) {
30215 const { prefix, suffix } = config || {};
30216 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
30217 ValidatedText,
30218 {
30219 ...{
30220 data,
30221 field,
30222 onChange,
30223 hideLabelFromVision,
30224 markWhenOptional,
30225 validity,
30226 prefix: prefix ? (0, import_element105.createElement)(prefix) : void 0,
30227 suffix: suffix ? (0, import_element105.createElement)(suffix) : void 0
30228 }
30229 }
30230 );
30231 }
30232
30233 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
30234 var import_components42 = __toESM(require_components(), 1);
30235 var import_element106 = __toESM(require_element(), 1);
30236 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1);
30237 var { ValidatedToggleControl } = unlock3(import_components42.privateApis);
30238 function Toggle({
30239 field,
30240 onChange,
30241 data,
30242 hideLabelFromVision,
30243 markWhenOptional,
30244 validity
30245 }) {
30246 const { label, description, getValue, setValue, isValid: isValid2 } = field;
30247 const disabled2 = field.isDisabled({ item: data, field });
30248 const onChangeControl = (0, import_element106.useCallback)(() => {
30249 onChange(
30250 setValue({ item: data, value: !getValue({ item: data }) })
30251 );
30252 }, [onChange, setValue, data, getValue]);
30253 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
30254 ValidatedToggleControl,
30255 {
30256 required: !!isValid2.required,
30257 markWhenOptional,
30258 customValidity: getCustomValidity(isValid2, validity),
30259 hidden: hideLabelFromVision,
30260 label,
30261 help: description,
30262 checked: getValue({ item: data }),
30263 onChange: onChangeControl,
30264 disabled: disabled2
30265 }
30266 );
30267 }
30268
30269 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
30270 var import_components43 = __toESM(require_components(), 1);
30271 var import_element107 = __toESM(require_element(), 1);
30272 var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1);
30273 var { ValidatedTextareaControl } = unlock3(import_components43.privateApis);
30274 function Textarea({
30275 data,
30276 field,
30277 onChange,
30278 hideLabelFromVision,
30279 markWhenOptional,
30280 config,
30281 validity
30282 }) {
30283 const { rows = 4 } = config || {};
30284 const disabled2 = field.isDisabled({ item: data, field });
30285 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
30286 const value = field.getValue({ item: data });
30287 const onChangeControl = (0, import_element107.useCallback)(
30288 (newValue) => onChange(setValue({ item: data, value: newValue })),
30289 [data, onChange, setValue]
30290 );
30291 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
30292 ValidatedTextareaControl,
30293 {
30294 required: !!isValid2.required,
30295 markWhenOptional,
30296 customValidity: getCustomValidity(isValid2, validity),
30297 label,
30298 placeholder,
30299 value: value ?? "",
30300 help: description,
30301 onChange: onChangeControl,
30302 rows,
30303 disabled: disabled2,
30304 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
30305 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
30306 __next40pxDefaultSize: true,
30307 hideLabelFromVision
30308 }
30309 );
30310 }
30311
30312 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
30313 var import_components44 = __toESM(require_components(), 1);
30314 var import_element108 = __toESM(require_element(), 1);
30315 var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1);
30316 var { ValidatedToggleGroupControl } = unlock3(import_components44.privateApis);
30317 function ToggleGroup({
30318 data,
30319 field,
30320 onChange,
30321 hideLabelFromVision,
30322 markWhenOptional,
30323 validity
30324 }) {
30325 const { getValue, setValue, isValid: isValid2 } = field;
30326 const disabled2 = field.isDisabled({ item: data, field });
30327 const value = getValue({ item: data });
30328 const onChangeControl = (0, import_element108.useCallback)(
30329 (newValue) => onChange(setValue({ item: data, value: newValue })),
30330 [data, onChange, setValue]
30331 );
30332 const { elements, isLoading } = useElements({
30333 elements: field.elements,
30334 getElements: field.getElements
30335 });
30336 if (isLoading) {
30337 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(import_components44.Spinner, {});
30338 }
30339 if (elements.length === 0) {
30340 return null;
30341 }
30342 const selectedOption = elements.find((el) => el.value === value);
30343 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
30344 ValidatedToggleGroupControl,
30345 {
30346 required: !!field.isValid?.required,
30347 markWhenOptional,
30348 customValidity: getCustomValidity(isValid2, validity),
30349 __next40pxDefaultSize: true,
30350 isBlock: true,
30351 label: field.label,
30352 help: selectedOption?.description || field.description,
30353 onChange: onChangeControl,
30354 value,
30355 hideLabelFromVision,
30356 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
30357 import_components44.__experimentalToggleGroupControlOption,
30358 {
30359 label: el.label,
30360 value: el.value,
30361 disabled: disabled2
30362 },
30363 el.value
30364 ))
30365 }
30366 );
30367 }
30368
30369 // packages/dataviews/build-module/components/dataform-controls/array.mjs
30370 var import_components45 = __toESM(require_components(), 1);
30371 var import_element109 = __toESM(require_element(), 1);
30372 var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1);
30373 var { ValidatedFormTokenField } = unlock3(import_components45.privateApis);
30374 function ArrayControl({
30375 data,
30376 field,
30377 onChange,
30378 hideLabelFromVision,
30379 markWhenOptional,
30380 validity
30381 }) {
30382 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
30383 const value = getValue({ item: data });
30384 const disabled2 = field.isDisabled({ item: data, field });
30385 const { elements, isLoading } = useElements({
30386 elements: field.elements,
30387 getElements: field.getElements
30388 });
30389 const arrayValueAsElements = (0, import_element109.useMemo)(
30390 () => Array.isArray(value) ? value.map((token) => {
30391 const element = elements?.find(
30392 (suggestion) => suggestion.value === token
30393 );
30394 return element || { value: token, label: token };
30395 }) : [],
30396 [value, elements]
30397 );
30398 const onChangeControl = (0, import_element109.useCallback)(
30399 (tokens) => {
30400 const valueTokens = tokens.map((token) => {
30401 if (typeof token === "object" && "value" in token) {
30402 return token.value;
30403 }
30404 return token;
30405 });
30406 onChange(setValue({ item: data, value: valueTokens }));
30407 },
30408 [onChange, setValue, data]
30409 );
30410 if (isLoading) {
30411 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components45.Spinner, {});
30412 }
30413 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
30414 ValidatedFormTokenField,
30415 {
30416 required: !!isValid2?.required,
30417 markWhenOptional,
30418 customValidity: getCustomValidity(isValid2, validity),
30419 label: hideLabelFromVision ? void 0 : label,
30420 value: arrayValueAsElements,
30421 onChange: onChangeControl,
30422 placeholder,
30423 suggestions: elements?.map((element) => element.value),
30424 disabled: disabled2,
30425 __experimentalValidateInput: (token) => {
30426 if (field.isValid?.elements && elements) {
30427 return elements.some(
30428 (element) => element.value === token || element.label === token
30429 );
30430 }
30431 return true;
30432 },
30433 __experimentalExpandOnFocus: elements && elements.length > 0,
30434 help: description ?? (field.isValid?.elements ? "" : void 0),
30435 displayTransform: (token) => {
30436 if (typeof token === "object" && "label" in token) {
30437 return token.label;
30438 }
30439 if (typeof token === "string" && elements) {
30440 const element = elements.find(
30441 (el) => el.value === token
30442 );
30443 return element?.label || token;
30444 }
30445 return token;
30446 },
30447 __experimentalRenderItem: ({ item }) => {
30448 if (typeof item === "string" && elements) {
30449 const element = elements.find(
30450 (el) => el.value === item
30451 );
30452 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("span", { children: element?.label || item });
30453 }
30454 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("span", { children: item });
30455 }
30456 }
30457 );
30458 }
30459
30460 // node_modules/colord/index.mjs
30461 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
30462 var t = function(r3) {
30463 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
30464 };
30465 var n = function(r3, t2, n2) {
30466 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
30467 };
30468 var e = function(r3, t2, n2) {
30469 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
30470 };
30471 var u = function(r3) {
30472 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
30473 };
30474 var a = function(r3) {
30475 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
30476 };
30477 var o = function(r3) {
30478 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
30479 };
30480 var i = /^#([0-9a-f]{3,8})$/i;
30481 var s = function(r3) {
30482 var t2 = r3.toString(16);
30483 return t2.length < 2 ? "0" + t2 : t2;
30484 };
30485 var h = function(r3) {
30486 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;
30487 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
30488 };
30489 var b = function(r3) {
30490 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
30491 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
30492 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;
30493 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 };
30494 };
30495 var g = function(r3) {
30496 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
30497 };
30498 var d = function(r3) {
30499 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
30500 };
30501 var f = function(r3) {
30502 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 }));
30503 var t2, n2, e2;
30504 };
30505 var c = function(r3) {
30506 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 };
30507 var t2, n2, e2, u2;
30508 };
30509 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30510 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30511 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30512 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30513 var y = { string: [[function(r3) {
30514 var t2 = i.exec(r3);
30515 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;
30516 }, "hex"], [function(r3) {
30517 var t2 = v.exec(r3) || m.exec(r3);
30518 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;
30519 }, "rgb"], [function(t2) {
30520 var n2 = l.exec(t2) || p.exec(t2);
30521 if (!n2) return null;
30522 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) });
30523 return f(a2);
30524 }, "hsl"]], object: [[function(r3) {
30525 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
30526 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
30527 }, "rgb"], [function(r3) {
30528 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
30529 if (!t(n2) || !t(e2) || !t(u2)) return null;
30530 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
30531 return f(i2);
30532 }, "hsl"], [function(r3) {
30533 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
30534 if (!t(n2) || !t(a2) || !t(o2)) return null;
30535 var h2 = (function(r4) {
30536 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
30537 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
30538 return b(h2);
30539 }, "hsv"]] };
30540 var N = function(r3, t2) {
30541 for (var n2 = 0; n2 < t2.length; n2++) {
30542 var e2 = t2[n2][0](r3);
30543 if (e2) return [e2, t2[n2][1]];
30544 }
30545 return [null, void 0];
30546 };
30547 var x = function(r3) {
30548 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
30549 };
30550 var M = function(r3, t2) {
30551 var n2 = c(r3);
30552 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
30553 };
30554 var H = function(r3) {
30555 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
30556 };
30557 var $ = function(r3, t2) {
30558 var n2 = c(r3);
30559 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
30560 };
30561 var j = (function() {
30562 function r3(r4) {
30563 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
30564 }
30565 return r3.prototype.isValid = function() {
30566 return null !== this.parsed;
30567 }, r3.prototype.brightness = function() {
30568 return n(H(this.rgba), 2);
30569 }, r3.prototype.isDark = function() {
30570 return H(this.rgba) < 0.5;
30571 }, r3.prototype.isLight = function() {
30572 return H(this.rgba) >= 0.5;
30573 }, r3.prototype.toHex = function() {
30574 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;
30575 var r4, t2, e2, u2, a2, i2;
30576 }, r3.prototype.toRgb = function() {
30577 return o(this.rgba);
30578 }, r3.prototype.toRgbString = function() {
30579 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 + ")";
30580 var r4, t2, n2, e2, u2;
30581 }, r3.prototype.toHsl = function() {
30582 return d(c(this.rgba));
30583 }, r3.prototype.toHslString = function() {
30584 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 + "%)";
30585 var r4, t2, n2, e2, u2;
30586 }, r3.prototype.toHsv = function() {
30587 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
30588 var r4;
30589 }, r3.prototype.invert = function() {
30590 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
30591 var r4;
30592 }, r3.prototype.saturate = function(r4) {
30593 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
30594 }, r3.prototype.desaturate = function(r4) {
30595 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
30596 }, r3.prototype.grayscale = function() {
30597 return w(M(this.rgba, -1));
30598 }, r3.prototype.lighten = function(r4) {
30599 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
30600 }, r3.prototype.darken = function(r4) {
30601 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
30602 }, r3.prototype.rotate = function(r4) {
30603 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
30604 }, r3.prototype.alpha = function(r4) {
30605 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
30606 var t2;
30607 }, r3.prototype.hue = function(r4) {
30608 var t2 = c(this.rgba);
30609 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
30610 }, r3.prototype.isEqual = function(r4) {
30611 return this.toHex() === w(r4).toHex();
30612 }, r3;
30613 })();
30614 var w = function(r3) {
30615 return r3 instanceof j ? r3 : new j(r3);
30616 };
30617
30618 // packages/dataviews/build-module/components/dataform-controls/color.mjs
30619 var import_components46 = __toESM(require_components(), 1);
30620 var import_element110 = __toESM(require_element(), 1);
30621 var import_i18n41 = __toESM(require_i18n(), 1);
30622 var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1);
30623 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components46.privateApis);
30624 var ColorPickerDropdown = ({
30625 color,
30626 onColorChange,
30627 disabled: disabled2
30628 }) => {
30629 const validColor = color && w(color).isValid() ? color : "#ffffff";
30630 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
30631 import_components46.Dropdown,
30632 {
30633 className: "dataviews-controls__color-picker-dropdown",
30634 popoverProps: { resize: false },
30635 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
30636 import_components46.Button,
30637 {
30638 onClick: onToggle,
30639 "aria-label": (0, import_i18n41.__)("Open color picker"),
30640 size: "small",
30641 disabled: disabled2,
30642 accessibleWhenDisabled: true,
30643 icon: () => /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components46.ColorIndicator, { colorValue: validColor })
30644 }
30645 ),
30646 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components46.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
30647 import_components46.ColorPicker,
30648 {
30649 color: validColor,
30650 onChange: onColorChange,
30651 enableAlpha: true
30652 }
30653 ) })
30654 }
30655 );
30656 };
30657 function Color({
30658 data,
30659 field,
30660 onChange,
30661 hideLabelFromVision,
30662 markWhenOptional,
30663 validity
30664 }) {
30665 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
30666 const disabled2 = field.isDisabled({ item: data, field });
30667 const value = field.getValue({ item: data }) || "";
30668 const handleColorChange = (0, import_element110.useCallback)(
30669 (newColor) => {
30670 onChange(setValue({ item: data, value: newColor }));
30671 },
30672 [data, onChange, setValue]
30673 );
30674 const handleInputChange = (0, import_element110.useCallback)(
30675 (newValue) => {
30676 onChange(setValue({ item: data, value: newValue || "" }));
30677 },
30678 [data, onChange, setValue]
30679 );
30680 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
30681 ValidatedInputControl3,
30682 {
30683 required: !!field.isValid?.required,
30684 markWhenOptional,
30685 customValidity: getCustomValidity(isValid2, validity),
30686 label,
30687 placeholder,
30688 value,
30689 help: description,
30690 onChange: handleInputChange,
30691 hideLabelFromVision,
30692 type: "text",
30693 disabled: disabled2,
30694 prefix: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components46.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
30695 ColorPickerDropdown,
30696 {
30697 color: value,
30698 onColorChange: handleColorChange,
30699 disabled: disabled2
30700 }
30701 ) })
30702 }
30703 );
30704 }
30705
30706 // packages/dataviews/build-module/components/dataform-controls/password.mjs
30707 var import_components47 = __toESM(require_components(), 1);
30708 var import_element111 = __toESM(require_element(), 1);
30709 var import_i18n42 = __toESM(require_i18n(), 1);
30710 var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1);
30711 function Password({
30712 data,
30713 field,
30714 onChange,
30715 hideLabelFromVision,
30716 markWhenOptional,
30717 validity
30718 }) {
30719 const [isVisible2, setIsVisible] = (0, import_element111.useState)(false);
30720 const disabled2 = field.isDisabled({ item: data, field });
30721 const toggleVisibility = (0, import_element111.useCallback)(() => {
30722 setIsVisible((prev) => !prev);
30723 }, []);
30724 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
30725 ValidatedText,
30726 {
30727 ...{
30728 data,
30729 field,
30730 onChange,
30731 hideLabelFromVision,
30732 markWhenOptional,
30733 validity,
30734 type: isVisible2 ? "text" : "password",
30735 suffix: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(import_components47.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
30736 import_components47.Button,
30737 {
30738 icon: isVisible2 ? unseen_default : seen_default,
30739 onClick: toggleVisibility,
30740 size: "small",
30741 label: isVisible2 ? (0, import_i18n42.__)("Hide password") : (0, import_i18n42.__)("Show password"),
30742 disabled: disabled2,
30743 accessibleWhenDisabled: true
30744 }
30745 ) })
30746 }
30747 }
30748 );
30749 }
30750
30751 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
30752 function hasElements(field) {
30753 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
30754 }
30755
30756 // packages/dataviews/build-module/components/dataform-controls/index.mjs
30757 var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1);
30758 var FORM_CONTROLS = {
30759 adaptiveSelect: AdaptiveSelect,
30760 array: ArrayControl,
30761 checkbox: Checkbox,
30762 color: Color,
30763 combobox: Combobox3,
30764 datetime: DateTime,
30765 date: DateControl,
30766 email: Email,
30767 telephone: Telephone,
30768 url: Url,
30769 integer: Integer,
30770 number: Number2,
30771 password: Password,
30772 radio: Radio,
30773 select: Select,
30774 text: Text3,
30775 toggle: Toggle,
30776 textarea: Textarea,
30777 toggleGroup: ToggleGroup
30778 };
30779 function isEditConfig(value) {
30780 return value && typeof value === "object" && typeof value.control === "string";
30781 }
30782 function createConfiguredControl(config) {
30783 const { control, ...controlConfig } = config;
30784 const BaseControlType = getControlByType(control);
30785 if (BaseControlType === null) {
30786 return null;
30787 }
30788 return function ConfiguredControl(props) {
30789 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(BaseControlType, { ...props, config: controlConfig });
30790 };
30791 }
30792 function getControl(field, fallback) {
30793 if (typeof field.Edit === "function") {
30794 return field.Edit;
30795 }
30796 if (typeof field.Edit === "string") {
30797 return getControlByType(field.Edit);
30798 }
30799 if (isEditConfig(field.Edit)) {
30800 return createConfiguredControl(field.Edit);
30801 }
30802 if (hasElements(field) && field.type !== "array") {
30803 return getControlByType("adaptiveSelect");
30804 }
30805 if (fallback === null) {
30806 return null;
30807 }
30808 return getControlByType(fallback);
30809 }
30810 function getControlByType(type) {
30811 if (Object.keys(FORM_CONTROLS).includes(type)) {
30812 return FORM_CONTROLS[type];
30813 }
30814 return null;
30815 }
30816
30817 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
30818 function getFilterBy(field, defaultOperators, validOperators) {
30819 if (field.filterBy === false) {
30820 return false;
30821 }
30822 const operators = field.filterBy?.operators?.filter(
30823 (op) => validOperators.includes(op)
30824 ) ?? defaultOperators;
30825 if (operators.length === 0) {
30826 return false;
30827 }
30828 return {
30829 isPrimary: !!field.filterBy?.isPrimary,
30830 operators
30831 };
30832 }
30833 var get_filter_by_default = getFilterBy;
30834
30835 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
30836 var getValueFromId = (id) => ({ item }) => {
30837 const path = id.split(".");
30838 let value = item;
30839 for (const segment of path) {
30840 if (value.hasOwnProperty(segment)) {
30841 value = value[segment];
30842 } else {
30843 value = void 0;
30844 }
30845 }
30846 return value;
30847 };
30848 var get_value_from_id_default = getValueFromId;
30849
30850 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
30851 var setValueFromId = (id) => ({ value }) => {
30852 const path = id.split(".");
30853 const result = {};
30854 let current = result;
30855 for (const segment of path.slice(0, -1)) {
30856 current[segment] = {};
30857 current = current[segment];
30858 }
30859 current[path.at(-1)] = value;
30860 return result;
30861 };
30862 var set_value_from_id_default = setValueFromId;
30863
30864 // packages/dataviews/build-module/field-types/email.mjs
30865 var import_i18n43 = __toESM(require_i18n(), 1);
30866
30867 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
30868 function RenderFromElements({
30869 item,
30870 field
30871 }) {
30872 const { elements, isLoading } = useElements({
30873 elements: field.elements,
30874 getElements: field.getElements
30875 });
30876 const value = field.getValue({ item });
30877 if (isLoading) {
30878 return value;
30879 }
30880 if (elements.length === 0) {
30881 return value;
30882 }
30883 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
30884 }
30885
30886 // packages/dataviews/build-module/field-types/utils/render-default.mjs
30887 var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1);
30888 function render({
30889 item,
30890 field
30891 }) {
30892 if (field.hasElements) {
30893 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(RenderFromElements, { item, field });
30894 }
30895 return field.getValueFormatted({ item, field });
30896 }
30897
30898 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
30899 var sort_text_default = (a2, b2, direction) => {
30900 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
30901 };
30902
30903 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
30904 function isValidRequired(item, field) {
30905 const value = field.getValue({ item });
30906 return ![void 0, "", null].includes(value);
30907 }
30908
30909 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
30910 function isValidMinLength(item, field) {
30911 if (typeof field.isValid.minLength?.constraint !== "number") {
30912 return false;
30913 }
30914 const value = field.getValue({ item });
30915 if ([void 0, "", null].includes(value)) {
30916 return true;
30917 }
30918 return String(value).length >= field.isValid.minLength.constraint;
30919 }
30920
30921 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
30922 function isValidMaxLength(item, field) {
30923 if (typeof field.isValid.maxLength?.constraint !== "number") {
30924 return false;
30925 }
30926 const value = field.getValue({ item });
30927 if ([void 0, "", null].includes(value)) {
30928 return true;
30929 }
30930 return String(value).length <= field.isValid.maxLength.constraint;
30931 }
30932
30933 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
30934 function isValidPattern(item, field) {
30935 if (field.isValid.pattern?.constraint === void 0) {
30936 return true;
30937 }
30938 try {
30939 const regexp = new RegExp(field.isValid.pattern.constraint);
30940 const value = field.getValue({ item });
30941 if ([void 0, "", null].includes(value)) {
30942 return true;
30943 }
30944 return regexp.test(String(value));
30945 } catch {
30946 return false;
30947 }
30948 }
30949
30950 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
30951 function isValidElements(item, field) {
30952 const elements = field.elements ?? [];
30953 const validValues = elements.map((el) => el.value);
30954 if (validValues.length === 0) {
30955 return true;
30956 }
30957 const value = field.getValue({ item });
30958 return [].concat(value).every((v2) => validValues.includes(v2));
30959 }
30960
30961 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
30962 function getValueFormatted({
30963 item,
30964 field
30965 }) {
30966 return field.getValue({ item });
30967 }
30968 var get_value_formatted_default_default = getValueFormatted;
30969
30970 // packages/dataviews/build-module/field-types/email.mjs
30971 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])?)*$/;
30972 function isValidCustom(item, field) {
30973 const value = field.getValue({ item });
30974 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
30975 return (0, import_i18n43.__)("Value must be a valid email address.");
30976 }
30977 return null;
30978 }
30979 var email_default = {
30980 type: "email",
30981 render,
30982 Edit: "email",
30983 sort: sort_text_default,
30984 enableSorting: true,
30985 enableGlobalSearch: false,
30986 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
30987 validOperators: [
30988 OPERATOR_IS,
30989 OPERATOR_IS_NOT,
30990 OPERATOR_CONTAINS,
30991 OPERATOR_NOT_CONTAINS,
30992 OPERATOR_STARTS_WITH,
30993 // Multiple selection
30994 OPERATOR_IS_ANY,
30995 OPERATOR_IS_NONE,
30996 OPERATOR_IS_ALL,
30997 OPERATOR_IS_NOT_ALL
30998 ],
30999 format: {},
31000 getValueFormatted: get_value_formatted_default_default,
31001 validate: {
31002 required: isValidRequired,
31003 pattern: isValidPattern,
31004 minLength: isValidMinLength,
31005 maxLength: isValidMaxLength,
31006 elements: isValidElements,
31007 custom: isValidCustom
31008 }
31009 };
31010
31011 // packages/dataviews/build-module/field-types/integer.mjs
31012 var import_i18n44 = __toESM(require_i18n(), 1);
31013
31014 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
31015 var sort_number_default = (a2, b2, direction) => {
31016 return direction === "asc" ? a2 - b2 : b2 - a2;
31017 };
31018
31019 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
31020 function isValidMin(item, field) {
31021 if (typeof field.isValid.min?.constraint !== "number") {
31022 return false;
31023 }
31024 const value = field.getValue({ item });
31025 if ([void 0, "", null].includes(value)) {
31026 return true;
31027 }
31028 return Number(value) >= field.isValid.min.constraint;
31029 }
31030
31031 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
31032 function isValidMax(item, field) {
31033 if (typeof field.isValid.max?.constraint !== "number") {
31034 return false;
31035 }
31036 const value = field.getValue({ item });
31037 if ([void 0, "", null].includes(value)) {
31038 return true;
31039 }
31040 return Number(value) <= field.isValid.max.constraint;
31041 }
31042
31043 // packages/dataviews/build-module/field-types/integer.mjs
31044 var format2 = {
31045 separatorThousand: ","
31046 };
31047 function getValueFormatted2({
31048 item,
31049 field
31050 }) {
31051 let value = field.getValue({ item });
31052 if (value === null || value === void 0) {
31053 return "";
31054 }
31055 value = Number(value);
31056 if (!Number.isFinite(value)) {
31057 return String(value);
31058 }
31059 let formatInteger;
31060 if (field.type !== "integer") {
31061 formatInteger = format2;
31062 } else {
31063 formatInteger = field.format;
31064 }
31065 const { separatorThousand } = formatInteger;
31066 const integerValue = Math.trunc(value);
31067 if (!separatorThousand) {
31068 return String(integerValue);
31069 }
31070 return String(integerValue).replace(
31071 /\B(?=(\d{3})+(?!\d))/g,
31072 separatorThousand
31073 );
31074 }
31075 function isValidCustom2(item, field) {
31076 const value = field.getValue({ item });
31077 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
31078 return (0, import_i18n44.__)("Value must be an integer.");
31079 }
31080 return null;
31081 }
31082 var integer_default = {
31083 type: "integer",
31084 render,
31085 Edit: "integer",
31086 sort: sort_number_default,
31087 enableSorting: true,
31088 enableGlobalSearch: false,
31089 defaultOperators: [
31090 OPERATOR_IS,
31091 OPERATOR_IS_NOT,
31092 OPERATOR_LESS_THAN,
31093 OPERATOR_GREATER_THAN,
31094 OPERATOR_LESS_THAN_OR_EQUAL,
31095 OPERATOR_GREATER_THAN_OR_EQUAL,
31096 OPERATOR_BETWEEN
31097 ],
31098 validOperators: [
31099 // Single-selection
31100 OPERATOR_IS,
31101 OPERATOR_IS_NOT,
31102 OPERATOR_LESS_THAN,
31103 OPERATOR_GREATER_THAN,
31104 OPERATOR_LESS_THAN_OR_EQUAL,
31105 OPERATOR_GREATER_THAN_OR_EQUAL,
31106 OPERATOR_BETWEEN,
31107 // Multiple-selection
31108 OPERATOR_IS_ANY,
31109 OPERATOR_IS_NONE,
31110 OPERATOR_IS_ALL,
31111 OPERATOR_IS_NOT_ALL
31112 ],
31113 format: format2,
31114 getValueFormatted: getValueFormatted2,
31115 validate: {
31116 required: isValidRequired,
31117 min: isValidMin,
31118 max: isValidMax,
31119 elements: isValidElements,
31120 custom: isValidCustom2
31121 }
31122 };
31123
31124 // packages/dataviews/build-module/field-types/number.mjs
31125 var import_i18n45 = __toESM(require_i18n(), 1);
31126 var format3 = {
31127 separatorThousand: ",",
31128 separatorDecimal: ".",
31129 decimals: 2
31130 };
31131 function getValueFormatted3({
31132 item,
31133 field
31134 }) {
31135 let value = field.getValue({ item });
31136 if (value === null || value === void 0) {
31137 return "";
31138 }
31139 value = Number(value);
31140 if (!Number.isFinite(value)) {
31141 return String(value);
31142 }
31143 let formatNumber;
31144 if (field.type !== "number") {
31145 formatNumber = format3;
31146 } else {
31147 formatNumber = field.format;
31148 }
31149 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
31150 const fixedValue = value.toFixed(decimals);
31151 const [integerPart, decimalPart] = fixedValue.split(".");
31152 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
31153 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
31154 }
31155 function isEmpty(value) {
31156 return value === "" || value === void 0 || value === null;
31157 }
31158 function isValidCustom3(item, field) {
31159 const value = field.getValue({ item });
31160 if (!isEmpty(value) && !Number.isFinite(value)) {
31161 return (0, import_i18n45.__)("Value must be a number.");
31162 }
31163 return null;
31164 }
31165 var number_default = {
31166 type: "number",
31167 render,
31168 Edit: "number",
31169 sort: sort_number_default,
31170 enableSorting: true,
31171 enableGlobalSearch: false,
31172 defaultOperators: [
31173 OPERATOR_IS,
31174 OPERATOR_IS_NOT,
31175 OPERATOR_LESS_THAN,
31176 OPERATOR_GREATER_THAN,
31177 OPERATOR_LESS_THAN_OR_EQUAL,
31178 OPERATOR_GREATER_THAN_OR_EQUAL,
31179 OPERATOR_BETWEEN
31180 ],
31181 validOperators: [
31182 // Single-selection
31183 OPERATOR_IS,
31184 OPERATOR_IS_NOT,
31185 OPERATOR_LESS_THAN,
31186 OPERATOR_GREATER_THAN,
31187 OPERATOR_LESS_THAN_OR_EQUAL,
31188 OPERATOR_GREATER_THAN_OR_EQUAL,
31189 OPERATOR_BETWEEN,
31190 // Multiple-selection
31191 OPERATOR_IS_ANY,
31192 OPERATOR_IS_NONE,
31193 OPERATOR_IS_ALL,
31194 OPERATOR_IS_NOT_ALL
31195 ],
31196 format: format3,
31197 getValueFormatted: getValueFormatted3,
31198 validate: {
31199 required: isValidRequired,
31200 min: isValidMin,
31201 max: isValidMax,
31202 elements: isValidElements,
31203 custom: isValidCustom3
31204 }
31205 };
31206
31207 // packages/dataviews/build-module/field-types/text.mjs
31208 var text_default = {
31209 type: "text",
31210 render,
31211 Edit: "text",
31212 sort: sort_text_default,
31213 enableSorting: true,
31214 enableGlobalSearch: false,
31215 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31216 validOperators: [
31217 // Single selection
31218 OPERATOR_IS,
31219 OPERATOR_IS_NOT,
31220 OPERATOR_CONTAINS,
31221 OPERATOR_NOT_CONTAINS,
31222 OPERATOR_STARTS_WITH,
31223 // Multiple selection
31224 OPERATOR_IS_ANY,
31225 OPERATOR_IS_NONE,
31226 OPERATOR_IS_ALL,
31227 OPERATOR_IS_NOT_ALL
31228 ],
31229 format: {},
31230 getValueFormatted: get_value_formatted_default_default,
31231 validate: {
31232 required: isValidRequired,
31233 pattern: isValidPattern,
31234 minLength: isValidMinLength,
31235 maxLength: isValidMaxLength,
31236 elements: isValidElements
31237 }
31238 };
31239
31240 // packages/dataviews/build-module/field-types/datetime.mjs
31241 var import_date7 = __toESM(require_date(), 1);
31242
31243 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
31244 var import_date6 = __toESM(require_date(), 1);
31245 function parseDateLike(value) {
31246 if (!value) {
31247 return null;
31248 }
31249 if (!isValid(new Date(value))) {
31250 return null;
31251 }
31252 const parsed = (0, import_date6.getDate)(value);
31253 return parsed && isValid(parsed) ? parsed : null;
31254 }
31255 function validateDateLikeBoundary(item, field, boundary) {
31256 const constraint = field.isValid[boundary]?.constraint;
31257 if (typeof constraint !== "string") {
31258 return false;
31259 }
31260 const value = field.getValue({ item });
31261 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
31262 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
31263 return true;
31264 }
31265 const parsedConstraint = parseDateLike(constraint);
31266 const parsedValue = parseDateLike(String(boundaryValue));
31267 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
31268 }
31269 function isValidMinDate(item, field) {
31270 return validateDateLikeBoundary(item, field, "min");
31271 }
31272 function isValidMaxDate(item, field) {
31273 return validateDateLikeBoundary(item, field, "max");
31274 }
31275
31276 // packages/dataviews/build-module/field-types/datetime.mjs
31277 var format4 = {
31278 datetime: (0, import_date7.getSettings)().formats.datetime,
31279 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
31280 };
31281 function getValueFormatted4({
31282 item,
31283 field
31284 }) {
31285 const value = field.getValue({ item });
31286 if (["", void 0, null].includes(value)) {
31287 return "";
31288 }
31289 let formatDatetime;
31290 if (field.type !== "datetime") {
31291 formatDatetime = format4;
31292 } else {
31293 formatDatetime = field.format;
31294 }
31295 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
31296 }
31297 var sort = (a2, b2, direction) => {
31298 const timeA = new Date(a2).getTime();
31299 const timeB = new Date(b2).getTime();
31300 return direction === "asc" ? timeA - timeB : timeB - timeA;
31301 };
31302 var datetime_default = {
31303 type: "datetime",
31304 render,
31305 Edit: "datetime",
31306 sort,
31307 enableSorting: true,
31308 enableGlobalSearch: false,
31309 defaultOperators: [
31310 OPERATOR_ON,
31311 OPERATOR_NOT_ON,
31312 OPERATOR_BEFORE,
31313 OPERATOR_AFTER,
31314 OPERATOR_BEFORE_INC,
31315 OPERATOR_AFTER_INC,
31316 OPERATOR_IN_THE_PAST,
31317 OPERATOR_OVER
31318 ],
31319 validOperators: [
31320 OPERATOR_ON,
31321 OPERATOR_NOT_ON,
31322 OPERATOR_BEFORE,
31323 OPERATOR_AFTER,
31324 OPERATOR_BEFORE_INC,
31325 OPERATOR_AFTER_INC,
31326 OPERATOR_IN_THE_PAST,
31327 OPERATOR_OVER
31328 ],
31329 format: format4,
31330 getValueFormatted: getValueFormatted4,
31331 validate: {
31332 required: isValidRequired,
31333 elements: isValidElements,
31334 min: isValidMinDate,
31335 max: isValidMaxDate
31336 }
31337 };
31338
31339 // packages/dataviews/build-module/field-types/date.mjs
31340 var import_date8 = __toESM(require_date(), 1);
31341 var format5 = {
31342 date: (0, import_date8.getSettings)().formats.date,
31343 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
31344 };
31345 function getValueFormatted5({
31346 item,
31347 field
31348 }) {
31349 const value = field.getValue({ item });
31350 if (["", void 0, null].includes(value)) {
31351 return "";
31352 }
31353 let formatDate2;
31354 if (field.type !== "date") {
31355 formatDate2 = format5;
31356 } else {
31357 formatDate2 = field.format;
31358 }
31359 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
31360 }
31361 var sort2 = (a2, b2, direction) => {
31362 const timeA = new Date(a2).getTime();
31363 const timeB = new Date(b2).getTime();
31364 return direction === "asc" ? timeA - timeB : timeB - timeA;
31365 };
31366 var date_default = {
31367 type: "date",
31368 render,
31369 Edit: "date",
31370 sort: sort2,
31371 enableSorting: true,
31372 enableGlobalSearch: false,
31373 defaultOperators: [
31374 OPERATOR_ON,
31375 OPERATOR_NOT_ON,
31376 OPERATOR_BEFORE,
31377 OPERATOR_AFTER,
31378 OPERATOR_BEFORE_INC,
31379 OPERATOR_AFTER_INC,
31380 OPERATOR_IN_THE_PAST,
31381 OPERATOR_OVER,
31382 OPERATOR_BETWEEN
31383 ],
31384 validOperators: [
31385 OPERATOR_ON,
31386 OPERATOR_NOT_ON,
31387 OPERATOR_BEFORE,
31388 OPERATOR_AFTER,
31389 OPERATOR_BEFORE_INC,
31390 OPERATOR_AFTER_INC,
31391 OPERATOR_IN_THE_PAST,
31392 OPERATOR_OVER,
31393 OPERATOR_BETWEEN
31394 ],
31395 format: format5,
31396 getValueFormatted: getValueFormatted5,
31397 validate: {
31398 required: isValidRequired,
31399 elements: isValidElements,
31400 min: isValidMinDate,
31401 max: isValidMaxDate
31402 }
31403 };
31404
31405 // packages/dataviews/build-module/field-types/boolean.mjs
31406 var import_i18n46 = __toESM(require_i18n(), 1);
31407
31408 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
31409 function isValidRequiredForBool(item, field) {
31410 const value = field.getValue({ item });
31411 return value === true;
31412 }
31413
31414 // packages/dataviews/build-module/field-types/boolean.mjs
31415 function getValueFormatted6({
31416 item,
31417 field
31418 }) {
31419 const value = field.getValue({ item });
31420 if (value === true) {
31421 return (0, import_i18n46.__)("True");
31422 }
31423 if (value === false) {
31424 return (0, import_i18n46.__)("False");
31425 }
31426 return "";
31427 }
31428 function isValidCustom4(item, field) {
31429 const value = field.getValue({ item });
31430 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
31431 return (0, import_i18n46.__)("Value must be true, false, or undefined");
31432 }
31433 return null;
31434 }
31435 var sort3 = (a2, b2, direction) => {
31436 const boolA = Boolean(a2);
31437 const boolB = Boolean(b2);
31438 if (boolA === boolB) {
31439 return 0;
31440 }
31441 if (direction === "asc") {
31442 return boolA ? 1 : -1;
31443 }
31444 return boolA ? -1 : 1;
31445 };
31446 var boolean_default = {
31447 type: "boolean",
31448 render,
31449 Edit: "checkbox",
31450 sort: sort3,
31451 validate: {
31452 required: isValidRequiredForBool,
31453 elements: isValidElements,
31454 custom: isValidCustom4
31455 },
31456 enableSorting: true,
31457 enableGlobalSearch: false,
31458 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31459 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31460 format: {},
31461 getValueFormatted: getValueFormatted6
31462 };
31463
31464 // packages/dataviews/build-module/field-types/media.mjs
31465 var media_default = {
31466 type: "media",
31467 render: () => null,
31468 Edit: null,
31469 sort: () => 0,
31470 enableSorting: false,
31471 enableGlobalSearch: false,
31472 defaultOperators: [],
31473 validOperators: [],
31474 format: {},
31475 getValueFormatted: get_value_formatted_default_default,
31476 // cannot validate any constraint, so
31477 // the only available validation for the field author
31478 // would be providing a custom validator.
31479 validate: {}
31480 };
31481
31482 // packages/dataviews/build-module/field-types/array.mjs
31483 var import_i18n47 = __toESM(require_i18n(), 1);
31484
31485 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
31486 function isValidRequiredForArray(item, field) {
31487 const value = field.getValue({ item });
31488 return Array.isArray(value) && value.length > 0 && value.every(
31489 (element) => ![void 0, "", null].includes(element)
31490 );
31491 }
31492
31493 // packages/dataviews/build-module/field-types/array.mjs
31494 function getValueFormatted7({
31495 item,
31496 field
31497 }) {
31498 const value = field.getValue({ item });
31499 const arr = Array.isArray(value) ? value : [];
31500 return arr.join(", ");
31501 }
31502 function render2({ item, field }) {
31503 return getValueFormatted7({ item, field });
31504 }
31505 function isValidCustom5(item, field) {
31506 const value = field.getValue({ item });
31507 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
31508 return (0, import_i18n47.__)("Value must be an array.");
31509 }
31510 if (!value.every((v2) => typeof v2 === "string")) {
31511 return (0, import_i18n47.__)("Every value must be a string.");
31512 }
31513 return null;
31514 }
31515 var sort4 = (a2, b2, direction) => {
31516 const arrA = Array.isArray(a2) ? a2 : [];
31517 const arrB = Array.isArray(b2) ? b2 : [];
31518 if (arrA.length !== arrB.length) {
31519 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
31520 }
31521 const joinedA = arrA.join(",");
31522 const joinedB = arrB.join(",");
31523 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
31524 };
31525 var array_default = {
31526 type: "array",
31527 render: render2,
31528 Edit: "array",
31529 sort: sort4,
31530 enableSorting: true,
31531 enableGlobalSearch: false,
31532 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31533 validOperators: [
31534 OPERATOR_IS_ANY,
31535 OPERATOR_IS_NONE,
31536 OPERATOR_IS_ALL,
31537 OPERATOR_IS_NOT_ALL
31538 ],
31539 format: {},
31540 getValueFormatted: getValueFormatted7,
31541 validate: {
31542 required: isValidRequiredForArray,
31543 elements: isValidElements,
31544 custom: isValidCustom5
31545 }
31546 };
31547
31548 // packages/dataviews/build-module/field-types/password.mjs
31549 function getValueFormatted8({
31550 item,
31551 field
31552 }) {
31553 return field.getValue({ item }) ? "••••••••" : "";
31554 }
31555 var password_default = {
31556 type: "password",
31557 render,
31558 Edit: "password",
31559 sort: () => 0,
31560 // Passwords should not be sortable for security reasons
31561 enableSorting: false,
31562 enableGlobalSearch: false,
31563 defaultOperators: [],
31564 validOperators: [],
31565 format: {},
31566 getValueFormatted: getValueFormatted8,
31567 validate: {
31568 required: isValidRequired,
31569 pattern: isValidPattern,
31570 minLength: isValidMinLength,
31571 maxLength: isValidMaxLength,
31572 elements: isValidElements
31573 }
31574 };
31575
31576 // packages/dataviews/build-module/field-types/telephone.mjs
31577 var telephone_default = {
31578 type: "telephone",
31579 render,
31580 Edit: "telephone",
31581 sort: sort_text_default,
31582 enableSorting: true,
31583 enableGlobalSearch: false,
31584 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31585 validOperators: [
31586 OPERATOR_IS,
31587 OPERATOR_IS_NOT,
31588 OPERATOR_CONTAINS,
31589 OPERATOR_NOT_CONTAINS,
31590 OPERATOR_STARTS_WITH,
31591 // Multiple selection
31592 OPERATOR_IS_ANY,
31593 OPERATOR_IS_NONE,
31594 OPERATOR_IS_ALL,
31595 OPERATOR_IS_NOT_ALL
31596 ],
31597 format: {},
31598 getValueFormatted: get_value_formatted_default_default,
31599 validate: {
31600 required: isValidRequired,
31601 pattern: isValidPattern,
31602 minLength: isValidMinLength,
31603 maxLength: isValidMaxLength,
31604 elements: isValidElements
31605 }
31606 };
31607
31608 // packages/dataviews/build-module/field-types/color.mjs
31609 var import_i18n48 = __toESM(require_i18n(), 1);
31610 var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1);
31611 function render3({ item, field }) {
31612 if (field.hasElements) {
31613 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(RenderFromElements, { item, field });
31614 }
31615 const value = get_value_formatted_default_default({ item, field });
31616 if (!value || !w(value).isValid()) {
31617 return value;
31618 }
31619 return /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
31620 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
31621 "div",
31622 {
31623 style: {
31624 width: "16px",
31625 height: "16px",
31626 borderRadius: "50%",
31627 backgroundColor: value,
31628 border: "1px solid #ddd",
31629 flexShrink: 0
31630 }
31631 }
31632 ),
31633 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("span", { children: value })
31634 ] });
31635 }
31636 function isValidCustom6(item, field) {
31637 const value = field.getValue({ item });
31638 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
31639 return (0, import_i18n48.__)("Value must be a valid color.");
31640 }
31641 return null;
31642 }
31643 var sort5 = (a2, b2, direction) => {
31644 const colorA = w(a2);
31645 const colorB = w(b2);
31646 if (!colorA.isValid() && !colorB.isValid()) {
31647 return 0;
31648 }
31649 if (!colorA.isValid()) {
31650 return direction === "asc" ? 1 : -1;
31651 }
31652 if (!colorB.isValid()) {
31653 return direction === "asc" ? -1 : 1;
31654 }
31655 const hslA = colorA.toHsl();
31656 const hslB = colorB.toHsl();
31657 if (hslA.h !== hslB.h) {
31658 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
31659 }
31660 if (hslA.s !== hslB.s) {
31661 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
31662 }
31663 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
31664 };
31665 var color_default = {
31666 type: "color",
31667 render: render3,
31668 Edit: "color",
31669 sort: sort5,
31670 enableSorting: true,
31671 enableGlobalSearch: false,
31672 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31673 validOperators: [
31674 OPERATOR_IS,
31675 OPERATOR_IS_NOT,
31676 OPERATOR_IS_ANY,
31677 OPERATOR_IS_NONE
31678 ],
31679 format: {},
31680 getValueFormatted: get_value_formatted_default_default,
31681 validate: {
31682 required: isValidRequired,
31683 elements: isValidElements,
31684 custom: isValidCustom6
31685 }
31686 };
31687
31688 // packages/dataviews/build-module/field-types/url.mjs
31689 var url_default = {
31690 type: "url",
31691 render,
31692 Edit: "url",
31693 sort: sort_text_default,
31694 enableSorting: true,
31695 enableGlobalSearch: false,
31696 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31697 validOperators: [
31698 OPERATOR_IS,
31699 OPERATOR_IS_NOT,
31700 OPERATOR_CONTAINS,
31701 OPERATOR_NOT_CONTAINS,
31702 OPERATOR_STARTS_WITH,
31703 // Multiple selection
31704 OPERATOR_IS_ANY,
31705 OPERATOR_IS_NONE,
31706 OPERATOR_IS_ALL,
31707 OPERATOR_IS_NOT_ALL
31708 ],
31709 format: {},
31710 getValueFormatted: get_value_formatted_default_default,
31711 validate: {
31712 required: isValidRequired,
31713 pattern: isValidPattern,
31714 minLength: isValidMinLength,
31715 maxLength: isValidMaxLength,
31716 elements: isValidElements
31717 }
31718 };
31719
31720 // packages/dataviews/build-module/field-types/no-type.mjs
31721 var sort6 = (a2, b2, direction) => {
31722 if (typeof a2 === "number" && typeof b2 === "number") {
31723 return sort_number_default(a2, b2, direction);
31724 }
31725 return sort_text_default(a2, b2, direction);
31726 };
31727 var no_type_default = {
31728 // type: no type for this one
31729 render,
31730 Edit: null,
31731 sort: sort6,
31732 enableSorting: true,
31733 enableGlobalSearch: false,
31734 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31735 validOperators: getAllOperatorNames(),
31736 format: {},
31737 getValueFormatted: get_value_formatted_default_default,
31738 validate: {
31739 required: isValidRequired,
31740 elements: isValidElements
31741 }
31742 };
31743
31744 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
31745 function supportsNumericRangeConstraint(type) {
31746 return type === "integer" || type === "number";
31747 }
31748 function supportsDateRangeConstraint(type) {
31749 return type === "date" || type === "datetime";
31750 }
31751 function normalizeRangeRule(value, fieldType, key) {
31752 const validator = fieldType.validate[key];
31753 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
31754 return { constraint: value, validate: validator };
31755 }
31756 return void 0;
31757 }
31758 function getIsValid(field, fieldType) {
31759 const rules = field.isValid;
31760 let required;
31761 if (rules?.required === true && fieldType.validate.required !== void 0) {
31762 required = {
31763 constraint: true,
31764 validate: fieldType.validate.required
31765 };
31766 }
31767 let elements;
31768 if ((rules?.elements === true || // elements is enabled unless the field opts-out
31769 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
31770 elements = {
31771 constraint: true,
31772 validate: fieldType.validate.elements
31773 };
31774 }
31775 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
31776 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
31777 const minLengthValue = rules?.minLength;
31778 let minLength;
31779 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
31780 minLength = {
31781 constraint: minLengthValue,
31782 validate: fieldType.validate.minLength
31783 };
31784 }
31785 const maxLengthValue = rules?.maxLength;
31786 let maxLength;
31787 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
31788 maxLength = {
31789 constraint: maxLengthValue,
31790 validate: fieldType.validate.maxLength
31791 };
31792 }
31793 const patternValue = rules?.pattern;
31794 let pattern;
31795 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
31796 pattern = {
31797 constraint: patternValue,
31798 validate: fieldType.validate.pattern
31799 };
31800 }
31801 const custom = rules?.custom ?? fieldType.validate.custom;
31802 return {
31803 required,
31804 elements,
31805 min: min2,
31806 max: max2,
31807 minLength,
31808 maxLength,
31809 pattern,
31810 custom
31811 };
31812 }
31813
31814 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
31815 function getFilter(fieldType) {
31816 return fieldType.validOperators.reduce((accumulator, operator) => {
31817 const operatorObj = getOperatorByName(operator);
31818 if (operatorObj?.filter) {
31819 accumulator[operator] = operatorObj.filter;
31820 }
31821 return accumulator;
31822 }, {});
31823 }
31824
31825 // packages/dataviews/build-module/field-types/utils/get-format.mjs
31826 function getFormat(field, fieldType) {
31827 return {
31828 ...fieldType.format,
31829 ...field.format
31830 };
31831 }
31832 var get_format_default = getFormat;
31833
31834 // packages/dataviews/build-module/field-types/index.mjs
31835 function getFieldTypeByName(type) {
31836 const found = [
31837 email_default,
31838 integer_default,
31839 number_default,
31840 text_default,
31841 datetime_default,
31842 date_default,
31843 boolean_default,
31844 media_default,
31845 array_default,
31846 password_default,
31847 telephone_default,
31848 color_default,
31849 url_default
31850 ].find((fieldType) => fieldType?.type === type);
31851 if (!!found) {
31852 return found;
31853 }
31854 return no_type_default;
31855 }
31856 function normalizeFields(fields) {
31857 return fields.map((field) => {
31858 const fieldType = getFieldTypeByName(field.type);
31859 const getValue = field.getValue || get_value_from_id_default(field.id);
31860 const sort7 = function(a2, b2, direction) {
31861 const aValue = getValue({ item: a2 });
31862 const bValue = getValue({ item: b2 });
31863 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
31864 };
31865 return {
31866 id: field.id,
31867 label: field.label || field.id,
31868 header: field.header || field.label || field.id,
31869 description: field.description,
31870 placeholder: field.placeholder,
31871 getValue,
31872 setValue: field.setValue || set_value_from_id_default(field.id),
31873 elements: field.elements,
31874 getElements: field.getElements,
31875 hasElements: hasElements(field),
31876 isVisible: field.isVisible,
31877 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
31878 enableHiding: field.enableHiding ?? true,
31879 readOnly: field.readOnly ?? false,
31880 // The type provides defaults for the following props
31881 type: fieldType.type,
31882 render: field.render ?? fieldType.render,
31883 Edit: getControl(field, fieldType.Edit),
31884 sort: sort7,
31885 enableSorting: field.enableSorting ?? fieldType.enableSorting,
31886 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
31887 isValid: getIsValid(field, fieldType),
31888 filterBy: get_filter_by_default(
31889 field,
31890 fieldType.defaultOperators,
31891 fieldType.validOperators
31892 ),
31893 filter: getFilter(fieldType),
31894 format: get_format_default(field, fieldType),
31895 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
31896 };
31897 });
31898 }
31899
31900 // packages/dataviews/build-module/hooks/use-data.mjs
31901 var import_element112 = __toESM(require_element(), 1);
31902 function useData({
31903 view,
31904 data: shownData,
31905 getItemId,
31906 isLoading,
31907 paginationInfo,
31908 selection
31909 }) {
31910 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
31911 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element112.useState)(
31912 !isLoading
31913 );
31914 (0, import_element112.useEffect)(() => {
31915 if (!isLoading) {
31916 setHasInitiallyLoaded(true);
31917 }
31918 }, [isLoading]);
31919 const previousDataRef = (0, import_element112.useRef)(shownData);
31920 const previousPaginationInfoRef = (0, import_element112.useRef)(paginationInfo);
31921 (0, import_element112.useEffect)(() => {
31922 if (!isLoading) {
31923 previousDataRef.current = shownData;
31924 previousPaginationInfoRef.current = paginationInfo;
31925 }
31926 }, [shownData, isLoading, paginationInfo]);
31927 const [visibleEntries, setVisibleEntries] = (0, import_element112.useState)([]);
31928 const positionMapRef = (0, import_element112.useRef)(/* @__PURE__ */ new Map());
31929 const allLoadedRecordsRef = (0, import_element112.useRef)([]);
31930 const prevViewParamsRef = (0, import_element112.useRef)({
31931 search: void 0,
31932 filters: void 0,
31933 perPage: void 0
31934 });
31935 const scrollDirectionRef = (0, import_element112.useRef)(void 0);
31936 const prevStartPositionRef = (0, import_element112.useRef)(void 0);
31937 const hasInitializedRef = (0, import_element112.useRef)(false);
31938 const allLoadedRecords = (0, import_element112.useMemo)(() => {
31939 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
31940 if (view.startPosition < prevStartPositionRef.current) {
31941 scrollDirectionRef.current = "up";
31942 } else if (view.startPosition > prevStartPositionRef.current) {
31943 scrollDirectionRef.current = "down";
31944 }
31945 }
31946 prevStartPositionRef.current = view.startPosition;
31947 const currentFiltersKey = JSON.stringify(view.filters ?? []);
31948 const prevFiltersKey = prevViewParamsRef.current.filters;
31949 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
31950 hasInitializedRef.current = true;
31951 prevViewParamsRef.current = {
31952 search: view.search,
31953 filters: currentFiltersKey,
31954 perPage: view.perPage
31955 };
31956 if (shouldReset) {
31957 positionMapRef.current.clear();
31958 scrollDirectionRef.current = void 0;
31959 const startPosition = view.search ? 1 : view.startPosition ?? 1;
31960 const records = shownData.map((record, index2) => {
31961 const position = startPosition + index2;
31962 positionMapRef.current.set(getItemId(record), position);
31963 return {
31964 ...record,
31965 position
31966 };
31967 });
31968 allLoadedRecordsRef.current = records;
31969 return records;
31970 }
31971 const prev = allLoadedRecordsRef.current;
31972 const shownDataIds = new Set(shownData.map(getItemId));
31973 const scrollDirection = scrollDirectionRef.current;
31974 const basePosition = view.search ? 1 : view.startPosition ?? 1;
31975 const newRecords = shownData.map((record, index2) => {
31976 const itemId = getItemId(record);
31977 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
31978 if (position !== void 0) {
31979 positionMapRef.current.set(itemId, position);
31980 }
31981 return {
31982 ...record,
31983 position
31984 };
31985 });
31986 if (newRecords.length === 0) {
31987 return prev;
31988 }
31989 const prevWithoutDuplicates = prev.filter(
31990 (record) => !shownDataIds.has(getItemId(record))
31991 );
31992 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
31993 allRecords.sort((a2, b2) => {
31994 const posA = a2.position;
31995 const posB = b2.position;
31996 return posA - posB;
31997 });
31998 let result = allRecords;
31999 if (visibleEntries.length > 0) {
32000 const visibleMin = Math.min(...visibleEntries);
32001 const visibleMax = Math.max(...visibleEntries);
32002 const buffer = 20;
32003 const recordPositions = allRecords.map(
32004 (r3) => r3.position
32005 );
32006 const minRecordPos = Math.min(...recordPositions);
32007 const maxRecordPos = Math.max(...recordPositions);
32008 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
32009 if (hasOverlap) {
32010 result = allRecords.filter((record) => {
32011 const itemId = getItemId(record);
32012 const isSelected2 = selection?.includes(itemId);
32013 if (isSelected2) {
32014 return true;
32015 }
32016 const itemPosition = record.position;
32017 if (scrollDirection === "up") {
32018 return itemPosition <= visibleMax + buffer;
32019 } else if (scrollDirection === "down") {
32020 return itemPosition >= visibleMin - buffer;
32021 }
32022 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
32023 });
32024 }
32025 }
32026 allLoadedRecordsRef.current = result;
32027 return result;
32028 }, [
32029 shownData,
32030 view.search,
32031 view.filters,
32032 view.perPage,
32033 view.startPosition,
32034 view.infiniteScrollEnabled,
32035 visibleEntries,
32036 selection,
32037 getItemId
32038 ]);
32039 if (!isInfiniteScrollEnabled) {
32040 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
32041 return {
32042 data: dataToReturn.map((item) => ({
32043 ...item,
32044 position: void 0
32045 })),
32046 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
32047 hasInitiallyLoaded,
32048 setVisibleEntries: void 0
32049 };
32050 }
32051 return {
32052 data: allLoadedRecords,
32053 paginationInfo,
32054 hasInitiallyLoaded,
32055 setVisibleEntries
32056 };
32057 }
32058
32059 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
32060 var import_element113 = __toESM(require_element(), 1);
32061 var import_compose14 = __toESM(require_compose(), 1);
32062 function captureAnchorElement(container, anchorElementRef, direction) {
32063 const containerRect = container.getBoundingClientRect();
32064 const centerY = containerRect.top + containerRect.height / 2;
32065 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
32066 if (items.length === 0) {
32067 return false;
32068 }
32069 const bestAnchor = items.reduce((best, item) => {
32070 const itemRect = item.getBoundingClientRect();
32071 const itemCenterY = itemRect.top + itemRect.height / 2;
32072 const distance = Math.abs(itemCenterY - centerY);
32073 const bestRect = best.getBoundingClientRect();
32074 const bestCenterY = bestRect.top + bestRect.height / 2;
32075 const bestDistance = Math.abs(bestCenterY - centerY);
32076 return distance < bestDistance ? item : best;
32077 });
32078 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
32079 const anchorRect = bestAnchor.getBoundingClientRect();
32080 anchorElementRef.current = {
32081 posinset,
32082 viewportOffset: anchorRect.top - containerRect.top,
32083 direction
32084 };
32085 return true;
32086 }
32087 function useInfiniteScroll({
32088 view,
32089 onChangeView,
32090 isLoading,
32091 paginationInfo,
32092 containerRef,
32093 setVisibleEntries
32094 }) {
32095 const anchorElementRef = (0, import_element113.useRef)(null);
32096 const viewRef = (0, import_element113.useRef)(view);
32097 const isLoadingRef = (0, import_element113.useRef)(isLoading);
32098 const onChangeViewRef = (0, import_element113.useRef)(onChangeView);
32099 const totalItemsRef = (0, import_element113.useRef)(paginationInfo.totalItems);
32100 (0, import_element113.useLayoutEffect)(() => {
32101 viewRef.current = view;
32102 isLoadingRef.current = isLoading;
32103 onChangeViewRef.current = onChangeView;
32104 totalItemsRef.current = paginationInfo.totalItems;
32105 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
32106 const intersectionObserverCallback = (0, import_element113.useCallback)(
32107 (entries) => {
32108 if (!setVisibleEntries) {
32109 return;
32110 }
32111 setVisibleEntries((prev) => {
32112 const newVisibleEntries = new Set(prev);
32113 let hasChanged = false;
32114 entries.forEach((entry) => {
32115 const posInSet = Number(
32116 entry.target?.attributes?.getNamedItem(
32117 "aria-posinset"
32118 )?.value
32119 );
32120 if (isNaN(posInSet)) {
32121 return;
32122 }
32123 if (entry.isIntersecting) {
32124 if (!newVisibleEntries.has(posInSet)) {
32125 newVisibleEntries.add(posInSet);
32126 hasChanged = true;
32127 }
32128 } else if (newVisibleEntries.has(posInSet)) {
32129 newVisibleEntries.delete(posInSet);
32130 hasChanged = true;
32131 }
32132 });
32133 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
32134 });
32135 },
32136 [setVisibleEntries]
32137 );
32138 (0, import_element113.useLayoutEffect)(() => {
32139 const container = containerRef.current;
32140 const anchor = anchorElementRef.current;
32141 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
32142 return;
32143 }
32144 const anchorElement = container.querySelector(
32145 `[aria-posinset="${anchor.posinset}"]`
32146 );
32147 if (anchorElement) {
32148 const containerRect = container.getBoundingClientRect();
32149 const anchorRect = anchorElement.getBoundingClientRect();
32150 const currentOffset = anchorRect.top - containerRect.top;
32151 const scrollAdjustment = currentOffset - anchor.viewportOffset;
32152 if (Math.abs(scrollAdjustment) > 1) {
32153 container.scrollTop += scrollAdjustment;
32154 }
32155 }
32156 anchorElementRef.current = null;
32157 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
32158 const intersectionObserverRef = (0, import_element113.useRef)(
32159 null
32160 );
32161 (0, import_element113.useEffect)(() => {
32162 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
32163 if (intersectionObserverRef.current) {
32164 intersectionObserverRef.current.disconnect();
32165 intersectionObserverRef.current = null;
32166 }
32167 return;
32168 }
32169 intersectionObserverRef.current = new IntersectionObserver(
32170 intersectionObserverCallback,
32171 { root: null, rootMargin: "0px", threshold: 0.1 }
32172 );
32173 return () => {
32174 if (intersectionObserverRef.current) {
32175 intersectionObserverRef.current.disconnect();
32176 intersectionObserverRef.current = null;
32177 }
32178 };
32179 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
32180 (0, import_element113.useEffect)(() => {
32181 if (!view.infiniteScrollEnabled || !containerRef.current) {
32182 return;
32183 }
32184 let lastScrollTop = 0;
32185 const BOTTOM_THRESHOLD = 600;
32186 const TOP_THRESHOLD = 800;
32187 const handleScroll = (0, import_compose14.throttle)((event) => {
32188 const currentView = viewRef.current;
32189 const totalItems = totalItemsRef.current;
32190 const target = event.target;
32191 const scrollTop = target.scrollTop;
32192 const scrollHeight = target.scrollHeight;
32193 const clientHeight = target.clientHeight;
32194 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
32195 lastScrollTop = scrollTop;
32196 if (isLoadingRef.current) {
32197 return;
32198 }
32199 const currentStartPosition = currentView.startPosition || 1;
32200 const batchSize = currentView.perPage || 10;
32201 const currentEndPosition = Math.min(
32202 currentStartPosition + batchSize,
32203 totalItems
32204 );
32205 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
32206 if (currentEndPosition < totalItems) {
32207 const newStartPosition = currentEndPosition;
32208 captureAnchorElement(target, anchorElementRef, "down");
32209 onChangeViewRef.current({
32210 ...currentView,
32211 startPosition: newStartPosition
32212 });
32213 }
32214 }
32215 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
32216 if (currentStartPosition > 1) {
32217 const calculatedStartPosition = currentStartPosition - batchSize;
32218 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
32219 captureAnchorElement(target, anchorElementRef, "up");
32220 onChangeViewRef.current({
32221 ...currentView,
32222 startPosition: newStartPosition
32223 });
32224 }
32225 }
32226 }, 50);
32227 const container = containerRef.current;
32228 container.addEventListener("scroll", handleScroll);
32229 return () => {
32230 container.removeEventListener("scroll", handleScroll);
32231 handleScroll.cancel();
32232 };
32233 }, [containerRef, view.infiniteScrollEnabled]);
32234 return {
32235 intersectionObserver: intersectionObserverRef.current
32236 };
32237 }
32238
32239 // packages/dataviews/build-module/dataviews/index.mjs
32240 var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1);
32241 var defaultGetItemId = (item) => item.id;
32242 var defaultIsItemClickable = () => true;
32243 var EMPTY_ARRAY6 = [];
32244 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
32245 var dataViewsLayouts = VIEW_LAYOUTS.filter(
32246 (viewLayout) => !viewLayout.isPicker
32247 );
32248 function DefaultUI({
32249 header,
32250 search = true,
32251 searchLabel = void 0
32252 }) {
32253 const { view } = (0, import_element114.useContext)(dataviews_context_default);
32254 const isInfiniteScroll = view.infiniteScrollEnabled;
32255 return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_jsx_runtime161.Fragment, { children: [
32256 /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(
32257 Stack,
32258 {
32259 direction: "row",
32260 align: "top",
32261 justify: "space-between",
32262 className: clsx_default("dataviews__view-actions", {
32263 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
32264 }),
32265 gap: "xs",
32266 children: [
32267 /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(
32268 Stack,
32269 {
32270 direction: "row",
32271 justify: "start",
32272 gap: "sm",
32273 className: "dataviews__search",
32274 children: [
32275 search && /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(dataviews_search_default, { label: searchLabel }),
32276 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(toggle_default, {})
32277 ]
32278 }
32279 ),
32280 /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
32281 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(dataviews_view_config_default, {}),
32282 header
32283 ] })
32284 ]
32285 }
32286 ),
32287 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
32288 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(DataViewsLayout, {}),
32289 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(DataViewsFooter, {})
32290 ] });
32291 }
32292 function DataViews({
32293 view,
32294 onChangeView,
32295 fields,
32296 search = true,
32297 searchLabel = void 0,
32298 actions = EMPTY_ARRAY6,
32299 data,
32300 getItemId = defaultGetItemId,
32301 getItemLevel,
32302 isLoading = false,
32303 paginationInfo,
32304 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
32305 selection: selectionProperty,
32306 onChangeSelection,
32307 onClickItem,
32308 renderItemLink,
32309 isItemClickable = defaultIsItemClickable,
32310 header,
32311 children,
32312 config = { perPageSizes: [10, 20, 50, 100] },
32313 empty,
32314 onReset
32315 }) {
32316 const [selectionState, setSelectionState] = (0, import_element114.useState)([]);
32317 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
32318 const selection = isUncontrolled ? selectionState : selectionProperty;
32319 const {
32320 data: displayData,
32321 paginationInfo: displayPaginationInfo,
32322 hasInitiallyLoaded,
32323 setVisibleEntries
32324 } = useData({
32325 view,
32326 data,
32327 getItemId,
32328 isLoading,
32329 selection,
32330 paginationInfo
32331 });
32332 const containerRef = (0, import_element114.useRef)(null);
32333 const [containerWidth, setContainerWidth] = (0, import_element114.useState)(0);
32334 const resizeObserverRef = (0, import_compose15.useResizeObserver)(
32335 (resizeObserverEntries) => {
32336 setContainerWidth(
32337 resizeObserverEntries[0].borderBoxSize[0].inlineSize
32338 );
32339 },
32340 { box: "border-box" }
32341 );
32342 const [openedFilter, setOpenedFilter] = (0, import_element114.useState)(null);
32343 function setSelectionWithChange(value) {
32344 const newValue = typeof value === "function" ? value(selection) : value;
32345 if (isUncontrolled) {
32346 setSelectionState(newValue);
32347 }
32348 if (onChangeSelection) {
32349 onChangeSelection(newValue);
32350 }
32351 }
32352 const _fields = (0, import_element114.useMemo)(() => normalizeFields(fields), [fields]);
32353 const _selection = (0, import_element114.useMemo)(() => {
32354 if (view.infiniteScrollEnabled) {
32355 return selection;
32356 }
32357 return selection.filter(
32358 (id) => data.some((item) => getItemId(item) === id)
32359 );
32360 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
32361 const filters = use_filters_default(_fields, view);
32362 const hasPrimaryOrLockedFilters = (0, import_element114.useMemo)(
32363 () => (filters || []).some(
32364 (filter) => filter.isPrimary || filter.isLocked
32365 ),
32366 [filters]
32367 );
32368 const [isShowingFilter, setIsShowingFilter] = (0, import_element114.useState)(
32369 hasPrimaryOrLockedFilters
32370 );
32371 const { intersectionObserver } = useInfiniteScroll({
32372 view,
32373 onChangeView,
32374 isLoading,
32375 paginationInfo,
32376 containerRef,
32377 setVisibleEntries
32378 });
32379 (0, import_element114.useEffect)(() => {
32380 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
32381 setIsShowingFilter(true);
32382 }
32383 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
32384 const defaultLayouts3 = (0, import_element114.useMemo)(
32385 () => Object.fromEntries(
32386 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
32387 return dataViewsLayouts.some(
32388 (viewLayout) => viewLayout.type === layoutType
32389 );
32390 }).map(([key, value]) => [
32391 key,
32392 value === true ? {} : value
32393 ])
32394 ),
32395 [defaultLayoutsProperty]
32396 );
32397 if (!defaultLayouts3[view.type]) {
32398 return null;
32399 }
32400 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
32401 dataviews_context_default.Provider,
32402 {
32403 value: {
32404 view,
32405 onChangeView,
32406 fields: _fields,
32407 actions,
32408 data: displayData,
32409 isLoading,
32410 paginationInfo: displayPaginationInfo,
32411 selection: _selection,
32412 onChangeSelection: setSelectionWithChange,
32413 openedFilter,
32414 setOpenedFilter,
32415 getItemId,
32416 getItemLevel,
32417 isItemClickable,
32418 onClickItem,
32419 renderItemLink,
32420 containerWidth,
32421 containerRef,
32422 resizeObserverRef,
32423 defaultLayouts: defaultLayouts3,
32424 filters,
32425 isShowingFilter,
32426 setIsShowingFilter,
32427 config,
32428 empty,
32429 hasInitiallyLoaded,
32430 onReset,
32431 intersectionObserver
32432 },
32433 children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
32434 DefaultUI,
32435 {
32436 header,
32437 search,
32438 searchLabel
32439 }
32440 ) })
32441 }
32442 );
32443 }
32444 var DataViewsSubComponents = DataViews;
32445 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
32446 DataViewsSubComponents.Filters = filters_default;
32447 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
32448 DataViewsSubComponents.FiltersToggle = toggle_default;
32449 DataViewsSubComponents.Layout = DataViewsLayout;
32450 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
32451 DataViewsSubComponents.Pagination = DataViewsPagination;
32452 DataViewsSubComponents.Search = dataviews_search_default;
32453 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
32454 DataViewsSubComponents.Footer = DataViewsFooter;
32455 var dataviews_default = DataViewsSubComponents;
32456
32457 // packages/dataviews/build-module/dataform/index.mjs
32458 var import_element126 = __toESM(require_element(), 1);
32459
32460 // packages/dataviews/build-module/components/dataform-context/index.mjs
32461 var import_element115 = __toESM(require_element(), 1);
32462 var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1);
32463 var DataFormContext = (0, import_element115.createContext)({
32464 fields: []
32465 });
32466 DataFormContext.displayName = "DataFormContext";
32467 function DataFormProvider({
32468 fields,
32469 children
32470 }) {
32471 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(DataFormContext.Provider, { value: { fields }, children });
32472 }
32473 var dataform_context_default = DataFormContext;
32474
32475 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
32476 var import_element125 = __toESM(require_element(), 1);
32477
32478 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
32479 var import_element116 = __toESM(require_element(), 1);
32480 var import_components48 = __toESM(require_components(), 1);
32481
32482 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
32483 var import_i18n49 = __toESM(require_i18n(), 1);
32484 var DEFAULT_LAYOUT = {
32485 type: "regular",
32486 labelPosition: "top"
32487 };
32488 var normalizeCardSummaryField = (sum) => {
32489 if (typeof sum === "string") {
32490 return [{ id: sum, visibility: "when-collapsed" }];
32491 }
32492 return sum.map((item) => {
32493 if (typeof item === "string") {
32494 return { id: item, visibility: "when-collapsed" };
32495 }
32496 return { id: item.id, visibility: item.visibility };
32497 });
32498 };
32499 function normalizeLayout(layout) {
32500 let normalizedLayout = DEFAULT_LAYOUT;
32501 if (layout?.type === "regular") {
32502 normalizedLayout = {
32503 type: "regular",
32504 labelPosition: layout?.labelPosition ?? "top"
32505 };
32506 } else if (layout?.type === "panel") {
32507 const summary = layout.summary ?? [];
32508 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
32509 const openAs = layout?.openAs;
32510 let normalizedOpenAs;
32511 if (typeof openAs === "object" && openAs.type === "modal") {
32512 normalizedOpenAs = {
32513 type: "modal",
32514 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n49.__)("Apply"),
32515 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n49.__)("Cancel")
32516 };
32517 } else if (openAs === "modal") {
32518 normalizedOpenAs = {
32519 type: "modal",
32520 applyLabel: (0, import_i18n49.__)("Apply"),
32521 cancelLabel: (0, import_i18n49.__)("Cancel")
32522 };
32523 } else {
32524 normalizedOpenAs = { type: "dropdown" };
32525 }
32526 normalizedLayout = {
32527 type: "panel",
32528 labelPosition: layout?.labelPosition ?? "side",
32529 openAs: normalizedOpenAs,
32530 summary: normalizedSummary,
32531 editVisibility: layout?.editVisibility ?? "on-hover"
32532 };
32533 } else if (layout?.type === "card") {
32534 if (layout.withHeader === false) {
32535 normalizedLayout = {
32536 type: "card",
32537 withHeader: false,
32538 isOpened: true,
32539 summary: [],
32540 isCollapsible: false
32541 };
32542 } else {
32543 const summary = layout.summary ?? [];
32544 normalizedLayout = {
32545 type: "card",
32546 withHeader: true,
32547 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
32548 summary: normalizeCardSummaryField(summary),
32549 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
32550 };
32551 }
32552 } else if (layout?.type === "row") {
32553 normalizedLayout = {
32554 type: "row",
32555 alignment: layout?.alignment ?? "center",
32556 styles: layout?.styles ?? {}
32557 };
32558 } else if (layout?.type === "details") {
32559 normalizedLayout = {
32560 type: "details",
32561 summary: layout?.summary ?? ""
32562 };
32563 }
32564 return normalizedLayout;
32565 }
32566 function normalizeForm(form) {
32567 const normalizedFormLayout = normalizeLayout(form?.layout);
32568 const normalizedFields = (form.fields ?? []).map(
32569 (field) => {
32570 if (typeof field === "string") {
32571 return {
32572 id: field,
32573 layout: normalizedFormLayout
32574 };
32575 }
32576 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
32577 return {
32578 id: field.id,
32579 layout: fieldLayout,
32580 ...!!field.label && { label: field.label },
32581 ...!!field.description && {
32582 description: field.description
32583 },
32584 ..."children" in field && Array.isArray(field.children) && {
32585 children: normalizeForm({
32586 fields: field.children,
32587 layout: DEFAULT_LAYOUT
32588 }).fields
32589 }
32590 };
32591 }
32592 );
32593 return {
32594 layout: normalizedFormLayout,
32595 fields: normalizedFields
32596 };
32597 }
32598 var normalize_form_default = normalizeForm;
32599
32600 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
32601 var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1);
32602 function Header4({ title }) {
32603 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
32604 Stack,
32605 {
32606 direction: "column",
32607 className: "dataforms-layouts-regular__header",
32608 gap: "lg",
32609 children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components48.__experimentalHeading, { level: 2, size: 13, children: title }) })
32610 }
32611 );
32612 }
32613 function FormRegularField({
32614 data,
32615 field,
32616 onChange,
32617 hideLabelFromVision,
32618 markWhenOptional,
32619 validity
32620 }) {
32621 const { fields } = (0, import_element116.useContext)(dataform_context_default);
32622 const layout = field.layout;
32623 const form = (0, import_element116.useMemo)(
32624 () => ({
32625 layout: DEFAULT_LAYOUT,
32626 fields: !!field.children ? field.children : []
32627 }),
32628 [field]
32629 );
32630 if (!!field.children) {
32631 return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(import_jsx_runtime163.Fragment, { children: [
32632 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Header4, { title: field.label }),
32633 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
32634 DataFormLayout,
32635 {
32636 data,
32637 form,
32638 onChange,
32639 validity: validity?.children
32640 }
32641 )
32642 ] });
32643 }
32644 const labelPosition = layout.labelPosition;
32645 const fieldDefinition = fields.find(
32646 (fieldDef) => fieldDef.id === field.id
32647 );
32648 if (!fieldDefinition || !fieldDefinition.Edit) {
32649 return null;
32650 }
32651 if (labelPosition === "side") {
32652 return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(
32653 Stack,
32654 {
32655 direction: "row",
32656 className: "dataforms-layouts-regular__field",
32657 gap: "sm",
32658 children: [
32659 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
32660 "div",
32661 {
32662 className: clsx_default(
32663 "dataforms-layouts-regular__field-label",
32664 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
32665 ),
32666 children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components48.BaseControl.VisualLabel, { children: fieldDefinition.label })
32667 }
32668 ),
32669 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
32670 fieldDefinition.render,
32671 {
32672 item: data,
32673 field: fieldDefinition
32674 }
32675 ) : /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
32676 fieldDefinition.Edit,
32677 {
32678 data,
32679 field: fieldDefinition,
32680 onChange,
32681 hideLabelFromVision: true,
32682 markWhenOptional,
32683 validity
32684 },
32685 fieldDefinition.id
32686 ) })
32687 ]
32688 }
32689 );
32690 }
32691 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_jsx_runtime163.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(import_jsx_runtime163.Fragment, { children: [
32692 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components48.BaseControl.VisualLabel, { children: fieldDefinition.label }),
32693 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
32694 fieldDefinition.render,
32695 {
32696 item: data,
32697 field: fieldDefinition
32698 }
32699 )
32700 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
32701 fieldDefinition.Edit,
32702 {
32703 data,
32704 field: fieldDefinition,
32705 onChange,
32706 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
32707 markWhenOptional,
32708 validity
32709 }
32710 ) });
32711 }
32712
32713 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
32714 var import_deepmerge2 = __toESM(require_cjs(), 1);
32715 var import_components51 = __toESM(require_components(), 1);
32716 var import_element121 = __toESM(require_element(), 1);
32717 var import_compose17 = __toESM(require_compose(), 1);
32718
32719 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
32720 var import_components50 = __toESM(require_components(), 1);
32721 var import_i18n50 = __toESM(require_i18n(), 1);
32722 var import_compose16 = __toESM(require_compose(), 1);
32723 var import_element117 = __toESM(require_element(), 1);
32724
32725 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
32726 function getLabelClassName(labelPosition, showError) {
32727 return clsx_default(
32728 "dataforms-layouts-panel__field-label",
32729 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
32730 { "has-error": showError }
32731 );
32732 }
32733 var get_label_classname_default = getLabelClassName;
32734
32735 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
32736 var import_components49 = __toESM(require_components(), 1);
32737 var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1);
32738 function getLabelContent(showError, errorMessage, fieldLabel) {
32739 return showError ? /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(tooltip_exports.Root, { children: [
32740 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
32741 tooltip_exports.Trigger,
32742 {
32743 render: /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
32744 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(import_components49.Icon, { icon: error_default, size: 16 }),
32745 /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(VisuallyHidden, { children: [
32746 errorMessage,
32747 ": "
32748 ] }),
32749 fieldLabel
32750 ] })
32751 }
32752 ),
32753 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(tooltip_exports.Popup, { children: errorMessage })
32754 ] }) : fieldLabel;
32755 }
32756 var get_label_content_default = getLabelContent;
32757
32758 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
32759 function getFirstValidationError(validity) {
32760 if (!validity) {
32761 return void 0;
32762 }
32763 const validityRules = Object.keys(validity).filter(
32764 (key) => key !== "children"
32765 );
32766 for (const key of validityRules) {
32767 const rule = validity[key];
32768 if (rule === void 0) {
32769 continue;
32770 }
32771 if (rule.type === "invalid") {
32772 if (rule.message) {
32773 return rule.message;
32774 }
32775 if (key === "required") {
32776 return "A required field is empty";
32777 }
32778 return "Unidentified validation error";
32779 }
32780 }
32781 if (validity.children) {
32782 for (const childValidity of Object.values(validity.children)) {
32783 const childError = getFirstValidationError(childValidity);
32784 if (childError) {
32785 return childError;
32786 }
32787 }
32788 }
32789 return void 0;
32790 }
32791 var get_first_validation_error_default = getFirstValidationError;
32792
32793 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
32794 var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1);
32795 function SummaryButton({
32796 data,
32797 field,
32798 fieldLabel,
32799 summaryFields,
32800 validity,
32801 touched,
32802 disabled: disabled2,
32803 isOpen,
32804 onClick
32805 }) {
32806 const { labelPosition, editVisibility } = field.layout;
32807 const errorMessage = get_first_validation_error_default(validity);
32808 const showError = touched && !!errorMessage;
32809 const labelClassName = get_label_classname_default(labelPosition, showError);
32810 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
32811 const className = clsx_default(
32812 "dataforms-layouts-panel__field-trigger",
32813 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
32814 {
32815 "is-disabled": disabled2,
32816 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
32817 }
32818 );
32819 const controlId = (0, import_compose16.useInstanceId)(
32820 SummaryButton,
32821 "dataforms-layouts-panel__field-control"
32822 );
32823 const ariaLabel = showError ? (0, import_i18n50.sprintf)(
32824 // translators: %s: Field name.
32825 (0, import_i18n50._x)("Edit %s (has errors)", "field"),
32826 fieldLabel || ""
32827 ) : (0, import_i18n50.sprintf)(
32828 // translators: %s: Field name.
32829 (0, import_i18n50._x)("Edit %s", "field"),
32830 fieldLabel || ""
32831 );
32832 const rowRef = (0, import_element117.useRef)(null);
32833 const editButtonRef = (0, import_element117.useRef)(null);
32834 const handleRowClick = (event) => {
32835 if (!isOpen && event.detail < 2 && !editButtonRef.current?.contains(event.target) && rowRef.current?.ownerDocument.defaultView?.getSelection()?.toString()) {
32836 return;
32837 }
32838 onClick();
32839 };
32840 const handleKeyDown = (event) => {
32841 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
32842 event.preventDefault();
32843 onClick();
32844 }
32845 };
32846 return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(
32847 "div",
32848 {
32849 ref: rowRef,
32850 className,
32851 onClick: !disabled2 ? handleRowClick : void 0,
32852 onKeyDown: !disabled2 ? handleKeyDown : void 0,
32853 children: [
32854 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("span", { className: labelClassName, children: labelContent }),
32855 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(tooltip_exports.Root, { children: [
32856 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
32857 tooltip_exports.Trigger,
32858 {
32859 render: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
32860 "span",
32861 {
32862 className: "dataforms-layouts-panel__field-label-error-content",
32863 role: "img",
32864 "aria-label": errorMessage,
32865 children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(import_components50.Icon, { icon: error_default, size: 16 })
32866 }
32867 )
32868 }
32869 ),
32870 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(tooltip_exports.Popup, { children: errorMessage })
32871 ] }),
32872 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
32873 "span",
32874 {
32875 id: `${controlId}`,
32876 className: "dataforms-layouts-panel__field-control",
32877 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
32878 "span",
32879 {
32880 style: {
32881 display: "flex",
32882 flexDirection: "column",
32883 alignItems: "flex-start",
32884 width: "100%",
32885 gap: "2px"
32886 },
32887 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
32888 "span",
32889 {
32890 style: { width: "100%" },
32891 children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
32892 summaryField.render,
32893 {
32894 item: data,
32895 field: summaryField
32896 }
32897 )
32898 },
32899 summaryField.id
32900 ))
32901 }
32902 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
32903 summaryField.render,
32904 {
32905 item: data,
32906 field: summaryField
32907 },
32908 summaryField.id
32909 ))
32910 }
32911 ),
32912 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
32913 import_components50.Button,
32914 {
32915 ref: editButtonRef,
32916 className: "dataforms-layouts-panel__field-trigger-icon",
32917 label: ariaLabel,
32918 icon: pencil_default,
32919 size: "small",
32920 "aria-expanded": isOpen,
32921 "aria-haspopup": "dialog",
32922 "aria-describedby": `${controlId}`
32923 }
32924 )
32925 ]
32926 }
32927 );
32928 }
32929
32930 // packages/dataviews/build-module/hooks/use-form-validity.mjs
32931 var import_deepmerge = __toESM(require_cjs(), 1);
32932 var import_es62 = __toESM(require_es6(), 1);
32933 var import_element118 = __toESM(require_element(), 1);
32934 var import_i18n51 = __toESM(require_i18n(), 1);
32935 function isFormValid(formValidity) {
32936 if (!formValidity) {
32937 return true;
32938 }
32939 return Object.values(formValidity).every((fieldValidation) => {
32940 return Object.entries(fieldValidation).every(
32941 ([key, validation]) => {
32942 if (key === "children" && validation && typeof validation === "object") {
32943 return isFormValid(validation);
32944 }
32945 return validation.type !== "invalid" && validation.type !== "validating";
32946 }
32947 );
32948 });
32949 }
32950 function getFormFieldsToValidate(form, fields) {
32951 const normalizedForm = normalize_form_default(form);
32952 if (normalizedForm.fields.length === 0) {
32953 return [];
32954 }
32955 const fieldsMap = /* @__PURE__ */ new Map();
32956 fields.forEach((field) => {
32957 fieldsMap.set(field.id, field);
32958 });
32959 function processFormField(formField) {
32960 if ("children" in formField && Array.isArray(formField.children)) {
32961 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
32962 if (processedChildren.length === 0) {
32963 return null;
32964 }
32965 const fieldDef2 = fieldsMap.get(formField.id);
32966 if (fieldDef2) {
32967 const [normalizedField2] = normalizeFields([
32968 fieldDef2
32969 ]);
32970 return {
32971 id: formField.id,
32972 children: processedChildren,
32973 field: normalizedField2
32974 };
32975 }
32976 return {
32977 id: formField.id,
32978 children: processedChildren
32979 };
32980 }
32981 const fieldDef = fieldsMap.get(formField.id);
32982 if (!fieldDef) {
32983 return null;
32984 }
32985 const [normalizedField] = normalizeFields([fieldDef]);
32986 return {
32987 id: formField.id,
32988 children: [],
32989 field: normalizedField
32990 };
32991 }
32992 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
32993 return toValidate;
32994 }
32995 function setValidityAtPath(formValidity, fieldValidity, path) {
32996 if (!formValidity) {
32997 formValidity = {};
32998 }
32999 if (path.length === 0) {
33000 return formValidity;
33001 }
33002 const result = { ...formValidity };
33003 let current = result;
33004 for (let i2 = 0; i2 < path.length - 1; i2++) {
33005 const segment = path[i2];
33006 if (!current[segment]) {
33007 current[segment] = {};
33008 }
33009 current[segment] = { ...current[segment] };
33010 current = current[segment];
33011 }
33012 const finalKey = path[path.length - 1];
33013 current[finalKey] = {
33014 ...current[finalKey] || {},
33015 ...fieldValidity
33016 };
33017 return result;
33018 }
33019 function removeValidationProperty(formValidity, path, property) {
33020 if (!formValidity || path.length === 0) {
33021 return formValidity;
33022 }
33023 const result = { ...formValidity };
33024 let current = result;
33025 for (let i2 = 0; i2 < path.length - 1; i2++) {
33026 const segment = path[i2];
33027 if (!current[segment]) {
33028 return formValidity;
33029 }
33030 current[segment] = { ...current[segment] };
33031 current = current[segment];
33032 }
33033 const finalKey = path[path.length - 1];
33034 if (!current[finalKey]) {
33035 return formValidity;
33036 }
33037 const fieldValidity = { ...current[finalKey] };
33038 delete fieldValidity[property];
33039 if (Object.keys(fieldValidity).length === 0) {
33040 delete current[finalKey];
33041 } else {
33042 current[finalKey] = fieldValidity;
33043 }
33044 if (Object.keys(result).length === 0) {
33045 return void 0;
33046 }
33047 return result;
33048 }
33049 function handleElementsValidationAsync(promise, formField, promiseHandler) {
33050 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
33051 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
33052 elementsCounterRef.current[formField.id] = currentToken;
33053 promise.then((result) => {
33054 if (currentToken !== elementsCounterRef.current[formField.id]) {
33055 return;
33056 }
33057 if (!Array.isArray(result)) {
33058 setFormValidity((prev) => {
33059 const newFormValidity = setValidityAtPath(
33060 prev,
33061 {
33062 elements: {
33063 type: "invalid",
33064 message: (0, import_i18n51.__)("Could not validate elements.")
33065 }
33066 },
33067 [...path, formField.id]
33068 );
33069 return newFormValidity;
33070 });
33071 return;
33072 }
33073 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
33074 ...formField.field,
33075 elements: result
33076 })) {
33077 setFormValidity((prev) => {
33078 const newFormValidity = setValidityAtPath(
33079 prev,
33080 {
33081 elements: {
33082 type: "invalid",
33083 message: (0, import_i18n51.__)(
33084 "Value must be one of the elements."
33085 )
33086 }
33087 },
33088 [...path, formField.id]
33089 );
33090 return newFormValidity;
33091 });
33092 } else {
33093 setFormValidity((prev) => {
33094 return removeValidationProperty(
33095 prev,
33096 [...path, formField.id],
33097 "elements"
33098 );
33099 });
33100 }
33101 }).catch((error2) => {
33102 if (currentToken !== elementsCounterRef.current[formField.id]) {
33103 return;
33104 }
33105 let errorMessage;
33106 if (error2 instanceof Error) {
33107 errorMessage = error2.message;
33108 } else {
33109 errorMessage = String(error2) || (0, import_i18n51.__)(
33110 "Unknown error when running elements validation asynchronously."
33111 );
33112 }
33113 setFormValidity((prev) => {
33114 const newFormValidity = setValidityAtPath(
33115 prev,
33116 {
33117 elements: {
33118 type: "invalid",
33119 message: errorMessage
33120 }
33121 },
33122 [...path, formField.id]
33123 );
33124 return newFormValidity;
33125 });
33126 });
33127 }
33128 function handleCustomValidationAsync(promise, formField, promiseHandler) {
33129 const { customCounterRef, setFormValidity, path } = promiseHandler;
33130 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
33131 customCounterRef.current[formField.id] = currentToken;
33132 promise.then((result) => {
33133 if (currentToken !== customCounterRef.current[formField.id]) {
33134 return;
33135 }
33136 if (result === null) {
33137 setFormValidity((prev) => {
33138 return removeValidationProperty(
33139 prev,
33140 [...path, formField.id],
33141 "custom"
33142 );
33143 });
33144 return;
33145 }
33146 if (typeof result === "string") {
33147 setFormValidity((prev) => {
33148 const newFormValidity = setValidityAtPath(
33149 prev,
33150 {
33151 custom: {
33152 type: "invalid",
33153 message: result
33154 }
33155 },
33156 [...path, formField.id]
33157 );
33158 return newFormValidity;
33159 });
33160 return;
33161 }
33162 setFormValidity((prev) => {
33163 const newFormValidity = setValidityAtPath(
33164 prev,
33165 {
33166 custom: {
33167 type: "invalid",
33168 message: (0, import_i18n51.__)("Validation could not be processed.")
33169 }
33170 },
33171 [...path, formField.id]
33172 );
33173 return newFormValidity;
33174 });
33175 }).catch((error2) => {
33176 if (currentToken !== customCounterRef.current[formField.id]) {
33177 return;
33178 }
33179 let errorMessage;
33180 if (error2 instanceof Error) {
33181 errorMessage = error2.message;
33182 } else {
33183 errorMessage = String(error2) || (0, import_i18n51.__)(
33184 "Unknown error when running custom validation asynchronously."
33185 );
33186 }
33187 setFormValidity((prev) => {
33188 const newFormValidity = setValidityAtPath(
33189 prev,
33190 {
33191 custom: {
33192 type: "invalid",
33193 message: errorMessage
33194 }
33195 },
33196 [...path, formField.id]
33197 );
33198 return newFormValidity;
33199 });
33200 });
33201 }
33202 function validateFormField(item, formField, promiseHandler) {
33203 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
33204 return {
33205 required: { type: "invalid" }
33206 };
33207 }
33208 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
33209 return {
33210 pattern: {
33211 type: "invalid",
33212 message: (0, import_i18n51.__)("Value does not match the required pattern.")
33213 }
33214 };
33215 }
33216 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
33217 return {
33218 min: {
33219 type: "invalid",
33220 message: (0, import_i18n51.__)("Value is below the minimum.")
33221 }
33222 };
33223 }
33224 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
33225 return {
33226 max: {
33227 type: "invalid",
33228 message: (0, import_i18n51.__)("Value is above the maximum.")
33229 }
33230 };
33231 }
33232 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
33233 return {
33234 minLength: {
33235 type: "invalid",
33236 message: (0, import_i18n51.__)("Value is too short.")
33237 }
33238 };
33239 }
33240 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
33241 return {
33242 maxLength: {
33243 type: "invalid",
33244 message: (0, import_i18n51.__)("Value is too long.")
33245 }
33246 };
33247 }
33248 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
33249 return {
33250 elements: {
33251 type: "invalid",
33252 message: (0, import_i18n51.__)("Value must be one of the elements.")
33253 }
33254 };
33255 }
33256 let customError;
33257 if (!!formField.field && formField.field.isValid.custom) {
33258 try {
33259 const value = formField.field.getValue({ item });
33260 customError = formField.field.isValid.custom(
33261 (0, import_deepmerge.default)(
33262 item,
33263 formField.field.setValue({
33264 item,
33265 value
33266 })
33267 ),
33268 formField.field
33269 );
33270 } catch (error2) {
33271 let errorMessage;
33272 if (error2 instanceof Error) {
33273 errorMessage = error2.message;
33274 } else {
33275 errorMessage = String(error2) || (0, import_i18n51.__)("Unknown error when running custom validation.");
33276 }
33277 return {
33278 custom: {
33279 type: "invalid",
33280 message: errorMessage
33281 }
33282 };
33283 }
33284 }
33285 if (typeof customError === "string") {
33286 return {
33287 custom: {
33288 type: "invalid",
33289 message: customError
33290 }
33291 };
33292 }
33293 const fieldValidity = {};
33294 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
33295 handleElementsValidationAsync(
33296 formField.field.getElements(),
33297 formField,
33298 promiseHandler
33299 );
33300 fieldValidity.elements = {
33301 type: "validating",
33302 message: (0, import_i18n51.__)("Validating…")
33303 };
33304 }
33305 if (customError instanceof Promise) {
33306 handleCustomValidationAsync(customError, formField, promiseHandler);
33307 fieldValidity.custom = {
33308 type: "validating",
33309 message: (0, import_i18n51.__)("Validating…")
33310 };
33311 }
33312 if (Object.keys(fieldValidity).length > 0) {
33313 return fieldValidity;
33314 }
33315 if (formField.children.length > 0) {
33316 const result = {};
33317 formField.children.forEach((child) => {
33318 result[child.id] = validateFormField(item, child, {
33319 ...promiseHandler,
33320 path: [...promiseHandler.path, formField.id, "children"]
33321 });
33322 });
33323 const filteredResult = {};
33324 Object.entries(result).forEach(([key, value]) => {
33325 if (value !== void 0) {
33326 filteredResult[key] = value;
33327 }
33328 });
33329 if (Object.keys(filteredResult).length === 0) {
33330 return void 0;
33331 }
33332 return {
33333 children: filteredResult
33334 };
33335 }
33336 return void 0;
33337 }
33338 function getFormFieldValue(formField, item) {
33339 const fieldValue = formField?.field?.getValue({ item });
33340 if (formField.children.length === 0) {
33341 return fieldValue;
33342 }
33343 const childrenValues = formField.children.map(
33344 (child) => getFormFieldValue(child, item)
33345 );
33346 if (!childrenValues) {
33347 return fieldValue;
33348 }
33349 return {
33350 value: fieldValue,
33351 children: childrenValues
33352 };
33353 }
33354 function useFormValidity(item, fields, form) {
33355 const [formValidity, setFormValidity] = (0, import_element118.useState)();
33356 const customCounterRef = (0, import_element118.useRef)({});
33357 const elementsCounterRef = (0, import_element118.useRef)({});
33358 const previousValuesRef = (0, import_element118.useRef)({});
33359 const validate = (0, import_element118.useCallback)(() => {
33360 const promiseHandler = {
33361 customCounterRef,
33362 elementsCounterRef,
33363 setFormValidity,
33364 path: [],
33365 item
33366 };
33367 const formFieldsToValidate = getFormFieldsToValidate(form, fields);
33368 if (formFieldsToValidate.length === 0) {
33369 setFormValidity(void 0);
33370 return;
33371 }
33372 const newFormValidity = {};
33373 const untouchedFields = [];
33374 formFieldsToValidate.forEach((formField) => {
33375 const value = getFormFieldValue(formField, item);
33376 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
33377 previousValuesRef.current[formField.id],
33378 value
33379 )) {
33380 untouchedFields.push(formField.id);
33381 return;
33382 }
33383 previousValuesRef.current[formField.id] = value;
33384 const fieldValidity = validateFormField(
33385 item,
33386 formField,
33387 promiseHandler
33388 );
33389 if (fieldValidity !== void 0) {
33390 newFormValidity[formField.id] = fieldValidity;
33391 }
33392 });
33393 setFormValidity((existingFormValidity) => {
33394 let validity = {
33395 ...existingFormValidity,
33396 ...newFormValidity
33397 };
33398 const fieldsToKeep = [
33399 ...untouchedFields,
33400 ...Object.keys(newFormValidity)
33401 ];
33402 Object.keys(validity).forEach((key) => {
33403 if (validity && !fieldsToKeep.includes(key)) {
33404 delete validity[key];
33405 }
33406 });
33407 if (Object.keys(validity).length === 0) {
33408 validity = void 0;
33409 }
33410 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
33411 if (areEqual) {
33412 return existingFormValidity;
33413 }
33414 return validity;
33415 });
33416 }, [item, fields, form]);
33417 (0, import_element118.useEffect)(() => {
33418 validate();
33419 }, [validate]);
33420 return {
33421 validity: formValidity,
33422 isValid: isFormValid(formValidity)
33423 };
33424 }
33425 var use_form_validity_default = useFormValidity;
33426
33427 // packages/dataviews/build-module/hooks/use-report-validity.mjs
33428 var import_element119 = __toESM(require_element(), 1);
33429 function useReportValidity(ref, shouldReport) {
33430 (0, import_element119.useEffect)(() => {
33431 if (shouldReport && ref.current) {
33432 const inputs = ref.current.querySelectorAll(
33433 "input, textarea, select"
33434 );
33435 inputs.forEach((input) => {
33436 input.reportValidity();
33437 });
33438 }
33439 }, [shouldReport, ref]);
33440 }
33441
33442 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
33443 var import_element120 = __toESM(require_element(), 1);
33444
33445 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
33446 function extractSummaryIds(summary) {
33447 if (Array.isArray(summary)) {
33448 return summary.map(
33449 (item) => typeof item === "string" ? item : item.id
33450 );
33451 }
33452 return [];
33453 }
33454 var getSummaryFields = (summaryField, fields) => {
33455 if (Array.isArray(summaryField) && summaryField.length > 0) {
33456 const summaryIds = extractSummaryIds(summaryField);
33457 return summaryIds.map(
33458 (summaryId) => fields.find((_field) => _field.id === summaryId)
33459 ).filter((_field) => _field !== void 0);
33460 }
33461 return [];
33462 };
33463
33464 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
33465 var getFieldDefinition = (field, fields) => {
33466 const fieldDefinition = fields.find((_field) => _field.id === field.id);
33467 if (!fieldDefinition) {
33468 return fields.find((_field) => {
33469 if (!!field.children) {
33470 const simpleChildren = field.children.filter(
33471 (child) => !child.children
33472 );
33473 if (simpleChildren.length === 0) {
33474 return false;
33475 }
33476 return _field.id === simpleChildren[0].id;
33477 }
33478 return _field.id === field.id;
33479 });
33480 }
33481 return fieldDefinition;
33482 };
33483 function useFieldFromFormField(field) {
33484 const { fields } = (0, import_element120.useContext)(dataform_context_default);
33485 const layout = field.layout;
33486 const summaryFields = getSummaryFields(layout.summary, fields);
33487 const fieldDefinition = getFieldDefinition(field, fields);
33488 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
33489 if (summaryFields.length === 0) {
33490 return {
33491 summaryFields: fieldDefinition ? [fieldDefinition] : [],
33492 fieldDefinition,
33493 fieldLabel
33494 };
33495 }
33496 return {
33497 summaryFields,
33498 fieldDefinition,
33499 fieldLabel
33500 };
33501 }
33502 var use_field_from_form_field_default = useFieldFromFormField;
33503
33504 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
33505 var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1);
33506 function ModalContent({
33507 data,
33508 field,
33509 onChange,
33510 fieldLabel,
33511 onClose,
33512 touched
33513 }) {
33514 const { openAs } = field.layout;
33515 const { applyLabel, cancelLabel } = openAs;
33516 const { fields } = (0, import_element121.useContext)(dataform_context_default);
33517 const [changes, setChanges] = (0, import_element121.useState)({});
33518 const modalData = (0, import_element121.useMemo)(() => {
33519 return (0, import_deepmerge2.default)(data, changes, {
33520 arrayMerge: (target, source) => source
33521 });
33522 }, [data, changes]);
33523 const form = (0, import_element121.useMemo)(
33524 () => ({
33525 layout: DEFAULT_LAYOUT,
33526 fields: !!field.children ? field.children : (
33527 // If not explicit children return the field id itself.
33528 [{ id: field.id, layout: DEFAULT_LAYOUT }]
33529 )
33530 }),
33531 [field]
33532 );
33533 const fieldsAsFieldType = fields.map((f2) => ({
33534 ...f2,
33535 Edit: f2.Edit === null ? void 0 : f2.Edit,
33536 isValid: {
33537 required: f2.isValid.required?.constraint,
33538 elements: f2.isValid.elements?.constraint,
33539 min: f2.isValid.min?.constraint,
33540 max: f2.isValid.max?.constraint,
33541 pattern: f2.isValid.pattern?.constraint,
33542 minLength: f2.isValid.minLength?.constraint,
33543 maxLength: f2.isValid.maxLength?.constraint
33544 }
33545 }));
33546 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
33547 const onApply = () => {
33548 onChange(changes);
33549 onClose();
33550 };
33551 const handleOnChange = (newValue) => {
33552 setChanges(
33553 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
33554 arrayMerge: (target, source) => source
33555 })
33556 );
33557 };
33558 const focusOnMountRef = (0, import_compose17.useFocusOnMount)("firstInputElement");
33559 const contentRef = (0, import_element121.useRef)(null);
33560 const mergedRef = (0, import_compose17.useMergeRefs)([focusOnMountRef, contentRef]);
33561 useReportValidity(contentRef, touched);
33562 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
33563 import_components51.Modal,
33564 {
33565 className: "dataforms-layouts-panel__modal",
33566 onRequestClose: onClose,
33567 isFullScreen: false,
33568 title: fieldLabel,
33569 size: "medium",
33570 children: [
33571 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33572 DataFormLayout,
33573 {
33574 data: modalData,
33575 form,
33576 onChange: handleOnChange,
33577 validity,
33578 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33579 FieldLayout,
33580 {
33581 data: modalData,
33582 field: childField,
33583 onChange: handleOnChange,
33584 hideLabelFromVision: form.fields.length < 2,
33585 markWhenOptional,
33586 validity: childFieldValidity
33587 },
33588 childField.id
33589 )
33590 }
33591 ) }),
33592 /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(
33593 Stack,
33594 {
33595 direction: "row",
33596 className: "dataforms-layouts-panel__modal-footer",
33597 gap: "md",
33598 children: [
33599 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(import_components51.__experimentalSpacer, { style: { flex: 1 } }),
33600 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33601 import_components51.Button,
33602 {
33603 variant: "tertiary",
33604 onClick: onClose,
33605 __next40pxDefaultSize: true,
33606 children: cancelLabel
33607 }
33608 ),
33609 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33610 import_components51.Button,
33611 {
33612 variant: "primary",
33613 onClick: onApply,
33614 __next40pxDefaultSize: true,
33615 children: applyLabel
33616 }
33617 )
33618 ]
33619 }
33620 )
33621 ]
33622 }
33623 );
33624 }
33625 function PanelModal({
33626 data,
33627 field,
33628 onChange,
33629 validity
33630 }) {
33631 const [touched, setTouched] = (0, import_element121.useState)(false);
33632 const [isOpen, setIsOpen] = (0, import_element121.useState)(false);
33633 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
33634 if (!fieldDefinition) {
33635 return null;
33636 }
33637 const handleClose = () => {
33638 setIsOpen(false);
33639 setTouched(true);
33640 };
33641 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(import_jsx_runtime166.Fragment, { children: [
33642 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33643 SummaryButton,
33644 {
33645 data,
33646 field,
33647 fieldLabel,
33648 summaryFields,
33649 validity,
33650 touched,
33651 disabled: fieldDefinition.readOnly === true,
33652 onClick: () => setIsOpen(true),
33653 isOpen
33654 }
33655 ),
33656 isOpen && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33657 ModalContent,
33658 {
33659 data,
33660 field,
33661 onChange,
33662 fieldLabel: fieldLabel ?? "",
33663 onClose: handleClose,
33664 touched
33665 }
33666 )
33667 ] });
33668 }
33669 var modal_default = PanelModal;
33670
33671 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
33672 var import_components52 = __toESM(require_components(), 1);
33673 var import_i18n52 = __toESM(require_i18n(), 1);
33674 var import_element122 = __toESM(require_element(), 1);
33675 var import_compose18 = __toESM(require_compose(), 1);
33676 var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1);
33677 function DropdownHeader({
33678 title,
33679 onClose
33680 }) {
33681 return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33682 Stack,
33683 {
33684 direction: "column",
33685 className: "dataforms-layouts-panel__dropdown-header",
33686 gap: "lg",
33687 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
33688 title && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(import_components52.__experimentalHeading, { level: 2, size: 13, children: title }),
33689 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(import_components52.__experimentalSpacer, { style: { flex: 1 } }),
33690 onClose && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33691 import_components52.Button,
33692 {
33693 label: (0, import_i18n52.__)("Close"),
33694 icon: close_small_default,
33695 onClick: onClose,
33696 size: "small"
33697 }
33698 )
33699 ] })
33700 }
33701 );
33702 }
33703 function DropdownContentWithValidation({
33704 touched,
33705 children
33706 }) {
33707 const ref = (0, import_element122.useRef)(null);
33708 useReportValidity(ref, touched);
33709 return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)("div", { ref, children });
33710 }
33711 function PanelDropdown({
33712 data,
33713 field,
33714 onChange,
33715 validity
33716 }) {
33717 const [touched, setTouched] = (0, import_element122.useState)(false);
33718 const [popoverAnchor, setPopoverAnchor] = (0, import_element122.useState)(
33719 null
33720 );
33721 const popoverProps = (0, import_element122.useMemo)(
33722 () => ({
33723 // Anchor the popover to the middle of the entire row so that it doesn't
33724 // move around when the label changes.
33725 anchor: popoverAnchor,
33726 placement: "left-start",
33727 offset: 36,
33728 shift: true
33729 }),
33730 [popoverAnchor]
33731 );
33732 const [dialogRef, dialogProps] = (0, import_compose18.__experimentalUseDialog)({
33733 focusOnMount: "firstInputElement"
33734 });
33735 const form = (0, import_element122.useMemo)(
33736 () => ({
33737 layout: DEFAULT_LAYOUT,
33738 fields: !!field.children ? field.children : (
33739 // If not explicit children return the field id itself.
33740 [{ id: field.id, layout: DEFAULT_LAYOUT }]
33741 )
33742 }),
33743 [field]
33744 );
33745 const formValidity = (0, import_element122.useMemo)(() => {
33746 if (validity === void 0) {
33747 return void 0;
33748 }
33749 if (!!field.children) {
33750 return validity?.children;
33751 }
33752 return { [field.id]: validity };
33753 }, [validity, field]);
33754 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
33755 if (!fieldDefinition) {
33756 return null;
33757 }
33758 return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33759 "div",
33760 {
33761 ref: setPopoverAnchor,
33762 className: "dataforms-layouts-panel__field-dropdown-anchor",
33763 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33764 import_components52.Dropdown,
33765 {
33766 contentClassName: "dataforms-layouts-panel__field-dropdown",
33767 popoverProps,
33768 focusOnMount: false,
33769 onToggle: (willOpen) => {
33770 if (!willOpen) {
33771 setTouched(true);
33772 }
33773 },
33774 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33775 SummaryButton,
33776 {
33777 data,
33778 field,
33779 fieldLabel,
33780 summaryFields,
33781 validity,
33782 touched,
33783 disabled: fieldDefinition.readOnly === true,
33784 isOpen,
33785 onClick: onToggle
33786 }
33787 ),
33788 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
33789 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33790 DropdownHeader,
33791 {
33792 title: fieldLabel,
33793 onClose
33794 }
33795 ),
33796 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33797 DataFormLayout,
33798 {
33799 data,
33800 form,
33801 onChange,
33802 validity: formValidity,
33803 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33804 FieldLayout,
33805 {
33806 data,
33807 field: childField,
33808 onChange,
33809 hideLabelFromVision: (form?.fields ?? []).length < 2,
33810 markWhenOptional,
33811 validity: childFieldValidity
33812 },
33813 childField.id
33814 )
33815 }
33816 )
33817 ] }) })
33818 }
33819 )
33820 }
33821 );
33822 }
33823 var dropdown_default = PanelDropdown;
33824
33825 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
33826 var import_jsx_runtime168 = __toESM(require_jsx_runtime(), 1);
33827 function FormPanelField({
33828 data,
33829 field,
33830 onChange,
33831 validity
33832 }) {
33833 const layout = field.layout;
33834 if (layout.openAs.type === "modal") {
33835 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
33836 modal_default,
33837 {
33838 data,
33839 field,
33840 onChange,
33841 validity
33842 }
33843 );
33844 }
33845 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
33846 dropdown_default,
33847 {
33848 data,
33849 field,
33850 onChange,
33851 validity
33852 }
33853 );
33854 }
33855
33856 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
33857 var import_element123 = __toESM(require_element(), 1);
33858
33859 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
33860 var import_i18n53 = __toESM(require_i18n(), 1);
33861 var import_jsx_runtime169 = __toESM(require_jsx_runtime(), 1);
33862 function countInvalidFields(validity) {
33863 if (!validity) {
33864 return 0;
33865 }
33866 let count = 0;
33867 const validityRules = Object.keys(validity).filter(
33868 (key) => key !== "children"
33869 );
33870 for (const key of validityRules) {
33871 const rule = validity[key];
33872 if (rule?.type === "invalid") {
33873 count++;
33874 }
33875 }
33876 if (validity.children) {
33877 for (const childValidity of Object.values(validity.children)) {
33878 count += countInvalidFields(childValidity);
33879 }
33880 }
33881 return count;
33882 }
33883 function ValidationBadge({
33884 validity
33885 }) {
33886 const invalidCount = countInvalidFields(validity);
33887 if (invalidCount === 0) {
33888 return null;
33889 }
33890 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(Badge, { intent: "high", children: (0, import_i18n53.sprintf)(
33891 /* translators: %d: Number of fields that need attention */
33892 (0, import_i18n53._n)(
33893 "%d field needs attention",
33894 "%d fields need attention",
33895 invalidCount
33896 ),
33897 invalidCount
33898 ) });
33899 }
33900
33901 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
33902 var import_jsx_runtime170 = __toESM(require_jsx_runtime(), 1);
33903 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
33904 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
33905 return false;
33906 }
33907 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
33908 const fieldConfig = summaryConfigArray.find((config) => {
33909 if (typeof config === "string") {
33910 return config === summaryField.id;
33911 }
33912 if (typeof config === "object" && "id" in config) {
33913 return config.id === summaryField.id;
33914 }
33915 return false;
33916 });
33917 if (!fieldConfig) {
33918 return false;
33919 }
33920 if (typeof fieldConfig === "string") {
33921 return true;
33922 }
33923 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
33924 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
33925 }
33926 return true;
33927 }
33928 function HeaderContent({
33929 data,
33930 fields,
33931 label,
33932 layout,
33933 isOpen,
33934 touched,
33935 validity
33936 }) {
33937 const summaryFields = getSummaryFields(layout.summary, fields);
33938 const visibleSummaryFields = summaryFields.filter(
33939 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
33940 );
33941 const hasBadge = touched && layout.isCollapsible;
33942 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
33943 return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
33944 Stack,
33945 {
33946 align: "center",
33947 justify: "space-between",
33948 className: "dataforms-layouts-card__field-header-content",
33949 children: [
33950 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(card_exports.Title, { children: label }),
33951 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
33952 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(ValidationBadge, { validity }),
33953 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
33954 summaryField.render,
33955 {
33956 item: data,
33957 field: summaryField
33958 },
33959 summaryField.id
33960 )) })
33961 ] })
33962 ]
33963 }
33964 );
33965 }
33966 function BodyContent({
33967 data,
33968 field,
33969 form,
33970 onChange,
33971 hideLabelFromVision,
33972 markWhenOptional,
33973 validity,
33974 withHeader
33975 }) {
33976 if (field.children) {
33977 return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(import_jsx_runtime170.Fragment, { children: [
33978 field.description && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
33979 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
33980 DataFormLayout,
33981 {
33982 data,
33983 form,
33984 onChange,
33985 validity: validity?.children
33986 }
33987 )
33988 ] });
33989 }
33990 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
33991 if (!SingleFieldLayout) {
33992 return null;
33993 }
33994 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
33995 SingleFieldLayout,
33996 {
33997 data,
33998 field,
33999 onChange,
34000 hideLabelFromVision: hideLabelFromVision || withHeader,
34001 markWhenOptional,
34002 validity
34003 }
34004 );
34005 }
34006 function FormCardField({
34007 data,
34008 field,
34009 onChange,
34010 hideLabelFromVision,
34011 markWhenOptional,
34012 validity
34013 }) {
34014 const { fields } = (0, import_element123.useContext)(dataform_context_default);
34015 const layout = field.layout;
34016 const contentRef = (0, import_element123.useRef)(null);
34017 const form = (0, import_element123.useMemo)(
34018 () => ({
34019 layout: DEFAULT_LAYOUT,
34020 fields: field.children ?? []
34021 }),
34022 [field]
34023 );
34024 const { isOpened, isCollapsible } = layout;
34025 const [isOpen, setIsOpen] = (0, import_element123.useState)(isOpened);
34026 const [touched, setTouched] = (0, import_element123.useState)(false);
34027 (0, import_element123.useEffect)(() => {
34028 setIsOpen(isOpened);
34029 }, [isOpened]);
34030 const handleOpenChange = (0, import_element123.useCallback)((open) => {
34031 if (!open) {
34032 setTouched(true);
34033 }
34034 setIsOpen(open);
34035 }, []);
34036 const handleBlur = (0, import_element123.useCallback)(() => {
34037 setTouched(true);
34038 }, []);
34039 useReportValidity(
34040 contentRef,
34041 (isCollapsible ? isOpen : true) && touched
34042 );
34043 let label = field.label;
34044 let withHeader;
34045 if (field.children) {
34046 withHeader = !!label && layout.withHeader;
34047 } else {
34048 const fieldDefinition = fields.find(
34049 (fieldDef) => fieldDef.id === field.id
34050 );
34051 if (!fieldDefinition || !fieldDefinition.Edit) {
34052 return null;
34053 }
34054 label = fieldDefinition.label;
34055 withHeader = !!label && layout.withHeader;
34056 }
34057 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
34058 BodyContent,
34059 {
34060 data,
34061 field,
34062 form,
34063 onChange,
34064 hideLabelFromVision,
34065 markWhenOptional,
34066 validity,
34067 withHeader
34068 }
34069 );
34070 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
34071 HeaderContent,
34072 {
34073 data,
34074 fields,
34075 label,
34076 layout,
34077 isOpen: isCollapsible ? !!isOpen : true,
34078 touched,
34079 validity
34080 }
34081 );
34082 if (withHeader && isCollapsible) {
34083 return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
34084 collapsible_card_exports.Root,
34085 {
34086 className: "dataforms-layouts-card__field",
34087 open: isOpen,
34088 onOpenChange: handleOpenChange,
34089 children: [
34090 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(collapsible_card_exports.Header, { children: headerContent }),
34091 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
34092 collapsible_card_exports.Content,
34093 {
34094 ref: contentRef,
34095 onBlur: handleBlur,
34096 children: bodyContent
34097 }
34098 )
34099 ]
34100 }
34101 );
34102 }
34103 return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
34104 withHeader && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(card_exports.Header, { children: headerContent }),
34105 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
34106 ] });
34107 }
34108
34109 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
34110 var import_components53 = __toESM(require_components(), 1);
34111 var import_jsx_runtime171 = __toESM(require_jsx_runtime(), 1);
34112 function Header5({ title }) {
34113 return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
34114 Stack,
34115 {
34116 direction: "column",
34117 className: "dataforms-layouts-row__header",
34118 gap: "lg",
34119 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(import_components53.__experimentalHeading, { level: 2, size: 13, children: title }) })
34120 }
34121 );
34122 }
34123 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(import_jsx_runtime171.Fragment, { children });
34124 function FormRowField({
34125 data,
34126 field,
34127 onChange,
34128 hideLabelFromVision,
34129 markWhenOptional,
34130 validity
34131 }) {
34132 const layout = field.layout;
34133 if (!!field.children) {
34134 const form = {
34135 layout: DEFAULT_LAYOUT,
34136 fields: field.children
34137 };
34138 return /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
34139 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(Header5, { title: field.label }),
34140 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
34141 DataFormLayout,
34142 {
34143 data,
34144 form,
34145 onChange,
34146 validity: validity?.children,
34147 as: EMPTY_WRAPPER,
34148 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
34149 "div",
34150 {
34151 className: "dataforms-layouts-row__field-control",
34152 style: layout.styles[childField.id],
34153 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
34154 FieldLayout,
34155 {
34156 data,
34157 field: childField,
34158 onChange,
34159 hideLabelFromVision,
34160 markWhenOptional,
34161 validity: childFieldValidity
34162 }
34163 )
34164 },
34165 childField.id
34166 )
34167 }
34168 ) })
34169 ] });
34170 }
34171 const RegularLayout = getFormFieldLayout("regular")?.component;
34172 if (!RegularLayout) {
34173 return null;
34174 }
34175 return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(import_jsx_runtime171.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
34176 RegularLayout,
34177 {
34178 data,
34179 field,
34180 onChange,
34181 markWhenOptional,
34182 validity
34183 }
34184 ) }) });
34185 }
34186
34187 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
34188 var import_element124 = __toESM(require_element(), 1);
34189 var import_i18n54 = __toESM(require_i18n(), 1);
34190 var import_jsx_runtime172 = __toESM(require_jsx_runtime(), 1);
34191 function FormDetailsField({
34192 data,
34193 field,
34194 onChange,
34195 validity
34196 }) {
34197 const { fields } = (0, import_element124.useContext)(dataform_context_default);
34198 const detailsRef = (0, import_element124.useRef)(null);
34199 const contentRef = (0, import_element124.useRef)(null);
34200 const [touched, setTouched] = (0, import_element124.useState)(false);
34201 const [isOpen, setIsOpen] = (0, import_element124.useState)(false);
34202 const form = (0, import_element124.useMemo)(
34203 () => ({
34204 layout: DEFAULT_LAYOUT,
34205 fields: field.children ?? []
34206 }),
34207 [field]
34208 );
34209 (0, import_element124.useEffect)(() => {
34210 const details = detailsRef.current;
34211 if (!details) {
34212 return;
34213 }
34214 const handleToggle = () => {
34215 const nowOpen = details.open;
34216 if (!nowOpen) {
34217 setTouched(true);
34218 }
34219 setIsOpen(nowOpen);
34220 };
34221 details.addEventListener("toggle", handleToggle);
34222 return () => {
34223 details.removeEventListener("toggle", handleToggle);
34224 };
34225 }, []);
34226 useReportValidity(contentRef, isOpen && touched);
34227 const handleBlur = (0, import_element124.useCallback)(() => {
34228 setTouched(true);
34229 }, []);
34230 if (!field.children) {
34231 return null;
34232 }
34233 const summaryFieldId = field.layout.summary ?? "";
34234 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
34235 let summaryContent;
34236 if (summaryField && summaryField.render) {
34237 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(summaryField.render, { item: data, field: summaryField });
34238 } else {
34239 summaryContent = field.label || (0, import_i18n54.__)("More details");
34240 }
34241 return /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)(
34242 "details",
34243 {
34244 ref: detailsRef,
34245 className: "dataforms-layouts-details__details",
34246 children: [
34247 /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)(
34248 Stack,
34249 {
34250 direction: "row",
34251 align: "center",
34252 gap: "md",
34253 className: "dataforms-layouts-details__summary-content",
34254 children: [
34255 summaryContent,
34256 touched && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(ValidationBadge, { validity })
34257 ]
34258 }
34259 ) }),
34260 /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
34261 "div",
34262 {
34263 ref: contentRef,
34264 className: "dataforms-layouts-details__content",
34265 onBlur: handleBlur,
34266 children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
34267 DataFormLayout,
34268 {
34269 data,
34270 form,
34271 onChange,
34272 validity: validity?.children
34273 }
34274 )
34275 }
34276 )
34277 ]
34278 }
34279 );
34280 }
34281
34282 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
34283 var import_jsx_runtime173 = __toESM(require_jsx_runtime(), 1);
34284 var FORM_FIELD_LAYOUTS = [
34285 {
34286 type: "regular",
34287 component: FormRegularField,
34288 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
34289 Stack,
34290 {
34291 direction: "column",
34292 className: "dataforms-layouts__wrapper",
34293 gap: "lg",
34294 children
34295 }
34296 )
34297 },
34298 {
34299 type: "panel",
34300 component: FormPanelField,
34301 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
34302 Stack,
34303 {
34304 direction: "column",
34305 className: "dataforms-layouts__wrapper",
34306 gap: "md",
34307 children
34308 }
34309 )
34310 },
34311 {
34312 type: "card",
34313 component: FormCardField,
34314 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
34315 Stack,
34316 {
34317 direction: "column",
34318 className: "dataforms-layouts__wrapper",
34319 gap: "xl",
34320 children
34321 }
34322 )
34323 },
34324 {
34325 type: "row",
34326 component: FormRowField,
34327 wrapper: ({
34328 children,
34329 layout
34330 }) => /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
34331 Stack,
34332 {
34333 direction: "column",
34334 className: "dataforms-layouts__wrapper",
34335 gap: "lg",
34336 children: /* @__PURE__ */ (0, import_jsx_runtime173.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
34337 Stack,
34338 {
34339 direction: "row",
34340 gap: "lg",
34341 align: layout.alignment,
34342 children
34343 }
34344 ) })
34345 }
34346 )
34347 },
34348 {
34349 type: "details",
34350 component: FormDetailsField
34351 }
34352 ];
34353 function getFormFieldLayout(type) {
34354 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
34355 }
34356
34357 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
34358 var import_jsx_runtime174 = __toESM(require_jsx_runtime(), 1);
34359 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
34360 function DataFormLayout({
34361 data,
34362 form,
34363 onChange,
34364 validity,
34365 children,
34366 as
34367 }) {
34368 const { fields: fieldDefinitions } = (0, import_element125.useContext)(dataform_context_default);
34369 const markWhenOptional = (0, import_element125.useMemo)(() => {
34370 const requiredCount = fieldDefinitions.filter(
34371 (f2) => !!f2.isValid?.required
34372 ).length;
34373 const optionalCount = fieldDefinitions.length - requiredCount;
34374 return requiredCount > optionalCount;
34375 }, [fieldDefinitions]);
34376 function getFieldDefinition2(field) {
34377 return fieldDefinitions.find(
34378 (fieldDefinition) => fieldDefinition.id === field.id
34379 );
34380 }
34381 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
34382 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
34383 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
34384 if (!FieldLayout) {
34385 return null;
34386 }
34387 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
34388 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
34389 return null;
34390 }
34391 if (children) {
34392 return children(
34393 FieldLayout,
34394 formField,
34395 validity?.[formField.id],
34396 markWhenOptional
34397 );
34398 }
34399 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
34400 FieldLayout,
34401 {
34402 data,
34403 field: formField,
34404 onChange,
34405 markWhenOptional,
34406 validity: validity?.[formField.id]
34407 },
34408 formField.id
34409 );
34410 }) });
34411 }
34412
34413 // packages/dataviews/build-module/dataform/index.mjs
34414 var import_jsx_runtime175 = __toESM(require_jsx_runtime(), 1);
34415 function DataForm({
34416 data,
34417 form,
34418 fields,
34419 onChange,
34420 validity
34421 }) {
34422 const normalizedForm = (0, import_element126.useMemo)(() => normalize_form_default(form), [form]);
34423 const normalizedFields = (0, import_element126.useMemo)(
34424 () => normalizeFields(fields),
34425 [fields]
34426 );
34427 if (!form.fields) {
34428 return null;
34429 }
34430 return /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
34431 DataFormLayout,
34432 {
34433 data,
34434 form: normalizedForm,
34435 onChange,
34436 validity
34437 }
34438 ) });
34439 }
34440
34441 // packages/content-types/build-module/post-types/list.mjs
34442 var import_core_data9 = __toESM(require_core_data(), 1);
34443 var import_element135 = __toESM(require_element(), 1);
34444 var import_i18n68 = __toESM(require_i18n(), 1);
34445 import { useNavigate as useNavigate3, useSearch } from "@wordpress/route";
34446
34447 // node_modules/dequal/dist/index.mjs
34448 var has = Object.prototype.hasOwnProperty;
34449 function find(iter, tar, key) {
34450 for (key of iter.keys()) {
34451 if (dequal(key, tar)) return key;
34452 }
34453 }
34454 function dequal(foo, bar) {
34455 var ctor, len, tmp;
34456 if (foo === bar) return true;
34457 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
34458 if (ctor === Date) return foo.getTime() === bar.getTime();
34459 if (ctor === RegExp) return foo.toString() === bar.toString();
34460 if (ctor === Array) {
34461 if ((len = foo.length) === bar.length) {
34462 while (len-- && dequal(foo[len], bar[len])) ;
34463 }
34464 return len === -1;
34465 }
34466 if (ctor === Set) {
34467 if (foo.size !== bar.size) {
34468 return false;
34469 }
34470 for (len of foo) {
34471 tmp = len;
34472 if (tmp && typeof tmp === "object") {
34473 tmp = find(bar, tmp);
34474 if (!tmp) return false;
34475 }
34476 if (!bar.has(tmp)) return false;
34477 }
34478 return true;
34479 }
34480 if (ctor === Map) {
34481 if (foo.size !== bar.size) {
34482 return false;
34483 }
34484 for (len of foo) {
34485 tmp = len[0];
34486 if (tmp && typeof tmp === "object") {
34487 tmp = find(bar, tmp);
34488 if (!tmp) return false;
34489 }
34490 if (!dequal(len[1], bar.get(tmp))) {
34491 return false;
34492 }
34493 }
34494 return true;
34495 }
34496 if (ctor === ArrayBuffer) {
34497 foo = new Uint8Array(foo);
34498 bar = new Uint8Array(bar);
34499 } else if (ctor === DataView) {
34500 if ((len = foo.byteLength) === bar.byteLength) {
34501 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
34502 }
34503 return len === -1;
34504 }
34505 if (ArrayBuffer.isView(foo)) {
34506 if ((len = foo.byteLength) === bar.byteLength) {
34507 while (len-- && foo[len] === bar[len]) ;
34508 }
34509 return len === -1;
34510 }
34511 if (!ctor || typeof foo === "object") {
34512 len = 0;
34513 for (ctor in foo) {
34514 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
34515 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
34516 }
34517 return Object.keys(bar).length === len;
34518 }
34519 }
34520 return foo !== foo && bar !== bar;
34521 }
34522
34523 // packages/views/build-module/use-view.mjs
34524 var import_element127 = __toESM(require_element(), 1);
34525 var import_data6 = __toESM(require_data(), 1);
34526 var import_preferences = __toESM(require_preferences(), 1);
34527
34528 // packages/views/build-module/preference-keys.mjs
34529 function generatePreferenceKey(kind, name, slug) {
34530 return `dataviews-${kind}-${name}-${slug}`;
34531 }
34532
34533 // packages/views/build-module/filter-utils.mjs
34534 var SCALAR_VALUES = [
34535 "titleField",
34536 "mediaField",
34537 "descriptionField",
34538 "showTitle",
34539 "showMedia",
34540 "showDescription",
34541 "showLevels",
34542 "infiniteScrollEnabled"
34543 ];
34544 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
34545 if (!activeViewOverrides) {
34546 return view;
34547 }
34548 let result = view;
34549 for (const key of SCALAR_VALUES) {
34550 if (key in activeViewOverrides) {
34551 result = { ...result, [key]: activeViewOverrides[key] };
34552 }
34553 }
34554 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
34555 const activeFields = new Set(
34556 activeViewOverrides.filters.map((f2) => f2.field)
34557 );
34558 const preserved = (view.filters ?? []).filter(
34559 (f2) => !activeFields.has(f2.field)
34560 );
34561 result = {
34562 ...result,
34563 filters: [...preserved, ...activeViewOverrides.filters]
34564 };
34565 }
34566 if (activeViewOverrides.sort) {
34567 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
34568 if (isDefaultSort) {
34569 result = {
34570 ...result,
34571 sort: activeViewOverrides.sort
34572 };
34573 }
34574 }
34575 if (activeViewOverrides.layout) {
34576 result = {
34577 ...result,
34578 layout: {
34579 ...result.layout,
34580 ...activeViewOverrides.layout
34581 }
34582 };
34583 }
34584 if (activeViewOverrides.groupBy) {
34585 result = {
34586 ...result,
34587 groupBy: activeViewOverrides.groupBy
34588 };
34589 }
34590 return result;
34591 }
34592 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
34593 if (!activeViewOverrides) {
34594 return view;
34595 }
34596 let result = view;
34597 for (const key of SCALAR_VALUES) {
34598 if (key in activeViewOverrides) {
34599 const { [key]: _, ...rest } = result;
34600 result = rest;
34601 }
34602 }
34603 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
34604 const activeFields = new Set(
34605 activeViewOverrides.filters.map((f2) => f2.field)
34606 );
34607 result = {
34608 ...result,
34609 filters: (view.filters ?? []).filter(
34610 (f2) => !activeFields.has(f2.field)
34611 )
34612 };
34613 }
34614 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
34615 result = {
34616 ...result,
34617 sort: defaultView?.sort
34618 };
34619 }
34620 if (activeViewOverrides.layout && "layout" in result && result.layout) {
34621 const layout = { ...result.layout };
34622 for (const key of Object.keys(activeViewOverrides.layout)) {
34623 delete layout[key];
34624 }
34625 result = {
34626 ...result,
34627 layout: Object.keys(layout).length > 0 ? layout : void 0
34628 };
34629 }
34630 if (activeViewOverrides.groupBy && "groupBy" in result) {
34631 const { groupBy: _, ...rest } = result;
34632 result = rest;
34633 }
34634 return result;
34635 }
34636
34637 // packages/views/build-module/use-view.mjs
34638 function omit3(obj, keys) {
34639 const result = { ...obj };
34640 for (const key of keys) {
34641 delete result[key];
34642 }
34643 return result;
34644 }
34645 function useView(config) {
34646 const {
34647 kind,
34648 name,
34649 slug,
34650 defaultView,
34651 activeViewOverrides,
34652 queryParams,
34653 onChangeQueryParams
34654 } = config;
34655 const preferenceKey = generatePreferenceKey(kind, name, slug);
34656 const persistedView = (0, import_data6.useSelect)(
34657 (select2) => {
34658 return select2(import_preferences.store).get(
34659 "core/views",
34660 preferenceKey
34661 );
34662 },
34663 [preferenceKey]
34664 );
34665 const { set: set3 } = (0, import_data6.useDispatch)(import_preferences.store);
34666 const baseView = (0, import_element127.useMemo)(
34667 () => persistedView ?? defaultView ?? {},
34668 [persistedView, defaultView]
34669 );
34670 const page = Number(queryParams?.page ?? baseView.page ?? 1);
34671 const search = queryParams?.search ?? baseView.search ?? "";
34672 const combinedOverrides = (0, import_element127.useMemo)(() => {
34673 const rawDefaults = config.defaultLayouts?.[baseView.type];
34674 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
34675 return { ...layoutTypeDefaults, ...activeViewOverrides };
34676 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
34677 const view = (0, import_element127.useMemo)(() => {
34678 return mergeActiveViewOverrides(
34679 {
34680 ...baseView,
34681 page,
34682 search
34683 },
34684 combinedOverrides,
34685 defaultView
34686 );
34687 }, [baseView, page, search, combinedOverrides, defaultView]);
34688 const isModified = !!persistedView;
34689 const updateView = (0, import_element127.useCallback)(
34690 (newView) => {
34691 const urlParams = {
34692 page: newView?.page,
34693 search: newView?.search
34694 };
34695 const preferenceView = stripActiveViewOverrides(
34696 omit3(newView, ["page", "search"]),
34697 combinedOverrides,
34698 defaultView
34699 );
34700 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
34701 onChangeQueryParams(urlParams);
34702 }
34703 const comparableBaseView = stripActiveViewOverrides(
34704 baseView,
34705 combinedOverrides,
34706 defaultView
34707 );
34708 const comparableDefaultView = stripActiveViewOverrides(
34709 defaultView,
34710 combinedOverrides,
34711 defaultView
34712 );
34713 if (!dequal(comparableBaseView, preferenceView)) {
34714 if (dequal(preferenceView, comparableDefaultView)) {
34715 set3("core/views", preferenceKey, void 0);
34716 } else {
34717 set3("core/views", preferenceKey, preferenceView);
34718 }
34719 }
34720 },
34721 [
34722 onChangeQueryParams,
34723 page,
34724 search,
34725 baseView,
34726 defaultView,
34727 combinedOverrides,
34728 set3,
34729 preferenceKey
34730 ]
34731 );
34732 const resetToDefault = (0, import_element127.useCallback)(() => {
34733 set3("core/views", preferenceKey, void 0);
34734 }, [preferenceKey, set3]);
34735 return {
34736 view,
34737 isModified,
34738 updateView,
34739 resetToDefault
34740 };
34741 }
34742
34743 // packages/views/build-module/load-view.mjs
34744 var import_data7 = __toESM(require_data(), 1);
34745 var import_preferences2 = __toESM(require_preferences(), 1);
34746
34747 // packages/views/build-module/use-view-config.mjs
34748 var import_data8 = __toESM(require_data(), 1);
34749 var import_core_data = __toESM(require_core_data(), 1);
34750
34751 // packages/views/build-module/lock-unlock.mjs
34752 var import_private_apis4 = __toESM(require_private_apis(), 1);
34753 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
34754 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
34755 "@wordpress/views"
34756 );
34757
34758 // packages/content-types/build-module/post-types/actions/activate.mjs
34759 var import_i18n55 = __toESM(require_i18n(), 1);
34760
34761 // packages/content-types/build-module/utils/actions.mjs
34762 var import_core_data2 = __toESM(require_core_data(), 1);
34763 var import_notices = __toESM(require_notices(), 1);
34764 function createStatusAction(config) {
34765 const isEligible = (item) => item.status !== config.targetStatus;
34766 return {
34767 id: config.id,
34768 label: config.label,
34769 supportsBulk: true,
34770 isEligible,
34771 async callback(items, { registry }) {
34772 const itemsToUpdate = items.filter(isEligible);
34773 if (itemsToUpdate.length === 0) {
34774 return;
34775 }
34776 const { saveEntityRecord } = registry.dispatch(import_core_data2.store);
34777 const { createSuccessNotice, createErrorNotice } = registry.dispatch(import_notices.store);
34778 const promiseResult = await Promise.allSettled(
34779 itemsToUpdate.map(
34780 (item) => saveEntityRecord(
34781 "postType",
34782 config.entity,
34783 { id: item.id, status: config.targetStatus },
34784 { throwOnError: true }
34785 )
34786 )
34787 );
34788 if (promiseResult.every(({ status }) => status === "fulfilled")) {
34789 createSuccessNotice(
34790 itemsToUpdate.length === 1 ? config.messages.successSingle : config.messages.successMany(itemsToUpdate.length),
34791 { type: "snackbar" }
34792 );
34793 return;
34794 }
34795 let errorMessage;
34796 if (promiseResult.length === 1) {
34797 const typedError = promiseResult[0];
34798 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
34799 errorMessage = typedError.reason.message;
34800 } else {
34801 errorMessage = config.messages.failSingle;
34802 }
34803 } else {
34804 const errorMessages = /* @__PURE__ */ new Set();
34805 const failedPromises = promiseResult.filter(
34806 ({ status }) => status === "rejected"
34807 );
34808 for (const failedPromise of failedPromises) {
34809 const typedError = failedPromise;
34810 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
34811 errorMessages.add(typedError.reason.message);
34812 }
34813 }
34814 if (errorMessages.size === 0) {
34815 errorMessage = config.messages.failMany;
34816 } else if (errorMessages.size === 1) {
34817 errorMessage = config.messages.errorSingle(
34818 [...errorMessages][0]
34819 );
34820 } else {
34821 errorMessage = config.messages.errorMany(
34822 [...errorMessages].join(",")
34823 );
34824 }
34825 }
34826 createErrorNotice(errorMessage, { type: "snackbar" });
34827 }
34828 };
34829 }
34830
34831 // packages/content-types/build-module/constants.mjs
34832 var POST_TYPES_PATH = "/post-types";
34833 var TAXONOMIES_PATH = "/taxonomies";
34834 var POST_TYPE_ENTITY = "wp_user_post_type";
34835 var TAXONOMY_ENTITY = "wp_user_taxonomy";
34836 var NEW_ID = "new";
34837
34838 // packages/content-types/build-module/post-types/actions/activate.mjs
34839 var activateAction = createStatusAction({
34840 id: "activate",
34841 label: (0, import_i18n55.__)("Activate"),
34842 entity: POST_TYPE_ENTITY,
34843 targetStatus: "publish",
34844 messages: {
34845 successSingle: (0, import_i18n55.__)("Post type activated."),
34846 successMany: (count) => (0, import_i18n55.sprintf)(
34847 /* translators: %d: The number of post types. */
34848 (0, import_i18n55._n)(
34849 "%d post type activated.",
34850 "%d post types activated.",
34851 count
34852 ),
34853 count
34854 ),
34855 failSingle: (0, import_i18n55.__)("Failed to activate post type."),
34856 failMany: (0, import_i18n55.__)("Failed to activate post types."),
34857 errorSingle: (message2) => (0, import_i18n55.sprintf)(
34858 /* translators: %s: an error message */
34859 (0, import_i18n55.__)("An error occurred while activating the post type: %s"),
34860 message2
34861 ),
34862 errorMany: (messages) => (0, import_i18n55.sprintf)(
34863 /* translators: %s: a list of comma separated error messages */
34864 (0, import_i18n55.__)(
34865 "Some errors occurred while activating the post types: %s"
34866 ),
34867 messages
34868 )
34869 }
34870 });
34871 var activate_default = activateAction;
34872
34873 // packages/content-types/build-module/post-types/actions/deactivate.mjs
34874 var import_i18n56 = __toESM(require_i18n(), 1);
34875 var deactivateAction = createStatusAction({
34876 id: "deactivate",
34877 label: (0, import_i18n56.__)("Deactivate"),
34878 entity: POST_TYPE_ENTITY,
34879 targetStatus: "draft",
34880 messages: {
34881 successSingle: (0, import_i18n56.__)("Post type deactivated."),
34882 successMany: (count) => (0, import_i18n56.sprintf)(
34883 /* translators: %d: The number of post types. */
34884 (0, import_i18n56._n)(
34885 "%d post type deactivated.",
34886 "%d post types deactivated.",
34887 count
34888 ),
34889 count
34890 ),
34891 failSingle: (0, import_i18n56.__)("Failed to deactivate post type."),
34892 failMany: (0, import_i18n56.__)("Failed to deactivate post types."),
34893 errorSingle: (message2) => (0, import_i18n56.sprintf)(
34894 /* translators: %s: an error message */
34895 (0, import_i18n56.__)("An error occurred while deactivating the post type: %s"),
34896 message2
34897 ),
34898 errorMany: (messages) => (0, import_i18n56.sprintf)(
34899 /* translators: %s: a list of comma separated error messages */
34900 (0, import_i18n56.__)(
34901 "Some errors occurred while deactivating the post types: %s"
34902 ),
34903 messages
34904 )
34905 }
34906 });
34907 var deactivate_default = deactivateAction;
34908
34909 // packages/content-types/build-module/post-types/actions/delete.mjs
34910 var import_components54 = __toESM(require_components(), 1);
34911 var import_core_data4 = __toESM(require_core_data(), 1);
34912 var import_data10 = __toESM(require_data(), 1);
34913 var import_element129 = __toESM(require_element(), 1);
34914 var import_i18n57 = __toESM(require_i18n(), 1);
34915 var import_notices2 = __toESM(require_notices(), 1);
34916
34917 // packages/content-types/build-module/utils/use-maybe-invalidate-content-type-cache.mjs
34918 var import_element128 = __toESM(require_element(), 1);
34919 var import_core_data3 = __toESM(require_core_data(), 1);
34920 var import_data9 = __toESM(require_data(), 1);
34921 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1);
34922 function useMaybeInvalidateContentTypeCache() {
34923 const registry = (0, import_data9.useRegistry)();
34924 return (0, import_element128.useCallback)(
34925 (prev, next, entityName) => {
34926 if ((0, import_is_shallow_equal.isShallowEqual)([...prev].sort(), [...next].sort())) {
34927 return;
34928 }
34929 const resolvers = registry.select(import_core_data3.store).getCachedResolvers();
34930 const cache = resolvers.getEntityRecords;
34931 cache?.forEach((_value, args) => {
34932 if (args[0] === "postType" && args[1] === entityName) {
34933 registry.dispatch(import_core_data3.store).invalidateResolution("getEntityRecords", args);
34934 }
34935 });
34936 },
34937 [registry]
34938 );
34939 }
34940
34941 // packages/content-types/build-module/post-types/actions/delete.mjs
34942 var import_jsx_runtime176 = __toESM(require_jsx_runtime(), 1);
34943 function DeletePostTypeModal({
34944 items,
34945 closeModal,
34946 onActionPerformed
34947 }) {
34948 const [isDeleting, setIsDeleting] = (0, import_element129.useState)(false);
34949 const { deleteEntityRecord } = (0, import_data10.useDispatch)(import_core_data4.store);
34950 const { createSuccessNotice, createErrorNotice } = (0, import_data10.useDispatch)(import_notices2.store);
34951 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
34952 async function onDelete() {
34953 if (isDeleting) {
34954 return;
34955 }
34956 setIsDeleting(true);
34957 const itemsToDelete = items.filter((item) => item.id !== void 0);
34958 const promiseResult = await Promise.allSettled(
34959 itemsToDelete.map(
34960 (item) => deleteEntityRecord(
34961 "postType",
34962 POST_TYPE_ENTITY,
34963 item.id,
34964 { force: true },
34965 { throwOnError: true }
34966 )
34967 )
34968 );
34969 if (promiseResult.every(({ status }) => status === "fulfilled")) {
34970 createSuccessNotice(
34971 itemsToDelete.length === 1 ? (0, import_i18n57.sprintf)(
34972 /* translators: %s: The post type's plural label. */
34973 (0, import_i18n57.__)('"%s" post type deleted.'),
34974 itemsToDelete[0].title.raw
34975 ) : (0, import_i18n57.sprintf)(
34976 /* translators: %d: The number of post types. */
34977 (0, import_i18n57._n)(
34978 "%d post type deleted.",
34979 "%d post types deleted.",
34980 itemsToDelete.length
34981 ),
34982 itemsToDelete.length
34983 ),
34984 { type: "snackbar" }
34985 );
34986 } else {
34987 let errorMessage;
34988 if (promiseResult.length === 1) {
34989 const typedError = promiseResult[0];
34990 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
34991 errorMessage = typedError.reason.message;
34992 } else {
34993 errorMessage = (0, import_i18n57.__)("Failed to delete post type.");
34994 }
34995 } else {
34996 const errorMessages = /* @__PURE__ */ new Set();
34997 const failedPromises = promiseResult.filter(
34998 ({ status }) => status === "rejected"
34999 );
35000 for (const failedPromise of failedPromises) {
35001 const typedError = failedPromise;
35002 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
35003 errorMessages.add(typedError.reason.message);
35004 }
35005 }
35006 if (errorMessages.size === 0) {
35007 errorMessage = (0, import_i18n57.__)("Failed to delete post types.");
35008 } else if (errorMessages.size === 1) {
35009 errorMessage = (0, import_i18n57.sprintf)(
35010 /* translators: %s: an error message */
35011 (0, import_i18n57.__)(
35012 "An error occurred while deleting the post type: %s"
35013 ),
35014 [...errorMessages][0]
35015 );
35016 } else {
35017 errorMessage = (0, import_i18n57.sprintf)(
35018 /* translators: %s: a list of comma separated error messages */
35019 (0, import_i18n57.__)(
35020 "Some errors occurred while deleting the post types: %s"
35021 ),
35022 [...errorMessages].join(",")
35023 );
35024 }
35025 }
35026 createErrorNotice(errorMessage, { type: "snackbar" });
35027 }
35028 const deletedRefs = itemsToDelete.filter((_, i2) => promiseResult[i2].status === "fulfilled").flatMap((item) => item.config.taxonomies);
35029 maybeInvalidateCache(deletedRefs, [], TAXONOMY_ENTITY);
35030 onActionPerformed?.(itemsToDelete);
35031 setIsDeleting(false);
35032 closeModal?.();
35033 }
35034 return /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(Stack, { direction: "column", gap: "md", children: [
35035 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(Text, { children: items.length > 1 ? (0, import_i18n57.sprintf)(
35036 /* translators: %d: number of post types to delete. */
35037 (0, import_i18n57._n)(
35038 "Are you sure you want to delete %d post type?",
35039 "Are you sure you want to delete %d post types?",
35040 items.length
35041 ),
35042 items.length
35043 ) : (0, import_i18n57.sprintf)(
35044 /* translators: %s: The post type's plural label. */
35045 (0, import_i18n57.__)('Are you sure you want to delete "%s"?'),
35046 items[0].title.raw
35047 ) }),
35048 /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
35049 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
35050 import_components54.Button,
35051 {
35052 __next40pxDefaultSize: true,
35053 variant: "tertiary",
35054 onClick: closeModal,
35055 disabled: isDeleting,
35056 accessibleWhenDisabled: true,
35057 children: (0, import_i18n57.__)("Cancel")
35058 }
35059 ),
35060 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
35061 import_components54.Button,
35062 {
35063 __next40pxDefaultSize: true,
35064 variant: "primary",
35065 isDestructive: true,
35066 isBusy: isDeleting,
35067 disabled: isDeleting,
35068 accessibleWhenDisabled: true,
35069 onClick: onDelete,
35070 children: (0, import_i18n57._x)("Delete", "verb")
35071 }
35072 )
35073 ] })
35074 ] });
35075 }
35076 var deletePostTypeAction = {
35077 id: "delete-post-type",
35078 label: (0, import_i18n57._x)("Delete", "verb"),
35079 icon: trash_default,
35080 supportsBulk: true,
35081 hideModalHeader: true,
35082 modalFocusOnMount: "firstContentElement",
35083 modalSize: "small",
35084 RenderModal: DeletePostTypeModal
35085 };
35086 var delete_default = deletePostTypeAction;
35087
35088 // packages/content-types/build-module/post-types/actions/duplicate.mjs
35089 var import_components56 = __toESM(require_components(), 1);
35090 var import_core_data7 = __toESM(require_core_data(), 1);
35091 var import_data13 = __toESM(require_data(), 1);
35092 var import_element132 = __toESM(require_element(), 1);
35093 var import_i18n62 = __toESM(require_i18n(), 1);
35094 var import_notices3 = __toESM(require_notices(), 1);
35095
35096 // packages/content-types/build-module/post-types/fields/general.mjs
35097 var import_core_data6 = __toESM(require_core_data(), 1);
35098 var import_data12 = __toESM(require_data(), 1);
35099 var import_element131 = __toESM(require_element(), 1);
35100 var import_i18n61 = __toESM(require_i18n(), 1);
35101 var import_url4 = __toESM(require_url(), 1);
35102
35103 // packages/content-types/build-module/utils/fields.mjs
35104 var import_components55 = __toESM(require_components(), 1);
35105 var import_i18n58 = __toESM(require_i18n(), 1);
35106 var import_url3 = __toESM(require_url(), 1);
35107 var import_jsx_runtime177 = __toESM(require_jsx_runtime(), 1);
35108 var { ValidatedInputControl: ValidatedInputControl4, ValidatedToggleControl: ValidatedToggleControl2 } = unlock2(
35109 import_components55.privateApis
35110 );
35111 function getCustomValidity2(validity) {
35112 if (validity?.required?.message) {
35113 return validity.required;
35114 }
35115 if (validity?.pattern) {
35116 return validity.pattern;
35117 }
35118 if (validity?.maxLength) {
35119 return validity.maxLength;
35120 }
35121 return validity?.custom;
35122 }
35123 function createBooleanField(id, label, options) {
35124 const field = {
35125 id,
35126 label,
35127 type: "boolean",
35128 description: options.description,
35129 Edit: "toggle",
35130 getValue: ({ item }) => item.config[id],
35131 setValue: ({ item, value }) => ({
35132 config: { ...item.config, [id]: !!value }
35133 }),
35134 filterBy: false,
35135 enableSorting: false
35136 };
35137 if (options.isVisible) {
35138 field.isVisible = options.isVisible;
35139 }
35140 return field;
35141 }
35142 function createLabelField(id, label, options = {}) {
35143 const field = {
35144 id,
35145 label,
35146 type: "text",
35147 placeholder: options.placeholder,
35148 description: options.description,
35149 getValue: ({ item }) => item.config.labels[id] ?? "",
35150 setValue: ({ item, value }) => ({
35151 config: {
35152 ...item.config,
35153 labels: {
35154 ...item.config.labels,
35155 [id]: String(value ?? "")
35156 }
35157 }
35158 }),
35159 isValid: {
35160 ...options.required ? { required: true } : {},
35161 // Mirrors the server REST schema: 200 chars for labels.
35162 maxLength: 200
35163 },
35164 enableSorting: false
35165 };
35166 if (options.isVisible) {
35167 field.isVisible = options.isVisible;
35168 }
35169 return field;
35170 }
35171 var titleField = {
35172 id: "title",
35173 label: (0, import_i18n58.__)("Title"),
35174 type: "text",
35175 enableGlobalSearch: true,
35176 getValue: ({ item }) => item.title.raw,
35177 setValue: ({ value }) => ({
35178 title: { raw: String(value ?? "") }
35179 }),
35180 isValid: {
35181 required: true,
35182 // Title is stored as the plural label — mirrors the server REST schema (200 chars).
35183 maxLength: 200
35184 },
35185 filterBy: false,
35186 enableHiding: false
35187 };
35188 var pluralLabelField = {
35189 id: "plural_name",
35190 label: (0, import_i18n58.__)("Plural label"),
35191 type: "text",
35192 getValue: ({ item }) => item.title.raw,
35193 setValue: ({ value }) => ({
35194 title: { raw: String(value ?? "") }
35195 }),
35196 isValid: {
35197 required: true,
35198 maxLength: 200
35199 }
35200 };
35201 var singularLabelField = createLabelField(
35202 "singular_name",
35203 (0, import_i18n58.__)("Singular label"),
35204 { required: true }
35205 );
35206 function createDescriptionField(description) {
35207 return {
35208 id: "description",
35209 label: (0, import_i18n58.__)("Description"),
35210 type: "text",
35211 Edit: { control: "textarea", rows: 3 },
35212 description,
35213 getValue: ({ item }) => item.config.description,
35214 setValue: ({ item, value }) => ({
35215 config: { ...item.config, description: String(value ?? "") }
35216 }),
35217 // Mirrors the server REST schema (1000 chars for description).
35218 isValid: { maxLength: 1e3 },
35219 enableSorting: false
35220 };
35221 }
35222 var statusField = {
35223 id: "status",
35224 label: (0, import_i18n58.__)("Status"),
35225 description: (0, import_i18n58.__)("Enabled and registered with WordPress when active."),
35226 // The field keeps `label: 'Status'` so the filter chip and column header
35227 // read naturally ("Status: Active"); the form toggle uses its own "Active"
35228 // label — the on/off semantic is clearer next to a switch.
35229 Edit: ({
35230 data,
35231 field,
35232 onChange,
35233 hideLabelFromVision,
35234 markWhenOptional,
35235 validity
35236 }) => {
35237 const isActive = field.getValue({ item: data }) === "publish";
35238 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
35239 ValidatedToggleControl2,
35240 {
35241 label: (0, import_i18n58.__)("Active"),
35242 hidden: hideLabelFromVision,
35243 help: field.description,
35244 markWhenOptional,
35245 customValidity: getCustomValidity2(validity),
35246 checked: isActive,
35247 onChange: (next) => onChange(
35248 field.setValue({
35249 item: data,
35250 value: next ? "publish" : "draft"
35251 })
35252 )
35253 }
35254 );
35255 },
35256 elements: [
35257 { value: "publish", label: (0, import_i18n58.__)("Active") },
35258 { value: "draft", label: (0, import_i18n58.__)("Inactive") }
35259 ],
35260 render: ({ item }) => {
35261 const isActive = item.status === "publish";
35262 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Badge, { intent: isActive ? "stable" : "draft", children: isActive ? (0, import_i18n58.__)("Active") : (0, import_i18n58.__)("Inactive") });
35263 },
35264 enableSorting: false
35265 };
35266 function SlugEdit({
35267 data,
35268 field,
35269 onChange,
35270 hideLabelFromVision,
35271 markWhenOptional,
35272 validity
35273 }) {
35274 const { label, description, getValue, setValue } = field;
35275 const isValid2 = field.isValid;
35276 const value = getValue({ item: data }) ?? "";
35277 const handleChange = (newValue) => onChange(setValue({ item: data, value: newValue }));
35278 const onFocus = () => {
35279 if (data.id !== void 0 || data.slug) {
35280 return;
35281 }
35282 const singular = data.config.labels.singular_name?.trim();
35283 if (!singular) {
35284 return;
35285 }
35286 const cleaned = (0, import_url3.cleanForSlug)(singular);
35287 if (/[^a-z0-9_-]/.test(cleaned)) {
35288 return;
35289 }
35290 const trimmed = cleaned.slice(0, isValid2.maxLength.constraint).replace(/-+$/, "");
35291 if (trimmed) {
35292 handleChange(trimmed);
35293 }
35294 };
35295 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
35296 ValidatedInputControl4,
35297 {
35298 __next40pxDefaultSize: true,
35299 required: !!isValid2.required,
35300 markWhenOptional,
35301 customValidity: getCustomValidity2(validity),
35302 label,
35303 value,
35304 help: description,
35305 onChange: handleChange,
35306 onFocus,
35307 hideLabelFromVision,
35308 pattern: isValid2.pattern?.constraint,
35309 maxLength: isValid2.maxLength.constraint
35310 }
35311 );
35312 }
35313
35314 // packages/content-types/build-module/utils/overflowing-badges.mjs
35315 var import_i18n59 = __toESM(require_i18n(), 1);
35316 var import_jsx_runtime178 = __toESM(require_jsx_runtime(), 1);
35317 var DEFAULT_MAX = 3;
35318 function OverflowingBadges({
35319 items,
35320 max: max2 = DEFAULT_MAX
35321 }) {
35322 const visible = items.slice(0, max2);
35323 const hidden = items.slice(max2);
35324 const moreLabel = (0, import_i18n59.sprintf)(
35325 /* translators: %d: number of additional items */
35326 (0, import_i18n59._n)("Show %d more", "Show %d more", hidden.length),
35327 hidden.length
35328 );
35329 const popoverTitle = (0, import_i18n59.sprintf)(
35330 /* translators: %d: number of additional items */
35331 (0, import_i18n59._n)("%d more item", "%d more items", hidden.length),
35332 hidden.length
35333 );
35334 return /* @__PURE__ */ (0, import_jsx_runtime178.jsxs)(
35335 Stack,
35336 {
35337 direction: "row",
35338 wrap: "wrap",
35339 gap: "xs",
35340 align: "center",
35341 render: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)("span", {}),
35342 children: [
35343 visible.map((item) => /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(Badge, { children: item.label }, item.key)),
35344 hidden.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(tooltip_exports.Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(tooltip_exports.Root, { children: /* @__PURE__ */ (0, import_jsx_runtime178.jsxs)(popover_exports.Root, { children: [
35345 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
35346 tooltip_exports.Trigger,
35347 {
35348 render: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
35349 popover_exports.Trigger,
35350 {
35351 render: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
35352 Button4,
35353 {
35354 variant: "outline",
35355 tone: "neutral",
35356 size: "small",
35357 "aria-label": moreLabel,
35358 style: {
35359 minWidth: "auto",
35360 borderRadius: "var(--wpds-border-radius-lg, 8px)",
35361 fontWeight: "normal"
35362 },
35363 children: (0, import_i18n59.sprintf)(
35364 /* translators: %d: number of additional items */
35365 (0, import_i18n59.__)("+%d"),
35366 hidden.length
35367 )
35368 }
35369 )
35370 }
35371 )
35372 }
35373 ),
35374 /* @__PURE__ */ (0, import_jsx_runtime178.jsxs)(popover_exports.Popup, { style: { maxWidth: 320 }, children: [
35375 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(popover_exports.Title, {}), children: popoverTitle }),
35376 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(Stack, { direction: "row", wrap: "wrap", gap: "xs", children: hidden.map((item) => /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(Badge, { children: item.label }, item.key)) })
35377 ] }),
35378 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(tooltip_exports.Popup, { children: moreLabel })
35379 ] }) }) })
35380 ]
35381 }
35382 );
35383 }
35384
35385 // packages/content-types/build-module/post-types/utils.mjs
35386 var import_core_data5 = __toESM(require_core_data(), 1);
35387 var import_data11 = __toESM(require_data(), 1);
35388 var import_element130 = __toESM(require_element(), 1);
35389 var import_i18n60 = __toESM(require_i18n(), 1);
35390
35391 // packages/content-types/build-module/utils/form-data.mjs
35392 function pickStoredLabels(source, keys) {
35393 const labels = {};
35394 for (const key of keys) {
35395 const value = source?.[key];
35396 if (typeof value === "string") {
35397 labels[key] = value;
35398 }
35399 }
35400 return labels;
35401 }
35402 function serializeLabels(source, keys) {
35403 const labels = {};
35404 for (const key of keys) {
35405 const value = source[key];
35406 if (typeof value === "string" && value.trim() !== "") {
35407 labels[key] = value.trim();
35408 }
35409 }
35410 labels.singular_name = source.singular_name;
35411 return labels;
35412 }
35413
35414 // packages/content-types/build-module/post-types/utils.mjs
35415 var DEFAULT_SUPPORTS = ["title", "editor"];
35416 var BLANK_RECORD = {
35417 slug: "",
35418 status: "publish",
35419 title: { raw: "" },
35420 config: {
35421 labels: { singular_name: "" },
35422 taxonomies: [],
35423 supports: [...DEFAULT_SUPPORTS],
35424 description: "",
35425 public: true,
35426 hierarchical: false,
35427 has_archive: false,
35428 show_in_rest: true
35429 }
35430 };
35431 var STRING_LABEL_KEYS = [
35432 "singular_name",
35433 "menu_name",
35434 "all_items",
35435 "add_new",
35436 "add_new_item",
35437 "edit_item",
35438 "new_item",
35439 "view_item",
35440 "view_items",
35441 "search_items",
35442 "not_found",
35443 "not_found_in_trash",
35444 "parent_item_colon",
35445 "archives",
35446 "attributes",
35447 "insert_into_item",
35448 "uploaded_to_this_item",
35449 "featured_image",
35450 "set_featured_image",
35451 "remove_featured_image",
35452 "use_featured_image",
35453 "filter_items_list",
35454 "items_list_navigation",
35455 "items_list"
35456 ];
35457 function deriveLabels(plural, singular) {
35458 const lcPlural = plural.toLowerCase();
35459 const lcSingular = singular.toLowerCase();
35460 return {
35461 menu_name: plural,
35462 all_items: (0, import_i18n60.sprintf)(
35463 /* translators: %s: Plural post type label. */
35464 (0, import_i18n60.__)("All %s"),
35465 plural
35466 ),
35467 add_new: (0, import_i18n60.__)("Add New"),
35468 add_new_item: (0, import_i18n60.sprintf)(
35469 /* translators: %s: Singular post type label. */
35470 (0, import_i18n60.__)("Add New %s"),
35471 singular
35472 ),
35473 edit_item: (0, import_i18n60.sprintf)(
35474 /* translators: %s: Singular post type label. */
35475 (0, import_i18n60.__)("Edit %s"),
35476 singular
35477 ),
35478 new_item: (0, import_i18n60.sprintf)(
35479 /* translators: %s: Singular post type label. */
35480 (0, import_i18n60.__)("New %s"),
35481 singular
35482 ),
35483 view_item: (0, import_i18n60.sprintf)(
35484 /* translators: %s: Singular post type label. */
35485 (0, import_i18n60.__)("View %s"),
35486 singular
35487 ),
35488 view_items: (0, import_i18n60.sprintf)(
35489 /* translators: %s: Plural post type label. */
35490 (0, import_i18n60.__)("View %s"),
35491 plural
35492 ),
35493 search_items: (0, import_i18n60.sprintf)(
35494 /* translators: %s: Plural post type label. */
35495 (0, import_i18n60.__)("Search %s"),
35496 plural
35497 ),
35498 not_found: (0, import_i18n60.sprintf)(
35499 /* translators: %s: Plural post type label, lowercase. */
35500 (0, import_i18n60.__)("No %s found."),
35501 lcPlural
35502 ),
35503 not_found_in_trash: (0, import_i18n60.sprintf)(
35504 /* translators: %s: Plural post type label, lowercase. */
35505 (0, import_i18n60.__)("No %s found in Trash."),
35506 lcPlural
35507 ),
35508 parent_item_colon: (0, import_i18n60.sprintf)(
35509 /* translators: %s: Singular post type label. */
35510 (0, import_i18n60.__)("Parent %s:"),
35511 singular
35512 ),
35513 archives: (0, import_i18n60.sprintf)(
35514 /* translators: %s: Singular post type label. */
35515 (0, import_i18n60.__)("%s Archives"),
35516 singular
35517 ),
35518 attributes: (0, import_i18n60.sprintf)(
35519 /* translators: %s: Singular post type label. */
35520 (0, import_i18n60.__)("%s Attributes"),
35521 singular
35522 ),
35523 insert_into_item: (0, import_i18n60.sprintf)(
35524 /* translators: %s: Singular post type label, lowercase. */
35525 (0, import_i18n60.__)("Insert into %s"),
35526 lcSingular
35527 ),
35528 uploaded_to_this_item: (0, import_i18n60.sprintf)(
35529 /* translators: %s: Singular post type label, lowercase. */
35530 (0, import_i18n60.__)("Uploaded to this %s"),
35531 lcSingular
35532 ),
35533 featured_image: (0, import_i18n60.__)("Featured image"),
35534 set_featured_image: (0, import_i18n60.__)("Set featured image"),
35535 remove_featured_image: (0, import_i18n60.__)("Remove featured image"),
35536 use_featured_image: (0, import_i18n60.__)("Use as featured image"),
35537 filter_items_list: (0, import_i18n60.sprintf)(
35538 /* translators: %s: Plural post type label, lowercase. */
35539 (0, import_i18n60.__)("Filter %s list"),
35540 lcPlural
35541 ),
35542 items_list_navigation: (0, import_i18n60.sprintf)(
35543 /* translators: %s: Plural post type label. */
35544 (0, import_i18n60.__)("%s list navigation"),
35545 plural
35546 ),
35547 items_list: (0, import_i18n60.sprintf)(
35548 /* translators: %s: Plural post type label. */
35549 (0, import_i18n60.__)("%s list"),
35550 plural
35551 )
35552 };
35553 }
35554 var SUPPORT_FEATURES = [
35555 "title",
35556 "editor",
35557 "thumbnail",
35558 "excerpt",
35559 "comments",
35560 "revisions",
35561 "author",
35562 "page-attributes",
35563 "custom-fields",
35564 "trackbacks",
35565 "post-formats"
35566 ];
35567 function toFormData(row) {
35568 const config = row.config ?? {};
35569 const labels = pickStoredLabels(
35570 config.labels,
35571 STRING_LABEL_KEYS
35572 );
35573 const supports = Array.isArray(config.supports) ? config.supports.filter(
35574 (s2) => SUPPORT_FEATURES.includes(s2)
35575 ) : [...DEFAULT_SUPPORTS];
35576 return {
35577 id: row.id,
35578 slug: row.slug,
35579 status: row.status,
35580 title: { raw: row.title.raw },
35581 config: {
35582 labels: { singular_name: "", ...labels },
35583 taxonomies: Array.isArray(config.taxonomies) ? config.taxonomies : [],
35584 supports,
35585 description: config.description ?? "",
35586 public: config.public ?? true,
35587 hierarchical: config.hierarchical ?? false,
35588 has_archive: config.has_archive ?? false,
35589 show_in_rest: config.show_in_rest ?? true
35590 },
35591 count: row.count
35592 };
35593 }
35594 function serializeForSave(data) {
35595 const { config } = data;
35596 const labels = serializeLabels(
35597 config.labels,
35598 STRING_LABEL_KEYS
35599 );
35600 const description = config.description.trim();
35601 return {
35602 ...data.id !== void 0 ? { id: data.id } : {},
35603 slug: data.slug,
35604 status: data.status,
35605 title: data.title.raw,
35606 config: {
35607 labels,
35608 taxonomies: config.taxonomies,
35609 supports: config.supports,
35610 public: config.public,
35611 hierarchical: config.hierarchical,
35612 has_archive: config.has_archive,
35613 show_in_rest: config.show_in_rest,
35614 ...description !== "" ? { description } : {}
35615 }
35616 };
35617 }
35618 var CORE_TAXONOMY_SLUGS = ["category", "post_tag"];
35619 function usePublicTaxonomies() {
35620 const taxonomies = (0, import_data11.useSelect)(
35621 (select2) => select2(import_core_data5.store).getTaxonomies({ per_page: -1 }),
35622 []
35623 );
35624 return (0, import_element130.useMemo)(() => {
35625 return taxonomies?.filter((t2) => !!t2.visibility?.public).sort((a2, b2) => {
35626 const aIsCore = CORE_TAXONOMY_SLUGS.includes(a2.slug);
35627 const bIsCore = CORE_TAXONOMY_SLUGS.includes(b2.slug);
35628 if (aIsCore !== bIsCore) {
35629 return aIsCore ? -1 : 1;
35630 }
35631 return a2.name.localeCompare(b2.name);
35632 });
35633 }, [taxonomies]);
35634 }
35635
35636 // packages/content-types/build-module/post-types/fields/general.mjs
35637 var import_jsx_runtime179 = __toESM(require_jsx_runtime(), 1);
35638 var SUPPORT_LABELS = {
35639 title: (0, import_i18n61.__)("Title"),
35640 editor: (0, import_i18n61.__)("Editor"),
35641 thumbnail: (0, import_i18n61.__)("Featured image"),
35642 excerpt: (0, import_i18n61.__)("Excerpt"),
35643 comments: (0, import_i18n61.__)("Comments"),
35644 revisions: (0, import_i18n61.__)("Revisions"),
35645 author: (0, import_i18n61.__)("Author"),
35646 "page-attributes": (0, import_i18n61.__)("Page attributes"),
35647 "custom-fields": (0, import_i18n61.__)("Custom fields"),
35648 trackbacks: (0, import_i18n61.__)("Trackbacks"),
35649 "post-formats": (0, import_i18n61.__)("Post formats")
35650 };
35651 var descriptionField = createDescriptionField(
35652 (0, import_i18n61.__)(
35653 "Optional summary of the post type. Shown in admin UIs that surface post type details."
35654 )
35655 );
35656 var publicField = createBooleanField("public", (0, import_i18n61.__)("Public"), {
35657 description: (0, import_i18n61.__)(
35658 "Whether the post type is intended for use publicly either via the admin interface or by front-end users."
35659 )
35660 });
35661 var hierarchicalField = createBooleanField(
35662 "hierarchical",
35663 (0, import_i18n61.__)("Hierarchical"),
35664 {
35665 description: (0, import_i18n61.__)(
35666 "When on, posts of this type can have parent-child relationships like pages, and the parent picker is shown in the editor. When off, they behave like posts."
35667 )
35668 }
35669 );
35670 var hasArchiveField = createBooleanField(
35671 "has_archive",
35672 (0, import_i18n61.__)("Has archive"),
35673 {
35674 description: (0, import_i18n61.__)(
35675 "Whether the post type has an archive page (e.g. /book/). Requires permalink rewrite rules to be flushed after enabling."
35676 )
35677 }
35678 );
35679 var showInRestField = createBooleanField(
35680 "show_in_rest",
35681 (0, import_i18n61.__)("Show in REST API"),
35682 {
35683 description: (0, import_i18n61.__)(
35684 "Required for the block editor. Disable only if posts of this type should not be available via the REST API."
35685 )
35686 }
35687 );
35688 var countField = {
35689 id: "count",
35690 label: (0, import_i18n61.__)("Posts"),
35691 type: "integer",
35692 readOnly: true,
35693 render: ({ item }) => {
35694 const count = item.count;
35695 if (item.status !== "publish" || !count) {
35696 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("span", { "aria-hidden": "true", children: "—" });
35697 }
35698 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
35699 Link,
35700 {
35701 href: (0, import_url4.addQueryArgs)("edit.php", {
35702 post_type: item.slug
35703 }),
35704 children: count
35705 }
35706 );
35707 },
35708 enableSorting: false,
35709 filterBy: false
35710 };
35711 var supportsField = {
35712 id: "supports",
35713 label: (0, import_i18n61.__)("Supports"),
35714 type: "array",
35715 description: (0, import_i18n61.__)(
35716 "Editor features and metadata enabled for posts of this type."
35717 ),
35718 elements: SUPPORT_FEATURES.map((feature) => ({
35719 value: feature,
35720 label: SUPPORT_LABELS[feature]
35721 })),
35722 enableSorting: false,
35723 getValue: ({ item }) => item.config.supports,
35724 setValue: ({ item, value }) => ({
35725 config: {
35726 ...item.config,
35727 supports: Array.isArray(value) ? value.filter(
35728 (v2) => SUPPORT_FEATURES.includes(v2)
35729 ) : []
35730 }
35731 }),
35732 render: ({ item }) => {
35733 const features = item.config.supports;
35734 if (!features || features.length === 0) {
35735 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("span", { "aria-hidden": "true", children: "—" });
35736 }
35737 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
35738 OverflowingBadges,
35739 {
35740 items: features.map((f2) => ({
35741 key: f2,
35742 label: SUPPORT_LABELS[f2] ?? f2
35743 }))
35744 }
35745 );
35746 },
35747 filterBy: false
35748 };
35749 var SLUG_MAX_LENGTH = 20;
35750 function useSlugField(originalSlug, currentValue) {
35751 const registeredPostTypes = (0, import_data12.useSelect)(
35752 (select2) => select2(import_core_data6.store).getPostTypes(),
35753 []
35754 );
35755 const showRenameWarning = originalSlug !== void 0 && currentValue !== originalSlug;
35756 return (0, import_element131.useMemo)(
35757 () => ({
35758 id: "slug",
35759 label: (0, import_i18n61.__)("Post type key"),
35760 type: "text",
35761 enableGlobalSearch: true,
35762 description: /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(Stack, { direction: "column", gap: "sm", render: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("span", {}), children: [
35763 showRenameWarning && /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(notice_exports.Root, { intent: "warning", render: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("span", {}), children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(notice_exports.Description, { children: (0, import_i18n61.__)(
35764 "Changing the key renames the post type — existing posts may become inaccessible until a migration updates the database."
35765 ) }) }),
35766 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("span", { children: (0, import_i18n61.__)(
35767 "Lower case letters, numbers, underscores, and dashes only. Maximum length: 20 characters."
35768 ) })
35769 ] }),
35770 isValid: {
35771 required: true,
35772 pattern: "^[a-z0-9_\\-]+$",
35773 maxLength: SLUG_MAX_LENGTH,
35774 custom: async (value) => {
35775 const slug = value.slug;
35776 if (originalSlug !== void 0 && slug === originalSlug) {
35777 return null;
35778 }
35779 const slugTaken = (registeredPostTypes ?? []).some(
35780 (pt) => pt.slug === slug
35781 );
35782 if (slugTaken) {
35783 return (0, import_i18n61.__)("This post type key is already in use.");
35784 }
35785 const drafts = await (0, import_data12.resolveSelect)(
35786 import_core_data6.store
35787 ).getEntityRecords("postType", POST_TYPE_ENTITY, {
35788 slug,
35789 status: "draft",
35790 _fields: "id,name",
35791 per_page: 1
35792 });
35793 return drafts?.length ? (0, import_i18n61.__)("This post type key is already in use.") : null;
35794 }
35795 },
35796 Edit: SlugEdit,
35797 filterBy: false,
35798 enableSorting: false
35799 }),
35800 [registeredPostTypes, originalSlug, showRenameWarning]
35801 );
35802 }
35803 function useTaxonomiesField() {
35804 const publicTaxonomies = usePublicTaxonomies();
35805 return (0, import_element131.useMemo)(() => {
35806 const elements = (publicTaxonomies ?? []).map((tax) => ({
35807 value: tax.slug,
35808 label: tax.name
35809 }));
35810 const labelMap = Object.fromEntries(
35811 elements.map((e2) => [e2.value, e2.label])
35812 );
35813 return {
35814 id: "taxonomies",
35815 label: (0, import_i18n61.__)("Taxonomies"),
35816 type: "array",
35817 description: (0, import_i18n61.__)(
35818 "One or more taxonomies that should be associated with this post type."
35819 ),
35820 elements,
35821 enableSorting: false,
35822 getValue: ({ item }) => item.config.taxonomies,
35823 setValue: ({ item, value }) => ({
35824 config: {
35825 ...item.config,
35826 taxonomies: Array.isArray(value) ? value : []
35827 }
35828 }),
35829 render: ({ item }) => {
35830 const slugs = item.config.taxonomies;
35831 if (!slugs || slugs.length === 0) {
35832 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("span", { "aria-hidden": "true", children: "—" });
35833 }
35834 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
35835 OverflowingBadges,
35836 {
35837 items: slugs.map((s2) => ({
35838 key: s2,
35839 label: labelMap[s2] ?? s2
35840 }))
35841 }
35842 );
35843 },
35844 filterBy: false
35845 };
35846 }, [publicTaxonomies]);
35847 }
35848 var defaultForm = {
35849 layout: { type: "regular" },
35850 fields: [
35851 "plural_name",
35852 "singular_name",
35853 "slug",
35854 "taxonomies",
35855 "public",
35856 "hierarchical",
35857 "has_archive",
35858 "status"
35859 ]
35860 };
35861 var generalForm = {
35862 layout: { type: "regular" },
35863 fields: [
35864 "plural_name",
35865 "singular_name",
35866 "slug",
35867 "description",
35868 "taxonomies",
35869 "supports",
35870 "public",
35871 "hierarchical",
35872 "has_archive",
35873 "show_in_rest",
35874 "status"
35875 ]
35876 };
35877
35878 // packages/content-types/build-module/post-types/actions/duplicate.mjs
35879 var import_jsx_runtime180 = __toESM(require_jsx_runtime(), 1);
35880 var SLUG_MAX_LENGTH2 = 20;
35881 var duplicateForm = {
35882 layout: { type: "regular" },
35883 fields: ["plural_name", "singular_name", "slug"]
35884 };
35885 function buildCopySlug(slug) {
35886 const match2 = slug.match(/^(.*?)(\d+)$/);
35887 const base = match2 ? match2[1] : slug;
35888 const nextNumber = String(match2 ? parseInt(match2[2], 10) + 1 : 2);
35889 return `${base.slice(
35890 0,
35891 SLUG_MAX_LENGTH2 - nextNumber.length
35892 )}${nextNumber}`;
35893 }
35894 function DuplicatePostTypeModal({
35895 items,
35896 closeModal,
35897 onActionPerformed
35898 }) {
35899 const source = items[0];
35900 const [data, setData] = (0, import_element132.useState)(() => ({
35901 ...source,
35902 id: void 0,
35903 status: "draft",
35904 title: {
35905 raw: (0, import_i18n62.sprintf)(
35906 /* translators: %s: existing post type title. */
35907 (0, import_i18n62._x)("%s (Copy)", "post type"),
35908 source.title.raw
35909 )
35910 },
35911 slug: buildCopySlug(source.slug)
35912 }));
35913 const [isDuplicating, setIsDuplicating] = (0, import_element132.useState)(false);
35914 const slugField = useSlugField(void 0, data.slug);
35915 const fields = (0, import_element132.useMemo)(
35916 () => [
35917 pluralLabelField,
35918 singularLabelField,
35919 slugField
35920 ],
35921 [slugField]
35922 );
35923 const { validity, isValid: isValid2 } = use_form_validity_default(
35924 data,
35925 fields,
35926 duplicateForm
35927 );
35928 const { saveEntityRecord } = (0, import_data13.useDispatch)(import_core_data7.store);
35929 const { createSuccessNotice, createErrorNotice } = (0, import_data13.useDispatch)(import_notices3.store);
35930 async function onDuplicate() {
35931 if (isDuplicating || !isValid2) {
35932 return;
35933 }
35934 setIsDuplicating(true);
35935 try {
35936 await saveEntityRecord(
35937 "postType",
35938 POST_TYPE_ENTITY,
35939 serializeForSave(data),
35940 { throwOnError: true }
35941 );
35942 createSuccessNotice(
35943 (0, import_i18n62.sprintf)(
35944 /* translators: %s: post type plural label. */
35945 (0, import_i18n62.__)('"%s" post type created.'),
35946 data.title.raw
35947 ),
35948 { type: "snackbar" }
35949 );
35950 onActionPerformed?.(items);
35951 closeModal?.();
35952 } catch (error2) {
35953 const typedError = error2;
35954 createErrorNotice(
35955 typedError?.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n62.__)("Failed to duplicate post type."),
35956 { type: "snackbar" }
35957 );
35958 } finally {
35959 setIsDuplicating(false);
35960 }
35961 }
35962 return /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(Stack, { direction: "column", gap: "md", children: [
35963 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
35964 DataForm,
35965 {
35966 data,
35967 fields,
35968 form: duplicateForm,
35969 validity,
35970 onChange: (edits) => setData(
35971 (prev) => ({ ...prev, ...edits })
35972 )
35973 }
35974 ),
35975 /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
35976 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
35977 import_components56.Button,
35978 {
35979 __next40pxDefaultSize: true,
35980 variant: "tertiary",
35981 onClick: closeModal,
35982 disabled: isDuplicating,
35983 accessibleWhenDisabled: true,
35984 children: (0, import_i18n62.__)("Cancel")
35985 }
35986 ),
35987 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
35988 import_components56.Button,
35989 {
35990 __next40pxDefaultSize: true,
35991 variant: "primary",
35992 isBusy: isDuplicating,
35993 disabled: isDuplicating || !isValid2,
35994 accessibleWhenDisabled: true,
35995 onClick: onDuplicate,
35996 children: (0, import_i18n62._x)("Duplicate", "action label")
35997 }
35998 )
35999 ] })
36000 ] });
36001 }
36002 var duplicatePostTypeAction = {
36003 id: "duplicate-post-type",
36004 label: (0, import_i18n62._x)("Duplicate", "action label"),
36005 icon: copy_default,
36006 modalHeader: (0, import_i18n62.__)("Duplicate post type"),
36007 modalFocusOnMount: "firstContentElement",
36008 RenderModal: DuplicatePostTypeModal
36009 };
36010 var duplicate_default = duplicatePostTypeAction;
36011
36012 // packages/content-types/build-module/post-types/actions/view-posts.mjs
36013 var import_i18n63 = __toESM(require_i18n(), 1);
36014 var import_url5 = __toESM(require_url(), 1);
36015 var viewPostsAction = {
36016 id: "view-posts",
36017 label: (items) => items[0]?.config.labels.view_items || (items[0]?.config.hierarchical ? (0, import_i18n63.__)("View pages") : (0, import_i18n63.__)("View posts")),
36018 // Drafts are not registered with WordPress, so `edit.php?post_type=…`
36019 // would 404. Only surface the link for active post types.
36020 isEligible: (item) => item.status === "publish",
36021 callback: (items, { onActionPerformed }) => {
36022 const item = items[0];
36023 if (!item?.slug) {
36024 return;
36025 }
36026 document.location.href = (0, import_url5.addQueryArgs)("edit.php", {
36027 post_type: item.slug
36028 });
36029 onActionPerformed?.(items);
36030 }
36031 };
36032 var view_posts_default = viewPostsAction;
36033
36034 // packages/content-types/build-module/post-types/fields/labels.mjs
36035 var import_i18n65 = __toESM(require_i18n(), 1);
36036
36037 // packages/content-types/build-module/utils/labels.mjs
36038 var import_components57 = __toESM(require_components(), 1);
36039 var import_i18n64 = __toESM(require_i18n(), 1);
36040 var import_jsx_runtime181 = __toESM(require_jsx_runtime(), 1);
36041 var LABELS_ACTIONS_FIELD_ID = "__labels_actions";
36042 function createLabelsActionsField(options) {
36043 const { labelKeys, deriveLabels: deriveLabels3, helpText } = options;
36044 function LabelsActionsEdit({
36045 data,
36046 onChange
36047 }) {
36048 const plural = data.title.raw.trim();
36049 const singular = data.config.labels.singular_name.trim();
36050 const canAutoFill = !!plural.length && !!singular.length;
36051 const currentLabels = data.config.labels;
36052 const hasOverrides = labelKeys.some(
36053 (key) => key !== "singular_name" && (currentLabels[key] ?? "") !== ""
36054 );
36055 return /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(Stack, { direction: "column", gap: "md", children: [
36056 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Text, { variant: "body-md", children: helpText }),
36057 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
36058 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36059 import_components57.Button,
36060 {
36061 __next40pxDefaultSize: true,
36062 variant: "secondary",
36063 size: "compact",
36064 accessibleWhenDisabled: true,
36065 disabled: !canAutoFill,
36066 onClick: () => onChange({
36067 config: {
36068 ...data.config,
36069 labels: {
36070 ...data.config.labels,
36071 ...deriveLabels3(plural, singular)
36072 }
36073 }
36074 }),
36075 children: (0, import_i18n64.__)("Auto-fill labels")
36076 }
36077 ),
36078 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36079 import_components57.Button,
36080 {
36081 __next40pxDefaultSize: true,
36082 size: "compact",
36083 icon: trash_default,
36084 isDestructive: true,
36085 label: (0, import_i18n64.__)("Clear labels"),
36086 accessibleWhenDisabled: true,
36087 disabled: !hasOverrides,
36088 onClick: () => {
36089 const cleared = {
36090 singular_name: data.config.labels.singular_name
36091 };
36092 for (const key of labelKeys) {
36093 if (key !== "singular_name") {
36094 cleared[key] = "";
36095 }
36096 }
36097 onChange({
36098 config: { ...data.config, labels: cleared }
36099 });
36100 }
36101 }
36102 )
36103 ] })
36104 ] });
36105 }
36106 return {
36107 id: LABELS_ACTIONS_FIELD_ID,
36108 label: "",
36109 getValue: () => "",
36110 setValue: () => ({}),
36111 Edit: LabelsActionsEdit,
36112 enableSorting: false,
36113 filterBy: false
36114 };
36115 }
36116
36117 // packages/content-types/build-module/post-types/fields/labels.mjs
36118 var menuNameField = createLabelField("menu_name", (0, import_i18n65.__)("Menu name"), {
36119 placeholder: (0, import_i18n65.__)("Posts"),
36120 description: (0, import_i18n65.__)("Defaults to the plural label.")
36121 });
36122 var allItemsField = createLabelField("all_items", (0, import_i18n65.__)("All items"), {
36123 placeholder: (0, import_i18n65.__)("All Posts")
36124 });
36125 var addNewField = createLabelField("add_new", (0, import_i18n65.__)("Add new"), {
36126 placeholder: (0, import_i18n65.__)("Add New"),
36127 description: (0, import_i18n65.__)("Shown in the admin menu and on toolbar buttons.")
36128 });
36129 var addNewItemLabelField = createLabelField(
36130 "add_new_item",
36131 (0, import_i18n65.__)("Add new item"),
36132 { placeholder: (0, import_i18n65.__)("Add New Post") }
36133 );
36134 var editItemField = createLabelField("edit_item", (0, import_i18n65.__)("Edit item"), {
36135 placeholder: (0, import_i18n65.__)("Edit Post")
36136 });
36137 var newItemField = createLabelField("new_item", (0, import_i18n65.__)("New item"), {
36138 placeholder: (0, import_i18n65.__)("New Post")
36139 });
36140 var viewItemField = createLabelField("view_item", (0, import_i18n65.__)("View item"), {
36141 placeholder: (0, import_i18n65.__)("View Post")
36142 });
36143 var viewItemsField = createLabelField(
36144 "view_items",
36145 (0, import_i18n65.__)("View items"),
36146 {
36147 placeholder: (0, import_i18n65.__)("View Posts"),
36148 description: (0, import_i18n65.__)("Used as the link label for the post type archive.")
36149 }
36150 );
36151 var searchItemsField = createLabelField(
36152 "search_items",
36153 (0, import_i18n65.__)("Search items"),
36154 { placeholder: (0, import_i18n65.__)("Search Posts") }
36155 );
36156 var notFoundField = createLabelField("not_found", (0, import_i18n65.__)("Not found"), {
36157 placeholder: (0, import_i18n65.__)("No posts found."),
36158 description: (0, import_i18n65.__)("Shown in the admin list when no posts match.")
36159 });
36160 var notFoundInTrashField = createLabelField(
36161 "not_found_in_trash",
36162 (0, import_i18n65.__)("Not found in trash"),
36163 { placeholder: (0, import_i18n65.__)("No posts found in Trash.") }
36164 );
36165 var archivesField = createLabelField("archives", (0, import_i18n65.__)("Archives"), {
36166 placeholder: (0, import_i18n65.__)("Post Archives"),
36167 description: (0, import_i18n65.__)(
36168 "Used in the navigation menus block when adding a link to the post type archive."
36169 )
36170 });
36171 var attributesField = createLabelField(
36172 "attributes",
36173 (0, import_i18n65.__)("Attributes"),
36174 {
36175 placeholder: (0, import_i18n65.__)("Post Attributes"),
36176 description: (0, import_i18n65.__)(
36177 "Title of the Attributes meta box. Not used on non-hierarchical post types."
36178 ),
36179 isVisible: (item) => item.config.hierarchical
36180 }
36181 );
36182 var parentItemColonField = createLabelField(
36183 "parent_item_colon",
36184 (0, import_i18n65.__)("Parent item with colon"),
36185 {
36186 placeholder: (0, import_i18n65.__)("Parent Page:"),
36187 description: (0, import_i18n65.__)(
36188 "Shown above the parent dropdown. Not used on non-hierarchical post types."
36189 ),
36190 isVisible: (item) => item.config.hierarchical
36191 }
36192 );
36193 var insertIntoItemField = createLabelField(
36194 "insert_into_item",
36195 (0, import_i18n65.__)("Insert into item"),
36196 {
36197 placeholder: (0, import_i18n65.__)("Insert into post"),
36198 description: (0, import_i18n65.__)("Shown in the media library uploader.")
36199 }
36200 );
36201 var uploadedToThisItemField = createLabelField(
36202 "uploaded_to_this_item",
36203 (0, import_i18n65.__)("Uploaded to this item"),
36204 {
36205 placeholder: (0, import_i18n65.__)("Uploaded to this post")
36206 }
36207 );
36208 var featuredImageField = createLabelField(
36209 "featured_image",
36210 (0, import_i18n65.__)("Featured image"),
36211 {
36212 placeholder: (0, import_i18n65.__)("Featured image")
36213 }
36214 );
36215 var setFeaturedImageField = createLabelField(
36216 "set_featured_image",
36217 (0, import_i18n65.__)("Set featured image"),
36218 {
36219 placeholder: (0, import_i18n65.__)("Set featured image")
36220 }
36221 );
36222 var removeFeaturedImageField = createLabelField(
36223 "remove_featured_image",
36224 (0, import_i18n65.__)("Remove featured image"),
36225 {
36226 placeholder: (0, import_i18n65.__)("Remove featured image")
36227 }
36228 );
36229 var useFeaturedImageField = createLabelField(
36230 "use_featured_image",
36231 (0, import_i18n65.__)("Use as featured image"),
36232 {
36233 placeholder: (0, import_i18n65.__)("Use as featured image")
36234 }
36235 );
36236 var filterItemsListField = createLabelField(
36237 "filter_items_list",
36238 (0, import_i18n65.__)("Filter items list"),
36239 {
36240 placeholder: (0, import_i18n65.__)("Filter posts list"),
36241 description: (0, import_i18n65.__)(
36242 "Screen reader text for the admin list filter controls."
36243 )
36244 }
36245 );
36246 var itemsListNavigationField = createLabelField(
36247 "items_list_navigation",
36248 (0, import_i18n65.__)("Items list navigation"),
36249 {
36250 placeholder: (0, import_i18n65.__)("Posts list navigation"),
36251 description: (0, import_i18n65.__)("Screen reader text for the admin list pagination.")
36252 }
36253 );
36254 var itemsListField = createLabelField(
36255 "items_list",
36256 (0, import_i18n65.__)("Items list"),
36257 {
36258 placeholder: (0, import_i18n65.__)("Posts list"),
36259 description: (0, import_i18n65.__)("Screen reader text for the admin list table.")
36260 }
36261 );
36262 var labelsActionsField = createLabelsActionsField(
36263 {
36264 labelKeys: STRING_LABEL_KEYS,
36265 deriveLabels,
36266 helpText: (0, import_i18n65.__)(
36267 "Override the text WordPress shows in admin lists, menus, and forms. Auto-fill replaces every label below with values derived from the current plural and singular names — including any you have already customized. Clearing removes all overrides so WordPress falls back to its defaults. If you rename the post type after auto-filling, click Auto-fill again to keep them in sync."
36268 )
36269 }
36270 );
36271 var labelsForm = {
36272 layout: { type: "regular" },
36273 fields: [
36274 {
36275 id: LABELS_ACTIONS_FIELD_ID,
36276 layout: { type: "regular", labelPosition: "none" }
36277 },
36278 // singular_name lives in the General card, so exclude it here.
36279 ...STRING_LABEL_KEYS.filter((key) => key !== "singular_name")
36280 ]
36281 };
36282
36283 // packages/content-types/build-module/post-types/actions/edit.mjs
36284 var import_element133 = __toESM(require_element(), 1);
36285 var import_i18n66 = __toESM(require_i18n(), 1);
36286 import { useNavigate as useNavigate2 } from "@wordpress/route";
36287 function useEditPostTypeAction() {
36288 const navigate = useNavigate2();
36289 return (0, import_element133.useMemo)(
36290 () => ({
36291 id: "edit-post-type",
36292 label: (0, import_i18n66.__)("Edit"),
36293 callback: (items) => {
36294 const item = items[0];
36295 if (item?.id === void 0) {
36296 return;
36297 }
36298 navigate({
36299 to: `${POST_TYPES_PATH}/${item.id}`
36300 });
36301 }
36302 }),
36303 [navigate]
36304 );
36305 }
36306
36307 // packages/content-types/build-module/post-types/actions/quick-edit.mjs
36308 var import_components58 = __toESM(require_components(), 1);
36309 var import_core_data8 = __toESM(require_core_data(), 1);
36310 var import_data14 = __toESM(require_data(), 1);
36311 var import_element134 = __toESM(require_element(), 1);
36312 var import_i18n67 = __toESM(require_i18n(), 1);
36313 var import_notices4 = __toESM(require_notices(), 1);
36314 var import_jsx_runtime182 = __toESM(require_jsx_runtime(), 1);
36315 function QuickEditPostTypeModal({
36316 items,
36317 closeModal
36318 }) {
36319 const item = items[0];
36320 const [data, setData] = (0, import_element134.useState)(item);
36321 const [isSaving, setIsSaving] = (0, import_element134.useState)(false);
36322 const slugField = useSlugField(item.slug, data.slug);
36323 const taxonomiesField = useTaxonomiesField();
36324 const fields = (0, import_element134.useMemo)(
36325 () => [
36326 pluralLabelField,
36327 singularLabelField,
36328 slugField,
36329 taxonomiesField,
36330 publicField,
36331 hierarchicalField,
36332 hasArchiveField,
36333 statusField
36334 ],
36335 [slugField, taxonomiesField]
36336 );
36337 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, defaultForm);
36338 const { saveEntityRecord } = (0, import_data14.useDispatch)(import_core_data8.store);
36339 const { createSuccessNotice, createErrorNotice } = (0, import_data14.useDispatch)(import_notices4.store);
36340 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
36341 async function onSave() {
36342 if (isSaving || !isValid2) {
36343 return;
36344 }
36345 setIsSaving(true);
36346 try {
36347 await saveEntityRecord(
36348 "postType",
36349 POST_TYPE_ENTITY,
36350 serializeForSave({ ...data, id: item.id }),
36351 { throwOnError: true }
36352 );
36353 createSuccessNotice(
36354 (0, import_i18n67.sprintf)(
36355 /* translators: %s: post type plural label. */
36356 (0, import_i18n67.__)('"%s" post type updated.'),
36357 data.title.raw
36358 ),
36359 { type: "snackbar" }
36360 );
36361 maybeInvalidateCache(
36362 item.config.taxonomies,
36363 data.config.taxonomies,
36364 TAXONOMY_ENTITY
36365 );
36366 closeModal?.();
36367 } catch (error2) {
36368 createErrorNotice(
36369 error2?.message && error2?.code !== "unknown_error" ? error2.message : (0, import_i18n67.__)("Failed to update post type."),
36370 { type: "snackbar" }
36371 );
36372 } finally {
36373 setIsSaving(false);
36374 }
36375 }
36376 return /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(
36377 "form",
36378 {
36379 onSubmit: (event) => {
36380 event.preventDefault();
36381 onSave();
36382 },
36383 children: [
36384 /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(
36385 Stack,
36386 {
36387 className: "dataviews-action-modal__quick-edit-post-type-header",
36388 direction: "row",
36389 justify: "space-between",
36390 align: "center",
36391 children: [
36392 /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(Text, { variant: "heading-sm", render: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("h2", {}), children: (0, import_i18n67.__)("Quick edit post type") }),
36393 /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
36394 import_components58.Button,
36395 {
36396 size: "small",
36397 icon: close_small_default,
36398 label: (0, import_i18n67.__)("Close"),
36399 onClick: closeModal
36400 }
36401 )
36402 ]
36403 }
36404 ),
36405 /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("div", { className: "dataviews-action-modal__quick-edit-post-type-content", children: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
36406 DataForm,
36407 {
36408 data,
36409 fields,
36410 form: defaultForm,
36411 validity,
36412 onChange: (edits) => setData(
36413 (prev) => ({ ...prev, ...edits })
36414 )
36415 }
36416 ) }),
36417 /* @__PURE__ */ (0, import_jsx_runtime182.jsxs)(
36418 Stack,
36419 {
36420 className: "dataviews-action-modal__quick-edit-post-type-footer",
36421 direction: "row",
36422 gap: "sm",
36423 children: [
36424 /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
36425 import_components58.Button,
36426 {
36427 __next40pxDefaultSize: true,
36428 variant: "secondary",
36429 onClick: closeModal,
36430 children: (0, import_i18n67.__)("Cancel")
36431 }
36432 ),
36433 /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
36434 import_components58.Button,
36435 {
36436 __next40pxDefaultSize: true,
36437 variant: "primary",
36438 type: "submit",
36439 isBusy: isSaving,
36440 disabled: isSaving || !isValid2,
36441 accessibleWhenDisabled: true,
36442 children: (0, import_i18n67.__)("Done")
36443 }
36444 )
36445 ]
36446 }
36447 )
36448 ]
36449 }
36450 );
36451 }
36452 var quickEditPostTypeAction = {
36453 id: "quick-edit-post-type",
36454 label: (0, import_i18n67.__)("Quick edit"),
36455 icon: pencil_default,
36456 isPrimary: true,
36457 hideModalHeader: true,
36458 RenderModal: QuickEditPostTypeModal
36459 };
36460 var quick_edit_default = quickEditPostTypeAction;
36461
36462 // packages/content-types/build-module/post-types/list.mjs
36463 var import_jsx_runtime183 = __toESM(require_jsx_runtime(), 1);
36464 var defaultLayouts = {
36465 table: {}
36466 };
36467 var DEFAULT_VIEW = {
36468 type: "table",
36469 perPage: 20,
36470 page: 1,
36471 fields: ["taxonomies", "count", "status"],
36472 titleField: "title",
36473 layout: {
36474 styles: {
36475 taxonomies: { minWidth: 230 },
36476 supports: { minWidth: 230 }
36477 }
36478 }
36479 };
36480 function PostTypesList() {
36481 const navigate = useNavigate3();
36482 const searchParams = useSearch({ from: POST_TYPES_PATH });
36483 const handleQueryParamsChange = (0, import_element135.useCallback)(
36484 (params) => {
36485 navigate({
36486 search: {
36487 ...searchParams,
36488 ...params
36489 }
36490 });
36491 },
36492 [searchParams, navigate]
36493 );
36494 const { view, updateView, isModified, resetToDefault } = useView({
36495 kind: "postType",
36496 name: POST_TYPE_ENTITY,
36497 slug: "default",
36498 defaultView: DEFAULT_VIEW,
36499 queryParams: searchParams,
36500 onChangeQueryParams: handleQueryParamsChange
36501 });
36502 const editAction = useEditPostTypeAction();
36503 const postTypeActions = (0, import_element135.useMemo)(
36504 () => [
36505 editAction,
36506 quick_edit_default,
36507 duplicate_default,
36508 view_posts_default,
36509 activate_default,
36510 deactivate_default,
36511 delete_default
36512 ],
36513 [editAction]
36514 );
36515 const slugField = useSlugField();
36516 const taxonomiesField = useTaxonomiesField();
36517 const fields = (0, import_element135.useMemo)(
36518 () => [
36519 titleField,
36520 taxonomiesField,
36521 countField,
36522 statusField,
36523 publicField,
36524 slugField,
36525 hierarchicalField,
36526 hasArchiveField,
36527 supportsField
36528 ],
36529 [slugField, taxonomiesField]
36530 );
36531 const queryArgs = (0, import_element135.useMemo)(() => {
36532 const statusFilter = view.filters?.find(
36533 (filter) => filter.field === "status"
36534 );
36535 return {
36536 per_page: view.perPage,
36537 page: view.page,
36538 context: "edit",
36539 order: view.sort?.direction,
36540 orderby: view.sort?.field,
36541 search: view.search,
36542 status: statusFilter?.value ?? ["publish", "draft"]
36543 };
36544 }, [view]);
36545 const { records, isResolving, hasResolved, totalItems, totalPages } = (0, import_core_data9.useEntityRecords)(
36546 "postType",
36547 POST_TYPE_ENTITY,
36548 queryArgs
36549 );
36550 const data = (0, import_element135.useMemo)(
36551 () => (records ?? []).map(toFormData),
36552 [records]
36553 );
36554 const paginationInfo = (0, import_element135.useMemo)(
36555 () => ({
36556 totalItems: totalItems ?? 0,
36557 totalPages: totalPages ?? 0
36558 }),
36559 [totalItems, totalPages]
36560 );
36561 return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
36562 dataviews_default,
36563 {
36564 data,
36565 fields,
36566 actions: postTypeActions,
36567 view,
36568 onChangeView: updateView,
36569 onReset: isModified ? resetToDefault : false,
36570 isLoading: isResolving || !hasResolved,
36571 paginationInfo,
36572 defaultLayouts,
36573 getItemId: (item) => String(item.id),
36574 isItemClickable: () => true,
36575 onClickItem: (item) => navigate({
36576 to: `${POST_TYPES_PATH}/${item.id}`
36577 }),
36578 header: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
36579 import_components59.Button,
36580 {
36581 variant: "primary",
36582 size: "compact",
36583 __next40pxDefaultSize: true,
36584 onClick: () => navigate({
36585 to: `${POST_TYPES_PATH}/${NEW_ID}`
36586 }),
36587 children: (0, import_i18n68.__)("Add post type")
36588 }
36589 )
36590 }
36591 );
36592 }
36593
36594 // packages/content-types/build-module/post-types/edit.mjs
36595 var import_components60 = __toESM(require_components(), 1);
36596 var import_compose19 = __toESM(require_compose(), 1);
36597 var import_core_data10 = __toESM(require_core_data(), 1);
36598 var import_data15 = __toESM(require_data(), 1);
36599 var import_element136 = __toESM(require_element(), 1);
36600 var import_i18n69 = __toESM(require_i18n(), 1);
36601 var import_notices5 = __toESM(require_notices(), 1);
36602 import { useNavigate as useNavigate4, useParams } from "@wordpress/route";
36603 var import_jsx_runtime184 = __toESM(require_jsx_runtime(), 1);
36604 function PostTypeEdit() {
36605 const { id } = useParams({ from: `${POST_TYPES_PATH}/$id` });
36606 const navigate = useNavigate4();
36607 const isAddMode = id === NEW_ID;
36608 const postTypeId = parseInt(id, 10);
36609 const record = (0, import_data15.useSelect)(
36610 (select2) => {
36611 return !isAddMode && // beforeLoad (route.ts) guarantees the record is in cache.
36612 select2(import_core_data10.store).getEntityRecord(
36613 "postType",
36614 POST_TYPE_ENTITY,
36615 postTypeId
36616 );
36617 },
36618 [isAddMode, postTypeId]
36619 );
36620 const initialData = !isAddMode && record ? toFormData(record) : BLANK_RECORD;
36621 const title = isAddMode ? (0, import_i18n69.__)("Add post type") : initialData.title.raw;
36622 const commonProps = { initialData, title };
36623 const postTypePageProps = isAddMode ? {
36624 ...commonProps,
36625 isAddMode: true,
36626 breadcrumbLabel: (0, import_i18n69.__)("Add new"),
36627 subTitle: (0, import_i18n69.__)(
36628 "Define a new post type. Fill in the essentials under General; expand Labels to customize."
36629 ),
36630 onSaved: (saved) => navigate({
36631 to: `${POST_TYPES_PATH}/${saved.id}`
36632 })
36633 } : {
36634 ...commonProps,
36635 isAddMode: false,
36636 breadcrumbLabel: title,
36637 subTitle: (0, import_i18n69.__)(
36638 "Edit this post type. Expand the Labels section to adjust labels."
36639 )
36640 };
36641 return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(PostTypePage, { ...postTypePageProps }, id);
36642 }
36643 function PostTypePage({
36644 isAddMode,
36645 initialData,
36646 title,
36647 breadcrumbLabel,
36648 subTitle,
36649 onSaved
36650 }) {
36651 const [data, setData] = (0, import_element136.useState)(initialData);
36652 const [isSaving, setIsSaving] = (0, import_element136.useState)(false);
36653 const originalSlug = !isAddMode ? initialData.slug : void 0;
36654 const slugField = useSlugField(originalSlug, data.slug);
36655 const taxonomiesField = useTaxonomiesField();
36656 const fields = (0, import_element136.useMemo)(
36657 () => [
36658 // General
36659 pluralLabelField,
36660 singularLabelField,
36661 slugField,
36662 descriptionField,
36663 taxonomiesField,
36664 supportsField,
36665 publicField,
36666 hierarchicalField,
36667 hasArchiveField,
36668 showInRestField,
36669 statusField,
36670 // Labels
36671 labelsActionsField,
36672 menuNameField,
36673 allItemsField,
36674 addNewField,
36675 addNewItemLabelField,
36676 editItemField,
36677 newItemField,
36678 viewItemField,
36679 viewItemsField,
36680 searchItemsField,
36681 notFoundField,
36682 notFoundInTrashField,
36683 parentItemColonField,
36684 archivesField,
36685 attributesField,
36686 insertIntoItemField,
36687 uploadedToThisItemField,
36688 featuredImageField,
36689 setFeaturedImageField,
36690 removeFeaturedImageField,
36691 useFeaturedImageField,
36692 filterItemsListField,
36693 itemsListNavigationField,
36694 itemsListField
36695 ],
36696 [slugField, taxonomiesField]
36697 );
36698 const form = (0, import_element136.useMemo)(
36699 () => ({
36700 layout: { type: "card", isCollapsible: true },
36701 fields: [
36702 {
36703 id: "general",
36704 label: (0, import_i18n69.__)("General"),
36705 description: (0, import_i18n69.__)(
36706 "Core identity, taxonomies, supports, and activation."
36707 ),
36708 layout: {
36709 type: "card",
36710 isCollapsible: true,
36711 isOpened: true
36712 },
36713 children: generalForm.fields
36714 },
36715 {
36716 id: "labels",
36717 label: (0, import_i18n69.__)("Labels"),
36718 layout: {
36719 type: "card",
36720 isCollapsible: true,
36721 isOpened: false
36722 },
36723 children: labelsForm.fields
36724 }
36725 ]
36726 }),
36727 []
36728 );
36729 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, form);
36730 const formId = (0, import_compose19.useInstanceId)(PostTypePage, "post-type-form");
36731 const { saveEntityRecord } = (0, import_data15.useDispatch)(import_core_data10.store);
36732 const { createSuccessNotice, createErrorNotice } = (0, import_data15.useDispatch)(import_notices5.store);
36733 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
36734 async function onSave() {
36735 if (isSaving || !isValid2) {
36736 return;
36737 }
36738 setIsSaving(true);
36739 try {
36740 const saved = await saveEntityRecord(
36741 "postType",
36742 POST_TYPE_ENTITY,
36743 serializeForSave(data),
36744 { throwOnError: true }
36745 );
36746 const successMessage = isAddMode ? (0, import_i18n69.sprintf)(
36747 /* translators: %s: post type plural label. */
36748 (0, import_i18n69.__)('"%s" post type created.'),
36749 data.title.raw
36750 ) : (0, import_i18n69.sprintf)(
36751 /* translators: %s: post type plural label. */
36752 (0, import_i18n69.__)('"%s" post type updated.'),
36753 data.title.raw
36754 );
36755 createSuccessNotice(successMessage, { type: "snackbar" });
36756 maybeInvalidateCache(
36757 initialData.config.taxonomies,
36758 data.config.taxonomies,
36759 TAXONOMY_ENTITY
36760 );
36761 if (saved?.id !== void 0) {
36762 onSaved?.({ ...data, id: saved.id });
36763 }
36764 } catch (error2) {
36765 let errorMessage;
36766 if (error2?.message && error2?.code !== "unknown_error") {
36767 errorMessage = error2.message;
36768 } else if (isAddMode) {
36769 errorMessage = (0, import_i18n69.__)("Failed to create post type.");
36770 } else {
36771 errorMessage = (0, import_i18n69.__)("Failed to update post type.");
36772 }
36773 createErrorNotice(errorMessage, { type: "snackbar" });
36774 } finally {
36775 setIsSaving(false);
36776 }
36777 }
36778 return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
36779 page_default,
36780 {
36781 ariaLabel: title,
36782 breadcrumbs: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
36783 breadcrumbs_default,
36784 {
36785 items: [
36786 { label: (0, import_i18n69.__)("Post Types"), to: POST_TYPES_PATH },
36787 { label: breadcrumbLabel }
36788 ]
36789 }
36790 ),
36791 subTitle,
36792 actions: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
36793 import_components60.Button,
36794 {
36795 __next40pxDefaultSize: true,
36796 variant: "primary",
36797 size: "compact",
36798 type: "submit",
36799 form: formId,
36800 isBusy: isSaving,
36801 disabled: isSaving || !isValid2,
36802 accessibleWhenDisabled: true,
36803 children: isAddMode ? (0, import_i18n69.__)("Create") : (0, import_i18n69.__)("Save")
36804 }
36805 ),
36806 children: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
36807 Stack,
36808 {
36809 direction: "column",
36810 gap: "md",
36811 className: "post-type-form",
36812 render: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
36813 "form",
36814 {
36815 id: formId,
36816 onSubmit: (event) => {
36817 event.preventDefault();
36818 onSave();
36819 }
36820 }
36821 ),
36822 children: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
36823 DataForm,
36824 {
36825 data,
36826 fields,
36827 form,
36828 validity,
36829 onChange: (edits) => setData(
36830 (prev) => ({
36831 ...prev,
36832 ...edits
36833 })
36834 )
36835 }
36836 )
36837 }
36838 )
36839 }
36840 );
36841 }
36842
36843 // packages/content-types/build-module/taxonomies/list.mjs
36844 var import_components64 = __toESM(require_components(), 1);
36845 var import_core_data16 = __toESM(require_core_data(), 1);
36846 var import_element143 = __toESM(require_element(), 1);
36847 var import_i18n82 = __toESM(require_i18n(), 1);
36848 import { useNavigate as useNavigate6, useSearch as useSearch2 } from "@wordpress/route";
36849
36850 // packages/content-types/build-module/taxonomies/actions/activate.mjs
36851 var import_i18n70 = __toESM(require_i18n(), 1);
36852 var activateAction2 = createStatusAction({
36853 id: "activate",
36854 label: (0, import_i18n70.__)("Activate"),
36855 entity: TAXONOMY_ENTITY,
36856 targetStatus: "publish",
36857 messages: {
36858 successSingle: (0, import_i18n70.__)("Taxonomy activated."),
36859 successMany: (count) => (0, import_i18n70.sprintf)(
36860 /* translators: %d: The number of taxonomies. */
36861 (0, import_i18n70._n)(
36862 "%d taxonomy activated.",
36863 "%d taxonomies activated.",
36864 count
36865 ),
36866 count
36867 ),
36868 failSingle: (0, import_i18n70.__)("Failed to activate taxonomy."),
36869 failMany: (0, import_i18n70.__)("Failed to activate taxonomies."),
36870 errorSingle: (message2) => (0, import_i18n70.sprintf)(
36871 /* translators: %s: an error message */
36872 (0, import_i18n70.__)("An error occurred while activating the taxonomy: %s"),
36873 message2
36874 ),
36875 errorMany: (messages) => (0, import_i18n70.sprintf)(
36876 /* translators: %s: a list of comma separated error messages */
36877 (0, import_i18n70.__)(
36878 "Some errors occurred while activating the taxonomies: %s"
36879 ),
36880 messages
36881 )
36882 }
36883 });
36884 var activate_default2 = activateAction2;
36885
36886 // packages/content-types/build-module/taxonomies/actions/deactivate.mjs
36887 var import_i18n71 = __toESM(require_i18n(), 1);
36888 var deactivateAction2 = createStatusAction({
36889 id: "deactivate",
36890 label: (0, import_i18n71.__)("Deactivate"),
36891 entity: TAXONOMY_ENTITY,
36892 targetStatus: "draft",
36893 messages: {
36894 successSingle: (0, import_i18n71.__)("Taxonomy deactivated."),
36895 successMany: (count) => (0, import_i18n71.sprintf)(
36896 /* translators: %d: The number of taxonomies. */
36897 (0, import_i18n71._n)(
36898 "%d taxonomy deactivated.",
36899 "%d taxonomies deactivated.",
36900 count
36901 ),
36902 count
36903 ),
36904 failSingle: (0, import_i18n71.__)("Failed to deactivate taxonomy."),
36905 failMany: (0, import_i18n71.__)("Failed to deactivate taxonomies."),
36906 errorSingle: (message2) => (0, import_i18n71.sprintf)(
36907 /* translators: %s: an error message */
36908 (0, import_i18n71.__)("An error occurred while deactivating the taxonomy: %s"),
36909 message2
36910 ),
36911 errorMany: (messages) => (0, import_i18n71.sprintf)(
36912 /* translators: %s: a list of comma separated error messages */
36913 (0, import_i18n71.__)(
36914 "Some errors occurred while deactivating the taxonomies: %s"
36915 ),
36916 messages
36917 )
36918 }
36919 });
36920 var deactivate_default2 = deactivateAction2;
36921
36922 // packages/content-types/build-module/taxonomies/actions/delete.mjs
36923 var import_components61 = __toESM(require_components(), 1);
36924 var import_core_data11 = __toESM(require_core_data(), 1);
36925 var import_data16 = __toESM(require_data(), 1);
36926 var import_element137 = __toESM(require_element(), 1);
36927 var import_i18n72 = __toESM(require_i18n(), 1);
36928 var import_notices6 = __toESM(require_notices(), 1);
36929 var import_jsx_runtime185 = __toESM(require_jsx_runtime(), 1);
36930 function DeleteTaxonomyModal({
36931 items,
36932 closeModal,
36933 onActionPerformed
36934 }) {
36935 const [isDeleting, setIsDeleting] = (0, import_element137.useState)(false);
36936 const { deleteEntityRecord } = (0, import_data16.useDispatch)(import_core_data11.store);
36937 const { createSuccessNotice, createErrorNotice } = (0, import_data16.useDispatch)(import_notices6.store);
36938 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
36939 async function onDelete() {
36940 if (isDeleting) {
36941 return;
36942 }
36943 setIsDeleting(true);
36944 const itemsToDelete = items.filter((item) => item.id !== void 0);
36945 const promiseResult = await Promise.allSettled(
36946 itemsToDelete.map(
36947 (item) => deleteEntityRecord(
36948 "postType",
36949 TAXONOMY_ENTITY,
36950 item.id,
36951 { force: true },
36952 { throwOnError: true }
36953 )
36954 )
36955 );
36956 if (promiseResult.every(({ status }) => status === "fulfilled")) {
36957 createSuccessNotice(
36958 itemsToDelete.length === 1 ? (0, import_i18n72.sprintf)(
36959 /* translators: %s: The taxonomy's plural label. */
36960 (0, import_i18n72.__)('"%s" taxonomy deleted.'),
36961 itemsToDelete[0].title.raw
36962 ) : (0, import_i18n72.sprintf)(
36963 /* translators: %d: The number of taxonomies. */
36964 (0, import_i18n72._n)(
36965 "%d taxonomy deleted.",
36966 "%d taxonomies deleted.",
36967 itemsToDelete.length
36968 ),
36969 itemsToDelete.length
36970 ),
36971 { type: "snackbar" }
36972 );
36973 } else {
36974 let errorMessage;
36975 if (promiseResult.length === 1) {
36976 const typedError = promiseResult[0];
36977 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
36978 errorMessage = typedError.reason.message;
36979 } else {
36980 errorMessage = (0, import_i18n72.__)("Failed to delete taxonomy.");
36981 }
36982 } else {
36983 const errorMessages = /* @__PURE__ */ new Set();
36984 const failedPromises = promiseResult.filter(
36985 ({ status }) => status === "rejected"
36986 );
36987 for (const failedPromise of failedPromises) {
36988 const typedError = failedPromise;
36989 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
36990 errorMessages.add(typedError.reason.message);
36991 }
36992 }
36993 if (errorMessages.size === 0) {
36994 errorMessage = (0, import_i18n72.__)("Failed to delete taxonomies.");
36995 } else if (errorMessages.size === 1) {
36996 errorMessage = (0, import_i18n72.sprintf)(
36997 /* translators: %s: an error message */
36998 (0, import_i18n72.__)(
36999 "An error occurred while deleting the taxonomy: %s"
37000 ),
37001 [...errorMessages][0]
37002 );
37003 } else {
37004 errorMessage = (0, import_i18n72.sprintf)(
37005 /* translators: %s: a list of comma separated error messages */
37006 (0, import_i18n72.__)(
37007 "Some errors occurred while deleting the taxonomies: %s"
37008 ),
37009 [...errorMessages].join(",")
37010 );
37011 }
37012 }
37013 createErrorNotice(errorMessage, { type: "snackbar" });
37014 }
37015 const deletedRefs = itemsToDelete.filter((_, i2) => promiseResult[i2].status === "fulfilled").flatMap((item) => item.config.object_type);
37016 maybeInvalidateCache(deletedRefs, [], POST_TYPE_ENTITY);
37017 onActionPerformed?.(itemsToDelete);
37018 setIsDeleting(false);
37019 closeModal?.();
37020 }
37021 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(Stack, { direction: "column", gap: "md", children: [
37022 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Text, { children: items.length > 1 ? (0, import_i18n72.sprintf)(
37023 /* translators: %d: number of taxonomies to delete. */
37024 (0, import_i18n72._n)(
37025 "Are you sure you want to delete %d taxonomy?",
37026 "Are you sure you want to delete %d taxonomies?",
37027 items.length
37028 ),
37029 items.length
37030 ) : (0, import_i18n72.sprintf)(
37031 /* translators: %s: The taxonomy's plural label. */
37032 (0, import_i18n72.__)('Are you sure you want to delete "%s"?'),
37033 items[0].title.raw
37034 ) }),
37035 /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
37036 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
37037 import_components61.Button,
37038 {
37039 __next40pxDefaultSize: true,
37040 variant: "tertiary",
37041 onClick: closeModal,
37042 disabled: isDeleting,
37043 accessibleWhenDisabled: true,
37044 children: (0, import_i18n72.__)("Cancel")
37045 }
37046 ),
37047 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
37048 import_components61.Button,
37049 {
37050 __next40pxDefaultSize: true,
37051 variant: "primary",
37052 isDestructive: true,
37053 isBusy: isDeleting,
37054 disabled: isDeleting,
37055 accessibleWhenDisabled: true,
37056 onClick: onDelete,
37057 children: (0, import_i18n72._x)("Delete", "verb")
37058 }
37059 )
37060 ] })
37061 ] });
37062 }
37063 var deleteTaxonomyAction = {
37064 id: "delete-taxonomy",
37065 label: (0, import_i18n72._x)("Delete", "verb"),
37066 icon: trash_default,
37067 supportsBulk: true,
37068 hideModalHeader: true,
37069 modalFocusOnMount: "firstContentElement",
37070 modalSize: "small",
37071 RenderModal: DeleteTaxonomyModal
37072 };
37073 var delete_default2 = deleteTaxonomyAction;
37074
37075 // packages/content-types/build-module/taxonomies/actions/duplicate.mjs
37076 var import_components62 = __toESM(require_components(), 1);
37077 var import_core_data14 = __toESM(require_core_data(), 1);
37078 var import_data19 = __toESM(require_data(), 1);
37079 var import_element140 = __toESM(require_element(), 1);
37080 var import_i18n75 = __toESM(require_i18n(), 1);
37081 var import_notices7 = __toESM(require_notices(), 1);
37082
37083 // packages/content-types/build-module/taxonomies/fields/general.mjs
37084 var import_core_data13 = __toESM(require_core_data(), 1);
37085 var import_data18 = __toESM(require_data(), 1);
37086 var import_element139 = __toESM(require_element(), 1);
37087 var import_i18n74 = __toESM(require_i18n(), 1);
37088 var import_url6 = __toESM(require_url(), 1);
37089
37090 // packages/content-types/build-module/taxonomies/utils.mjs
37091 var import_core_data12 = __toESM(require_core_data(), 1);
37092 var import_data17 = __toESM(require_data(), 1);
37093 var import_element138 = __toESM(require_element(), 1);
37094 var import_i18n73 = __toESM(require_i18n(), 1);
37095 var BLANK_RECORD2 = {
37096 slug: "",
37097 status: "publish",
37098 title: { raw: "" },
37099 config: {
37100 labels: { singular_name: "" },
37101 object_type: [],
37102 description: "",
37103 public: true,
37104 hierarchical: false,
37105 publicly_queryable: true,
37106 show_ui: true,
37107 show_in_menu: true,
37108 show_in_nav_menus: true,
37109 show_tagcloud: true,
37110 show_in_quick_edit: true,
37111 show_admin_column: false,
37112 show_in_rest: true,
37113 sort: false,
37114 default_term_enabled: false,
37115 default_term: { name: "" }
37116 }
37117 };
37118 var STRING_LABEL_KEYS2 = [
37119 "singular_name",
37120 "menu_name",
37121 "all_items",
37122 "edit_item",
37123 "view_item",
37124 "update_item",
37125 "add_new_item",
37126 "new_item_name",
37127 "search_items",
37128 "not_found",
37129 "back_to_items",
37130 "parent_item",
37131 "popular_items",
37132 "separate_items_with_commas",
37133 "parent_item_colon",
37134 "add_or_remove_items",
37135 "choose_from_most_used"
37136 ];
37137 function deriveLabels2(plural, singular) {
37138 const lcPlural = plural.toLowerCase();
37139 return {
37140 menu_name: plural,
37141 all_items: (0, import_i18n73.sprintf)(
37142 /* translators: %s: Plural taxonomy label. */
37143 (0, import_i18n73.__)("All %s"),
37144 plural
37145 ),
37146 edit_item: (0, import_i18n73.sprintf)(
37147 /* translators: %s: Singular taxonomy label. */
37148 (0, import_i18n73.__)("Edit %s"),
37149 singular
37150 ),
37151 view_item: (0, import_i18n73.sprintf)(
37152 /* translators: %s: Singular taxonomy label. */
37153 (0, import_i18n73.__)("View %s"),
37154 singular
37155 ),
37156 update_item: (0, import_i18n73.sprintf)(
37157 /* translators: %s: Singular taxonomy label. */
37158 (0, import_i18n73.__)("Update %s"),
37159 singular
37160 ),
37161 add_new_item: (0, import_i18n73.sprintf)(
37162 /* translators: %s: Singular taxonomy label. */
37163 (0, import_i18n73.__)("Add New %s"),
37164 singular
37165 ),
37166 new_item_name: (0, import_i18n73.sprintf)(
37167 /* translators: %s: Singular taxonomy label. */
37168 (0, import_i18n73.__)("New %s Name"),
37169 singular
37170 ),
37171 search_items: (0, import_i18n73.sprintf)(
37172 /* translators: %s: Plural taxonomy label. */
37173 (0, import_i18n73.__)("Search %s"),
37174 plural
37175 ),
37176 not_found: (0, import_i18n73.sprintf)(
37177 /* translators: %s: Plural taxonomy label, lowercase. */
37178 (0, import_i18n73.__)("No %s found."),
37179 lcPlural
37180 ),
37181 back_to_items: (0, import_i18n73.sprintf)(
37182 /* translators: %s: Plural taxonomy label. */
37183 (0, import_i18n73.__)("← Back to %s"),
37184 plural
37185 ),
37186 parent_item: (0, import_i18n73.sprintf)(
37187 /* translators: %s: Singular taxonomy label. */
37188 (0, import_i18n73.__)("Parent %s"),
37189 singular
37190 ),
37191 popular_items: (0, import_i18n73.sprintf)(
37192 /* translators: %s: Plural taxonomy label. */
37193 (0, import_i18n73.__)("Popular %s"),
37194 plural
37195 ),
37196 separate_items_with_commas: (0, import_i18n73.sprintf)(
37197 /* translators: %s: Plural taxonomy label, lowercase. */
37198 (0, import_i18n73.__)("Separate %s with commas"),
37199 lcPlural
37200 ),
37201 parent_item_colon: (0, import_i18n73.sprintf)(
37202 /* translators: %s: Singular taxonomy label. */
37203 (0, import_i18n73.__)("Parent %s:"),
37204 singular
37205 ),
37206 add_or_remove_items: (0, import_i18n73.sprintf)(
37207 /* translators: %s: Plural taxonomy label, lowercase. */
37208 (0, import_i18n73.__)("Add or remove %s"),
37209 lcPlural
37210 ),
37211 choose_from_most_used: (0, import_i18n73.sprintf)(
37212 /* translators: %s: Plural taxonomy label, lowercase. */
37213 (0, import_i18n73.__)("Choose from the most used %s"),
37214 lcPlural
37215 )
37216 };
37217 }
37218 function toFormData2(row) {
37219 const config = row.config ?? {};
37220 const labels = pickStoredLabels(
37221 config.labels,
37222 STRING_LABEL_KEYS2
37223 );
37224 const defaultTermName = config.default_term?.name ?? "";
37225 const formConfig = {
37226 labels: { singular_name: "", ...labels },
37227 object_type: Array.isArray(row.object_type) ? row.object_type : [],
37228 description: config.description ?? "",
37229 public: config.public,
37230 hierarchical: config.hierarchical,
37231 publicly_queryable: config.publicly_queryable,
37232 show_ui: config.show_ui,
37233 show_in_menu: config.show_in_menu,
37234 show_in_nav_menus: config.show_in_nav_menus,
37235 show_tagcloud: config.show_tagcloud,
37236 show_in_quick_edit: config.show_in_quick_edit,
37237 show_admin_column: config.show_admin_column,
37238 show_in_rest: config.show_in_rest,
37239 sort: !!config.sort,
37240 default_term_enabled: defaultTermName !== "",
37241 default_term: { name: defaultTermName }
37242 };
37243 return {
37244 id: row.id,
37245 slug: row.slug,
37246 status: row.status,
37247 title: { raw: row.title.raw },
37248 config: formConfig,
37249 count: row.count
37250 };
37251 }
37252 function serializeForSave2(data) {
37253 const { config } = data;
37254 const labels = serializeLabels(
37255 config.labels,
37256 STRING_LABEL_KEYS2
37257 );
37258 const description = config.description.trim();
37259 const defaultTermName = config.default_term.name.trim();
37260 const includeDefaultTerm = config.default_term_enabled && defaultTermName !== "";
37261 return {
37262 ...data.id !== void 0 ? { id: data.id } : {},
37263 slug: data.slug,
37264 status: data.status,
37265 title: data.title.raw,
37266 object_type: config.object_type,
37267 config: {
37268 labels,
37269 public: config.public,
37270 hierarchical: config.hierarchical,
37271 publicly_queryable: config.publicly_queryable,
37272 show_ui: config.show_ui,
37273 show_in_menu: config.show_in_menu,
37274 show_in_nav_menus: config.show_in_nav_menus,
37275 show_tagcloud: config.show_tagcloud,
37276 show_in_quick_edit: config.show_in_quick_edit,
37277 show_admin_column: config.show_admin_column,
37278 show_in_rest: config.show_in_rest,
37279 sort: config.sort,
37280 ...description !== "" ? { description } : {},
37281 ...includeDefaultTerm ? { default_term: { name: defaultTermName } } : {}
37282 }
37283 };
37284 }
37285 function usePublicPostTypes() {
37286 const postTypes = (0, import_data17.useSelect)(
37287 (select2) => select2(import_core_data12.store).getPostTypes({ per_page: -1 }),
37288 []
37289 );
37290 return (0, import_element138.useMemo)(() => {
37291 return postTypes?.filter(({ viewable }) => viewable).sort((a2, b2) => {
37292 if (a2.slug === "post") {
37293 return -1;
37294 }
37295 if (b2.slug === "post") {
37296 return 1;
37297 }
37298 return a2.name.localeCompare(b2.name);
37299 });
37300 }, [postTypes]);
37301 }
37302
37303 // packages/content-types/build-module/taxonomies/fields/general.mjs
37304 var import_jsx_runtime186 = __toESM(require_jsx_runtime(), 1);
37305 var descriptionField2 = createDescriptionField(
37306 (0, import_i18n74.__)(
37307 "Optional summary of the taxonomy. Shown in admin UIs that surface taxonomy details."
37308 )
37309 );
37310 var hierarchicalField2 = createBooleanField(
37311 "hierarchical",
37312 (0, import_i18n74.__)("Hierarchical"),
37313 {
37314 description: (0, import_i18n74.__)(
37315 "When on, terms behave like categories with parent-child relationships. When off, terms behave like tags."
37316 )
37317 }
37318 );
37319 var SLUG_MAX_LENGTH3 = 32;
37320 function useSlugField2(originalSlug, currentValue) {
37321 const registeredTaxonomies = (0, import_data18.useSelect)(
37322 (select2) => select2(import_core_data13.store).getTaxonomies(),
37323 []
37324 );
37325 const showRenameWarning = originalSlug !== void 0 && currentValue !== originalSlug;
37326 return (0, import_element139.useMemo)(
37327 () => ({
37328 id: "slug",
37329 label: (0, import_i18n74.__)("Taxonomy key"),
37330 type: "text",
37331 enableGlobalSearch: true,
37332 description: /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(Stack, { direction: "column", gap: "sm", render: /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", {}), children: [
37333 showRenameWarning && /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(notice_exports.Root, { intent: "warning", render: /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", {}), children: /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(notice_exports.Description, { children: (0, import_i18n74.__)(
37334 "Changing the key renames the taxonomy — existing terms may become inaccessible until a migration updates the database."
37335 ) }) }),
37336 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", { children: (0, import_i18n74.__)(
37337 "Lower case letters, numbers, underscores, and dashes only. Maximum length: 32 characters."
37338 ) })
37339 ] }),
37340 isValid: {
37341 required: true,
37342 pattern: "^[a-z0-9_\\-]+$",
37343 maxLength: SLUG_MAX_LENGTH3,
37344 custom: async (value) => {
37345 const slug = value.slug;
37346 if (originalSlug !== void 0 && slug === originalSlug) {
37347 return null;
37348 }
37349 const slugTaken = (registeredTaxonomies ?? []).some(
37350 (t2) => t2.slug === slug
37351 );
37352 if (slugTaken) {
37353 return (0, import_i18n74.__)("This taxonomy key is already in use.");
37354 }
37355 const drafts = await (0, import_data18.resolveSelect)(
37356 import_core_data13.store
37357 ).getEntityRecords("postType", TAXONOMY_ENTITY, {
37358 slug,
37359 status: "draft",
37360 _fields: "id,name",
37361 per_page: 1
37362 });
37363 return drafts?.length ? (0, import_i18n74.__)("This taxonomy key is already in use.") : null;
37364 }
37365 },
37366 Edit: SlugEdit,
37367 filterBy: false,
37368 enableSorting: false
37369 }),
37370 [registeredTaxonomies, originalSlug, showRenameWarning]
37371 );
37372 }
37373 function useObjectTypeField() {
37374 const publicPostTypes = usePublicPostTypes();
37375 return (0, import_element139.useMemo)(() => {
37376 const elements = (publicPostTypes ?? []).map((pt) => ({
37377 value: pt.slug,
37378 label: pt.name
37379 }));
37380 const labelMap = Object.fromEntries(
37381 elements.map((e2) => [e2.value, e2.label])
37382 );
37383 return {
37384 id: "object_type",
37385 label: (0, import_i18n74.__)("Post types"),
37386 type: "array",
37387 description: (0, import_i18n74.__)(
37388 "One or more post types with which the taxonomy should be associated."
37389 ),
37390 elements,
37391 enableSorting: false,
37392 getValue: ({ item }) => item.config.object_type,
37393 setValue: ({ item, value }) => ({
37394 config: {
37395 ...item.config,
37396 object_type: Array.isArray(value) ? value : []
37397 }
37398 }),
37399 render: ({ item }) => {
37400 const slugs = item.config.object_type;
37401 if (!slugs || slugs.length === 0) {
37402 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", { "aria-hidden": "true", children: "—" });
37403 }
37404 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
37405 OverflowingBadges,
37406 {
37407 items: slugs.map((s2) => ({
37408 key: s2,
37409 label: labelMap[s2] ?? s2
37410 }))
37411 }
37412 );
37413 },
37414 isValid: { required: true },
37415 filterBy: { operators: ["isAny"] }
37416 };
37417 }, [publicPostTypes]);
37418 }
37419 var countField2 = {
37420 id: "count",
37421 label: (0, import_i18n74.__)("Terms"),
37422 type: "integer",
37423 readOnly: true,
37424 render: ({ item }) => {
37425 const count = item.count;
37426 if (item.status !== "publish" || !count) {
37427 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", { "aria-hidden": "true", children: "—" });
37428 }
37429 const postType = item.config.object_type?.[0];
37430 if (!postType) {
37431 return count;
37432 }
37433 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
37434 Link,
37435 {
37436 href: (0, import_url6.addQueryArgs)("edit-tags.php", {
37437 taxonomy: item.slug,
37438 post_type: postType
37439 }),
37440 children: count
37441 }
37442 );
37443 },
37444 enableSorting: false,
37445 filterBy: false
37446 };
37447 var defaultForm2 = {
37448 layout: { type: "regular" },
37449 fields: [
37450 "plural_name",
37451 "singular_name",
37452 "slug",
37453 "object_type",
37454 "hierarchical",
37455 "status"
37456 ]
37457 };
37458 var generalFormFields = [
37459 "plural_name",
37460 "singular_name",
37461 "slug",
37462 "object_type",
37463 "description",
37464 "hierarchical",
37465 "status"
37466 ];
37467
37468 // packages/content-types/build-module/taxonomies/actions/duplicate.mjs
37469 var import_jsx_runtime187 = __toESM(require_jsx_runtime(), 1);
37470 var SLUG_MAX_LENGTH4 = 32;
37471 var duplicateForm2 = {
37472 layout: { type: "regular" },
37473 fields: ["plural_name", "singular_name", "slug"]
37474 };
37475 function buildCopySlug2(slug) {
37476 const match2 = slug.match(/^(.*?)(\d+)$/);
37477 const base = match2 ? match2[1] : slug;
37478 const nextNumber = String(match2 ? parseInt(match2[2], 10) + 1 : 2);
37479 return `${base.slice(
37480 0,
37481 SLUG_MAX_LENGTH4 - nextNumber.length
37482 )}${nextNumber}`;
37483 }
37484 function DuplicateTaxonomyModal({
37485 items,
37486 closeModal,
37487 onActionPerformed
37488 }) {
37489 const source = items[0];
37490 const [data, setData] = (0, import_element140.useState)(() => ({
37491 ...source,
37492 id: void 0,
37493 status: "draft",
37494 title: {
37495 raw: (0, import_i18n75.sprintf)(
37496 /* translators: %s: existing taxonomy title. */
37497 (0, import_i18n75._x)("%s (Copy)", "taxonomy"),
37498 source.title.raw
37499 )
37500 },
37501 slug: buildCopySlug2(source.slug)
37502 }));
37503 const [isDuplicating, setIsDuplicating] = (0, import_element140.useState)(false);
37504 const slugField = useSlugField2(void 0, data.slug);
37505 const fields = (0, import_element140.useMemo)(
37506 () => [
37507 pluralLabelField,
37508 singularLabelField,
37509 slugField
37510 ],
37511 [slugField]
37512 );
37513 const { validity, isValid: isValid2 } = use_form_validity_default(
37514 data,
37515 fields,
37516 duplicateForm2
37517 );
37518 const { saveEntityRecord } = (0, import_data19.useDispatch)(import_core_data14.store);
37519 const { createSuccessNotice, createErrorNotice } = (0, import_data19.useDispatch)(import_notices7.store);
37520 async function onDuplicate() {
37521 if (isDuplicating || !isValid2) {
37522 return;
37523 }
37524 setIsDuplicating(true);
37525 try {
37526 await saveEntityRecord(
37527 "postType",
37528 TAXONOMY_ENTITY,
37529 serializeForSave2(data),
37530 { throwOnError: true }
37531 );
37532 createSuccessNotice(
37533 (0, import_i18n75.sprintf)(
37534 /* translators: %s: taxonomy plural label. */
37535 (0, import_i18n75.__)('"%s" taxonomy created.'),
37536 data.title.raw
37537 ),
37538 { type: "snackbar" }
37539 );
37540 onActionPerformed?.(items);
37541 closeModal?.();
37542 } catch (error2) {
37543 const typedError = error2;
37544 createErrorNotice(
37545 typedError?.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n75.__)("Failed to duplicate taxonomy."),
37546 { type: "snackbar" }
37547 );
37548 } finally {
37549 setIsDuplicating(false);
37550 }
37551 }
37552 return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Stack, { direction: "column", gap: "md", children: [
37553 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
37554 DataForm,
37555 {
37556 data,
37557 fields,
37558 form: duplicateForm2,
37559 validity,
37560 onChange: (edits) => setData(
37561 (prev) => ({ ...prev, ...edits })
37562 )
37563 }
37564 ),
37565 /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
37566 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
37567 import_components62.Button,
37568 {
37569 __next40pxDefaultSize: true,
37570 variant: "tertiary",
37571 onClick: closeModal,
37572 disabled: isDuplicating,
37573 accessibleWhenDisabled: true,
37574 children: (0, import_i18n75.__)("Cancel")
37575 }
37576 ),
37577 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
37578 import_components62.Button,
37579 {
37580 __next40pxDefaultSize: true,
37581 variant: "primary",
37582 isBusy: isDuplicating,
37583 disabled: isDuplicating || !isValid2,
37584 accessibleWhenDisabled: true,
37585 onClick: onDuplicate,
37586 children: (0, import_i18n75._x)("Duplicate", "action label")
37587 }
37588 )
37589 ] })
37590 ] });
37591 }
37592 var duplicateTaxonomyAction = {
37593 id: "duplicate-taxonomy",
37594 label: (0, import_i18n75._x)("Duplicate", "action label"),
37595 icon: copy_default,
37596 modalHeader: (0, import_i18n75.__)("Duplicate taxonomy"),
37597 modalFocusOnMount: "firstContentElement",
37598 RenderModal: DuplicateTaxonomyModal
37599 };
37600 var duplicate_default2 = duplicateTaxonomyAction;
37601
37602 // packages/content-types/build-module/taxonomies/actions/view-terms.mjs
37603 var import_i18n76 = __toESM(require_i18n(), 1);
37604 var import_url7 = __toESM(require_url(), 1);
37605 var viewTermsAction = {
37606 id: "view-terms",
37607 label: (0, import_i18n76.__)("View terms"),
37608 // Drafts aren't registered, and `edit-tags.php` requires a `post_type`
37609 // query arg to render the term list, so the taxonomy must also be
37610 // attached to at least one post type.
37611 isEligible: (item) => item.status === "publish" && Array.isArray(item.config.object_type) && item.config.object_type.length > 0,
37612 callback: (items, { onActionPerformed }) => {
37613 const item = items[0];
37614 const postType = item?.config.object_type?.[0];
37615 if (!item?.slug || !postType) {
37616 return;
37617 }
37618 document.location.href = (0, import_url7.addQueryArgs)("edit-tags.php", {
37619 taxonomy: item.slug,
37620 post_type: postType
37621 });
37622 onActionPerformed?.(items);
37623 }
37624 };
37625 var view_terms_default = viewTermsAction;
37626
37627 // packages/content-types/build-module/taxonomies/fields/advanced.mjs
37628 var import_i18n77 = __toESM(require_i18n(), 1);
37629 var sortField = createBooleanField("sort", (0, import_i18n77.__)("Sort terms"), {
37630 description: (0, import_i18n77.__)(
37631 "Whether terms in this taxonomy should be saved in the order they are assigned to an item."
37632 )
37633 });
37634 var defaultTermEnabledField = createBooleanField(
37635 "default_term_enabled",
37636 (0, import_i18n77.__)("Set a default term"),
37637 {
37638 description: (0, import_i18n77.__)(
37639 'Default term to be used for the taxonomy, similar to how "Uncategorized" works for categories.'
37640 )
37641 }
37642 );
37643 var defaultTermNameField = {
37644 id: "default_term_name",
37645 label: (0, import_i18n77.__)("Default term name"),
37646 type: "text",
37647 description: (0, import_i18n77.__)(
37648 "Once saved, updating the name creates a new term — the previous default term remains in the terms list. To change the term's slug or description, edit it from the terms list."
37649 ),
37650 getValue: ({ item }) => item.config.default_term.name,
37651 setValue: ({ item, value }) => ({
37652 config: {
37653 ...item.config,
37654 default_term: { name: String(value ?? "") }
37655 }
37656 }),
37657 isValid: {
37658 // `useFormValidity` does not skip invisible fields, so `required:
37659 // true` would mark the form invalid whenever the toggle is off.
37660 // Gate the requirement on the toggle via `custom` instead.
37661 custom: (item) => {
37662 if (!item.config.default_term_enabled) {
37663 return null;
37664 }
37665 return item.config.default_term.name.trim() ? null : (0, import_i18n77.__)("A default term name is required.");
37666 },
37667 // Mirrors `wp_terms.name` column width (varchar(200)).
37668 maxLength: 200
37669 },
37670 isVisible: (item) => item.config.default_term_enabled,
37671 enableSorting: false,
37672 filterBy: false
37673 };
37674 var advancedFormFields = [
37675 "sort",
37676 "default_term_enabled",
37677 "default_term_name"
37678 ];
37679
37680 // packages/content-types/build-module/taxonomies/fields/labels.mjs
37681 var import_i18n78 = __toESM(require_i18n(), 1);
37682 var menuNameField2 = createLabelField("menu_name", (0, import_i18n78.__)("Menu name"), {
37683 placeholder: (0, import_i18n78.__)("Categories"),
37684 description: (0, import_i18n78.__)("Defaults to the plural label.")
37685 });
37686 var allItemsField2 = createLabelField("all_items", (0, import_i18n78.__)("All items"), {
37687 placeholder: (0, import_i18n78.__)("All Categories")
37688 });
37689 var editItemField2 = createLabelField("edit_item", (0, import_i18n78.__)("Edit item"), {
37690 placeholder: (0, import_i18n78.__)("Edit Category")
37691 });
37692 var viewItemField2 = createLabelField("view_item", (0, import_i18n78.__)("View item"), {
37693 placeholder: (0, import_i18n78.__)("View Category")
37694 });
37695 var updateItemField = createLabelField(
37696 "update_item",
37697 (0, import_i18n78.__)("Update item"),
37698 { placeholder: (0, import_i18n78.__)("Update Category") }
37699 );
37700 var addNewItemLabelField2 = createLabelField(
37701 "add_new_item",
37702 (0, import_i18n78.__)("Add new item"),
37703 { placeholder: (0, import_i18n78.__)("Add New Category") }
37704 );
37705 var newItemNameField = createLabelField(
37706 "new_item_name",
37707 (0, import_i18n78.__)("New item name"),
37708 { placeholder: (0, import_i18n78.__)("New Category Name") }
37709 );
37710 var searchItemsField2 = createLabelField(
37711 "search_items",
37712 (0, import_i18n78.__)("Search items"),
37713 { placeholder: (0, import_i18n78.__)("Search Categories") }
37714 );
37715 var notFoundField2 = createLabelField("not_found", (0, import_i18n78.__)("Not found"), {
37716 placeholder: (0, import_i18n78.__)("No categories found."),
37717 description: (0, import_i18n78.__)(
37718 "The text displayed when no terms are available in the term meta box and tag cloud."
37719 )
37720 });
37721 var backToItemsField = createLabelField(
37722 "back_to_items",
37723 (0, import_i18n78.__)("Back to items"),
37724 {
37725 placeholder: (0, import_i18n78.__)("← Back to Categories"),
37726 description: (0, import_i18n78.__)("Label displayed after a term has been updated.")
37727 }
37728 );
37729 var parentItemField = createLabelField(
37730 "parent_item",
37731 (0, import_i18n78.__)("Parent item"),
37732 {
37733 placeholder: (0, import_i18n78.__)("Parent Category"),
37734 description: (0, import_i18n78.__)("Not used on non-hierarchical taxonomies."),
37735 isVisible: (item) => item.config.hierarchical
37736 }
37737 );
37738 var popularItemsField = createLabelField(
37739 "popular_items",
37740 (0, import_i18n78.__)("Popular items"),
37741 {
37742 placeholder: (0, import_i18n78.__)("Popular Tags"),
37743 description: (0, import_i18n78.__)(
37744 "The popular items text. Not used on hierarchical taxonomies."
37745 ),
37746 isVisible: (item) => !item.config.hierarchical
37747 }
37748 );
37749 var separateItemsField = createLabelField(
37750 "separate_items_with_commas",
37751 (0, import_i18n78.__)("Separate items with commas"),
37752 {
37753 placeholder: (0, import_i18n78.__)("Separate tags with commas"),
37754 description: (0, import_i18n78.__)(
37755 "Shown in the taxonomy meta box. Not used on hierarchical taxonomies."
37756 ),
37757 isVisible: (item) => !item.config.hierarchical
37758 }
37759 );
37760 var parentItemColonField2 = createLabelField(
37761 "parent_item_colon",
37762 (0, import_i18n78.__)("Parent item with colon"),
37763 {
37764 placeholder: (0, import_i18n78.__)("Parent Category:"),
37765 description: (0, import_i18n78.__)("Same as Parent item, with a colon at the end."),
37766 isVisible: (item) => item.config.hierarchical
37767 }
37768 );
37769 var addOrRemoveItemsField = createLabelField(
37770 "add_or_remove_items",
37771 (0, import_i18n78.__)("Add or remove items"),
37772 {
37773 placeholder: (0, import_i18n78.__)("Add or remove tags"),
37774 description: (0, import_i18n78.__)(
37775 "Shown in the meta box when JavaScript is disabled. Not used on hierarchical taxonomies."
37776 ),
37777 isVisible: (item) => !item.config.hierarchical
37778 }
37779 );
37780 var chooseFromMostUsedField = createLabelField(
37781 "choose_from_most_used",
37782 (0, import_i18n78.__)("Choose from the most used"),
37783 {
37784 placeholder: (0, import_i18n78.__)("Choose from the most used tags"),
37785 description: (0, import_i18n78.__)(
37786 "Shown in the taxonomy meta box. Not used on hierarchical taxonomies."
37787 ),
37788 isVisible: (item) => !item.config.hierarchical
37789 }
37790 );
37791 var labelsActionsField2 = createLabelsActionsField(
37792 {
37793 labelKeys: STRING_LABEL_KEYS2,
37794 deriveLabels: deriveLabels2,
37795 helpText: (0, import_i18n78.__)(
37796 "Override the text WordPress shows in admin lists, menus, and forms. Auto-fill replaces every label below with values derived from the current plural and singular names — including any you have already customized. Clearing removes all overrides so WordPress falls back to its defaults. If you rename the taxonomy after auto-filling, click Auto-fill again to keep them in sync."
37797 )
37798 }
37799 );
37800 var labelsFormFields = [
37801 {
37802 id: LABELS_ACTIONS_FIELD_ID,
37803 layout: { type: "regular", labelPosition: "none" }
37804 },
37805 // singular_name lives in the General card, so exclude it here.
37806 ...STRING_LABEL_KEYS2.filter((key) => key !== "singular_name")
37807 ];
37808
37809 // packages/content-types/build-module/taxonomies/fields/visibility.mjs
37810 var import_i18n79 = __toESM(require_i18n(), 1);
37811 var publicField2 = createBooleanField("public", (0, import_i18n79.__)("Public"), {
37812 description: (0, import_i18n79.__)(
37813 "Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users."
37814 )
37815 });
37816 var showInRestField2 = createBooleanField(
37817 "show_in_rest",
37818 (0, import_i18n79.__)("Show in REST API"),
37819 {
37820 description: (0, import_i18n79.__)(
37821 "Required for the block editor. Turn off only for taxonomies that should not be exposed via REST."
37822 )
37823 }
37824 );
37825 var publiclyQueryableField = createBooleanField(
37826 "publicly_queryable",
37827 (0, import_i18n79.__)("Publicly queryable"),
37828 {
37829 description: (0, import_i18n79.__)(
37830 "Whether front-end queries (e.g. ?taxonomy=…&term=…) can return terms from this taxonomy."
37831 )
37832 }
37833 );
37834 var showUiField = createBooleanField(
37835 "show_ui",
37836 (0, import_i18n79.__)("Show admin UI"),
37837 {
37838 description: (0, import_i18n79.__)(
37839 "Whether to generate a default admin interface for managing terms."
37840 )
37841 }
37842 );
37843 var showInMenuField = createBooleanField(
37844 "show_in_menu",
37845 (0, import_i18n79.__)("Show in admin menu"),
37846 {
37847 description: (0, import_i18n79.__)(
37848 "Whether to show the taxonomy in the admin menu. Has no effect when Show admin UI is off; the value is preserved either way."
37849 ),
37850 // Hide when `show_ui` is off — `show_in_menu` is silently ignored by
37851 // register_taxonomy() in that case, so showing the toggle would be
37852 // misleading. The stored value is preserved across the toggle.
37853 isVisible: (item) => item.config.show_ui
37854 }
37855 );
37856 var showInQuickEditField = createBooleanField(
37857 "show_in_quick_edit",
37858 (0, import_i18n79.__)("Show in Quick Edit"),
37859 {
37860 description: (0, import_i18n79.__)(
37861 "Whether to show the taxonomy in the Quick/Bulk Edit panel."
37862 )
37863 }
37864 );
37865 var showAdminColumnField = createBooleanField(
37866 "show_admin_column",
37867 (0, import_i18n79.__)("Show admin column"),
37868 {
37869 description: (0, import_i18n79.__)(
37870 "Whether to display a column for the taxonomy on the associated post type list tables."
37871 )
37872 }
37873 );
37874 var showInNavMenusField = createBooleanField(
37875 "show_in_nav_menus",
37876 (0, import_i18n79.__)("Available in nav menus"),
37877 {
37878 description: (0, import_i18n79.__)(
37879 "Whether terms are selectable in the theme nav menu builder."
37880 )
37881 }
37882 );
37883 var showTagcloudField = createBooleanField(
37884 "show_tagcloud",
37885 (0, import_i18n79.__)("Available in Tag Cloud widget"),
37886 {
37887 description: (0, import_i18n79.__)(
37888 "Whether terms can be displayed in the Tag Cloud widget."
37889 )
37890 }
37891 );
37892 var visibilityFormFields = [
37893 "public",
37894 "show_in_rest",
37895 "publicly_queryable",
37896 "show_ui",
37897 "show_in_menu",
37898 "show_in_quick_edit",
37899 "show_in_nav_menus",
37900 "show_tagcloud",
37901 "show_admin_column"
37902 ];
37903
37904 // packages/content-types/build-module/taxonomies/actions/edit.mjs
37905 var import_element141 = __toESM(require_element(), 1);
37906 var import_i18n80 = __toESM(require_i18n(), 1);
37907 import { useNavigate as useNavigate5 } from "@wordpress/route";
37908 function useEditTaxonomyAction() {
37909 const navigate = useNavigate5();
37910 return (0, import_element141.useMemo)(
37911 () => ({
37912 id: "edit-taxonomy",
37913 label: (0, import_i18n80.__)("Edit"),
37914 callback: (items) => {
37915 const item = items[0];
37916 if (item?.id === void 0) {
37917 return;
37918 }
37919 navigate({
37920 to: `${TAXONOMIES_PATH}/${item.id}`
37921 });
37922 }
37923 }),
37924 [navigate]
37925 );
37926 }
37927
37928 // packages/content-types/build-module/taxonomies/actions/quick-edit.mjs
37929 var import_components63 = __toESM(require_components(), 1);
37930 var import_core_data15 = __toESM(require_core_data(), 1);
37931 var import_data20 = __toESM(require_data(), 1);
37932 var import_element142 = __toESM(require_element(), 1);
37933 var import_i18n81 = __toESM(require_i18n(), 1);
37934 var import_notices8 = __toESM(require_notices(), 1);
37935 var import_jsx_runtime188 = __toESM(require_jsx_runtime(), 1);
37936 function QuickEditTaxonomyModal({
37937 items,
37938 closeModal
37939 }) {
37940 const item = items[0];
37941 const [data, setData] = (0, import_element142.useState)(item);
37942 const [isSaving, setIsSaving] = (0, import_element142.useState)(false);
37943 const slugField = useSlugField2(item.slug, data.slug);
37944 const objectTypeField = useObjectTypeField();
37945 const fields = (0, import_element142.useMemo)(
37946 () => [
37947 pluralLabelField,
37948 singularLabelField,
37949 slugField,
37950 objectTypeField,
37951 publicField2,
37952 hierarchicalField2,
37953 statusField
37954 ],
37955 [slugField, objectTypeField]
37956 );
37957 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, defaultForm2);
37958 const { saveEntityRecord } = (0, import_data20.useDispatch)(import_core_data15.store);
37959 const { createSuccessNotice, createErrorNotice } = (0, import_data20.useDispatch)(import_notices8.store);
37960 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
37961 async function onSave() {
37962 if (isSaving || !isValid2) {
37963 return;
37964 }
37965 setIsSaving(true);
37966 try {
37967 await saveEntityRecord(
37968 "postType",
37969 TAXONOMY_ENTITY,
37970 serializeForSave2({ ...data, id: item.id }),
37971 { throwOnError: true }
37972 );
37973 createSuccessNotice(
37974 (0, import_i18n81.sprintf)(
37975 /* translators: %s: taxonomy plural label. */
37976 (0, import_i18n81.__)('"%s" taxonomy updated.'),
37977 data.title.raw
37978 ),
37979 { type: "snackbar" }
37980 );
37981 maybeInvalidateCache(
37982 item.config.object_type,
37983 data.config.object_type,
37984 POST_TYPE_ENTITY
37985 );
37986 closeModal?.();
37987 } catch (error2) {
37988 createErrorNotice(
37989 error2?.message && error2?.code !== "unknown_error" ? error2.message : (0, import_i18n81.__)("Failed to update taxonomy."),
37990 { type: "snackbar" }
37991 );
37992 } finally {
37993 setIsSaving(false);
37994 }
37995 }
37996 return /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(
37997 "form",
37998 {
37999 onSubmit: (event) => {
38000 event.preventDefault();
38001 onSave();
38002 },
38003 children: [
38004 /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(
38005 Stack,
38006 {
38007 className: "dataviews-action-modal__quick-edit-taxonomy-header",
38008 direction: "row",
38009 justify: "space-between",
38010 align: "center",
38011 children: [
38012 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(Text, { variant: "heading-sm", render: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("h2", {}), children: (0, import_i18n81.__)("Quick edit taxonomy") }),
38013 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
38014 import_components63.Button,
38015 {
38016 size: "small",
38017 icon: close_small_default,
38018 label: (0, import_i18n81.__)("Close"),
38019 onClick: closeModal
38020 }
38021 )
38022 ]
38023 }
38024 ),
38025 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("div", { className: "dataviews-action-modal__quick-edit-taxonomy-content", children: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
38026 DataForm,
38027 {
38028 data,
38029 fields,
38030 form: defaultForm2,
38031 validity,
38032 onChange: (edits) => setData(
38033 (prev) => ({ ...prev, ...edits })
38034 )
38035 }
38036 ) }),
38037 /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(
38038 Stack,
38039 {
38040 className: "dataviews-action-modal__quick-edit-taxonomy-footer",
38041 direction: "row",
38042 gap: "sm",
38043 children: [
38044 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
38045 import_components63.Button,
38046 {
38047 __next40pxDefaultSize: true,
38048 variant: "secondary",
38049 onClick: closeModal,
38050 children: (0, import_i18n81.__)("Cancel")
38051 }
38052 ),
38053 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
38054 import_components63.Button,
38055 {
38056 __next40pxDefaultSize: true,
38057 variant: "primary",
38058 type: "submit",
38059 isBusy: isSaving,
38060 disabled: isSaving || !isValid2,
38061 accessibleWhenDisabled: true,
38062 children: (0, import_i18n81.__)("Done")
38063 }
38064 )
38065 ]
38066 }
38067 )
38068 ]
38069 }
38070 );
38071 }
38072 var quickEditTaxonomyAction = {
38073 id: "quick-edit-taxonomy",
38074 label: (0, import_i18n81.__)("Quick edit"),
38075 icon: pencil_default,
38076 isPrimary: true,
38077 hideModalHeader: true,
38078 RenderModal: QuickEditTaxonomyModal
38079 };
38080 var quick_edit_default2 = quickEditTaxonomyAction;
38081
38082 // packages/content-types/build-module/taxonomies/list.mjs
38083 var import_jsx_runtime189 = __toESM(require_jsx_runtime(), 1);
38084 var defaultLayouts2 = {
38085 table: {}
38086 };
38087 var DEFAULT_VIEW2 = {
38088 type: "table",
38089 perPage: 20,
38090 page: 1,
38091 fields: ["object_type", "count", "status"],
38092 titleField: "title",
38093 layout: {
38094 styles: {
38095 object_type: { minWidth: 230 }
38096 }
38097 }
38098 };
38099 function TaxonomiesList() {
38100 const navigate = useNavigate6();
38101 const searchParams = useSearch2({ from: TAXONOMIES_PATH });
38102 const handleQueryParamsChange = (0, import_element143.useCallback)(
38103 (params) => {
38104 navigate({
38105 search: {
38106 ...searchParams,
38107 ...params
38108 }
38109 });
38110 },
38111 [searchParams, navigate]
38112 );
38113 const { view, updateView, isModified, resetToDefault } = useView({
38114 kind: "postType",
38115 name: TAXONOMY_ENTITY,
38116 slug: "default",
38117 defaultView: DEFAULT_VIEW2,
38118 queryParams: searchParams,
38119 onChangeQueryParams: handleQueryParamsChange
38120 });
38121 const editAction = useEditTaxonomyAction();
38122 const taxonomyActions = (0, import_element143.useMemo)(
38123 () => [
38124 editAction,
38125 quick_edit_default2,
38126 duplicate_default2,
38127 view_terms_default,
38128 activate_default2,
38129 deactivate_default2,
38130 delete_default2
38131 ],
38132 [editAction]
38133 );
38134 const slugField = useSlugField2();
38135 const objectTypeField = useObjectTypeField();
38136 const fields = (0, import_element143.useMemo)(
38137 () => [
38138 titleField,
38139 objectTypeField,
38140 countField2,
38141 statusField,
38142 publicField2,
38143 slugField,
38144 hierarchicalField2
38145 ],
38146 [slugField, objectTypeField]
38147 );
38148 const queryArgs = (0, import_element143.useMemo)(() => {
38149 const statusFilter = view.filters?.find(
38150 (filter) => filter.field === "status"
38151 );
38152 const objectTypeFilter = view.filters?.find(
38153 (filter) => filter.field === "object_type"
38154 );
38155 return {
38156 per_page: view.perPage,
38157 page: view.page,
38158 context: "edit",
38159 order: view.sort?.direction,
38160 orderby: view.sort?.field,
38161 search: view.search,
38162 status: statusFilter?.value ?? ["publish", "draft"],
38163 object_type: objectTypeFilter?.value
38164 };
38165 }, [view]);
38166 const { records, isResolving, hasResolved, totalItems, totalPages } = (0, import_core_data16.useEntityRecords)(
38167 "postType",
38168 TAXONOMY_ENTITY,
38169 queryArgs
38170 );
38171 const data = (0, import_element143.useMemo)(
38172 () => (records ?? []).map(toFormData2),
38173 [records]
38174 );
38175 const paginationInfo = (0, import_element143.useMemo)(
38176 () => ({
38177 totalItems: totalItems ?? 0,
38178 totalPages: totalPages ?? 0
38179 }),
38180 [totalItems, totalPages]
38181 );
38182 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
38183 dataviews_default,
38184 {
38185 data,
38186 fields,
38187 actions: taxonomyActions,
38188 view,
38189 onChangeView: updateView,
38190 onReset: isModified ? resetToDefault : false,
38191 isLoading: isResolving || !hasResolved,
38192 paginationInfo,
38193 defaultLayouts: defaultLayouts2,
38194 getItemId: (item) => String(item.id),
38195 isItemClickable: () => true,
38196 onClickItem: (item) => navigate({
38197 to: `${TAXONOMIES_PATH}/${item.id}`
38198 }),
38199 header: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
38200 import_components64.Button,
38201 {
38202 variant: "primary",
38203 size: "compact",
38204 __next40pxDefaultSize: true,
38205 onClick: () => navigate({
38206 to: `${TAXONOMIES_PATH}/${NEW_ID}`
38207 }),
38208 children: (0, import_i18n82.__)("Add taxonomy")
38209 }
38210 )
38211 }
38212 );
38213 }
38214
38215 // packages/content-types/build-module/taxonomies/edit.mjs
38216 var import_components65 = __toESM(require_components(), 1);
38217 var import_compose20 = __toESM(require_compose(), 1);
38218 var import_core_data17 = __toESM(require_core_data(), 1);
38219 var import_data21 = __toESM(require_data(), 1);
38220 var import_element144 = __toESM(require_element(), 1);
38221 var import_i18n83 = __toESM(require_i18n(), 1);
38222 var import_notices9 = __toESM(require_notices(), 1);
38223 import { useNavigate as useNavigate7, useParams as useParams2 } from "@wordpress/route";
38224 var import_jsx_runtime190 = __toESM(require_jsx_runtime(), 1);
38225 function TaxonomyEdit() {
38226 const { id } = useParams2({ from: `${TAXONOMIES_PATH}/$id` });
38227 const navigate = useNavigate7();
38228 const isAddMode = id === NEW_ID;
38229 const taxonomyId = parseInt(id, 10);
38230 const record = (0, import_data21.useSelect)(
38231 (select2) => {
38232 return !isAddMode && // beforeLoad (route.ts) guarantees the record is in cache.
38233 select2(import_core_data17.store).getEntityRecord(
38234 "postType",
38235 TAXONOMY_ENTITY,
38236 taxonomyId
38237 );
38238 },
38239 [isAddMode, taxonomyId]
38240 );
38241 const initialData = !isAddMode && record ? toFormData2(record) : BLANK_RECORD2;
38242 const title = isAddMode ? (0, import_i18n83.__)("Add taxonomy") : initialData.title.raw;
38243 const commonProps = { initialData, title };
38244 const taxonomyPageProps = isAddMode ? {
38245 ...commonProps,
38246 isAddMode: true,
38247 breadcrumbLabel: (0, import_i18n83.__)("Add new"),
38248 subTitle: (0, import_i18n83.__)(
38249 "Define a new taxonomy. Fill in the essentials under General; expand Labels to customize."
38250 ),
38251 onSaved: (saved) => navigate({
38252 to: `${TAXONOMIES_PATH}/${saved.id}`
38253 })
38254 } : {
38255 ...commonProps,
38256 isAddMode: false,
38257 breadcrumbLabel: title,
38258 subTitle: (0, import_i18n83.__)(
38259 "Edit this taxonomy. Expand the Labels section to adjust labels."
38260 )
38261 };
38262 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(TaxonomyPage, { ...taxonomyPageProps }, id);
38263 }
38264 function TaxonomyPage({
38265 isAddMode,
38266 initialData,
38267 title,
38268 breadcrumbLabel,
38269 subTitle,
38270 onSaved
38271 }) {
38272 const [data, setData] = (0, import_element144.useState)(initialData);
38273 const [isSaving, setIsSaving] = (0, import_element144.useState)(false);
38274 const originalSlug = !isAddMode ? initialData.slug : void 0;
38275 const slugField = useSlugField2(originalSlug, data.slug);
38276 const objectTypeField = useObjectTypeField();
38277 const fields = (0, import_element144.useMemo)(
38278 () => [
38279 // General
38280 pluralLabelField,
38281 singularLabelField,
38282 slugField,
38283 descriptionField2,
38284 objectTypeField,
38285 hierarchicalField2,
38286 statusField,
38287 // Visibility
38288 publicField2,
38289 showInRestField2,
38290 publiclyQueryableField,
38291 showUiField,
38292 showInMenuField,
38293 showInQuickEditField,
38294 showAdminColumnField,
38295 showInNavMenusField,
38296 showTagcloudField,
38297 // Labels
38298 labelsActionsField2,
38299 menuNameField2,
38300 allItemsField2,
38301 editItemField2,
38302 viewItemField2,
38303 updateItemField,
38304 addNewItemLabelField2,
38305 newItemNameField,
38306 searchItemsField2,
38307 notFoundField2,
38308 backToItemsField,
38309 parentItemField,
38310 popularItemsField,
38311 separateItemsField,
38312 parentItemColonField2,
38313 addOrRemoveItemsField,
38314 chooseFromMostUsedField,
38315 // Advanced
38316 sortField,
38317 defaultTermEnabledField,
38318 defaultTermNameField
38319 ],
38320 [slugField, objectTypeField]
38321 );
38322 const form = (0, import_element144.useMemo)(
38323 () => ({
38324 layout: { type: "card", isCollapsible: true },
38325 fields: [
38326 {
38327 id: "general",
38328 label: (0, import_i18n83.__)("General"),
38329 description: (0, import_i18n83.__)(
38330 "Core identity, post types, and activation."
38331 ),
38332 layout: {
38333 type: "card",
38334 isCollapsible: true,
38335 isOpened: true
38336 },
38337 children: generalFormFields
38338 },
38339 {
38340 id: "visibility",
38341 label: (0, import_i18n83.__)("Visibility"),
38342 description: (0, import_i18n83.__)(
38343 "Where this taxonomy appears: REST API, admin UI, and front-end surfaces."
38344 ),
38345 layout: {
38346 type: "card",
38347 isCollapsible: true,
38348 isOpened: false
38349 },
38350 children: visibilityFormFields
38351 },
38352 {
38353 id: "labels",
38354 label: (0, import_i18n83.__)("Labels"),
38355 layout: {
38356 type: "card",
38357 isCollapsible: true,
38358 isOpened: false
38359 },
38360 children: labelsFormFields
38361 },
38362 {
38363 id: "advanced",
38364 label: (0, import_i18n83.__)("Advanced"),
38365 layout: {
38366 type: "card",
38367 isCollapsible: true,
38368 isOpened: false
38369 },
38370 children: advancedFormFields
38371 }
38372 ]
38373 }),
38374 []
38375 );
38376 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, form);
38377 const formId = (0, import_compose20.useInstanceId)(TaxonomyPage, "taxonomy-form");
38378 const { saveEntityRecord } = (0, import_data21.useDispatch)(import_core_data17.store);
38379 const { createSuccessNotice, createErrorNotice } = (0, import_data21.useDispatch)(import_notices9.store);
38380 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
38381 async function onSave() {
38382 if (isSaving || !isValid2) {
38383 return;
38384 }
38385 setIsSaving(true);
38386 try {
38387 const saved = await saveEntityRecord(
38388 "postType",
38389 TAXONOMY_ENTITY,
38390 serializeForSave2(data),
38391 { throwOnError: true }
38392 );
38393 const successMessage = isAddMode ? (0, import_i18n83.sprintf)(
38394 /* translators: %s: taxonomy plural label. */
38395 (0, import_i18n83.__)('"%s" taxonomy created.'),
38396 data.title.raw
38397 ) : (0, import_i18n83.sprintf)(
38398 /* translators: %s: taxonomy plural label. */
38399 (0, import_i18n83.__)('"%s" taxonomy updated.'),
38400 data.title.raw
38401 );
38402 createSuccessNotice(successMessage, { type: "snackbar" });
38403 maybeInvalidateCache(
38404 initialData.config.object_type,
38405 data.config.object_type,
38406 POST_TYPE_ENTITY
38407 );
38408 if (saved?.id !== void 0) {
38409 onSaved?.({ ...data, id: saved.id });
38410 }
38411 } catch (error2) {
38412 let errorMessage;
38413 if (error2?.message && error2?.code !== "unknown_error") {
38414 errorMessage = error2.message;
38415 } else if (isAddMode) {
38416 errorMessage = (0, import_i18n83.__)("Failed to create taxonomy.");
38417 } else {
38418 errorMessage = (0, import_i18n83.__)("Failed to update taxonomy.");
38419 }
38420 createErrorNotice(errorMessage, { type: "snackbar" });
38421 } finally {
38422 setIsSaving(false);
38423 }
38424 }
38425 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
38426 page_default,
38427 {
38428 ariaLabel: title,
38429 breadcrumbs: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
38430 breadcrumbs_default,
38431 {
38432 items: [
38433 { label: (0, import_i18n83.__)("Taxonomies"), to: TAXONOMIES_PATH },
38434 { label: breadcrumbLabel }
38435 ]
38436 }
38437 ),
38438 subTitle,
38439 actions: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
38440 import_components65.Button,
38441 {
38442 __next40pxDefaultSize: true,
38443 variant: "primary",
38444 size: "compact",
38445 type: "submit",
38446 form: formId,
38447 isBusy: isSaving,
38448 disabled: isSaving || !isValid2,
38449 accessibleWhenDisabled: true,
38450 children: isAddMode ? (0, import_i18n83.__)("Create") : (0, import_i18n83.__)("Save")
38451 }
38452 ),
38453 children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
38454 Stack,
38455 {
38456 direction: "column",
38457 gap: "md",
38458 className: "taxonomy-form",
38459 render: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
38460 "form",
38461 {
38462 id: formId,
38463 onSubmit: (event) => {
38464 event.preventDefault();
38465 onSave();
38466 }
38467 }
38468 ),
38469 children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
38470 DataForm,
38471 {
38472 data,
38473 fields,
38474 form,
38475 validity,
38476 onChange: (edits) => setData(
38477 (prev) => ({
38478 ...prev,
38479 ...edits
38480 })
38481 )
38482 }
38483 )
38484 }
38485 )
38486 }
38487 );
38488 }
38489 export {
38490 Layout,
38491 NEW_ID,
38492 POST_TYPES_PATH,
38493 POST_TYPE_ENTITY,
38494 PostTypeEdit,
38495 PostTypesList,
38496 TAXONOMIES_PATH,
38497 TAXONOMY_ENTITY,
38498 TaxonomiesList,
38499 TaxonomyEdit
38500 };
38501 /*! Bundled license information:
38502
38503 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
38504 (**
38505 * @license React
38506 * use-sync-external-store-shim.development.js
38507 *
38508 * Copyright (c) Meta Platforms, Inc. and affiliates.
38509 *
38510 * This source code is licensed under the MIT license found in the
38511 * LICENSE file in the root directory of this source tree.
38512 *)
38513
38514 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
38515 (**
38516 * @license React
38517 * use-sync-external-store-shim/with-selector.development.js
38518 *
38519 * Copyright (c) Meta Platforms, Inc. and affiliates.
38520 *
38521 * This source code is licensed under the MIT license found in the
38522 * LICENSE file in the root directory of this source tree.
38523 *)
38524
38525 tabbable/dist/index.esm.js:
38526 (*!
38527 * tabbable 6.4.0
38528 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
38529 *)
38530 */
38531 //# sourceMappingURL=index.js.map
38532