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

content.js in Gutenberg 23.2.2, at build/routes/dashboard/content.js

38,250 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 key2 of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key2) && key2 !== except)
18 __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || 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 === React79.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 = useState50({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect10(
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 React79 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState50 = React79.useState, useEffect47 = React79.useEffect, useLayoutEffect10 = React79.useLayoutEffect, useDebugValue2 = React79.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 !== React79.useSyncExternalStore ? React79.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 React79 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef61 = React79.useRef, useEffect47 = React79.useEffect, useMemo57 = React79.useMemo, useDebugValue2 = React79.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef61(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo57(
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/data
257 var require_data = __commonJS({
258 "package-external:@wordpress/data"(exports, module) {
259 module.exports = window.wp.data;
260 }
261 });
262
263 // package-external:@wordpress/notices
264 var require_notices = __commonJS({
265 "package-external:@wordpress/notices"(exports, module) {
266 module.exports = window.wp.notices;
267 }
268 });
269
270 // package-external:@wordpress/api-fetch
271 var require_api_fetch = __commonJS({
272 "package-external:@wordpress/api-fetch"(exports, module) {
273 module.exports = window.wp.apiFetch;
274 }
275 });
276
277 // package-external:@wordpress/preferences
278 var require_preferences = __commonJS({
279 "package-external:@wordpress/preferences"(exports, module) {
280 module.exports = window.wp.preferences;
281 }
282 });
283
284 // node_modules/fast-deep-equal/es6/index.js
285 var require_es6 = __commonJS({
286 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
287 "use strict";
288 module.exports = function equal(a2, b2) {
289 if (a2 === b2) return true;
290 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
291 if (a2.constructor !== b2.constructor) return false;
292 var length, i2, keys;
293 if (Array.isArray(a2)) {
294 length = a2.length;
295 if (length != b2.length) return false;
296 for (i2 = length; i2-- !== 0; )
297 if (!equal(a2[i2], b2[i2])) return false;
298 return true;
299 }
300 if (a2 instanceof Map && b2 instanceof Map) {
301 if (a2.size !== b2.size) return false;
302 for (i2 of a2.entries())
303 if (!b2.has(i2[0])) return false;
304 for (i2 of a2.entries())
305 if (!equal(i2[1], b2.get(i2[0]))) return false;
306 return true;
307 }
308 if (a2 instanceof Set && b2 instanceof Set) {
309 if (a2.size !== b2.size) return false;
310 for (i2 of a2.entries())
311 if (!b2.has(i2[0])) return false;
312 return true;
313 }
314 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
315 length = a2.length;
316 if (length != b2.length) return false;
317 for (i2 = length; i2-- !== 0; )
318 if (a2[i2] !== b2[i2]) return false;
319 return true;
320 }
321 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
322 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
323 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
324 keys = Object.keys(a2);
325 length = keys.length;
326 if (length !== Object.keys(b2).length) return false;
327 for (i2 = length; i2-- !== 0; )
328 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
329 for (i2 = length; i2-- !== 0; ) {
330 var key2 = keys[i2];
331 if (!equal(a2[key2], b2[key2])) return false;
332 }
333 return true;
334 }
335 return a2 !== a2 && b2 !== b2;
336 };
337 }
338 });
339
340 // package-external:@wordpress/keycodes
341 var require_keycodes = __commonJS({
342 "package-external:@wordpress/keycodes"(exports, module) {
343 module.exports = window.wp.keycodes;
344 }
345 });
346
347 // node_modules/remove-accents/index.js
348 var require_remove_accents = __commonJS({
349 "node_modules/remove-accents/index.js"(exports, module) {
350 var characterMap = {
351 "\xC0": "A",
352 "\xC1": "A",
353 "\xC2": "A",
354 "\xC3": "A",
355 "\xC4": "A",
356 "\xC5": "A",
357 "\u1EA4": "A",
358 "\u1EAE": "A",
359 "\u1EB2": "A",
360 "\u1EB4": "A",
361 "\u1EB6": "A",
362 "\xC6": "AE",
363 "\u1EA6": "A",
364 "\u1EB0": "A",
365 "\u0202": "A",
366 "\u1EA2": "A",
367 "\u1EA0": "A",
368 "\u1EA8": "A",
369 "\u1EAA": "A",
370 "\u1EAC": "A",
371 "\xC7": "C",
372 "\u1E08": "C",
373 "\xC8": "E",
374 "\xC9": "E",
375 "\xCA": "E",
376 "\xCB": "E",
377 "\u1EBE": "E",
378 "\u1E16": "E",
379 "\u1EC0": "E",
380 "\u1E14": "E",
381 "\u1E1C": "E",
382 "\u0206": "E",
383 "\u1EBA": "E",
384 "\u1EBC": "E",
385 "\u1EB8": "E",
386 "\u1EC2": "E",
387 "\u1EC4": "E",
388 "\u1EC6": "E",
389 "\xCC": "I",
390 "\xCD": "I",
391 "\xCE": "I",
392 "\xCF": "I",
393 "\u1E2E": "I",
394 "\u020A": "I",
395 "\u1EC8": "I",
396 "\u1ECA": "I",
397 "\xD0": "D",
398 "\xD1": "N",
399 "\xD2": "O",
400 "\xD3": "O",
401 "\xD4": "O",
402 "\xD5": "O",
403 "\xD6": "O",
404 "\xD8": "O",
405 "\u1ED0": "O",
406 "\u1E4C": "O",
407 "\u1E52": "O",
408 "\u020E": "O",
409 "\u1ECE": "O",
410 "\u1ECC": "O",
411 "\u1ED4": "O",
412 "\u1ED6": "O",
413 "\u1ED8": "O",
414 "\u1EDC": "O",
415 "\u1EDE": "O",
416 "\u1EE0": "O",
417 "\u1EDA": "O",
418 "\u1EE2": "O",
419 "\xD9": "U",
420 "\xDA": "U",
421 "\xDB": "U",
422 "\xDC": "U",
423 "\u1EE6": "U",
424 "\u1EE4": "U",
425 "\u1EEC": "U",
426 "\u1EEE": "U",
427 "\u1EF0": "U",
428 "\xDD": "Y",
429 "\xE0": "a",
430 "\xE1": "a",
431 "\xE2": "a",
432 "\xE3": "a",
433 "\xE4": "a",
434 "\xE5": "a",
435 "\u1EA5": "a",
436 "\u1EAF": "a",
437 "\u1EB3": "a",
438 "\u1EB5": "a",
439 "\u1EB7": "a",
440 "\xE6": "ae",
441 "\u1EA7": "a",
442 "\u1EB1": "a",
443 "\u0203": "a",
444 "\u1EA3": "a",
445 "\u1EA1": "a",
446 "\u1EA9": "a",
447 "\u1EAB": "a",
448 "\u1EAD": "a",
449 "\xE7": "c",
450 "\u1E09": "c",
451 "\xE8": "e",
452 "\xE9": "e",
453 "\xEA": "e",
454 "\xEB": "e",
455 "\u1EBF": "e",
456 "\u1E17": "e",
457 "\u1EC1": "e",
458 "\u1E15": "e",
459 "\u1E1D": "e",
460 "\u0207": "e",
461 "\u1EBB": "e",
462 "\u1EBD": "e",
463 "\u1EB9": "e",
464 "\u1EC3": "e",
465 "\u1EC5": "e",
466 "\u1EC7": "e",
467 "\xEC": "i",
468 "\xED": "i",
469 "\xEE": "i",
470 "\xEF": "i",
471 "\u1E2F": "i",
472 "\u020B": "i",
473 "\u1EC9": "i",
474 "\u1ECB": "i",
475 "\xF0": "d",
476 "\xF1": "n",
477 "\xF2": "o",
478 "\xF3": "o",
479 "\xF4": "o",
480 "\xF5": "o",
481 "\xF6": "o",
482 "\xF8": "o",
483 "\u1ED1": "o",
484 "\u1E4D": "o",
485 "\u1E53": "o",
486 "\u020F": "o",
487 "\u1ECF": "o",
488 "\u1ECD": "o",
489 "\u1ED5": "o",
490 "\u1ED7": "o",
491 "\u1ED9": "o",
492 "\u1EDD": "o",
493 "\u1EDF": "o",
494 "\u1EE1": "o",
495 "\u1EDB": "o",
496 "\u1EE3": "o",
497 "\xF9": "u",
498 "\xFA": "u",
499 "\xFB": "u",
500 "\xFC": "u",
501 "\u1EE7": "u",
502 "\u1EE5": "u",
503 "\u1EED": "u",
504 "\u1EEF": "u",
505 "\u1EF1": "u",
506 "\xFD": "y",
507 "\xFF": "y",
508 "\u0100": "A",
509 "\u0101": "a",
510 "\u0102": "A",
511 "\u0103": "a",
512 "\u0104": "A",
513 "\u0105": "a",
514 "\u0106": "C",
515 "\u0107": "c",
516 "\u0108": "C",
517 "\u0109": "c",
518 "\u010A": "C",
519 "\u010B": "c",
520 "\u010C": "C",
521 "\u010D": "c",
522 "C\u0306": "C",
523 "c\u0306": "c",
524 "\u010E": "D",
525 "\u010F": "d",
526 "\u0110": "D",
527 "\u0111": "d",
528 "\u0112": "E",
529 "\u0113": "e",
530 "\u0114": "E",
531 "\u0115": "e",
532 "\u0116": "E",
533 "\u0117": "e",
534 "\u0118": "E",
535 "\u0119": "e",
536 "\u011A": "E",
537 "\u011B": "e",
538 "\u011C": "G",
539 "\u01F4": "G",
540 "\u011D": "g",
541 "\u01F5": "g",
542 "\u011E": "G",
543 "\u011F": "g",
544 "\u0120": "G",
545 "\u0121": "g",
546 "\u0122": "G",
547 "\u0123": "g",
548 "\u0124": "H",
549 "\u0125": "h",
550 "\u0126": "H",
551 "\u0127": "h",
552 "\u1E2A": "H",
553 "\u1E2B": "h",
554 "\u0128": "I",
555 "\u0129": "i",
556 "\u012A": "I",
557 "\u012B": "i",
558 "\u012C": "I",
559 "\u012D": "i",
560 "\u012E": "I",
561 "\u012F": "i",
562 "\u0130": "I",
563 "\u0131": "i",
564 "\u0132": "IJ",
565 "\u0133": "ij",
566 "\u0134": "J",
567 "\u0135": "j",
568 "\u0136": "K",
569 "\u0137": "k",
570 "\u1E30": "K",
571 "\u1E31": "k",
572 "K\u0306": "K",
573 "k\u0306": "k",
574 "\u0139": "L",
575 "\u013A": "l",
576 "\u013B": "L",
577 "\u013C": "l",
578 "\u013D": "L",
579 "\u013E": "l",
580 "\u013F": "L",
581 "\u0140": "l",
582 "\u0141": "l",
583 "\u0142": "l",
584 "\u1E3E": "M",
585 "\u1E3F": "m",
586 "M\u0306": "M",
587 "m\u0306": "m",
588 "\u0143": "N",
589 "\u0144": "n",
590 "\u0145": "N",
591 "\u0146": "n",
592 "\u0147": "N",
593 "\u0148": "n",
594 "\u0149": "n",
595 "N\u0306": "N",
596 "n\u0306": "n",
597 "\u014C": "O",
598 "\u014D": "o",
599 "\u014E": "O",
600 "\u014F": "o",
601 "\u0150": "O",
602 "\u0151": "o",
603 "\u0152": "OE",
604 "\u0153": "oe",
605 "P\u0306": "P",
606 "p\u0306": "p",
607 "\u0154": "R",
608 "\u0155": "r",
609 "\u0156": "R",
610 "\u0157": "r",
611 "\u0158": "R",
612 "\u0159": "r",
613 "R\u0306": "R",
614 "r\u0306": "r",
615 "\u0212": "R",
616 "\u0213": "r",
617 "\u015A": "S",
618 "\u015B": "s",
619 "\u015C": "S",
620 "\u015D": "s",
621 "\u015E": "S",
622 "\u0218": "S",
623 "\u0219": "s",
624 "\u015F": "s",
625 "\u0160": "S",
626 "\u0161": "s",
627 "\u0162": "T",
628 "\u0163": "t",
629 "\u021B": "t",
630 "\u021A": "T",
631 "\u0164": "T",
632 "\u0165": "t",
633 "\u0166": "T",
634 "\u0167": "t",
635 "T\u0306": "T",
636 "t\u0306": "t",
637 "\u0168": "U",
638 "\u0169": "u",
639 "\u016A": "U",
640 "\u016B": "u",
641 "\u016C": "U",
642 "\u016D": "u",
643 "\u016E": "U",
644 "\u016F": "u",
645 "\u0170": "U",
646 "\u0171": "u",
647 "\u0172": "U",
648 "\u0173": "u",
649 "\u0216": "U",
650 "\u0217": "u",
651 "V\u0306": "V",
652 "v\u0306": "v",
653 "\u0174": "W",
654 "\u0175": "w",
655 "\u1E82": "W",
656 "\u1E83": "w",
657 "X\u0306": "X",
658 "x\u0306": "x",
659 "\u0176": "Y",
660 "\u0177": "y",
661 "\u0178": "Y",
662 "Y\u0306": "Y",
663 "y\u0306": "y",
664 "\u0179": "Z",
665 "\u017A": "z",
666 "\u017B": "Z",
667 "\u017C": "z",
668 "\u017D": "Z",
669 "\u017E": "z",
670 "\u017F": "s",
671 "\u0192": "f",
672 "\u01A0": "O",
673 "\u01A1": "o",
674 "\u01AF": "U",
675 "\u01B0": "u",
676 "\u01CD": "A",
677 "\u01CE": "a",
678 "\u01CF": "I",
679 "\u01D0": "i",
680 "\u01D1": "O",
681 "\u01D2": "o",
682 "\u01D3": "U",
683 "\u01D4": "u",
684 "\u01D5": "U",
685 "\u01D6": "u",
686 "\u01D7": "U",
687 "\u01D8": "u",
688 "\u01D9": "U",
689 "\u01DA": "u",
690 "\u01DB": "U",
691 "\u01DC": "u",
692 "\u1EE8": "U",
693 "\u1EE9": "u",
694 "\u1E78": "U",
695 "\u1E79": "u",
696 "\u01FA": "A",
697 "\u01FB": "a",
698 "\u01FC": "AE",
699 "\u01FD": "ae",
700 "\u01FE": "O",
701 "\u01FF": "o",
702 "\xDE": "TH",
703 "\xFE": "th",
704 "\u1E54": "P",
705 "\u1E55": "p",
706 "\u1E64": "S",
707 "\u1E65": "s",
708 "X\u0301": "X",
709 "x\u0301": "x",
710 "\u0403": "\u0413",
711 "\u0453": "\u0433",
712 "\u040C": "\u041A",
713 "\u045C": "\u043A",
714 "A\u030B": "A",
715 "a\u030B": "a",
716 "E\u030B": "E",
717 "e\u030B": "e",
718 "I\u030B": "I",
719 "i\u030B": "i",
720 "\u01F8": "N",
721 "\u01F9": "n",
722 "\u1ED2": "O",
723 "\u1ED3": "o",
724 "\u1E50": "O",
725 "\u1E51": "o",
726 "\u1EEA": "U",
727 "\u1EEB": "u",
728 "\u1E80": "W",
729 "\u1E81": "w",
730 "\u1EF2": "Y",
731 "\u1EF3": "y",
732 "\u0200": "A",
733 "\u0201": "a",
734 "\u0204": "E",
735 "\u0205": "e",
736 "\u0208": "I",
737 "\u0209": "i",
738 "\u020C": "O",
739 "\u020D": "o",
740 "\u0210": "R",
741 "\u0211": "r",
742 "\u0214": "U",
743 "\u0215": "u",
744 "B\u030C": "B",
745 "b\u030C": "b",
746 "\u010C\u0323": "C",
747 "\u010D\u0323": "c",
748 "\xCA\u030C": "E",
749 "\xEA\u030C": "e",
750 "F\u030C": "F",
751 "f\u030C": "f",
752 "\u01E6": "G",
753 "\u01E7": "g",
754 "\u021E": "H",
755 "\u021F": "h",
756 "J\u030C": "J",
757 "\u01F0": "j",
758 "\u01E8": "K",
759 "\u01E9": "k",
760 "M\u030C": "M",
761 "m\u030C": "m",
762 "P\u030C": "P",
763 "p\u030C": "p",
764 "Q\u030C": "Q",
765 "q\u030C": "q",
766 "\u0158\u0329": "R",
767 "\u0159\u0329": "r",
768 "\u1E66": "S",
769 "\u1E67": "s",
770 "V\u030C": "V",
771 "v\u030C": "v",
772 "W\u030C": "W",
773 "w\u030C": "w",
774 "X\u030C": "X",
775 "x\u030C": "x",
776 "Y\u030C": "Y",
777 "y\u030C": "y",
778 "A\u0327": "A",
779 "a\u0327": "a",
780 "B\u0327": "B",
781 "b\u0327": "b",
782 "\u1E10": "D",
783 "\u1E11": "d",
784 "\u0228": "E",
785 "\u0229": "e",
786 "\u0190\u0327": "E",
787 "\u025B\u0327": "e",
788 "\u1E28": "H",
789 "\u1E29": "h",
790 "I\u0327": "I",
791 "i\u0327": "i",
792 "\u0197\u0327": "I",
793 "\u0268\u0327": "i",
794 "M\u0327": "M",
795 "m\u0327": "m",
796 "O\u0327": "O",
797 "o\u0327": "o",
798 "Q\u0327": "Q",
799 "q\u0327": "q",
800 "U\u0327": "U",
801 "u\u0327": "u",
802 "X\u0327": "X",
803 "x\u0327": "x",
804 "Z\u0327": "Z",
805 "z\u0327": "z",
806 "\u0439": "\u0438",
807 "\u0419": "\u0418",
808 "\u0451": "\u0435",
809 "\u0401": "\u0415"
810 };
811 var chars = Object.keys(characterMap).join("|");
812 var allAccents = new RegExp(chars, "g");
813 var firstAccent = new RegExp(chars, "");
814 function matcher(match2) {
815 return characterMap[match2];
816 }
817 var removeAccents3 = function(string) {
818 return string.replace(allAccents, matcher);
819 };
820 var hasAccents = function(string) {
821 return !!string.match(firstAccent);
822 };
823 module.exports = removeAccents3;
824 module.exports.has = hasAccents;
825 module.exports.remove = removeAccents3;
826 }
827 });
828
829 // package-external:@wordpress/date
830 var require_date = __commonJS({
831 "package-external:@wordpress/date"(exports, module) {
832 module.exports = window.wp.date;
833 }
834 });
835
836 // package-external:@wordpress/warning
837 var require_warning = __commonJS({
838 "package-external:@wordpress/warning"(exports, module) {
839 module.exports = window.wp.warning;
840 }
841 });
842
843 // package-external:@wordpress/deprecated
844 var require_deprecated = __commonJS({
845 "package-external:@wordpress/deprecated"(exports, module) {
846 module.exports = window.wp.deprecated;
847 }
848 });
849
850 // package-external:@wordpress/core-data
851 var require_core_data = __commonJS({
852 "package-external:@wordpress/core-data"(exports, module) {
853 module.exports = window.wp.coreData;
854 }
855 });
856
857 // node_modules/clsx/dist/clsx.mjs
858 function r(e2) {
859 var t2, f2, n2 = "";
860 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
861 else if ("object" == typeof e2) if (Array.isArray(e2)) {
862 var o2 = e2.length;
863 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
864 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
865 return n2;
866 }
867 function clsx() {
868 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
869 return n2;
870 }
871 var clsx_default = clsx;
872
873 // node_modules/@base-ui/utils/esm/error.js
874 var set;
875 if (true) {
876 set = /* @__PURE__ */ new Set();
877 }
878 function error(...messages) {
879 if (true) {
880 const messageKey = messages.join(" ");
881 if (!set.has(messageKey)) {
882 set.add(messageKey);
883 console.error(`Base UI: ${messageKey}`);
884 }
885 }
886 }
887
888 // node_modules/@base-ui/utils/esm/useStableCallback.js
889 var React2 = __toESM(require_react(), 1);
890
891 // node_modules/@base-ui/utils/esm/useRefWithInit.js
892 var React = __toESM(require_react(), 1);
893 var UNINITIALIZED = {};
894 function useRefWithInit(init2, initArg) {
895 const ref = React.useRef(UNINITIALIZED);
896 if (ref.current === UNINITIALIZED) {
897 ref.current = init2(initArg);
898 }
899 return ref;
900 }
901
902 // node_modules/@base-ui/utils/esm/useStableCallback.js
903 var useInsertionEffect = React2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
904 var useSafeInsertionEffect = (
905 // React 17 doesn't have useInsertionEffect.
906 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
907 useInsertionEffect !== React2.useLayoutEffect ? useInsertionEffect : (fn) => fn()
908 );
909 function useStableCallback(callback) {
910 const stable = useRefWithInit(createStableCallback).current;
911 stable.next = callback;
912 useSafeInsertionEffect(stable.effect);
913 return stable.trampoline;
914 }
915 function createStableCallback() {
916 const stable = {
917 next: void 0,
918 callback: assertNotCalled,
919 trampoline: (...args) => stable.callback?.(...args),
920 effect: () => {
921 stable.callback = stable.next;
922 }
923 };
924 return stable;
925 }
926 function assertNotCalled() {
927 if (true) {
928 throw (
929 /* minify-error-disabled */
930 new Error("Base UI: Cannot call an event handler while rendering.")
931 );
932 }
933 }
934
935 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
936 var React3 = __toESM(require_react(), 1);
937 var noop = () => {
938 };
939 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
940
941 // node_modules/@base-ui/utils/esm/warn.js
942 var set2;
943 if (true) {
944 set2 = /* @__PURE__ */ new Set();
945 }
946 function warn(...messages) {
947 if (true) {
948 const messageKey = messages.join(" ");
949 if (!set2.has(messageKey)) {
950 set2.add(messageKey);
951 console.warn(`Base UI: ${messageKey}`);
952 }
953 }
954 }
955
956 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
957 var React4 = __toESM(require_react(), 1);
958 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
959 if (true) DirectionContext.displayName = "DirectionContext";
960 function useDirection() {
961 const context = React4.useContext(DirectionContext);
962 return context?.direction ?? "ltr";
963 }
964
965 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
966 var React7 = __toESM(require_react(), 1);
967
968 // node_modules/@base-ui/utils/esm/useMergedRefs.js
969 function useMergedRefs(a2, b2, c2, d2) {
970 const forkRef = useRefWithInit(createForkRef).current;
971 if (didChange(forkRef, a2, b2, c2, d2)) {
972 update(forkRef, [a2, b2, c2, d2]);
973 }
974 return forkRef.callback;
975 }
976 function useMergedRefsN(refs) {
977 const forkRef = useRefWithInit(createForkRef).current;
978 if (didChangeN(forkRef, refs)) {
979 update(forkRef, refs);
980 }
981 return forkRef.callback;
982 }
983 function createForkRef() {
984 return {
985 callback: null,
986 cleanup: null,
987 refs: []
988 };
989 }
990 function didChange(forkRef, a2, b2, c2, d2) {
991 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
992 }
993 function didChangeN(forkRef, newRefs) {
994 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
995 }
996 function update(forkRef, refs) {
997 forkRef.refs = refs;
998 if (refs.every((ref) => ref == null)) {
999 forkRef.callback = null;
1000 return;
1001 }
1002 forkRef.callback = (instance) => {
1003 if (forkRef.cleanup) {
1004 forkRef.cleanup();
1005 forkRef.cleanup = null;
1006 }
1007 if (instance != null) {
1008 const cleanupCallbacks = Array(refs.length).fill(null);
1009 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1010 const ref = refs[i2];
1011 if (ref == null) {
1012 continue;
1013 }
1014 switch (typeof ref) {
1015 case "function": {
1016 const refCleanup = ref(instance);
1017 if (typeof refCleanup === "function") {
1018 cleanupCallbacks[i2] = refCleanup;
1019 }
1020 break;
1021 }
1022 case "object": {
1023 ref.current = instance;
1024 break;
1025 }
1026 default:
1027 }
1028 }
1029 forkRef.cleanup = () => {
1030 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1031 const ref = refs[i2];
1032 if (ref == null) {
1033 continue;
1034 }
1035 switch (typeof ref) {
1036 case "function": {
1037 const cleanupCallback = cleanupCallbacks[i2];
1038 if (typeof cleanupCallback === "function") {
1039 cleanupCallback();
1040 } else {
1041 ref(null);
1042 }
1043 break;
1044 }
1045 case "object": {
1046 ref.current = null;
1047 break;
1048 }
1049 default:
1050 }
1051 }
1052 };
1053 }
1054 };
1055 }
1056
1057 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1058 var React6 = __toESM(require_react(), 1);
1059
1060 // node_modules/@base-ui/utils/esm/reactVersion.js
1061 var React5 = __toESM(require_react(), 1);
1062 var majorVersion = parseInt(React5.version, 10);
1063 function isReactVersionAtLeast(reactVersionToCheck) {
1064 return majorVersion >= reactVersionToCheck;
1065 }
1066
1067 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1068 function getReactElementRef(element) {
1069 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1070 return null;
1071 }
1072 const reactElement = element;
1073 const propsWithRef = reactElement.props;
1074 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1075 }
1076
1077 // node_modules/@base-ui/utils/esm/mergeObjects.js
1078 function mergeObjects(a2, b2) {
1079 if (a2 && !b2) {
1080 return a2;
1081 }
1082 if (!a2 && b2) {
1083 return b2;
1084 }
1085 if (a2 || b2) {
1086 return {
1087 ...a2,
1088 ...b2
1089 };
1090 }
1091 return void 0;
1092 }
1093
1094 // node_modules/@base-ui/utils/esm/empty.js
1095 function NOOP() {
1096 }
1097 var EMPTY_ARRAY = Object.freeze([]);
1098 var EMPTY_OBJECT = Object.freeze({});
1099
1100 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1101 function getStateAttributesProps(state, customMapping) {
1102 const props = {};
1103 for (const key2 in state) {
1104 const value = state[key2];
1105 if (customMapping?.hasOwnProperty(key2)) {
1106 const customProps = customMapping[key2](value);
1107 if (customProps != null) {
1108 Object.assign(props, customProps);
1109 }
1110 continue;
1111 }
1112 if (value === true) {
1113 props[`data-${key2.toLowerCase()}`] = "";
1114 } else if (value) {
1115 props[`data-${key2.toLowerCase()}`] = value.toString();
1116 }
1117 }
1118 return props;
1119 }
1120
1121 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1122 function resolveClassName(className, state) {
1123 return typeof className === "function" ? className(state) : className;
1124 }
1125
1126 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1127 function resolveStyle(style, state) {
1128 return typeof style === "function" ? style(state) : style;
1129 }
1130
1131 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1132 var EMPTY_PROPS = {};
1133 function mergeProps(a2, b2, c2, d2, e2) {
1134 if (!c2 && !d2 && !e2 && !a2) {
1135 return createInitialMergedProps(b2);
1136 }
1137 let merged = createInitialMergedProps(a2);
1138 if (b2) {
1139 merged = mergeInto(merged, b2);
1140 }
1141 if (c2) {
1142 merged = mergeInto(merged, c2);
1143 }
1144 if (d2) {
1145 merged = mergeInto(merged, d2);
1146 }
1147 if (e2) {
1148 merged = mergeInto(merged, e2);
1149 }
1150 return merged;
1151 }
1152 function mergePropsN(props) {
1153 if (props.length === 0) {
1154 return EMPTY_PROPS;
1155 }
1156 if (props.length === 1) {
1157 return createInitialMergedProps(props[0]);
1158 }
1159 let merged = createInitialMergedProps(props[0]);
1160 for (let i2 = 1; i2 < props.length; i2 += 1) {
1161 merged = mergeInto(merged, props[i2]);
1162 }
1163 return merged;
1164 }
1165 function createInitialMergedProps(inputProps) {
1166 if (isPropsGetter(inputProps)) {
1167 return {
1168 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1169 };
1170 }
1171 return copyInitialProps(inputProps);
1172 }
1173 function mergeInto(merged, inputProps) {
1174 if (isPropsGetter(inputProps)) {
1175 return resolvePropsGetter(inputProps, merged);
1176 }
1177 return mutablyMergeInto(merged, inputProps);
1178 }
1179 function copyInitialProps(inputProps) {
1180 const copiedProps = {
1181 ...inputProps
1182 };
1183 for (const propName in copiedProps) {
1184 const propValue = copiedProps[propName];
1185 if (isEventHandler(propName, propValue)) {
1186 copiedProps[propName] = wrapEventHandler(propValue);
1187 }
1188 }
1189 return copiedProps;
1190 }
1191 function mutablyMergeInto(mergedProps, externalProps) {
1192 if (!externalProps) {
1193 return mergedProps;
1194 }
1195 for (const propName in externalProps) {
1196 const externalPropValue = externalProps[propName];
1197 switch (propName) {
1198 case "style": {
1199 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1200 break;
1201 }
1202 case "className": {
1203 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1204 break;
1205 }
1206 default: {
1207 if (isEventHandler(propName, externalPropValue)) {
1208 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1209 } else {
1210 mergedProps[propName] = externalPropValue;
1211 }
1212 }
1213 }
1214 }
1215 return mergedProps;
1216 }
1217 function isEventHandler(key2, value) {
1218 const code0 = key2.charCodeAt(0);
1219 const code1 = key2.charCodeAt(1);
1220 const code2 = key2.charCodeAt(2);
1221 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1222 }
1223 function isPropsGetter(inputProps) {
1224 return typeof inputProps === "function";
1225 }
1226 function resolvePropsGetter(inputProps, previousProps) {
1227 if (isPropsGetter(inputProps)) {
1228 return inputProps(previousProps);
1229 }
1230 return inputProps ?? EMPTY_PROPS;
1231 }
1232 function mergeEventHandlers(ourHandler, theirHandler) {
1233 if (!theirHandler) {
1234 return ourHandler;
1235 }
1236 if (!ourHandler) {
1237 return wrapEventHandler(theirHandler);
1238 }
1239 return (...args) => {
1240 const event = args[0];
1241 if (isSyntheticEvent(event)) {
1242 const baseUIEvent = event;
1243 makeEventPreventable(baseUIEvent);
1244 const result2 = theirHandler(...args);
1245 if (!baseUIEvent.baseUIHandlerPrevented) {
1246 ourHandler?.(...args);
1247 }
1248 return result2;
1249 }
1250 const result = theirHandler(...args);
1251 ourHandler?.(...args);
1252 return result;
1253 };
1254 }
1255 function wrapEventHandler(handler) {
1256 if (!handler) {
1257 return handler;
1258 }
1259 return (...args) => {
1260 const event = args[0];
1261 if (isSyntheticEvent(event)) {
1262 makeEventPreventable(event);
1263 }
1264 return handler(...args);
1265 };
1266 }
1267 function makeEventPreventable(event) {
1268 event.preventBaseUIHandler = () => {
1269 event.baseUIHandlerPrevented = true;
1270 };
1271 return event;
1272 }
1273 function mergeClassNames(ourClassName, theirClassName) {
1274 if (theirClassName) {
1275 if (ourClassName) {
1276 return theirClassName + " " + ourClassName;
1277 }
1278 return theirClassName;
1279 }
1280 return ourClassName;
1281 }
1282 function isSyntheticEvent(event) {
1283 return event != null && typeof event === "object" && "nativeEvent" in event;
1284 }
1285
1286 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1287 var import_react = __toESM(require_react(), 1);
1288 function useRenderElement(element, componentProps, params = {}) {
1289 const renderProp = componentProps.render;
1290 const outProps = useRenderElementProps(componentProps, params);
1291 if (params.enabled === false) {
1292 return null;
1293 }
1294 const state = params.state ?? EMPTY_OBJECT;
1295 return evaluateRenderProp(element, renderProp, outProps, state);
1296 }
1297 function useRenderElementProps(componentProps, params = {}) {
1298 const {
1299 className: classNameProp,
1300 style: styleProp,
1301 render: renderProp
1302 } = componentProps;
1303 const {
1304 state = EMPTY_OBJECT,
1305 ref,
1306 props,
1307 stateAttributesMapping: stateAttributesMapping6,
1308 enabled = true
1309 } = params;
1310 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1311 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1312 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping6) : EMPTY_OBJECT;
1313 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1314 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1315 if (typeof document !== "undefined") {
1316 if (!enabled) {
1317 useMergedRefs(null, null);
1318 } else if (Array.isArray(ref)) {
1319 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1320 } else {
1321 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1322 }
1323 }
1324 if (!enabled) {
1325 return EMPTY_OBJECT;
1326 }
1327 if (className !== void 0) {
1328 outProps.className = mergeClassNames(outProps.className, className);
1329 }
1330 if (style !== void 0) {
1331 outProps.style = mergeObjects(outProps.style, style);
1332 }
1333 return outProps;
1334 }
1335 function resolveRenderFunctionProps(props) {
1336 if (Array.isArray(props)) {
1337 return mergePropsN(props);
1338 }
1339 return mergeProps(void 0, props);
1340 }
1341 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1342 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1343 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1344 function evaluateRenderProp(element, render4, props, state) {
1345 if (render4) {
1346 if (typeof render4 === "function") {
1347 if (true) {
1348 warnIfRenderPropLooksLikeComponent(render4);
1349 }
1350 return render4(props, state);
1351 }
1352 const mergedProps = mergeProps(props, render4.props);
1353 mergedProps.ref = props.ref;
1354 let newElement = render4;
1355 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1356 const children = React7.Children.toArray(render4);
1357 newElement = children[0];
1358 }
1359 if (true) {
1360 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1361 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"));
1362 }
1363 }
1364 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1365 }
1366 if (element) {
1367 if (typeof element === "string") {
1368 return renderTag(element, props);
1369 }
1370 }
1371 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1372 }
1373 function warnIfRenderPropLooksLikeComponent(renderFn) {
1374 const functionName = renderFn.name;
1375 if (functionName.length === 0) {
1376 return;
1377 }
1378 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1379 return;
1380 }
1381 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1382 return;
1383 }
1384 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");
1385 }
1386 function renderTag(Tag, props) {
1387 if (Tag === "button") {
1388 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1389 type: "button",
1390 ...props,
1391 key: props.key
1392 });
1393 }
1394 if (Tag === "img") {
1395 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1396 alt: "",
1397 ...props,
1398 key: props.key
1399 });
1400 }
1401 return /* @__PURE__ */ React7.createElement(Tag, props);
1402 }
1403
1404 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1405 var reason_parts_exports = {};
1406 __export(reason_parts_exports, {
1407 cancelOpen: () => cancelOpen,
1408 chipRemovePress: () => chipRemovePress,
1409 clearPress: () => clearPress,
1410 closePress: () => closePress,
1411 closeWatcher: () => closeWatcher,
1412 decrementPress: () => decrementPress,
1413 disabled: () => disabled,
1414 drag: () => drag,
1415 escapeKey: () => escapeKey,
1416 focusOut: () => focusOut,
1417 imperativeAction: () => imperativeAction,
1418 incrementPress: () => incrementPress,
1419 inputBlur: () => inputBlur,
1420 inputChange: () => inputChange,
1421 inputClear: () => inputClear,
1422 inputPaste: () => inputPaste,
1423 inputPress: () => inputPress,
1424 itemPress: () => itemPress,
1425 keyboard: () => keyboard,
1426 linkPress: () => linkPress,
1427 listNavigation: () => listNavigation,
1428 none: () => none,
1429 outsidePress: () => outsidePress,
1430 pointer: () => pointer,
1431 scrub: () => scrub,
1432 siblingOpen: () => siblingOpen,
1433 swipe: () => swipe,
1434 trackPress: () => trackPress,
1435 triggerFocus: () => triggerFocus,
1436 triggerHover: () => triggerHover,
1437 triggerPress: () => triggerPress,
1438 wheel: () => wheel,
1439 windowResize: () => windowResize
1440 });
1441 var none = "none";
1442 var triggerPress = "trigger-press";
1443 var triggerHover = "trigger-hover";
1444 var triggerFocus = "trigger-focus";
1445 var outsidePress = "outside-press";
1446 var itemPress = "item-press";
1447 var closePress = "close-press";
1448 var linkPress = "link-press";
1449 var clearPress = "clear-press";
1450 var chipRemovePress = "chip-remove-press";
1451 var trackPress = "track-press";
1452 var incrementPress = "increment-press";
1453 var decrementPress = "decrement-press";
1454 var inputChange = "input-change";
1455 var inputClear = "input-clear";
1456 var inputBlur = "input-blur";
1457 var inputPaste = "input-paste";
1458 var inputPress = "input-press";
1459 var focusOut = "focus-out";
1460 var escapeKey = "escape-key";
1461 var closeWatcher = "close-watcher";
1462 var listNavigation = "list-navigation";
1463 var keyboard = "keyboard";
1464 var pointer = "pointer";
1465 var drag = "drag";
1466 var wheel = "wheel";
1467 var scrub = "scrub";
1468 var cancelOpen = "cancel-open";
1469 var siblingOpen = "sibling-open";
1470 var disabled = "disabled";
1471 var imperativeAction = "imperative-action";
1472 var swipe = "swipe";
1473 var windowResize = "window-resize";
1474
1475 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1476 function createChangeEventDetails(reason, event, trigger, customProperties) {
1477 let canceled = false;
1478 let allowPropagation = false;
1479 const custom = customProperties ?? EMPTY_OBJECT;
1480 const details = {
1481 reason,
1482 event: event ?? new Event("base-ui"),
1483 cancel() {
1484 canceled = true;
1485 },
1486 allowPropagation() {
1487 allowPropagation = true;
1488 },
1489 get isCanceled() {
1490 return canceled;
1491 },
1492 get isPropagationAllowed() {
1493 return allowPropagation;
1494 },
1495 trigger,
1496 ...custom
1497 };
1498 return details;
1499 }
1500
1501 // node_modules/@base-ui/utils/esm/useId.js
1502 var React9 = __toESM(require_react(), 1);
1503
1504 // node_modules/@base-ui/utils/esm/safeReact.js
1505 var React8 = __toESM(require_react(), 1);
1506 var SafeReact = {
1507 ...React8
1508 };
1509
1510 // node_modules/@base-ui/utils/esm/useId.js
1511 var globalId = 0;
1512 function useGlobalId(idOverride, prefix = "mui") {
1513 const [defaultId, setDefaultId] = React9.useState(idOverride);
1514 const id = idOverride || defaultId;
1515 React9.useEffect(() => {
1516 if (defaultId == null) {
1517 globalId += 1;
1518 setDefaultId(`${prefix}-${globalId}`);
1519 }
1520 }, [defaultId, prefix]);
1521 return id;
1522 }
1523 var maybeReactUseId = SafeReact.useId;
1524 function useId(idOverride, prefix) {
1525 if (maybeReactUseId !== void 0) {
1526 const reactId = maybeReactUseId();
1527 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1528 }
1529 return useGlobalId(idOverride, prefix);
1530 }
1531
1532 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1533 function useBaseUiId(idOverride) {
1534 return useId(idOverride, "base-ui");
1535 }
1536
1537 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1538 var ReactDOM = __toESM(require_react_dom(), 1);
1539
1540 // node_modules/@base-ui/utils/esm/useOnMount.js
1541 var React10 = __toESM(require_react(), 1);
1542 var EMPTY = [];
1543 function useOnMount(fn) {
1544 React10.useEffect(fn, EMPTY);
1545 }
1546
1547 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1548 var EMPTY2 = null;
1549 var LAST_RAF = globalThis.requestAnimationFrame;
1550 var Scheduler = class {
1551 /* This implementation uses an array as a backing data-structure for frame callbacks.
1552 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1553 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1554 * be much more efficient if there is a call pattern that alterns as
1555 * "request-cancel-request-cancel-…".
1556 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1557 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1558 callbacks = [];
1559 callbacksCount = 0;
1560 nextId = 1;
1561 startId = 1;
1562 isScheduled = false;
1563 tick = (timestamp) => {
1564 this.isScheduled = false;
1565 const currentCallbacks = this.callbacks;
1566 const currentCallbacksCount = this.callbacksCount;
1567 this.callbacks = [];
1568 this.callbacksCount = 0;
1569 this.startId = this.nextId;
1570 if (currentCallbacksCount > 0) {
1571 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1572 currentCallbacks[i2]?.(timestamp);
1573 }
1574 }
1575 };
1576 request(fn) {
1577 const id = this.nextId;
1578 this.nextId += 1;
1579 this.callbacks.push(fn);
1580 this.callbacksCount += 1;
1581 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1582 if (!this.isScheduled || didRAFChange) {
1583 requestAnimationFrame(this.tick);
1584 this.isScheduled = true;
1585 }
1586 return id;
1587 }
1588 cancel(id) {
1589 const index2 = id - this.startId;
1590 if (index2 < 0 || index2 >= this.callbacks.length) {
1591 return;
1592 }
1593 this.callbacks[index2] = null;
1594 this.callbacksCount -= 1;
1595 }
1596 };
1597 var scheduler = new Scheduler();
1598 var AnimationFrame = class _AnimationFrame {
1599 static create() {
1600 return new _AnimationFrame();
1601 }
1602 static request(fn) {
1603 return scheduler.request(fn);
1604 }
1605 static cancel(id) {
1606 return scheduler.cancel(id);
1607 }
1608 currentId = EMPTY2;
1609 /**
1610 * Executes `fn` after `delay`, clearing any previously scheduled call.
1611 */
1612 request(fn) {
1613 this.cancel();
1614 this.currentId = scheduler.request(() => {
1615 this.currentId = EMPTY2;
1616 fn();
1617 });
1618 }
1619 cancel = () => {
1620 if (this.currentId !== EMPTY2) {
1621 scheduler.cancel(this.currentId);
1622 this.currentId = EMPTY2;
1623 }
1624 };
1625 disposeEffect = () => {
1626 return this.cancel;
1627 };
1628 };
1629 function useAnimationFrame() {
1630 const timeout = useRefWithInit(AnimationFrame.create).current;
1631 useOnMount(timeout.disposeEffect);
1632 return timeout;
1633 }
1634
1635 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1636 function resolveRef(maybeRef) {
1637 if (maybeRef == null) {
1638 return maybeRef;
1639 }
1640 return "current" in maybeRef ? maybeRef.current : maybeRef;
1641 }
1642
1643 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1644 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1645 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1646 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1647 return TransitionStatusDataAttributes2;
1648 })({});
1649 var STARTING_HOOK = {
1650 [TransitionStatusDataAttributes.startingStyle]: ""
1651 };
1652 var ENDING_HOOK = {
1653 [TransitionStatusDataAttributes.endingStyle]: ""
1654 };
1655 var transitionStatusMapping = {
1656 transitionStatus(value) {
1657 if (value === "starting") {
1658 return STARTING_HOOK;
1659 }
1660 if (value === "ending") {
1661 return ENDING_HOOK;
1662 }
1663 return null;
1664 }
1665 };
1666
1667 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1668 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1669 const frame = useAnimationFrame();
1670 return useStableCallback((fnToExecute, signal = null) => {
1671 frame.cancel();
1672 const element = resolveRef(elementOrRef);
1673 if (element == null) {
1674 return;
1675 }
1676 const resolvedElement = element;
1677 const done = () => {
1678 ReactDOM.flushSync(fnToExecute);
1679 };
1680 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1681 fnToExecute();
1682 return;
1683 }
1684 function exec() {
1685 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1686 if (!signal?.aborted) {
1687 done();
1688 }
1689 }).catch(() => {
1690 if (treatAbortedAsFinished) {
1691 if (!signal?.aborted) {
1692 done();
1693 }
1694 return;
1695 }
1696 const currentAnimations = resolvedElement.getAnimations();
1697 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1698 exec();
1699 }
1700 });
1701 }
1702 if (waitForStartingStyleRemoved) {
1703 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1704 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1705 frame.request(exec);
1706 return;
1707 }
1708 const attributeObserver = new MutationObserver(() => {
1709 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1710 attributeObserver.disconnect();
1711 exec();
1712 }
1713 });
1714 attributeObserver.observe(resolvedElement, {
1715 attributes: true,
1716 attributeFilter: [startingStyleAttribute]
1717 });
1718 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1719 once: true
1720 });
1721 return;
1722 }
1723 frame.request(exec);
1724 });
1725 }
1726
1727 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1728 var React11 = __toESM(require_react(), 1);
1729 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1730 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1731 const [mounted, setMounted] = React11.useState(open);
1732 if (open && !mounted) {
1733 setMounted(true);
1734 setTransitionStatus("starting");
1735 }
1736 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1737 setTransitionStatus("ending");
1738 }
1739 if (!open && !mounted && transitionStatus === "ending") {
1740 setTransitionStatus(void 0);
1741 }
1742 useIsoLayoutEffect(() => {
1743 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1744 const frame = AnimationFrame.request(() => {
1745 setTransitionStatus("ending");
1746 });
1747 return () => {
1748 AnimationFrame.cancel(frame);
1749 };
1750 }
1751 return void 0;
1752 }, [open, mounted, transitionStatus, deferEndingState]);
1753 useIsoLayoutEffect(() => {
1754 if (!open || enableIdleState) {
1755 return void 0;
1756 }
1757 const frame = AnimationFrame.request(() => {
1758 setTransitionStatus(void 0);
1759 });
1760 return () => {
1761 AnimationFrame.cancel(frame);
1762 };
1763 }, [enableIdleState, open]);
1764 useIsoLayoutEffect(() => {
1765 if (!open || !enableIdleState) {
1766 return void 0;
1767 }
1768 if (open && mounted && transitionStatus !== "idle") {
1769 setTransitionStatus("starting");
1770 }
1771 const frame = AnimationFrame.request(() => {
1772 setTransitionStatus("idle");
1773 });
1774 return () => {
1775 AnimationFrame.cancel(frame);
1776 };
1777 }, [enableIdleState, open, mounted, transitionStatus]);
1778 return {
1779 mounted,
1780 setMounted,
1781 transitionStatus
1782 };
1783 }
1784
1785 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
1786 var React14 = __toESM(require_react(), 1);
1787
1788 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1789 function hasWindow() {
1790 return typeof window !== "undefined";
1791 }
1792 function getNodeName(node) {
1793 if (isNode(node)) {
1794 return (node.nodeName || "").toLowerCase();
1795 }
1796 return "#document";
1797 }
1798 function getWindow(node) {
1799 var _node$ownerDocument;
1800 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1801 }
1802 function getDocumentElement(node) {
1803 var _ref;
1804 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1805 }
1806 function isNode(value) {
1807 if (!hasWindow()) {
1808 return false;
1809 }
1810 return value instanceof Node || value instanceof getWindow(value).Node;
1811 }
1812 function isElement(value) {
1813 if (!hasWindow()) {
1814 return false;
1815 }
1816 return value instanceof Element || value instanceof getWindow(value).Element;
1817 }
1818 function isHTMLElement(value) {
1819 if (!hasWindow()) {
1820 return false;
1821 }
1822 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1823 }
1824 function isShadowRoot(value) {
1825 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1826 return false;
1827 }
1828 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1829 }
1830 function isOverflowElement(element) {
1831 const {
1832 overflow,
1833 overflowX,
1834 overflowY,
1835 display
1836 } = getComputedStyle2(element);
1837 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1838 }
1839 function isTableElement(element) {
1840 return /^(table|td|th)$/.test(getNodeName(element));
1841 }
1842 function isTopLayer(element) {
1843 try {
1844 if (element.matches(":popover-open")) {
1845 return true;
1846 }
1847 } catch (_e) {
1848 }
1849 try {
1850 return element.matches(":modal");
1851 } catch (_e) {
1852 return false;
1853 }
1854 }
1855 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1856 var containRe = /paint|layout|strict|content/;
1857 var isNotNone = (value) => !!value && value !== "none";
1858 var isWebKitValue;
1859 function isContainingBlock(elementOrCss) {
1860 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1861 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 || "");
1862 }
1863 function getContainingBlock(element) {
1864 let currentNode = getParentNode(element);
1865 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1866 if (isContainingBlock(currentNode)) {
1867 return currentNode;
1868 } else if (isTopLayer(currentNode)) {
1869 return null;
1870 }
1871 currentNode = getParentNode(currentNode);
1872 }
1873 return null;
1874 }
1875 function isWebKit() {
1876 if (isWebKitValue == null) {
1877 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1878 }
1879 return isWebKitValue;
1880 }
1881 function isLastTraversableNode(node) {
1882 return /^(html|body|#document)$/.test(getNodeName(node));
1883 }
1884 function getComputedStyle2(element) {
1885 return getWindow(element).getComputedStyle(element);
1886 }
1887 function getNodeScroll(element) {
1888 if (isElement(element)) {
1889 return {
1890 scrollLeft: element.scrollLeft,
1891 scrollTop: element.scrollTop
1892 };
1893 }
1894 return {
1895 scrollLeft: element.scrollX,
1896 scrollTop: element.scrollY
1897 };
1898 }
1899 function getParentNode(node) {
1900 if (getNodeName(node) === "html") {
1901 return node;
1902 }
1903 const result = (
1904 // Step into the shadow DOM of the parent of a slotted node.
1905 node.assignedSlot || // DOM Element detected.
1906 node.parentNode || // ShadowRoot detected.
1907 isShadowRoot(node) && node.host || // Fallback.
1908 getDocumentElement(node)
1909 );
1910 return isShadowRoot(result) ? result.host : result;
1911 }
1912 function getNearestOverflowAncestor(node) {
1913 const parentNode = getParentNode(node);
1914 if (isLastTraversableNode(parentNode)) {
1915 return node.ownerDocument ? node.ownerDocument.body : node.body;
1916 }
1917 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1918 return parentNode;
1919 }
1920 return getNearestOverflowAncestor(parentNode);
1921 }
1922 function getOverflowAncestors(node, list, traverseIframes) {
1923 var _node$ownerDocument2;
1924 if (list === void 0) {
1925 list = [];
1926 }
1927 if (traverseIframes === void 0) {
1928 traverseIframes = true;
1929 }
1930 const scrollableAncestor = getNearestOverflowAncestor(node);
1931 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1932 const win = getWindow(scrollableAncestor);
1933 if (isBody) {
1934 const frameElement = getFrameElement(win);
1935 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1936 } else {
1937 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1938 }
1939 }
1940 function getFrameElement(win) {
1941 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1942 }
1943
1944 // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js
1945 var React12 = __toESM(require_react(), 1);
1946 var CompositeRootContext = /* @__PURE__ */ React12.createContext(void 0);
1947 if (true) CompositeRootContext.displayName = "CompositeRootContext";
1948 function useCompositeRootContext(optional = false) {
1949 const context = React12.useContext(CompositeRootContext);
1950 if (context === void 0 && !optional) {
1951 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
1952 }
1953 return context;
1954 }
1955
1956 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js
1957 var React13 = __toESM(require_react(), 1);
1958 function useFocusableWhenDisabled(parameters) {
1959 const {
1960 focusableWhenDisabled,
1961 disabled: disabled2,
1962 composite = false,
1963 tabIndex: tabIndexProp = 0,
1964 isNativeButton
1965 } = parameters;
1966 const isFocusableComposite = composite && focusableWhenDisabled !== false;
1967 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
1968 const props = React13.useMemo(() => {
1969 const additionalProps = {
1970 // allow Tabbing away from focusableWhenDisabled elements
1971 onKeyDown(event) {
1972 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
1973 event.preventDefault();
1974 }
1975 }
1976 };
1977 if (!composite) {
1978 additionalProps.tabIndex = tabIndexProp;
1979 if (!isNativeButton && disabled2) {
1980 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
1981 }
1982 }
1983 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
1984 additionalProps["aria-disabled"] = disabled2;
1985 }
1986 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
1987 additionalProps.disabled = disabled2;
1988 }
1989 return additionalProps;
1990 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
1991 return {
1992 props
1993 };
1994 }
1995
1996 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
1997 function useButton(parameters = {}) {
1998 const {
1999 disabled: disabled2 = false,
2000 focusableWhenDisabled,
2001 tabIndex = 0,
2002 native: isNativeButton = true,
2003 composite: compositeProp
2004 } = parameters;
2005 const elementRef = React14.useRef(null);
2006 const compositeRootContext = useCompositeRootContext(true);
2007 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2008 const {
2009 props: focusableWhenDisabledProps
2010 } = useFocusableWhenDisabled({
2011 focusableWhenDisabled,
2012 disabled: disabled2,
2013 composite: isCompositeItem,
2014 tabIndex,
2015 isNativeButton
2016 });
2017 if (true) {
2018 React14.useEffect(() => {
2019 if (!elementRef.current) {
2020 return;
2021 }
2022 const isButtonTag = isButtonElement(elementRef.current);
2023 if (isNativeButton) {
2024 if (!isButtonTag) {
2025 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2026 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`.";
2027 error(`${message2}${ownerStackMessage}`);
2028 }
2029 } else if (isButtonTag) {
2030 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2031 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`.";
2032 error(`${message2}${ownerStackMessage}`);
2033 }
2034 }, [isNativeButton]);
2035 }
2036 const updateDisabled = React14.useCallback(() => {
2037 const element = elementRef.current;
2038 if (!isButtonElement(element)) {
2039 return;
2040 }
2041 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2042 element.disabled = false;
2043 }
2044 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2045 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2046 const getButtonProps = React14.useCallback((externalProps = {}) => {
2047 const {
2048 onClick: externalOnClick,
2049 onMouseDown: externalOnMouseDown,
2050 onKeyUp: externalOnKeyUp,
2051 onKeyDown: externalOnKeyDown,
2052 onPointerDown: externalOnPointerDown,
2053 ...otherExternalProps
2054 } = externalProps;
2055 const type = isNativeButton ? "button" : void 0;
2056 return mergeProps({
2057 type,
2058 onClick(event) {
2059 if (disabled2) {
2060 event.preventDefault();
2061 return;
2062 }
2063 externalOnClick?.(event);
2064 },
2065 onMouseDown(event) {
2066 if (!disabled2) {
2067 externalOnMouseDown?.(event);
2068 }
2069 },
2070 onKeyDown(event) {
2071 if (disabled2) {
2072 return;
2073 }
2074 makeEventPreventable(event);
2075 externalOnKeyDown?.(event);
2076 if (event.baseUIHandlerPrevented) {
2077 return;
2078 }
2079 const isCurrentTarget = event.target === event.currentTarget;
2080 const currentTarget = event.currentTarget;
2081 const isButton2 = isButtonElement(currentTarget);
2082 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2083 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2084 const isEnterKey = event.key === "Enter";
2085 const isSpaceKey = event.key === " ";
2086 const role = currentTarget.getAttribute("role");
2087 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2088 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2089 if (event.defaultPrevented && isTextNavigationRole) {
2090 return;
2091 }
2092 event.preventDefault();
2093 if (isLink || isNativeButton && isButton2) {
2094 currentTarget.click();
2095 event.preventBaseUIHandler();
2096 } else if (shouldClick) {
2097 externalOnClick?.(event);
2098 event.preventBaseUIHandler();
2099 }
2100 return;
2101 }
2102 if (shouldClick) {
2103 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2104 event.preventDefault();
2105 }
2106 if (!isNativeButton && isEnterKey) {
2107 externalOnClick?.(event);
2108 }
2109 }
2110 },
2111 onKeyUp(event) {
2112 if (disabled2) {
2113 return;
2114 }
2115 makeEventPreventable(event);
2116 externalOnKeyUp?.(event);
2117 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2118 event.preventDefault();
2119 return;
2120 }
2121 if (event.baseUIHandlerPrevented) {
2122 return;
2123 }
2124 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2125 externalOnClick?.(event);
2126 }
2127 },
2128 onPointerDown(event) {
2129 if (disabled2) {
2130 event.preventDefault();
2131 return;
2132 }
2133 externalOnPointerDown?.(event);
2134 }
2135 }, !isNativeButton ? {
2136 role: "button"
2137 } : void 0, focusableWhenDisabledProps, otherExternalProps);
2138 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2139 const buttonRef = useStableCallback((element) => {
2140 elementRef.current = element;
2141 updateDisabled();
2142 });
2143 return {
2144 getButtonProps,
2145 buttonRef
2146 };
2147 }
2148 function isButtonElement(elem) {
2149 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2150 }
2151 function isValidLinkElement(elem) {
2152 return Boolean(elem?.tagName === "A" && elem?.href);
2153 }
2154
2155 // node_modules/@base-ui/utils/esm/detectBrowser.js
2156 var hasNavigator = typeof navigator !== "undefined";
2157 var nav = getNavigatorData();
2158 var platform = getPlatform();
2159 var userAgent = getUserAgent();
2160 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2161 var isIOS = (
2162 // iPads can claim to be MacIntel
2163 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2164 );
2165 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2166 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2167 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2168 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2169 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2170 var isJSDOM = userAgent.includes("jsdom/");
2171 function getNavigatorData() {
2172 if (!hasNavigator) {
2173 return {
2174 platform: "",
2175 maxTouchPoints: -1
2176 };
2177 }
2178 const uaData = navigator.userAgentData;
2179 if (uaData?.platform) {
2180 return {
2181 platform: uaData.platform,
2182 maxTouchPoints: navigator.maxTouchPoints
2183 };
2184 }
2185 return {
2186 platform: navigator.platform ?? "",
2187 maxTouchPoints: navigator.maxTouchPoints ?? -1
2188 };
2189 }
2190 function getUserAgent() {
2191 if (!hasNavigator) {
2192 return "";
2193 }
2194 const uaData = navigator.userAgentData;
2195 if (uaData && Array.isArray(uaData.brands)) {
2196 return uaData.brands.map(({
2197 brand,
2198 version: version2
2199 }) => `${brand}/${version2}`).join(" ");
2200 }
2201 return navigator.userAgent;
2202 }
2203 function getPlatform() {
2204 if (!hasNavigator) {
2205 return "";
2206 }
2207 const uaData = navigator.userAgentData;
2208 if (uaData?.platform) {
2209 return uaData.platform;
2210 }
2211 return navigator.platform ?? "";
2212 }
2213
2214 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2215 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2216 var ACTIVE_KEY = "active";
2217 var SELECTED_KEY = "selected";
2218 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2219
2220 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2221 function activeElement(doc) {
2222 let element = doc.activeElement;
2223 while (element?.shadowRoot?.activeElement != null) {
2224 element = element.shadowRoot.activeElement;
2225 }
2226 return element;
2227 }
2228 function contains(parent, child) {
2229 if (!parent || !child) {
2230 return false;
2231 }
2232 const rootNode = child.getRootNode?.();
2233 if (parent.contains(child)) {
2234 return true;
2235 }
2236 if (rootNode && isShadowRoot(rootNode)) {
2237 let next = child;
2238 while (next) {
2239 if (parent === next) {
2240 return true;
2241 }
2242 next = next.parentNode || next.host;
2243 }
2244 }
2245 return false;
2246 }
2247 function getTarget(event) {
2248 if ("composedPath" in event) {
2249 return event.composedPath()[0];
2250 }
2251 return event.target;
2252 }
2253
2254 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2255 function isTargetInsideEnabledTrigger(target, triggerElements) {
2256 if (!isElement(target)) {
2257 return false;
2258 }
2259 const targetElement = target;
2260 if (triggerElements.hasElement(targetElement)) {
2261 return !targetElement.hasAttribute("data-trigger-disabled");
2262 }
2263 for (const [, trigger] of triggerElements.entries()) {
2264 if (contains(trigger, targetElement)) {
2265 return !trigger.hasAttribute("data-trigger-disabled");
2266 }
2267 }
2268 return false;
2269 }
2270 function isEventTargetWithin(event, node) {
2271 if (node == null) {
2272 return false;
2273 }
2274 if ("composedPath" in event) {
2275 return event.composedPath().includes(node);
2276 }
2277 const eventAgain = event;
2278 return eventAgain.target != null && node.contains(eventAgain.target);
2279 }
2280 function isRootElement(element) {
2281 return element.matches("html,body");
2282 }
2283 function isTypeableElement(element) {
2284 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2285 }
2286 function isInteractiveElement(element) {
2287 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2288 }
2289 function isTypeableCombobox(element) {
2290 if (!element) {
2291 return false;
2292 }
2293 return element.getAttribute("role") === "combobox" && isTypeableElement(element);
2294 }
2295 function matchesFocusVisible(element) {
2296 if (!element || isJSDOM) {
2297 return true;
2298 }
2299 try {
2300 return element.matches(":focus-visible");
2301 } catch (_e) {
2302 return true;
2303 }
2304 }
2305 function getFloatingFocusElement(floatingElement) {
2306 if (!floatingElement) {
2307 return null;
2308 }
2309 return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE) ? floatingElement : floatingElement.querySelector(`[${FOCUSABLE_ATTRIBUTE}]`) || floatingElement;
2310 }
2311
2312 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2313 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2314 const directChildren = nodes.filter((node) => node.parentId === id);
2315 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2316 }
2317 function getNodeAncestors(nodes, id) {
2318 let allAncestors = [];
2319 let currentParentId = nodes.find((node) => node.id === id)?.parentId;
2320 while (currentParentId) {
2321 const currentNode = nodes.find((node) => node.id === currentParentId);
2322 currentParentId = currentNode?.parentId;
2323 if (currentNode) {
2324 allAncestors = allAncestors.concat(currentNode);
2325 }
2326 }
2327 return allAncestors;
2328 }
2329
2330 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2331 function stopEvent(event) {
2332 event.preventDefault();
2333 event.stopPropagation();
2334 }
2335 function isReactEvent(event) {
2336 return "nativeEvent" in event;
2337 }
2338 function isVirtualClick(event) {
2339 if (event.pointerType === "" && event.isTrusted) {
2340 return true;
2341 }
2342 if (isAndroid && event.pointerType) {
2343 return event.type === "click" && event.buttons === 1;
2344 }
2345 return event.detail === 0 && !event.pointerType;
2346 }
2347 function isVirtualPointerEvent(event) {
2348 if (isJSDOM) {
2349 return false;
2350 }
2351 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.
2352 event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
2353 }
2354 function isMouseLikePointerType(pointerType, strict) {
2355 const values = ["mouse", "pen"];
2356 if (!strict) {
2357 values.push("", void 0);
2358 }
2359 return values.includes(pointerType);
2360 }
2361 function isClickLikeEvent(event) {
2362 const type = event.type;
2363 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2364 }
2365
2366 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2367 var sides = ["top", "right", "bottom", "left"];
2368 var min = Math.min;
2369 var max = Math.max;
2370 var round = Math.round;
2371 var floor = Math.floor;
2372 var createCoords = (v2) => ({
2373 x: v2,
2374 y: v2
2375 });
2376 var oppositeSideMap = {
2377 left: "right",
2378 right: "left",
2379 bottom: "top",
2380 top: "bottom"
2381 };
2382 function clamp(start, value, end) {
2383 return max(start, min(value, end));
2384 }
2385 function evaluate(value, param) {
2386 return typeof value === "function" ? value(param) : value;
2387 }
2388 function getSide(placement) {
2389 return placement.split("-")[0];
2390 }
2391 function getAlignment(placement) {
2392 return placement.split("-")[1];
2393 }
2394 function getOppositeAxis(axis) {
2395 return axis === "x" ? "y" : "x";
2396 }
2397 function getAxisLength(axis) {
2398 return axis === "y" ? "height" : "width";
2399 }
2400 function getSideAxis(placement) {
2401 const firstChar = placement[0];
2402 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2403 }
2404 function getAlignmentAxis(placement) {
2405 return getOppositeAxis(getSideAxis(placement));
2406 }
2407 function getAlignmentSides(placement, rects, rtl) {
2408 if (rtl === void 0) {
2409 rtl = false;
2410 }
2411 const alignment = getAlignment(placement);
2412 const alignmentAxis = getAlignmentAxis(placement);
2413 const length = getAxisLength(alignmentAxis);
2414 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2415 if (rects.reference[length] > rects.floating[length]) {
2416 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2417 }
2418 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2419 }
2420 function getExpandedPlacements(placement) {
2421 const oppositePlacement = getOppositePlacement(placement);
2422 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2423 }
2424 function getOppositeAlignmentPlacement(placement) {
2425 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2426 }
2427 var lrPlacement = ["left", "right"];
2428 var rlPlacement = ["right", "left"];
2429 var tbPlacement = ["top", "bottom"];
2430 var btPlacement = ["bottom", "top"];
2431 function getSideList(side, isStart, rtl) {
2432 switch (side) {
2433 case "top":
2434 case "bottom":
2435 if (rtl) return isStart ? rlPlacement : lrPlacement;
2436 return isStart ? lrPlacement : rlPlacement;
2437 case "left":
2438 case "right":
2439 return isStart ? tbPlacement : btPlacement;
2440 default:
2441 return [];
2442 }
2443 }
2444 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2445 const alignment = getAlignment(placement);
2446 let list = getSideList(getSide(placement), direction === "start", rtl);
2447 if (alignment) {
2448 list = list.map((side) => side + "-" + alignment);
2449 if (flipAlignment) {
2450 list = list.concat(list.map(getOppositeAlignmentPlacement));
2451 }
2452 }
2453 return list;
2454 }
2455 function getOppositePlacement(placement) {
2456 const side = getSide(placement);
2457 return oppositeSideMap[side] + placement.slice(side.length);
2458 }
2459 function expandPaddingObject(padding) {
2460 return {
2461 top: 0,
2462 right: 0,
2463 bottom: 0,
2464 left: 0,
2465 ...padding
2466 };
2467 }
2468 function getPaddingObject(padding) {
2469 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2470 top: padding,
2471 right: padding,
2472 bottom: padding,
2473 left: padding
2474 };
2475 }
2476 function rectToClientRect(rect) {
2477 const {
2478 x: x2,
2479 y: y2,
2480 width,
2481 height
2482 } = rect;
2483 return {
2484 width,
2485 height,
2486 top: y2,
2487 left: x2,
2488 right: x2 + width,
2489 bottom: y2 + height,
2490 x: x2,
2491 y: y2
2492 };
2493 }
2494
2495 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2496 function isHiddenByStyles(styles) {
2497 return styles.visibility === "hidden" || styles.visibility === "collapse";
2498 }
2499 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2500 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2501 return false;
2502 }
2503 if (typeof element.checkVisibility === "function") {
2504 return element.checkVisibility();
2505 }
2506 return styles.display !== "none" && styles.display !== "contents";
2507 }
2508
2509 // node_modules/@base-ui/utils/esm/owner.js
2510 function ownerDocument(node) {
2511 return node?.ownerDocument || document;
2512 }
2513
2514 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2515 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2516 function getParentElement(element) {
2517 const assignedSlot = element.assignedSlot;
2518 if (assignedSlot) {
2519 return assignedSlot;
2520 }
2521 if (element.parentElement) {
2522 return element.parentElement;
2523 }
2524 const rootNode = element.getRootNode();
2525 return isShadowRoot(rootNode) ? rootNode.host : null;
2526 }
2527 function getDetailsSummary(details) {
2528 for (const child of Array.from(details.children)) {
2529 if (getNodeName(child) === "summary") {
2530 return child;
2531 }
2532 }
2533 return null;
2534 }
2535 function isWithinOpenDetailsSummary(element, details) {
2536 const summary = getDetailsSummary(details);
2537 return !!summary && (element === summary || contains(summary, element));
2538 }
2539 function isFocusableCandidate(element) {
2540 const nodeName = element ? getNodeName(element) : "";
2541 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");
2542 }
2543 function isFocusableElement(element) {
2544 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2545 return false;
2546 }
2547 for (let current = element; current; current = getParentElement(current)) {
2548 const isAncestor = current !== element;
2549 const isSlot = getNodeName(current) === "slot";
2550 if (current.hasAttribute("inert")) {
2551 return false;
2552 }
2553 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2554 return false;
2555 }
2556 }
2557 return true;
2558 }
2559 function isVisibleInTabbableTree(element, isAncestor) {
2560 const styles = getComputedStyle2(element);
2561 if (!isAncestor) {
2562 return isElementVisible(element, styles);
2563 }
2564 return styles.display !== "none";
2565 }
2566 function getTabIndex(element) {
2567 const tabIndex = element.tabIndex;
2568 if (tabIndex < 0) {
2569 const nodeName = getNodeName(element);
2570 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2571 return 0;
2572 }
2573 }
2574 return tabIndex;
2575 }
2576 function getNamedRadioInput(element) {
2577 if (getNodeName(element) !== "input") {
2578 return null;
2579 }
2580 const input = element;
2581 return input.type === "radio" && input.name !== "" ? input : null;
2582 }
2583 function isTabbableRadio(element, candidates) {
2584 const input = getNamedRadioInput(element);
2585 if (!input) {
2586 return true;
2587 }
2588 const checkedRadio = candidates.find((candidate) => {
2589 const radio = getNamedRadioInput(candidate);
2590 return radio?.name === input.name && radio.form === input.form && radio.checked;
2591 });
2592 if (checkedRadio) {
2593 return checkedRadio === input;
2594 }
2595 return candidates.find((candidate) => {
2596 const radio = getNamedRadioInput(candidate);
2597 return radio?.name === input.name && radio.form === input.form;
2598 }) === input;
2599 }
2600 function getComposedChildren(container) {
2601 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2602 const assignedElements = container.assignedElements({
2603 flatten: true
2604 });
2605 if (assignedElements.length > 0) {
2606 return assignedElements;
2607 }
2608 }
2609 if (isHTMLElement(container) && container.shadowRoot) {
2610 return Array.from(container.shadowRoot.children);
2611 }
2612 return Array.from(container.children);
2613 }
2614 function appendCandidates(container, list) {
2615 getComposedChildren(container).forEach((child) => {
2616 if (isFocusableCandidate(child)) {
2617 list.push(child);
2618 }
2619 appendCandidates(child, list);
2620 });
2621 }
2622 function appendMatchingElements(container, selector2, list) {
2623 getComposedChildren(container).forEach((child) => {
2624 if (isHTMLElement(child) && child.matches(selector2)) {
2625 list.push(child);
2626 }
2627 appendMatchingElements(child, selector2, list);
2628 });
2629 }
2630 function isTabbable(element) {
2631 return isFocusableElement(element) && getTabIndex(element) >= 0;
2632 }
2633 function focusable(container) {
2634 const candidates = [];
2635 appendCandidates(container, candidates);
2636 return candidates.filter(isFocusableElement);
2637 }
2638 function tabbable(container) {
2639 const candidates = focusable(container);
2640 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2641 }
2642 function getTabbableIn(container, dir) {
2643 const list = tabbable(container);
2644 const len = list.length;
2645 if (len === 0) {
2646 return void 0;
2647 }
2648 const active = activeElement(ownerDocument(container));
2649 const index2 = list.indexOf(active);
2650 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2651 return list[nextIndex];
2652 }
2653 function getNextTabbable(referenceElement) {
2654 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2655 }
2656 function getPreviousTabbable(referenceElement) {
2657 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2658 }
2659 function isOutsideEvent(event, container) {
2660 const containerElement = container || event.currentTarget;
2661 const relatedTarget = event.relatedTarget;
2662 return !relatedTarget || !contains(containerElement, relatedTarget);
2663 }
2664 function disableFocusInside(container) {
2665 const tabbableElements = tabbable(container);
2666 tabbableElements.forEach((element) => {
2667 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2668 element.setAttribute("tabindex", "-1");
2669 });
2670 }
2671 function enableFocusInside(container) {
2672 const elements = [];
2673 appendMatchingElements(container, "[data-tabindex]", elements);
2674 elements.forEach((element) => {
2675 const tabindex = element.dataset.tabindex;
2676 delete element.dataset.tabindex;
2677 if (tabindex) {
2678 element.setAttribute("tabindex", tabindex);
2679 } else {
2680 element.removeAttribute("tabindex");
2681 }
2682 });
2683 }
2684
2685 // node_modules/@base-ui/react/esm/internals/composite/composite.js
2686 var ARROW_UP = "ArrowUp";
2687 var ARROW_DOWN = "ArrowDown";
2688 var ARROW_LEFT = "ArrowLeft";
2689 var ARROW_RIGHT = "ArrowRight";
2690 var HOME = "Home";
2691 var END = "End";
2692 var HORIZONTAL_KEYS = /* @__PURE__ */ new Set([ARROW_LEFT, ARROW_RIGHT]);
2693 var VERTICAL_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN]);
2694 var ARROW_KEYS = /* @__PURE__ */ new Set([...HORIZONTAL_KEYS, ...VERTICAL_KEYS]);
2695 var ALL_KEYS = /* @__PURE__ */ new Set([...ARROW_KEYS, HOME, END]);
2696 var COMPOSITE_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END]);
2697
2698 // node_modules/@base-ui/utils/esm/addEventListener.js
2699 function addEventListener(target, type, listener, options) {
2700 target.addEventListener(type, listener, options);
2701 return () => {
2702 target.removeEventListener(type, listener, options);
2703 };
2704 }
2705
2706 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2707 var React15 = __toESM(require_react(), 1);
2708 function useOpenChangeComplete(parameters) {
2709 const {
2710 enabled = true,
2711 open,
2712 ref,
2713 onComplete: onCompleteParam
2714 } = parameters;
2715 const onComplete = useStableCallback(onCompleteParam);
2716 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2717 React15.useEffect(() => {
2718 if (!enabled) {
2719 return void 0;
2720 }
2721 const abortController = new AbortController();
2722 runOnceAnimationsFinish(onComplete, abortController.signal);
2723 return () => {
2724 abortController.abort();
2725 };
2726 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2727 }
2728
2729 // node_modules/@base-ui/react/esm/alert-dialog/index.parts.js
2730 var index_parts_exports = {};
2731 __export(index_parts_exports, {
2732 Backdrop: () => DialogBackdrop,
2733 Close: () => DialogClose,
2734 Description: () => DialogDescription,
2735 Handle: () => DialogHandle,
2736 Popup: () => DialogPopup,
2737 Portal: () => DialogPortal,
2738 Root: () => AlertDialogRoot,
2739 Title: () => DialogTitle,
2740 Trigger: () => DialogTrigger,
2741 Viewport: () => DialogViewport,
2742 createHandle: () => createAlertDialogHandle
2743 });
2744
2745 // node_modules/@base-ui/react/esm/alert-dialog/root/AlertDialogRoot.js
2746 var React43 = __toESM(require_react(), 1);
2747
2748 // node_modules/@base-ui/react/esm/dialog/root/DialogRoot.js
2749 var React42 = __toESM(require_react(), 1);
2750
2751 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2752 var React16 = __toESM(require_react(), 1);
2753 function useOnFirstRender(fn) {
2754 const ref = React16.useRef(true);
2755 if (ref.current) {
2756 ref.current = false;
2757 fn();
2758 }
2759 }
2760
2761 // node_modules/@base-ui/react/esm/dialog/root/useDialogRoot.js
2762 var React39 = __toESM(require_react(), 1);
2763
2764 // node_modules/@base-ui/utils/esm/useTimeout.js
2765 var EMPTY3 = 0;
2766 var Timeout = class _Timeout {
2767 static create() {
2768 return new _Timeout();
2769 }
2770 currentId = EMPTY3;
2771 /**
2772 * Executes `fn` after `delay`, clearing any previously scheduled call.
2773 */
2774 start(delay, fn) {
2775 this.clear();
2776 this.currentId = setTimeout(() => {
2777 this.currentId = EMPTY3;
2778 fn();
2779 }, delay);
2780 }
2781 isStarted() {
2782 return this.currentId !== EMPTY3;
2783 }
2784 clear = () => {
2785 if (this.currentId !== EMPTY3) {
2786 clearTimeout(this.currentId);
2787 this.currentId = EMPTY3;
2788 }
2789 };
2790 disposeEffect = () => {
2791 return this.clear;
2792 };
2793 };
2794 function useTimeout() {
2795 const timeout = useRefWithInit(Timeout.create).current;
2796 useOnMount(timeout.disposeEffect);
2797 return timeout;
2798 }
2799
2800 // node_modules/@base-ui/utils/esm/useScrollLock.js
2801 var originalHtmlStyles = {};
2802 var originalBodyStyles = {};
2803 var originalHtmlScrollBehavior = "";
2804 function hasInsetScrollbars(referenceElement) {
2805 if (typeof document === "undefined") {
2806 return false;
2807 }
2808 const doc = ownerDocument(referenceElement);
2809 const win = getWindow(doc);
2810 return win.innerWidth - doc.documentElement.clientWidth > 0;
2811 }
2812 function supportsStableScrollbarGutter(referenceElement) {
2813 const supported = typeof CSS !== "undefined" && CSS.supports && CSS.supports("scrollbar-gutter", "stable");
2814 if (!supported || typeof document === "undefined") {
2815 return false;
2816 }
2817 const doc = ownerDocument(referenceElement);
2818 const html = doc.documentElement;
2819 const body = doc.body;
2820 const scrollContainer = isOverflowElement(html) ? html : body;
2821 const originalScrollContainerOverflowY = scrollContainer.style.overflowY;
2822 const originalHtmlStyleGutter = html.style.scrollbarGutter;
2823 html.style.scrollbarGutter = "stable";
2824 scrollContainer.style.overflowY = "scroll";
2825 const before = scrollContainer.offsetWidth;
2826 scrollContainer.style.overflowY = "hidden";
2827 const after = scrollContainer.offsetWidth;
2828 scrollContainer.style.overflowY = originalScrollContainerOverflowY;
2829 html.style.scrollbarGutter = originalHtmlStyleGutter;
2830 return before === after;
2831 }
2832 function preventScrollOverlayScrollbars(referenceElement) {
2833 const doc = ownerDocument(referenceElement);
2834 const html = doc.documentElement;
2835 const body = doc.body;
2836 const elementToLock = isOverflowElement(html) ? html : body;
2837 const originalElementToLockStyles = {
2838 overflowY: elementToLock.style.overflowY,
2839 overflowX: elementToLock.style.overflowX
2840 };
2841 Object.assign(elementToLock.style, {
2842 overflowY: "hidden",
2843 overflowX: "hidden"
2844 });
2845 return () => {
2846 Object.assign(elementToLock.style, originalElementToLockStyles);
2847 };
2848 }
2849 function preventScrollInsetScrollbars(referenceElement) {
2850 const doc = ownerDocument(referenceElement);
2851 const html = doc.documentElement;
2852 const body = doc.body;
2853 const win = getWindow(html);
2854 let scrollTop = 0;
2855 let scrollLeft = 0;
2856 let updateGutterOnly = false;
2857 const resizeFrame = AnimationFrame.create();
2858 if (isWebKit2 && (win.visualViewport?.scale ?? 1) !== 1) {
2859 return () => {
2860 };
2861 }
2862 function lockScroll() {
2863 const htmlStyles = win.getComputedStyle(html);
2864 const bodyStyles = win.getComputedStyle(body);
2865 const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || "";
2866 const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges");
2867 const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable";
2868 scrollTop = html.scrollTop;
2869 scrollLeft = html.scrollLeft;
2870 originalHtmlStyles = {
2871 scrollbarGutter: html.style.scrollbarGutter,
2872 overflowY: html.style.overflowY,
2873 overflowX: html.style.overflowX
2874 };
2875 originalHtmlScrollBehavior = html.style.scrollBehavior;
2876 originalBodyStyles = {
2877 position: body.style.position,
2878 height: body.style.height,
2879 width: body.style.width,
2880 boxSizing: body.style.boxSizing,
2881 overflowY: body.style.overflowY,
2882 overflowX: body.style.overflowX,
2883 scrollBehavior: body.style.scrollBehavior
2884 };
2885 const isScrollableY = html.scrollHeight > html.clientHeight;
2886 const isScrollableX = html.scrollWidth > html.clientWidth;
2887 const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll";
2888 const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll";
2889 const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth);
2890 const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight);
2891 const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);
2892 const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);
2893 const elementToLock = isOverflowElement(html) ? html : body;
2894 updateGutterOnly = supportsStableScrollbarGutter(referenceElement);
2895 if (updateGutterOnly) {
2896 html.style.scrollbarGutter = scrollbarGutterValue;
2897 elementToLock.style.overflowY = "hidden";
2898 elementToLock.style.overflowX = "hidden";
2899 return;
2900 }
2901 Object.assign(html.style, {
2902 scrollbarGutter: scrollbarGutterValue,
2903 overflowY: "hidden",
2904 overflowX: "hidden"
2905 });
2906 if (isScrollableY || hasConstantOverflowY) {
2907 html.style.overflowY = "scroll";
2908 }
2909 if (isScrollableX || hasConstantOverflowX) {
2910 html.style.overflowX = "scroll";
2911 }
2912 Object.assign(body.style, {
2913 position: "relative",
2914 height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : "100dvh",
2915 width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : "100vw",
2916 boxSizing: "border-box",
2917 overflow: "hidden",
2918 scrollBehavior: "unset"
2919 });
2920 body.scrollTop = scrollTop;
2921 body.scrollLeft = scrollLeft;
2922 html.setAttribute("data-base-ui-scroll-locked", "");
2923 html.style.scrollBehavior = "unset";
2924 }
2925 function cleanup() {
2926 Object.assign(html.style, originalHtmlStyles);
2927 Object.assign(body.style, originalBodyStyles);
2928 if (!updateGutterOnly) {
2929 html.scrollTop = scrollTop;
2930 html.scrollLeft = scrollLeft;
2931 html.removeAttribute("data-base-ui-scroll-locked");
2932 html.style.scrollBehavior = originalHtmlScrollBehavior;
2933 }
2934 }
2935 function handleResize() {
2936 cleanup();
2937 resizeFrame.request(lockScroll);
2938 }
2939 lockScroll();
2940 const unsubscribeResize = addEventListener(win, "resize", handleResize);
2941 return () => {
2942 resizeFrame.cancel();
2943 cleanup();
2944 if (typeof win.removeEventListener === "function") {
2945 unsubscribeResize();
2946 }
2947 };
2948 }
2949 var ScrollLocker = class {
2950 lockCount = 0;
2951 restore = null;
2952 timeoutLock = Timeout.create();
2953 timeoutUnlock = Timeout.create();
2954 acquire(referenceElement) {
2955 this.lockCount += 1;
2956 if (this.lockCount === 1 && this.restore === null) {
2957 this.timeoutLock.start(0, () => this.lock(referenceElement));
2958 }
2959 return this.release;
2960 }
2961 release = () => {
2962 this.lockCount -= 1;
2963 if (this.lockCount === 0 && this.restore) {
2964 this.timeoutUnlock.start(0, this.unlock);
2965 }
2966 };
2967 unlock = () => {
2968 if (this.lockCount === 0 && this.restore) {
2969 this.restore?.();
2970 this.restore = null;
2971 }
2972 };
2973 lock(referenceElement) {
2974 if (this.lockCount === 0 || this.restore !== null) {
2975 return;
2976 }
2977 const doc = ownerDocument(referenceElement);
2978 const html = doc.documentElement;
2979 const htmlOverflowY = getWindow(html).getComputedStyle(html).overflowY;
2980 if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") {
2981 this.restore = NOOP;
2982 return;
2983 }
2984 const hasOverlayScrollbars = isIOS || !hasInsetScrollbars(referenceElement);
2985 this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement);
2986 }
2987 };
2988 var SCROLL_LOCKER = new ScrollLocker();
2989 function useScrollLock(enabled = true, referenceElement = null) {
2990 useIsoLayoutEffect(() => {
2991 if (!enabled) {
2992 return void 0;
2993 }
2994 return SCROLL_LOCKER.acquire(referenceElement);
2995 }, [enabled, referenceElement]);
2996 }
2997
2998 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2999 var React17 = __toESM(require_react(), 1);
3000
3001 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
3002 function resolveValue(value, pointerType) {
3003 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3004 return 0;
3005 }
3006 if (typeof value === "function") {
3007 return value();
3008 }
3009 return value;
3010 }
3011 function getDelay(value, prop, pointerType) {
3012 const result = resolveValue(value, pointerType);
3013 if (typeof result === "number") {
3014 return result;
3015 }
3016 return result?.[prop];
3017 }
3018 function getRestMs(value) {
3019 if (typeof value === "function") {
3020 return value();
3021 }
3022 return value;
3023 }
3024 function isClickLikeOpenEvent(openEventType, interactedInside) {
3025 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3026 }
3027
3028 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3029 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
3030 var FloatingDelayGroupContext = /* @__PURE__ */ React17.createContext({
3031 hasProvider: false,
3032 timeoutMs: 0,
3033 delayRef: {
3034 current: 0
3035 },
3036 initialDelayRef: {
3037 current: 0
3038 },
3039 timeout: new Timeout(),
3040 currentIdRef: {
3041 current: null
3042 },
3043 currentContextRef: {
3044 current: null
3045 }
3046 });
3047 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3048 function FloatingDelayGroup(props) {
3049 const {
3050 children,
3051 delay,
3052 timeoutMs = 0
3053 } = props;
3054 const delayRef = React17.useRef(delay);
3055 const initialDelayRef = React17.useRef(delay);
3056 const currentIdRef = React17.useRef(null);
3057 const currentContextRef = React17.useRef(null);
3058 const timeout = useTimeout();
3059 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
3060 value: React17.useMemo(() => ({
3061 hasProvider: true,
3062 delayRef,
3063 initialDelayRef,
3064 currentIdRef,
3065 timeoutMs,
3066 currentContextRef,
3067 timeout
3068 }), [timeoutMs, timeout]),
3069 children
3070 });
3071 }
3072 function useDelayGroup(context, options = {
3073 open: false
3074 }) {
3075 const store = "rootStore" in context ? context.rootStore : context;
3076 const floatingId = store.useState("floatingId");
3077 const {
3078 open
3079 } = options;
3080 const groupContext = React17.useContext(FloatingDelayGroupContext);
3081 const {
3082 currentIdRef,
3083 delayRef,
3084 timeoutMs,
3085 initialDelayRef,
3086 currentContextRef,
3087 hasProvider,
3088 timeout
3089 } = groupContext;
3090 const [isInstantPhase, setIsInstantPhase] = React17.useState(false);
3091 useIsoLayoutEffect(() => {
3092 function unset() {
3093 setIsInstantPhase(false);
3094 currentContextRef.current?.setIsInstantPhase(false);
3095 currentIdRef.current = null;
3096 currentContextRef.current = null;
3097 delayRef.current = initialDelayRef.current;
3098 }
3099 if (!currentIdRef.current) {
3100 return void 0;
3101 }
3102 if (!open && currentIdRef.current === floatingId) {
3103 setIsInstantPhase(false);
3104 if (timeoutMs) {
3105 const closingId = floatingId;
3106 timeout.start(timeoutMs, () => {
3107 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3108 return;
3109 }
3110 unset();
3111 });
3112 return () => {
3113 timeout.clear();
3114 };
3115 }
3116 unset();
3117 }
3118 return void 0;
3119 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3120 useIsoLayoutEffect(() => {
3121 if (!open) {
3122 return;
3123 }
3124 const prevContext = currentContextRef.current;
3125 const prevId = currentIdRef.current;
3126 timeout.clear();
3127 currentContextRef.current = {
3128 onOpenChange: store.setOpen,
3129 setIsInstantPhase
3130 };
3131 currentIdRef.current = floatingId;
3132 delayRef.current = {
3133 open: 0,
3134 close: getDelay(initialDelayRef.current, "close")
3135 };
3136 if (prevId !== null && prevId !== floatingId) {
3137 setIsInstantPhase(true);
3138 prevContext?.setIsInstantPhase(true);
3139 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3140 } else {
3141 setIsInstantPhase(false);
3142 prevContext?.setIsInstantPhase(false);
3143 }
3144 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
3145 useIsoLayoutEffect(() => {
3146 return () => {
3147 currentContextRef.current = null;
3148 };
3149 }, [currentContextRef]);
3150 return React17.useMemo(() => ({
3151 hasProvider,
3152 delayRef,
3153 isInstantPhase
3154 }), [hasProvider, delayRef, isInstantPhase]);
3155 }
3156
3157 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingFocusManager.js
3158 var React21 = __toESM(require_react(), 1);
3159
3160 // node_modules/@base-ui/utils/esm/mergeCleanups.js
3161 function mergeCleanups(...cleanups) {
3162 return () => {
3163 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3164 const cleanup = cleanups[i2];
3165 if (cleanup) {
3166 cleanup();
3167 }
3168 }
3169 };
3170 }
3171
3172 // node_modules/@base-ui/utils/esm/useValueAsRef.js
3173 function useValueAsRef(value) {
3174 const latest = useRefWithInit(createLatestRef, value).current;
3175 latest.next = value;
3176 useIsoLayoutEffect(latest.effect);
3177 return latest;
3178 }
3179 function createLatestRef(value) {
3180 const latest = {
3181 current: value,
3182 next: value,
3183 effect: () => {
3184 latest.current = latest.next;
3185 }
3186 };
3187 return latest;
3188 }
3189
3190 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3191 var React18 = __toESM(require_react(), 1);
3192
3193 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3194 var visuallyHiddenBase = {
3195 clipPath: "inset(50%)",
3196 overflow: "hidden",
3197 whiteSpace: "nowrap",
3198 border: 0,
3199 padding: 0,
3200 width: 1,
3201 height: 1,
3202 margin: -1
3203 };
3204 var visuallyHidden = {
3205 ...visuallyHiddenBase,
3206 position: "fixed",
3207 top: 0,
3208 left: 0
3209 };
3210 var visuallyHiddenInput = {
3211 ...visuallyHiddenBase,
3212 position: "absolute"
3213 };
3214
3215 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3216 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3217 var FocusGuard = /* @__PURE__ */ React18.forwardRef(function FocusGuard2(props, ref) {
3218 const [role, setRole] = React18.useState();
3219 useIsoLayoutEffect(() => {
3220 if (isSafari) {
3221 setRole("button");
3222 }
3223 }, []);
3224 const restProps = {
3225 tabIndex: 0,
3226 // Role is only for VoiceOver
3227 role
3228 };
3229 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3230 ...props,
3231 ref,
3232 style: visuallyHidden,
3233 "aria-hidden": role ? void 0 : true,
3234 ...restProps,
3235 "data-base-ui-focus-guard": ""
3236 });
3237 });
3238 if (true) FocusGuard.displayName = "FocusGuard";
3239
3240 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3241 function createAttribute(name) {
3242 return `data-base-ui-${name}`;
3243 }
3244
3245 // node_modules/@base-ui/react/esm/floating-ui-react/utils/enqueueFocus.js
3246 var rafId = 0;
3247 function enqueueFocus(el, options = {}) {
3248 const {
3249 preventScroll = false,
3250 cancelPrevious = true,
3251 sync: sync2 = false
3252 } = options;
3253 if (cancelPrevious) {
3254 cancelAnimationFrame(rafId);
3255 }
3256 const exec = () => el?.focus({
3257 preventScroll
3258 });
3259 if (sync2) {
3260 exec();
3261 return NOOP;
3262 }
3263 const currentRafId = requestAnimationFrame(exec);
3264 rafId = currentRafId;
3265 return () => {
3266 if (rafId === currentRafId) {
3267 cancelAnimationFrame(currentRafId);
3268 rafId = 0;
3269 }
3270 };
3271 }
3272
3273 // node_modules/@base-ui/react/esm/floating-ui-react/utils/markOthers.js
3274 var counters = {
3275 inert: /* @__PURE__ */ new WeakMap(),
3276 "aria-hidden": /* @__PURE__ */ new WeakMap()
3277 };
3278 var markerName = "data-base-ui-inert";
3279 var uncontrolledElementsSets = {
3280 inert: /* @__PURE__ */ new WeakSet(),
3281 "aria-hidden": /* @__PURE__ */ new WeakSet()
3282 };
3283 var markerCounterMap = /* @__PURE__ */ new WeakMap();
3284 var lockCount = 0;
3285 function getUncontrolledElementsSet(controlAttribute) {
3286 return uncontrolledElementsSets[controlAttribute];
3287 }
3288 function unwrapHost(node) {
3289 if (!node) {
3290 return null;
3291 }
3292 return isShadowRoot(node) ? node.host : unwrapHost(node.parentNode);
3293 }
3294 var correctElements = (parent, targets) => targets.map((target) => {
3295 if (parent.contains(target)) {
3296 return target;
3297 }
3298 const correctedTarget = unwrapHost(target);
3299 if (parent.contains(correctedTarget)) {
3300 return correctedTarget;
3301 }
3302 return null;
3303 }).filter((x2) => x2 != null);
3304 var buildKeepSet = (targets) => {
3305 const keep = /* @__PURE__ */ new Set();
3306 targets.forEach((target) => {
3307 let node = target;
3308 while (node && !keep.has(node)) {
3309 keep.add(node);
3310 node = node.parentNode;
3311 }
3312 });
3313 return keep;
3314 };
3315 var collectOutsideElements = (root, keepElements, stopElements) => {
3316 const outside = [];
3317 const walk = (parent) => {
3318 if (!parent || stopElements.has(parent)) {
3319 return;
3320 }
3321 Array.from(parent.children).forEach((node) => {
3322 if (getNodeName(node) === "script") {
3323 return;
3324 }
3325 if (keepElements.has(node)) {
3326 walk(node);
3327 } else {
3328 outside.push(node);
3329 }
3330 });
3331 };
3332 walk(root);
3333 return outside;
3334 };
3335 function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert, {
3336 mark = true,
3337 markerIgnoreElements = []
3338 }) {
3339 const controlAttribute = inert ? "inert" : ariaHidden ? "aria-hidden" : null;
3340 let counterMap = null;
3341 let uncontrolledElementsSet = null;
3342 const avoidElements = correctElements(body, uncorrectedAvoidElements);
3343 const markerIgnoreTargets = mark ? correctElements(body, markerIgnoreElements) : [];
3344 const markerIgnoreSet = new Set(markerIgnoreTargets);
3345 const markerTargets = mark ? collectOutsideElements(body, buildKeepSet(avoidElements), new Set(avoidElements)).filter((target) => !markerIgnoreSet.has(target)) : [];
3346 const hiddenElements = [];
3347 const markedElements = [];
3348 if (controlAttribute) {
3349 const map = counters[controlAttribute];
3350 const currentUncontrolledElementsSet = getUncontrolledElementsSet(controlAttribute);
3351 uncontrolledElementsSet = currentUncontrolledElementsSet;
3352 counterMap = map;
3353 const ariaLiveElements = correctElements(body, Array.from(body.querySelectorAll("[aria-live]")));
3354 const controlElements = avoidElements.concat(ariaLiveElements);
3355 const controlTargets = collectOutsideElements(body, buildKeepSet(controlElements), new Set(controlElements));
3356 controlTargets.forEach((node) => {
3357 const attr2 = node.getAttribute(controlAttribute);
3358 const alreadyHidden = attr2 !== null && attr2 !== "false";
3359 const counterValue = (map.get(node) || 0) + 1;
3360 map.set(node, counterValue);
3361 hiddenElements.push(node);
3362 if (counterValue === 1 && alreadyHidden) {
3363 currentUncontrolledElementsSet.add(node);
3364 }
3365 if (!alreadyHidden) {
3366 node.setAttribute(controlAttribute, controlAttribute === "inert" ? "" : "true");
3367 }
3368 });
3369 }
3370 if (mark) {
3371 markerTargets.forEach((node) => {
3372 const markerValue = (markerCounterMap.get(node) || 0) + 1;
3373 markerCounterMap.set(node, markerValue);
3374 markedElements.push(node);
3375 if (markerValue === 1) {
3376 node.setAttribute(markerName, "");
3377 }
3378 });
3379 }
3380 lockCount += 1;
3381 return () => {
3382 if (counterMap) {
3383 hiddenElements.forEach((element) => {
3384 const currentCounterValue = counterMap.get(element) || 0;
3385 const counterValue = currentCounterValue - 1;
3386 counterMap.set(element, counterValue);
3387 if (!counterValue) {
3388 if (!uncontrolledElementsSet?.has(element) && controlAttribute) {
3389 element.removeAttribute(controlAttribute);
3390 }
3391 uncontrolledElementsSet?.delete(element);
3392 }
3393 });
3394 }
3395 if (mark) {
3396 markedElements.forEach((element) => {
3397 const markerValue = (markerCounterMap.get(element) || 0) - 1;
3398 markerCounterMap.set(element, markerValue);
3399 if (!markerValue) {
3400 element.removeAttribute(markerName);
3401 }
3402 });
3403 }
3404 lockCount -= 1;
3405 if (!lockCount) {
3406 counters.inert = /* @__PURE__ */ new WeakMap();
3407 counters["aria-hidden"] = /* @__PURE__ */ new WeakMap();
3408 uncontrolledElementsSets.inert = /* @__PURE__ */ new WeakSet();
3409 uncontrolledElementsSets["aria-hidden"] = /* @__PURE__ */ new WeakSet();
3410 markerCounterMap = /* @__PURE__ */ new WeakMap();
3411 }
3412 };
3413 }
3414 function markOthers(avoidElements, options = {}) {
3415 const {
3416 ariaHidden = false,
3417 inert = false,
3418 mark = true,
3419 markerIgnoreElements = []
3420 } = options;
3421 const body = ownerDocument(avoidElements[0]).body;
3422 return applyAttributeToOthers(avoidElements, body, ariaHidden, inert, {
3423 mark,
3424 markerIgnoreElements
3425 });
3426 }
3427
3428 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3429 var React19 = __toESM(require_react(), 1);
3430 var ReactDOM2 = __toESM(require_react_dom(), 1);
3431
3432 // node_modules/@base-ui/react/esm/internals/constants.js
3433 var DISABLED_TRANSITIONS_STYLE = {
3434 style: {
3435 transition: "none"
3436 }
3437 };
3438 var CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
3439 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3440 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3441 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3442 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3443 var POPUP_COLLISION_AVOIDANCE = {
3444 fallbackAxisSide: "end"
3445 };
3446 var ownerVisuallyHidden = {
3447 clipPath: "inset(50%)",
3448 position: "fixed",
3449 top: 0,
3450 left: 0
3451 };
3452
3453 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3454 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3455 var PortalContext = /* @__PURE__ */ React19.createContext(null);
3456 if (true) PortalContext.displayName = "PortalContext";
3457 var usePortalContext = () => React19.useContext(PortalContext);
3458 var attr = createAttribute("portal");
3459 function useFloatingPortalNode(props = {}) {
3460 const {
3461 ref,
3462 container: containerProp,
3463 componentProps = EMPTY_OBJECT,
3464 elementProps
3465 } = props;
3466 const uniqueId = useId();
3467 const portalContext = usePortalContext();
3468 const parentPortalNode = portalContext?.portalNode;
3469 const [containerElement, setContainerElement] = React19.useState(null);
3470 const [portalNode, setPortalNode] = React19.useState(null);
3471 const setPortalNodeRef = useStableCallback((node) => {
3472 if (node !== null) {
3473 setPortalNode(node);
3474 }
3475 });
3476 const containerRef = React19.useRef(null);
3477 useIsoLayoutEffect(() => {
3478 if (containerProp === null) {
3479 if (containerRef.current) {
3480 containerRef.current = null;
3481 setPortalNode(null);
3482 setContainerElement(null);
3483 }
3484 return;
3485 }
3486 if (uniqueId == null) {
3487 return;
3488 }
3489 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3490 if (resolvedContainer == null) {
3491 if (containerRef.current) {
3492 containerRef.current = null;
3493 setPortalNode(null);
3494 setContainerElement(null);
3495 }
3496 return;
3497 }
3498 if (containerRef.current !== resolvedContainer) {
3499 containerRef.current = resolvedContainer;
3500 setPortalNode(null);
3501 setContainerElement(resolvedContainer);
3502 }
3503 }, [containerProp, parentPortalNode, uniqueId]);
3504 const portalElement = useRenderElement("div", componentProps, {
3505 ref: [ref, setPortalNodeRef],
3506 props: [{
3507 id: uniqueId,
3508 [attr]: ""
3509 }, elementProps]
3510 });
3511 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3512 return {
3513 portalNode,
3514 portalSubtree
3515 };
3516 }
3517 var FloatingPortal = /* @__PURE__ */ React19.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3518 const {
3519 children,
3520 container,
3521 className,
3522 render: render4,
3523 renderGuards,
3524 style,
3525 ...elementProps
3526 } = componentProps;
3527 const {
3528 portalNode,
3529 portalSubtree
3530 } = useFloatingPortalNode({
3531 container,
3532 ref: forwardedRef,
3533 componentProps,
3534 elementProps
3535 });
3536 const beforeOutsideRef = React19.useRef(null);
3537 const afterOutsideRef = React19.useRef(null);
3538 const beforeInsideRef = React19.useRef(null);
3539 const afterInsideRef = React19.useRef(null);
3540 const [focusManagerState, setFocusManagerState] = React19.useState(null);
3541 const focusInsideDisabledRef = React19.useRef(false);
3542 const modal = focusManagerState?.modal;
3543 const open = focusManagerState?.open;
3544 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3545 React19.useEffect(() => {
3546 if (!portalNode || modal) {
3547 return void 0;
3548 }
3549 function onFocus(event) {
3550 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3551 if (event.type === "focusin") {
3552 if (focusInsideDisabledRef.current) {
3553 enableFocusInside(portalNode);
3554 focusInsideDisabledRef.current = false;
3555 }
3556 } else {
3557 disableFocusInside(portalNode);
3558 focusInsideDisabledRef.current = true;
3559 }
3560 }
3561 }
3562 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3563 }, [portalNode, modal]);
3564 React19.useEffect(() => {
3565 if (!portalNode || open !== false) {
3566 return;
3567 }
3568 enableFocusInside(portalNode);
3569 focusInsideDisabledRef.current = false;
3570 }, [open, portalNode]);
3571 const portalContextValue = React19.useMemo(() => ({
3572 beforeOutsideRef,
3573 afterOutsideRef,
3574 beforeInsideRef,
3575 afterInsideRef,
3576 portalNode,
3577 setFocusManagerState
3578 }), [portalNode]);
3579 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React19.Fragment, {
3580 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3581 value: portalContextValue,
3582 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3583 "data-type": "outside",
3584 ref: beforeOutsideRef,
3585 onFocus: (event) => {
3586 if (isOutsideEvent(event, portalNode)) {
3587 beforeInsideRef.current?.focus();
3588 } else {
3589 const domReference = focusManagerState ? focusManagerState.domReference : null;
3590 const prevTabbable = getPreviousTabbable(domReference);
3591 prevTabbable?.focus();
3592 }
3593 }
3594 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3595 "aria-owns": portalNode.id,
3596 style: ownerVisuallyHidden
3597 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3598 "data-type": "outside",
3599 ref: afterOutsideRef,
3600 onFocus: (event) => {
3601 if (isOutsideEvent(event, portalNode)) {
3602 afterInsideRef.current?.focus();
3603 } else {
3604 const domReference = focusManagerState ? focusManagerState.domReference : null;
3605 const nextTabbable = getNextTabbable(domReference);
3606 nextTabbable?.focus();
3607 if (focusManagerState?.closeOnFocusOut) {
3608 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3609 }
3610 }
3611 }
3612 })]
3613 })]
3614 });
3615 });
3616 if (true) FloatingPortal.displayName = "FloatingPortal";
3617
3618 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3619 var React20 = __toESM(require_react(), 1);
3620
3621 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3622 function createEventEmitter() {
3623 const map = /* @__PURE__ */ new Map();
3624 return {
3625 emit(event, data) {
3626 map.get(event)?.forEach((listener) => listener(data));
3627 },
3628 on(event, listener) {
3629 if (!map.has(event)) {
3630 map.set(event, /* @__PURE__ */ new Set());
3631 }
3632 map.get(event).add(listener);
3633 },
3634 off(event, listener) {
3635 map.get(event)?.delete(listener);
3636 }
3637 };
3638 }
3639
3640 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3641 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3642 var FloatingNodeContext = /* @__PURE__ */ React20.createContext(null);
3643 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3644 var FloatingTreeContext = /* @__PURE__ */ React20.createContext(null);
3645 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3646 var useFloatingParentNodeId = () => React20.useContext(FloatingNodeContext)?.id || null;
3647 var useFloatingTree = (externalTree) => {
3648 const contextTree = React20.useContext(FloatingTreeContext);
3649 return externalTree ?? contextTree;
3650 };
3651
3652 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingFocusManager.js
3653 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
3654 function getEventType(event, lastInteractionType) {
3655 const win = getWindow(getTarget(event));
3656 if (event instanceof win.KeyboardEvent) {
3657 return "keyboard";
3658 }
3659 if (event instanceof win.FocusEvent) {
3660 return lastInteractionType || "keyboard";
3661 }
3662 if ("pointerType" in event) {
3663 return event.pointerType || "keyboard";
3664 }
3665 if ("touches" in event) {
3666 return "touch";
3667 }
3668 if (event instanceof win.MouseEvent) {
3669 return lastInteractionType || (event.detail === 0 ? "keyboard" : "mouse");
3670 }
3671 return "";
3672 }
3673 var LIST_LIMIT = 20;
3674 var previouslyFocusedElements = [];
3675 function clearDisconnectedPreviouslyFocusedElements() {
3676 previouslyFocusedElements = previouslyFocusedElements.filter((entry) => {
3677 return entry.deref()?.isConnected;
3678 });
3679 }
3680 function addPreviouslyFocusedElement(element) {
3681 clearDisconnectedPreviouslyFocusedElements();
3682 if (element && getNodeName(element) !== "body") {
3683 previouslyFocusedElements.push(new WeakRef(element));
3684 if (previouslyFocusedElements.length > LIST_LIMIT) {
3685 previouslyFocusedElements = previouslyFocusedElements.slice(-LIST_LIMIT);
3686 }
3687 }
3688 }
3689 function getPreviouslyFocusedElement() {
3690 clearDisconnectedPreviouslyFocusedElements();
3691 return previouslyFocusedElements[previouslyFocusedElements.length - 1]?.deref();
3692 }
3693 function getFirstTabbableElement(container) {
3694 if (!container) {
3695 return null;
3696 }
3697 if (isTabbable(container)) {
3698 return container;
3699 }
3700 return tabbable(container)[0] || container;
3701 }
3702 function handleTabIndex(floatingFocusElement, orderRef) {
3703 if (floatingFocusElement.hasAttribute("tabindex") && !floatingFocusElement.hasAttribute("data-tabindex")) {
3704 return;
3705 }
3706 if (!orderRef.current.includes("floating") && !floatingFocusElement.getAttribute("role")?.includes("dialog")) {
3707 return;
3708 }
3709 const focusableElements = focusable(floatingFocusElement);
3710 const tabbableContent = focusableElements.filter((element) => {
3711 const dataTabIndex = element.getAttribute("data-tabindex") || "";
3712 return isTabbable(element) || element.hasAttribute("data-tabindex") && !dataTabIndex.startsWith("-");
3713 });
3714 const tabIndex = floatingFocusElement.getAttribute("tabindex");
3715 if (orderRef.current.includes("floating") || tabbableContent.length === 0) {
3716 if (tabIndex !== "0") {
3717 floatingFocusElement.setAttribute("tabindex", "0");
3718 }
3719 } else if (tabIndex !== "-1" || floatingFocusElement.hasAttribute("data-tabindex") && floatingFocusElement.getAttribute("data-tabindex") !== "-1") {
3720 floatingFocusElement.setAttribute("tabindex", "-1");
3721 floatingFocusElement.setAttribute("data-tabindex", "-1");
3722 }
3723 }
3724 function FloatingFocusManager(props) {
3725 const {
3726 context,
3727 children,
3728 disabled: disabled2 = false,
3729 initialFocus = true,
3730 returnFocus = true,
3731 restoreFocus = false,
3732 modal = true,
3733 closeOnFocusOut = true,
3734 openInteractionType = "",
3735 nextFocusableElement,
3736 previousFocusableElement,
3737 beforeContentFocusGuardRef,
3738 externalTree,
3739 getInsideElements
3740 } = props;
3741 const store = "rootStore" in context ? context.rootStore : context;
3742 const open = store.useState("open");
3743 const domReference = store.useState("domReferenceElement");
3744 const floating = store.useState("floatingElement");
3745 const {
3746 events: events2,
3747 dataRef
3748 } = store.context;
3749 const getNodeId = useStableCallback(() => dataRef.current.floatingContext?.nodeId);
3750 const ignoreInitialFocus = initialFocus === false;
3751 const isUntrappedTypeableCombobox = isTypeableCombobox(domReference) && ignoreInitialFocus;
3752 const orderRef = React21.useRef(["content"]);
3753 const initialFocusRef = useValueAsRef(initialFocus);
3754 const returnFocusRef = useValueAsRef(returnFocus);
3755 const openInteractionTypeRef = useValueAsRef(openInteractionType);
3756 const tree = useFloatingTree(externalTree);
3757 const portalContext = usePortalContext();
3758 const preventReturnFocusRef = React21.useRef(false);
3759 const isPointerDownRef = React21.useRef(false);
3760 const pointerDownOutsideRef = React21.useRef(false);
3761 const lastFocusedTabbableRef = React21.useRef(null);
3762 const closeTypeRef = React21.useRef("");
3763 const lastInteractionTypeRef = React21.useRef("");
3764 const beforeGuardRef = React21.useRef(null);
3765 const afterGuardRef = React21.useRef(null);
3766 const mergedBeforeGuardRef = useMergedRefs(beforeGuardRef, beforeContentFocusGuardRef, portalContext?.beforeInsideRef);
3767 const mergedAfterGuardRef = useMergedRefs(afterGuardRef, portalContext?.afterInsideRef);
3768 const blurTimeout = useTimeout();
3769 const pointerDownTimeout = useTimeout();
3770 const restoreFocusFrame = useAnimationFrame();
3771 const isInsidePortal = portalContext != null;
3772 const floatingFocusElement = getFloatingFocusElement(floating);
3773 const getTabbableContent = useStableCallback((container = floatingFocusElement) => {
3774 return container ? tabbable(container) : [];
3775 });
3776 const getResolvedInsideElements = useStableCallback(() => getInsideElements?.().filter((element) => element != null) ?? []);
3777 React21.useEffect(() => {
3778 if (disabled2 || !modal) {
3779 return void 0;
3780 }
3781 function onKeyDown(event) {
3782 if (event.key === "Tab") {
3783 if (contains(floatingFocusElement, activeElement(ownerDocument(floatingFocusElement))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
3784 stopEvent(event);
3785 }
3786 }
3787 }
3788 const doc = ownerDocument(floatingFocusElement);
3789 return addEventListener(doc, "keydown", onKeyDown);
3790 }, [disabled2, domReference, floatingFocusElement, modal, orderRef, isUntrappedTypeableCombobox, getTabbableContent]);
3791 React21.useEffect(() => {
3792 if (disabled2 || !open) {
3793 return void 0;
3794 }
3795 const doc = ownerDocument(floatingFocusElement);
3796 function clearPointerDownOutside() {
3797 pointerDownOutsideRef.current = false;
3798 }
3799 function onPointerDown(event) {
3800 const target = getTarget(event);
3801 const insideElements = getResolvedInsideElements();
3802 const pointerTargetInside = contains(floating, target) || contains(domReference, target) || contains(portalContext?.portalNode, target) || insideElements.some((element) => element === target || contains(element, target));
3803 pointerDownOutsideRef.current = !pointerTargetInside;
3804 lastInteractionTypeRef.current = event.pointerType || "keyboard";
3805 if (target?.closest(`[${CLICK_TRIGGER_IDENTIFIER}]`)) {
3806 isPointerDownRef.current = true;
3807 }
3808 }
3809 function onKeyDown() {
3810 lastInteractionTypeRef.current = "keyboard";
3811 }
3812 return mergeCleanups(addEventListener(doc, "pointerdown", onPointerDown, true), addEventListener(doc, "pointerup", clearPointerDownOutside, true), addEventListener(doc, "pointercancel", clearPointerDownOutside, true), addEventListener(doc, "keydown", onKeyDown, true));
3813 }, [disabled2, floating, domReference, floatingFocusElement, open, portalContext, getResolvedInsideElements]);
3814 React21.useEffect(() => {
3815 if (disabled2 || !closeOnFocusOut) {
3816 return void 0;
3817 }
3818 const doc = ownerDocument(floatingFocusElement);
3819 function handlePointerDown() {
3820 isPointerDownRef.current = true;
3821 pointerDownTimeout.start(0, () => {
3822 isPointerDownRef.current = false;
3823 });
3824 }
3825 function handleFocusIn(event) {
3826 const target = getTarget(event);
3827 if (isTabbable(target)) {
3828 lastFocusedTabbableRef.current = target;
3829 }
3830 }
3831 function handleFocusOutside(event) {
3832 const relatedTarget = event.relatedTarget;
3833 const currentTarget = event.currentTarget;
3834 const target = getTarget(event);
3835 queueMicrotask(() => {
3836 const nodeId = getNodeId();
3837 const triggers = store.context.triggerElements;
3838 const insideElements = getResolvedInsideElements();
3839 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);
3840 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)));
3841 if (currentTarget === domReference && floatingFocusElement) {
3842 handleTabIndex(floatingFocusElement, orderRef);
3843 }
3844 if (restoreFocus && currentTarget !== domReference && !isElementVisible(target) && activeElement(doc) === doc.body) {
3845 if (isHTMLElement(floatingFocusElement)) {
3846 floatingFocusElement.focus();
3847 if (restoreFocus === "popup") {
3848 restoreFocusFrame.request(() => {
3849 floatingFocusElement.focus();
3850 });
3851 return;
3852 }
3853 }
3854 const tabbableContent = getTabbableContent();
3855 const prevTabbable = lastFocusedTabbableRef.current;
3856 const nodeToFocus = (prevTabbable && tabbableContent.includes(prevTabbable) ? prevTabbable : null) || tabbableContent[tabbableContent.length - 1] || floatingFocusElement;
3857 if (isHTMLElement(nodeToFocus)) {
3858 nodeToFocus.focus();
3859 }
3860 }
3861 if (dataRef.current.insideReactTree) {
3862 dataRef.current.insideReactTree = false;
3863 return;
3864 }
3865 if ((isUntrappedTypeableCombobox ? true : !modal) && relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
3866 // For an "untrapped" typeable combobox (input role=combobox with
3867 // initialFocus=false), re-opening the popup and tabbing out should still close it even
3868 // when the previously focused element (e.g. the next tabbable outside the popup) is
3869 // focused again. Otherwise, the popup remains open on the second Tab sequence:
3870 // click input -> Tab (closes) -> click input -> Tab.
3871 // Allow closing when `isUntrappedTypeableCombobox` regardless of the previously focused element.
3872 (isUntrappedTypeableCombobox || relatedTarget !== getPreviouslyFocusedElement())) {
3873 preventReturnFocusRef.current = true;
3874 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event));
3875 }
3876 });
3877 }
3878 function markInsideReactTree() {
3879 if (pointerDownOutsideRef.current) {
3880 return;
3881 }
3882 dataRef.current.insideReactTree = true;
3883 blurTimeout.start(0, () => {
3884 dataRef.current.insideReactTree = false;
3885 });
3886 }
3887 const domReferenceElement = isHTMLElement(domReference) ? domReference : null;
3888 if (!floating && !domReferenceElement) {
3889 return void 0;
3890 }
3891 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));
3892 }, [disabled2, domReference, floating, floatingFocusElement, modal, tree, portalContext, store, closeOnFocusOut, restoreFocus, getTabbableContent, isUntrappedTypeableCombobox, getNodeId, orderRef, dataRef, blurTimeout, pointerDownTimeout, restoreFocusFrame, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]);
3893 React21.useEffect(() => {
3894 if (disabled2 || !floating || !open) {
3895 return void 0;
3896 }
3897 const portalNodes = Array.from(portalContext?.portalNode?.querySelectorAll(`[${createAttribute("portal")}]`) || []);
3898 const ancestors = tree ? getNodeAncestors(tree.nodesRef.current, getNodeId()) : [];
3899 const rootAncestorComboboxDomReference = ancestors.find((node) => isTypeableCombobox(node.context?.elements.domReference || null))?.context?.elements.domReference;
3900 const controlInsideElements = [floating, ...portalNodes, beforeGuardRef.current, afterGuardRef.current, portalContext?.beforeOutsideRef.current, portalContext?.afterOutsideRef.current, ...getResolvedInsideElements()];
3901 const insideElements = [...controlInsideElements, rootAncestorComboboxDomReference, resolveRef(previousFocusableElement), resolveRef(nextFocusableElement), isUntrappedTypeableCombobox ? domReference : null].filter((x2) => x2 != null);
3902 const ariaHiddenCleanup = markOthers(insideElements, {
3903 ariaHidden: modal || isUntrappedTypeableCombobox,
3904 mark: false
3905 });
3906 const markerInsideElements = [floating, ...portalNodes].filter((x2) => x2 != null);
3907 const markerCleanup = markOthers(markerInsideElements);
3908 return () => {
3909 markerCleanup();
3910 ariaHiddenCleanup();
3911 };
3912 }, [open, disabled2, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, tree, getNodeId, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]);
3913 useIsoLayoutEffect(() => {
3914 if (!open || disabled2 || !isHTMLElement(floatingFocusElement)) {
3915 return;
3916 }
3917 const doc = ownerDocument(floatingFocusElement);
3918 const previouslyFocusedElement = activeElement(doc);
3919 queueMicrotask(() => {
3920 const initialFocusValueOrFn = initialFocusRef.current;
3921 const resolvedInitialFocus = typeof initialFocusValueOrFn === "function" ? initialFocusValueOrFn(openInteractionTypeRef.current || "") : initialFocusValueOrFn;
3922 if (resolvedInitialFocus === void 0 || resolvedInitialFocus === false) {
3923 return;
3924 }
3925 const focusAlreadyInsideFloatingEl = contains(floatingFocusElement, previouslyFocusedElement);
3926 if (focusAlreadyInsideFloatingEl) {
3927 return;
3928 }
3929 let focusableElements = null;
3930 const getDefaultFocusElement = () => {
3931 if (focusableElements == null) {
3932 focusableElements = getTabbableContent(floatingFocusElement);
3933 }
3934 return focusableElements[0] || floatingFocusElement;
3935 };
3936 let elToFocus;
3937 if (resolvedInitialFocus === true || resolvedInitialFocus === null) {
3938 elToFocus = getDefaultFocusElement();
3939 } else {
3940 elToFocus = resolveRef(resolvedInitialFocus);
3941 }
3942 elToFocus = elToFocus || getDefaultFocusElement();
3943 enqueueFocus(elToFocus, {
3944 preventScroll: elToFocus === floatingFocusElement
3945 });
3946 });
3947 }, [disabled2, open, floatingFocusElement, ignoreInitialFocus, getTabbableContent, initialFocusRef, openInteractionTypeRef]);
3948 useIsoLayoutEffect(() => {
3949 if (disabled2 || !floatingFocusElement) {
3950 return void 0;
3951 }
3952 const doc = ownerDocument(floatingFocusElement);
3953 const previouslyFocusedElement = activeElement(doc);
3954 addPreviouslyFocusedElement(previouslyFocusedElement);
3955 function onOpenChangeLocal(details) {
3956 if (!details.open) {
3957 closeTypeRef.current = getEventType(details.nativeEvent, lastInteractionTypeRef.current);
3958 }
3959 if (details.reason === reason_parts_exports.triggerHover && details.nativeEvent.type === "mouseleave") {
3960 preventReturnFocusRef.current = true;
3961 }
3962 if (details.reason !== reason_parts_exports.outsidePress) {
3963 return;
3964 }
3965 if (details.nested) {
3966 preventReturnFocusRef.current = false;
3967 } else if (isVirtualClick(details.nativeEvent) || isVirtualPointerEvent(details.nativeEvent)) {
3968 preventReturnFocusRef.current = false;
3969 } else {
3970 let isPreventScrollSupported = false;
3971 ownerDocument(floatingFocusElement).createElement("div").focus({
3972 get preventScroll() {
3973 isPreventScrollSupported = true;
3974 return false;
3975 }
3976 });
3977 if (isPreventScrollSupported) {
3978 preventReturnFocusRef.current = false;
3979 } else {
3980 preventReturnFocusRef.current = true;
3981 }
3982 }
3983 }
3984 events2.on("openchange", onOpenChangeLocal);
3985 function getReturnElement() {
3986 const returnFocusValueOrFn = returnFocusRef.current;
3987 let resolvedReturnFocusValue = typeof returnFocusValueOrFn === "function" ? returnFocusValueOrFn(closeTypeRef.current) : returnFocusValueOrFn;
3988 if (resolvedReturnFocusValue === void 0 || resolvedReturnFocusValue === false) {
3989 return null;
3990 }
3991 if (resolvedReturnFocusValue === null) {
3992 resolvedReturnFocusValue = true;
3993 }
3994 if (typeof resolvedReturnFocusValue === "boolean") {
3995 const el = domReference || getPreviouslyFocusedElement();
3996 return el && el.isConnected ? el : null;
3997 }
3998 const fallback = domReference || getPreviouslyFocusedElement();
3999 return resolveRef(resolvedReturnFocusValue) || fallback || null;
4000 }
4001 return () => {
4002 events2.off("openchange", onOpenChangeLocal);
4003 const activeEl = activeElement(doc);
4004 const insideElements = getResolvedInsideElements();
4005 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));
4006 const returnFocusValueOrFn = returnFocusRef.current;
4007 const returnElement = getReturnElement();
4008 queueMicrotask(() => {
4009 const tabbableReturnElement = getFirstTabbableElement(returnElement);
4010 const hasExplicitReturnFocus = typeof returnFocusValueOrFn !== "boolean";
4011 if (returnFocusValueOrFn && !preventReturnFocusRef.current && isHTMLElement(tabbableReturnElement) && // If the focus moved somewhere else after mount, avoid returning focus
4012 // since it likely entered a different element which should be
4013 // respected: https://github.com/floating-ui/floating-ui/issues/2607
4014 (!hasExplicitReturnFocus && tabbableReturnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)) {
4015 tabbableReturnElement.focus({
4016 preventScroll: true
4017 });
4018 }
4019 preventReturnFocusRef.current = false;
4020 });
4021 };
4022 }, [disabled2, floating, floatingFocusElement, returnFocusRef, dataRef, events2, tree, domReference, getNodeId, getResolvedInsideElements]);
4023 useIsoLayoutEffect(() => {
4024 if (!isWebKit2 || open || !floating) {
4025 return;
4026 }
4027 const activeEl = activeElement(ownerDocument(floating));
4028 if (!isHTMLElement(activeEl) || !isTypeableElement(activeEl)) {
4029 return;
4030 }
4031 if (contains(floating, activeEl)) {
4032 activeEl.blur();
4033 }
4034 }, [open, floating]);
4035 useIsoLayoutEffect(() => {
4036 if (disabled2 || !portalContext) {
4037 return void 0;
4038 }
4039 portalContext.setFocusManagerState({
4040 modal,
4041 closeOnFocusOut,
4042 open,
4043 onOpenChange: store.setOpen,
4044 domReference
4045 });
4046 return () => {
4047 portalContext.setFocusManagerState(null);
4048 };
4049 }, [disabled2, portalContext, modal, open, store, closeOnFocusOut, domReference]);
4050 useIsoLayoutEffect(() => {
4051 if (disabled2 || !floatingFocusElement) {
4052 return void 0;
4053 }
4054 handleTabIndex(floatingFocusElement, orderRef);
4055 return () => {
4056 queueMicrotask(clearDisconnectedPreviouslyFocusedElements);
4057 };
4058 }, [disabled2, floatingFocusElement, orderRef]);
4059 const shouldRenderGuards = !disabled2 && (modal ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal);
4060 return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React21.Fragment, {
4061 children: [shouldRenderGuards && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FocusGuard, {
4062 "data-type": "inside",
4063 ref: mergedBeforeGuardRef,
4064 onFocus: (event) => {
4065 if (modal) {
4066 const els = getTabbableContent();
4067 enqueueFocus(els[els.length - 1]);
4068 } else if (portalContext?.portalNode) {
4069 preventReturnFocusRef.current = false;
4070 if (isOutsideEvent(event, portalContext.portalNode)) {
4071 const nextTabbable = getNextTabbable(domReference);
4072 nextTabbable?.focus();
4073 } else {
4074 resolveRef(previousFocusableElement ?? portalContext.beforeOutsideRef)?.focus();
4075 }
4076 }
4077 }
4078 }), children, shouldRenderGuards && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FocusGuard, {
4079 "data-type": "inside",
4080 ref: mergedAfterGuardRef,
4081 onFocus: (event) => {
4082 if (modal) {
4083 enqueueFocus(getTabbableContent()[0]);
4084 } else if (portalContext?.portalNode) {
4085 if (closeOnFocusOut) {
4086 preventReturnFocusRef.current = true;
4087 }
4088 if (isOutsideEvent(event, portalContext.portalNode)) {
4089 const prevTabbable = getPreviousTabbable(domReference);
4090 prevTabbable?.focus();
4091 } else {
4092 resolveRef(nextFocusableElement ?? portalContext.afterOutsideRef)?.focus();
4093 }
4094 }
4095 }
4096 })]
4097 });
4098 }
4099
4100 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClick.js
4101 var React22 = __toESM(require_react(), 1);
4102 function useClick(context, props = {}) {
4103 const store = "rootStore" in context ? context.rootStore : context;
4104 const dataRef = store.context.dataRef;
4105 const {
4106 enabled = true,
4107 event: eventOption = "click",
4108 toggle = true,
4109 ignoreMouse = false,
4110 stickIfOpen = true,
4111 touchOpenDelay = 0,
4112 reason = reason_parts_exports.triggerPress
4113 } = props;
4114 const pointerTypeRef = React22.useRef(void 0);
4115 const frame = useAnimationFrame();
4116 const touchOpenTimeout = useTimeout();
4117 const reference = React22.useMemo(() => ({
4118 onPointerDown(event) {
4119 pointerTypeRef.current = event.pointerType;
4120 },
4121 onMouseDown(event) {
4122 const pointerType = pointerTypeRef.current;
4123 const nativeEvent = event.nativeEvent;
4124 const open = store.select("open");
4125 if (event.button !== 0 || eventOption === "click" || isMouseLikePointerType(pointerType, true) && ignoreMouse) {
4126 return;
4127 }
4128 const openEvent = dataRef.current.openEvent;
4129 const openEventType = openEvent?.type;
4130 const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== event.currentTarget;
4131 const nextOpen = open && hasClickedOnInactiveTrigger || !(open && toggle && (openEvent && stickIfOpen ? openEventType === "click" || openEventType === "mousedown" : true));
4132 const target = getTarget(nativeEvent);
4133 if (isTypeableElement(target)) {
4134 const details = createChangeEventDetails(reason, nativeEvent, target);
4135 if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
4136 touchOpenTimeout.start(touchOpenDelay, () => {
4137 store.setOpen(true, details);
4138 });
4139 } else {
4140 store.setOpen(nextOpen, details);
4141 }
4142 return;
4143 }
4144 const eventCurrentTarget = event.currentTarget;
4145 frame.request(() => {
4146 const details = createChangeEventDetails(reason, nativeEvent, eventCurrentTarget);
4147 if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
4148 touchOpenTimeout.start(touchOpenDelay, () => {
4149 store.setOpen(true, details);
4150 });
4151 } else {
4152 store.setOpen(nextOpen, details);
4153 }
4154 });
4155 },
4156 onClick(event) {
4157 if (eventOption === "mousedown-only") {
4158 return;
4159 }
4160 const pointerType = pointerTypeRef.current;
4161 if (eventOption === "mousedown" && pointerType) {
4162 pointerTypeRef.current = void 0;
4163 return;
4164 }
4165 if (isMouseLikePointerType(pointerType, true) && ignoreMouse) {
4166 return;
4167 }
4168 const open = store.select("open");
4169 const openEvent = dataRef.current.openEvent;
4170 const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== event.currentTarget;
4171 const nextOpen = open && hasClickedOnInactiveTrigger || !(open && toggle && (openEvent && stickIfOpen ? isClickLikeEvent(openEvent) : true));
4172 const details = createChangeEventDetails(reason, event.nativeEvent, event.currentTarget);
4173 if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
4174 touchOpenTimeout.start(touchOpenDelay, () => {
4175 store.setOpen(true, details);
4176 });
4177 } else {
4178 store.setOpen(nextOpen, details);
4179 }
4180 },
4181 onKeyDown() {
4182 pointerTypeRef.current = void 0;
4183 }
4184 }), [dataRef, eventOption, ignoreMouse, store, stickIfOpen, toggle, frame, touchOpenTimeout, touchOpenDelay, reason]);
4185 return React22.useMemo(() => enabled ? {
4186 reference
4187 } : EMPTY_OBJECT, [enabled, reference]);
4188 }
4189
4190 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
4191 var React23 = __toESM(require_react(), 1);
4192 function createVirtualElement(domElement, data) {
4193 let offsetX = null;
4194 let offsetY = null;
4195 let isAutoUpdateEvent = false;
4196 return {
4197 contextElement: domElement || void 0,
4198 getBoundingClientRect() {
4199 const domRect = domElement?.getBoundingClientRect() || {
4200 width: 0,
4201 height: 0,
4202 x: 0,
4203 y: 0
4204 };
4205 const isXAxis = data.axis === "x" || data.axis === "both";
4206 const isYAxis = data.axis === "y" || data.axis === "both";
4207 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
4208 let width = domRect.width;
4209 let height = domRect.height;
4210 let x2 = domRect.x;
4211 let y2 = domRect.y;
4212 if (offsetX == null && data.x && isXAxis) {
4213 offsetX = domRect.x - data.x;
4214 }
4215 if (offsetY == null && data.y && isYAxis) {
4216 offsetY = domRect.y - data.y;
4217 }
4218 x2 -= offsetX || 0;
4219 y2 -= offsetY || 0;
4220 width = 0;
4221 height = 0;
4222 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
4223 width = data.axis === "y" ? domRect.width : 0;
4224 height = data.axis === "x" ? domRect.height : 0;
4225 x2 = isXAxis && data.x != null ? data.x : x2;
4226 y2 = isYAxis && data.y != null ? data.y : y2;
4227 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
4228 height = data.axis === "x" ? domRect.height : height;
4229 width = data.axis === "y" ? domRect.width : width;
4230 }
4231 isAutoUpdateEvent = true;
4232 return {
4233 width,
4234 height,
4235 x: x2,
4236 y: y2,
4237 top: y2,
4238 right: x2 + width,
4239 bottom: y2 + height,
4240 left: x2
4241 };
4242 }
4243 };
4244 }
4245 function isMouseBasedEvent(event) {
4246 return event != null && event.clientX != null;
4247 }
4248 function useClientPoint(context, props = {}) {
4249 const store = "rootStore" in context ? context.rootStore : context;
4250 const open = store.useState("open");
4251 const floating = store.useState("floatingElement");
4252 const domReference = store.useState("domReferenceElement");
4253 const dataRef = store.context.dataRef;
4254 const {
4255 enabled = true,
4256 axis = "both"
4257 } = props;
4258 const initialRef = React23.useRef(false);
4259 const cleanupListenerRef = React23.useRef(null);
4260 const [pointerType, setPointerType] = React23.useState();
4261 const [reactive, setReactive] = React23.useState([]);
4262 const setReference = useStableCallback((newX, newY, referenceElement) => {
4263 if (initialRef.current) {
4264 return;
4265 }
4266 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
4267 return;
4268 }
4269 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
4270 x: newX,
4271 y: newY,
4272 axis,
4273 dataRef,
4274 pointerType
4275 }));
4276 });
4277 const handleReferenceEnterOrMove = useStableCallback((event) => {
4278 if (!open) {
4279 setReference(event.clientX, event.clientY, event.currentTarget);
4280 } else if (!cleanupListenerRef.current) {
4281 setReactive([]);
4282 }
4283 });
4284 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
4285 const addListener = React23.useCallback(() => {
4286 if (!openCheck || !enabled) {
4287 return void 0;
4288 }
4289 const win = getWindow(floating);
4290 function handleMouseMove(event) {
4291 const target = getTarget(event);
4292 if (!contains(floating, target)) {
4293 setReference(event.clientX, event.clientY);
4294 } else {
4295 cleanupListenerRef.current?.();
4296 cleanupListenerRef.current = null;
4297 }
4298 }
4299 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
4300 const cleanup = () => {
4301 cleanupListenerRef.current?.();
4302 cleanupListenerRef.current = null;
4303 };
4304 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
4305 return cleanup;
4306 }
4307 store.set("positionReference", domReference);
4308 return void 0;
4309 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
4310 React23.useEffect(() => {
4311 return addListener();
4312 }, [addListener, reactive]);
4313 React23.useEffect(() => {
4314 if (enabled && !floating) {
4315 initialRef.current = false;
4316 }
4317 }, [enabled, floating]);
4318 React23.useEffect(() => {
4319 if (!enabled && open) {
4320 initialRef.current = true;
4321 }
4322 }, [enabled, open]);
4323 const reference = React23.useMemo(() => {
4324 function setPointerTypeRef(event) {
4325 setPointerType(event.pointerType);
4326 }
4327 return {
4328 onPointerDown: setPointerTypeRef,
4329 onPointerEnter: setPointerTypeRef,
4330 onMouseMove: handleReferenceEnterOrMove,
4331 onMouseEnter: handleReferenceEnterOrMove
4332 };
4333 }, [handleReferenceEnterOrMove]);
4334 return React23.useMemo(() => enabled ? {
4335 reference,
4336 trigger: reference
4337 } : {}, [enabled, reference]);
4338 }
4339
4340 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
4341 var React24 = __toESM(require_react(), 1);
4342 var bubbleHandlerKeys = {
4343 intentional: "onClick",
4344 sloppy: "onPointerDown"
4345 };
4346 function alwaysFalse() {
4347 return false;
4348 }
4349 function normalizeProp(normalizable) {
4350 return {
4351 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
4352 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
4353 };
4354 }
4355 function useDismiss(context, props = {}) {
4356 const store = "rootStore" in context ? context.rootStore : context;
4357 const open = store.useState("open");
4358 const floatingElement = store.useState("floatingElement");
4359 const {
4360 dataRef
4361 } = store.context;
4362 const {
4363 enabled = true,
4364 escapeKey: escapeKey2 = true,
4365 outsidePress: outsidePressProp = true,
4366 outsidePressEvent = "sloppy",
4367 referencePress = alwaysFalse,
4368 referencePressEvent = "sloppy",
4369 bubbles,
4370 externalTree
4371 } = props;
4372 const tree = useFloatingTree(externalTree);
4373 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
4374 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
4375 const outsidePressEnabled = outsidePress2 !== false;
4376 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
4377 const pressStartedInsideRef = React24.useRef(false);
4378 const pressStartPreventedRef = React24.useRef(false);
4379 const suppressNextOutsideClickRef = React24.useRef(false);
4380 const {
4381 escapeKey: escapeKeyBubbles,
4382 outsidePress: outsidePressBubbles
4383 } = normalizeProp(bubbles);
4384 const touchStateRef = React24.useRef(null);
4385 const cancelDismissOnEndTimeout = useTimeout();
4386 const clearInsideReactTreeTimeout = useTimeout();
4387 const clearInsideReactTree = useStableCallback(() => {
4388 clearInsideReactTreeTimeout.clear();
4389 dataRef.current.insideReactTree = false;
4390 });
4391 const isComposingRef = React24.useRef(false);
4392 const currentPointerTypeRef = React24.useRef("");
4393 const isReferencePressEnabled = useStableCallback(referencePress);
4394 const closeOnEscapeKeyDown = useStableCallback((event) => {
4395 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
4396 return;
4397 }
4398 if (isComposingRef.current) {
4399 return;
4400 }
4401 const nodeId = dataRef.current.floatingContext?.nodeId;
4402 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4403 if (!escapeKeyBubbles) {
4404 if (children.length > 0) {
4405 let shouldDismiss = true;
4406 children.forEach((child) => {
4407 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
4408 shouldDismiss = false;
4409 }
4410 });
4411 if (!shouldDismiss) {
4412 return;
4413 }
4414 }
4415 }
4416 const native = isReactEvent(event) ? event.nativeEvent : event;
4417 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4418 store.setOpen(false, eventDetails);
4419 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4420 event.stopPropagation();
4421 }
4422 });
4423 const markInsideReactTree = useStableCallback(() => {
4424 dataRef.current.insideReactTree = true;
4425 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4426 });
4427 React24.useEffect(() => {
4428 if (!open || !enabled) {
4429 return void 0;
4430 }
4431 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4432 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4433 const compositionTimeout = new Timeout();
4434 const preventedPressSuppressionTimeout = new Timeout();
4435 function handleCompositionStart() {
4436 compositionTimeout.clear();
4437 isComposingRef.current = true;
4438 }
4439 function handleCompositionEnd() {
4440 compositionTimeout.start(
4441 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4442 // Only apply to WebKit for the test to remain 0ms.
4443 isWebKit() ? 5 : 0,
4444 () => {
4445 isComposingRef.current = false;
4446 }
4447 );
4448 }
4449 function suppressImmediateOutsideClickAfterPreventedStart() {
4450 suppressNextOutsideClickRef.current = true;
4451 preventedPressSuppressionTimeout.start(0, () => {
4452 suppressNextOutsideClickRef.current = false;
4453 });
4454 }
4455 function resetPressStartState() {
4456 pressStartedInsideRef.current = false;
4457 pressStartPreventedRef.current = false;
4458 }
4459 function getOutsidePressEvent() {
4460 const type = currentPointerTypeRef.current;
4461 const computedType = type === "pen" || !type ? "mouse" : type;
4462 const outsidePressEventValue = getOutsidePressEventProp();
4463 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4464 if (typeof resolved === "string") {
4465 return resolved;
4466 }
4467 return resolved[computedType];
4468 }
4469 function shouldIgnoreEvent(event) {
4470 const computedOutsidePressEvent = getOutsidePressEvent();
4471 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4472 }
4473 function isEventWithinFloatingTree(event) {
4474 const nodeId = dataRef.current.floatingContext?.nodeId;
4475 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4476 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
4477 }
4478 function closeOnPressOutside(event) {
4479 if (shouldIgnoreEvent(event)) {
4480 clearInsideReactTree();
4481 return;
4482 }
4483 if (dataRef.current.insideReactTree) {
4484 clearInsideReactTree();
4485 return;
4486 }
4487 const target = getTarget(event);
4488 const inertSelector = `[${createAttribute("inert")}]`;
4489 const targetRoot = isElement(target) ? target.getRootNode() : null;
4490 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4491 const triggers = store.context.triggerElements;
4492 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4493 return;
4494 }
4495 let targetRootAncestor = isElement(target) ? target : null;
4496 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4497 const nextParent = getParentNode(targetRootAncestor);
4498 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4499 break;
4500 }
4501 targetRootAncestor = nextParent;
4502 }
4503 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4504 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4505 // element was injected after the floating element rendered.
4506 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4507 return;
4508 }
4509 if (isHTMLElement(target) && !("touches" in event)) {
4510 const lastTraversableNode = isLastTraversableNode(target);
4511 const style = getComputedStyle2(target);
4512 const scrollRe = /auto|scroll/;
4513 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4514 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4515 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4516 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4517 const isRTL7 = style.direction === "rtl";
4518 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4519 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4520 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4521 return;
4522 }
4523 }
4524 if (isEventWithinFloatingTree(event)) {
4525 return;
4526 }
4527 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4528 preventedPressSuppressionTimeout.clear();
4529 suppressNextOutsideClickRef.current = false;
4530 return;
4531 }
4532 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4533 return;
4534 }
4535 const nodeId = dataRef.current.floatingContext?.nodeId;
4536 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4537 if (children.length > 0) {
4538 let shouldDismiss = true;
4539 children.forEach((child) => {
4540 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
4541 shouldDismiss = false;
4542 }
4543 });
4544 if (!shouldDismiss) {
4545 return;
4546 }
4547 }
4548 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4549 clearInsideReactTree();
4550 }
4551 function handlePointerDown(event) {
4552 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
4553 return;
4554 }
4555 closeOnPressOutside(event);
4556 }
4557 function handleTouchStart(event) {
4558 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
4559 return;
4560 }
4561 const touch = event.touches[0];
4562 if (touch) {
4563 touchStateRef.current = {
4564 startTime: Date.now(),
4565 startX: touch.clientX,
4566 startY: touch.clientY,
4567 dismissOnTouchEnd: false,
4568 dismissOnMouseDown: true
4569 };
4570 cancelDismissOnEndTimeout.start(1e3, () => {
4571 if (touchStateRef.current) {
4572 touchStateRef.current.dismissOnTouchEnd = false;
4573 touchStateRef.current.dismissOnMouseDown = false;
4574 }
4575 });
4576 }
4577 }
4578 function addTargetEventListenerOnce(event, listener) {
4579 const target = getTarget(event);
4580 if (!target) {
4581 return;
4582 }
4583 const unsubscribe2 = addEventListener(target, event.type, () => {
4584 listener(event);
4585 unsubscribe2();
4586 });
4587 }
4588 function handleTouchStartCapture(event) {
4589 currentPointerTypeRef.current = "touch";
4590 addTargetEventListenerOnce(event, handleTouchStart);
4591 }
4592 function closeOnPressOutsideCapture(event) {
4593 cancelDismissOnEndTimeout.clear();
4594 if (event.type === "pointerdown") {
4595 currentPointerTypeRef.current = event.pointerType;
4596 }
4597 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4598 return;
4599 }
4600 addTargetEventListenerOnce(event, (targetEvent) => {
4601 if (targetEvent.type === "pointerdown") {
4602 handlePointerDown(targetEvent);
4603 } else {
4604 closeOnPressOutside(targetEvent);
4605 }
4606 });
4607 }
4608 function handlePressEndCapture(event) {
4609 if (!pressStartedInsideRef.current) {
4610 return;
4611 }
4612 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4613 resetPressStartState();
4614 if (getOutsidePressEvent() !== "intentional") {
4615 return;
4616 }
4617 if (event.type === "pointercancel") {
4618 if (pressStartedInsideDefaultPrevented) {
4619 suppressImmediateOutsideClickAfterPreventedStart();
4620 }
4621 return;
4622 }
4623 if (isEventWithinFloatingTree(event)) {
4624 return;
4625 }
4626 if (pressStartedInsideDefaultPrevented) {
4627 suppressImmediateOutsideClickAfterPreventedStart();
4628 return;
4629 }
4630 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4631 return;
4632 }
4633 preventedPressSuppressionTimeout.clear();
4634 suppressNextOutsideClickRef.current = true;
4635 clearInsideReactTree();
4636 }
4637 function handleTouchMove(event) {
4638 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
4639 return;
4640 }
4641 const touch = event.touches[0];
4642 if (!touch) {
4643 return;
4644 }
4645 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4646 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4647 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4648 if (distance > 5) {
4649 touchStateRef.current.dismissOnTouchEnd = true;
4650 }
4651 if (distance > 10) {
4652 closeOnPressOutside(event);
4653 cancelDismissOnEndTimeout.clear();
4654 touchStateRef.current = null;
4655 }
4656 }
4657 function handleTouchMoveCapture(event) {
4658 addTargetEventListenerOnce(event, handleTouchMove);
4659 }
4660 function handleTouchEnd(event) {
4661 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
4662 return;
4663 }
4664 if (touchStateRef.current.dismissOnTouchEnd) {
4665 closeOnPressOutside(event);
4666 }
4667 cancelDismissOnEndTimeout.clear();
4668 touchStateRef.current = null;
4669 }
4670 function handleTouchEndCapture(event) {
4671 addTargetEventListenerOnce(event, handleTouchEnd);
4672 }
4673 const doc = ownerDocument(floatingElement);
4674 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)));
4675 return () => {
4676 unsubscribe();
4677 compositionTimeout.clear();
4678 preventedPressSuppressionTimeout.clear();
4679 resetPressStartState();
4680 suppressNextOutsideClickRef.current = false;
4681 };
4682 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
4683 React24.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4684 const reference = React24.useMemo(() => ({
4685 onKeyDown: closeOnEscapeKeyDown,
4686 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
4687 if (!isReferencePressEnabled()) {
4688 return;
4689 }
4690 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4691 },
4692 ...referencePressEvent !== "intentional" && {
4693 onClick(event) {
4694 if (!isReferencePressEnabled()) {
4695 return;
4696 }
4697 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4698 }
4699 }
4700 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
4701 const markPressStartedInsideReactTree = useStableCallback((event) => {
4702 if (!open || !enabled || event.button !== 0) {
4703 return;
4704 }
4705 const target = getTarget(event.nativeEvent);
4706 if (!contains(store.select("floatingElement"), target)) {
4707 return;
4708 }
4709 if (!pressStartedInsideRef.current) {
4710 pressStartedInsideRef.current = true;
4711 pressStartPreventedRef.current = false;
4712 }
4713 });
4714 const markInsidePressStartPrevented = useStableCallback((event) => {
4715 if (!open || !enabled) {
4716 return;
4717 }
4718 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4719 return;
4720 }
4721 if (pressStartedInsideRef.current) {
4722 pressStartPreventedRef.current = true;
4723 }
4724 });
4725 const floating = React24.useMemo(() => ({
4726 onKeyDown: closeOnEscapeKeyDown,
4727 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4728 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4729 // See https://github.com/mui/base-ui/pull/3379
4730 onPointerDown: markInsidePressStartPrevented,
4731 onMouseDown: markInsidePressStartPrevented,
4732 onClickCapture: markInsideReactTree,
4733 onMouseDownCapture(event) {
4734 markInsideReactTree();
4735 markPressStartedInsideReactTree(event);
4736 },
4737 onPointerDownCapture(event) {
4738 markInsideReactTree();
4739 markPressStartedInsideReactTree(event);
4740 },
4741 onMouseUpCapture: markInsideReactTree,
4742 onTouchEndCapture: markInsideReactTree,
4743 onTouchMoveCapture: markInsideReactTree
4744 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4745 return React24.useMemo(() => enabled ? {
4746 reference,
4747 floating,
4748 trigger: reference
4749 } : {}, [enabled, reference, floating]);
4750 }
4751
4752 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
4753 var React30 = __toESM(require_react(), 1);
4754
4755 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4756 function computeCoordsFromPlacement(_ref, placement, rtl) {
4757 let {
4758 reference,
4759 floating
4760 } = _ref;
4761 const sideAxis = getSideAxis(placement);
4762 const alignmentAxis = getAlignmentAxis(placement);
4763 const alignLength = getAxisLength(alignmentAxis);
4764 const side = getSide(placement);
4765 const isVertical = sideAxis === "y";
4766 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4767 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4768 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4769 let coords;
4770 switch (side) {
4771 case "top":
4772 coords = {
4773 x: commonX,
4774 y: reference.y - floating.height
4775 };
4776 break;
4777 case "bottom":
4778 coords = {
4779 x: commonX,
4780 y: reference.y + reference.height
4781 };
4782 break;
4783 case "right":
4784 coords = {
4785 x: reference.x + reference.width,
4786 y: commonY
4787 };
4788 break;
4789 case "left":
4790 coords = {
4791 x: reference.x - floating.width,
4792 y: commonY
4793 };
4794 break;
4795 default:
4796 coords = {
4797 x: reference.x,
4798 y: reference.y
4799 };
4800 }
4801 switch (getAlignment(placement)) {
4802 case "start":
4803 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4804 break;
4805 case "end":
4806 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4807 break;
4808 }
4809 return coords;
4810 }
4811 async function detectOverflow(state, options) {
4812 var _await$platform$isEle;
4813 if (options === void 0) {
4814 options = {};
4815 }
4816 const {
4817 x: x2,
4818 y: y2,
4819 platform: platform3,
4820 rects,
4821 elements,
4822 strategy
4823 } = state;
4824 const {
4825 boundary = "clippingAncestors",
4826 rootBoundary = "viewport",
4827 elementContext = "floating",
4828 altBoundary = false,
4829 padding = 0
4830 } = evaluate(options, state);
4831 const paddingObject = getPaddingObject(padding);
4832 const altContext = elementContext === "floating" ? "reference" : "floating";
4833 const element = elements[altBoundary ? altContext : elementContext];
4834 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4835 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)),
4836 boundary,
4837 rootBoundary,
4838 strategy
4839 }));
4840 const rect = elementContext === "floating" ? {
4841 x: x2,
4842 y: y2,
4843 width: rects.floating.width,
4844 height: rects.floating.height
4845 } : rects.reference;
4846 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4847 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4848 x: 1,
4849 y: 1
4850 } : {
4851 x: 1,
4852 y: 1
4853 };
4854 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4855 elements,
4856 rect,
4857 offsetParent,
4858 strategy
4859 }) : rect);
4860 return {
4861 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4862 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4863 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4864 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4865 };
4866 }
4867 var MAX_RESET_COUNT = 50;
4868 var computePosition = async (reference, floating, config) => {
4869 const {
4870 placement = "bottom",
4871 strategy = "absolute",
4872 middleware = [],
4873 platform: platform3
4874 } = config;
4875 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4876 ...platform3,
4877 detectOverflow
4878 };
4879 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4880 let rects = await platform3.getElementRects({
4881 reference,
4882 floating,
4883 strategy
4884 });
4885 let {
4886 x: x2,
4887 y: y2
4888 } = computeCoordsFromPlacement(rects, placement, rtl);
4889 let statefulPlacement = placement;
4890 let resetCount = 0;
4891 const middlewareData = {};
4892 for (let i2 = 0; i2 < middleware.length; i2++) {
4893 const currentMiddleware = middleware[i2];
4894 if (!currentMiddleware) {
4895 continue;
4896 }
4897 const {
4898 name,
4899 fn
4900 } = currentMiddleware;
4901 const {
4902 x: nextX,
4903 y: nextY,
4904 data,
4905 reset
4906 } = await fn({
4907 x: x2,
4908 y: y2,
4909 initialPlacement: placement,
4910 placement: statefulPlacement,
4911 strategy,
4912 middlewareData,
4913 rects,
4914 platform: platformWithDetectOverflow,
4915 elements: {
4916 reference,
4917 floating
4918 }
4919 });
4920 x2 = nextX != null ? nextX : x2;
4921 y2 = nextY != null ? nextY : y2;
4922 middlewareData[name] = {
4923 ...middlewareData[name],
4924 ...data
4925 };
4926 if (reset && resetCount < MAX_RESET_COUNT) {
4927 resetCount++;
4928 if (typeof reset === "object") {
4929 if (reset.placement) {
4930 statefulPlacement = reset.placement;
4931 }
4932 if (reset.rects) {
4933 rects = reset.rects === true ? await platform3.getElementRects({
4934 reference,
4935 floating,
4936 strategy
4937 }) : reset.rects;
4938 }
4939 ({
4940 x: x2,
4941 y: y2
4942 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4943 }
4944 i2 = -1;
4945 }
4946 }
4947 return {
4948 x: x2,
4949 y: y2,
4950 placement: statefulPlacement,
4951 strategy,
4952 middlewareData
4953 };
4954 };
4955 var flip = function(options) {
4956 if (options === void 0) {
4957 options = {};
4958 }
4959 return {
4960 name: "flip",
4961 options,
4962 async fn(state) {
4963 var _middlewareData$arrow, _middlewareData$flip;
4964 const {
4965 placement,
4966 middlewareData,
4967 rects,
4968 initialPlacement,
4969 platform: platform3,
4970 elements
4971 } = state;
4972 const {
4973 mainAxis: checkMainAxis = true,
4974 crossAxis: checkCrossAxis = true,
4975 fallbackPlacements: specifiedFallbackPlacements,
4976 fallbackStrategy = "bestFit",
4977 fallbackAxisSideDirection = "none",
4978 flipAlignment = true,
4979 ...detectOverflowOptions
4980 } = evaluate(options, state);
4981 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4982 return {};
4983 }
4984 const side = getSide(placement);
4985 const initialSideAxis = getSideAxis(initialPlacement);
4986 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4987 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4988 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4989 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4990 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4991 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4992 }
4993 const placements2 = [initialPlacement, ...fallbackPlacements];
4994 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4995 const overflows = [];
4996 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4997 if (checkMainAxis) {
4998 overflows.push(overflow[side]);
4999 }
5000 if (checkCrossAxis) {
5001 const sides2 = getAlignmentSides(placement, rects, rtl);
5002 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
5003 }
5004 overflowsData = [...overflowsData, {
5005 placement,
5006 overflows
5007 }];
5008 if (!overflows.every((side2) => side2 <= 0)) {
5009 var _middlewareData$flip2, _overflowsData$filter;
5010 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
5011 const nextPlacement = placements2[nextIndex];
5012 if (nextPlacement) {
5013 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
5014 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
5015 // overflows the main axis.
5016 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
5017 return {
5018 data: {
5019 index: nextIndex,
5020 overflows: overflowsData
5021 },
5022 reset: {
5023 placement: nextPlacement
5024 }
5025 };
5026 }
5027 }
5028 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;
5029 if (!resetPlacement) {
5030 switch (fallbackStrategy) {
5031 case "bestFit": {
5032 var _overflowsData$filter2;
5033 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
5034 if (hasFallbackAxisSideDirection) {
5035 const currentSideAxis = getSideAxis(d2.placement);
5036 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
5037 // reading directions favoring greater width.
5038 currentSideAxis === "y";
5039 }
5040 return true;
5041 }).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];
5042 if (placement2) {
5043 resetPlacement = placement2;
5044 }
5045 break;
5046 }
5047 case "initialPlacement":
5048 resetPlacement = initialPlacement;
5049 break;
5050 }
5051 }
5052 if (placement !== resetPlacement) {
5053 return {
5054 reset: {
5055 placement: resetPlacement
5056 }
5057 };
5058 }
5059 }
5060 return {};
5061 }
5062 };
5063 };
5064 function getSideOffsets(overflow, rect) {
5065 return {
5066 top: overflow.top - rect.height,
5067 right: overflow.right - rect.width,
5068 bottom: overflow.bottom - rect.height,
5069 left: overflow.left - rect.width
5070 };
5071 }
5072 function isAnySideFullyClipped(overflow) {
5073 return sides.some((side) => overflow[side] >= 0);
5074 }
5075 var hide = function(options) {
5076 if (options === void 0) {
5077 options = {};
5078 }
5079 return {
5080 name: "hide",
5081 options,
5082 async fn(state) {
5083 const {
5084 rects,
5085 platform: platform3
5086 } = state;
5087 const {
5088 strategy = "referenceHidden",
5089 ...detectOverflowOptions
5090 } = evaluate(options, state);
5091 switch (strategy) {
5092 case "referenceHidden": {
5093 const overflow = await platform3.detectOverflow(state, {
5094 ...detectOverflowOptions,
5095 elementContext: "reference"
5096 });
5097 const offsets = getSideOffsets(overflow, rects.reference);
5098 return {
5099 data: {
5100 referenceHiddenOffsets: offsets,
5101 referenceHidden: isAnySideFullyClipped(offsets)
5102 }
5103 };
5104 }
5105 case "escaped": {
5106 const overflow = await platform3.detectOverflow(state, {
5107 ...detectOverflowOptions,
5108 altBoundary: true
5109 });
5110 const offsets = getSideOffsets(overflow, rects.floating);
5111 return {
5112 data: {
5113 escapedOffsets: offsets,
5114 escaped: isAnySideFullyClipped(offsets)
5115 }
5116 };
5117 }
5118 default: {
5119 return {};
5120 }
5121 }
5122 }
5123 };
5124 };
5125 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
5126 async function convertValueToCoords(state, options) {
5127 const {
5128 placement,
5129 platform: platform3,
5130 elements
5131 } = state;
5132 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
5133 const side = getSide(placement);
5134 const alignment = getAlignment(placement);
5135 const isVertical = getSideAxis(placement) === "y";
5136 const mainAxisMulti = originSides.has(side) ? -1 : 1;
5137 const crossAxisMulti = rtl && isVertical ? -1 : 1;
5138 const rawValue = evaluate(options, state);
5139 let {
5140 mainAxis,
5141 crossAxis,
5142 alignmentAxis
5143 } = typeof rawValue === "number" ? {
5144 mainAxis: rawValue,
5145 crossAxis: 0,
5146 alignmentAxis: null
5147 } : {
5148 mainAxis: rawValue.mainAxis || 0,
5149 crossAxis: rawValue.crossAxis || 0,
5150 alignmentAxis: rawValue.alignmentAxis
5151 };
5152 if (alignment && typeof alignmentAxis === "number") {
5153 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
5154 }
5155 return isVertical ? {
5156 x: crossAxis * crossAxisMulti,
5157 y: mainAxis * mainAxisMulti
5158 } : {
5159 x: mainAxis * mainAxisMulti,
5160 y: crossAxis * crossAxisMulti
5161 };
5162 }
5163 var offset = function(options) {
5164 if (options === void 0) {
5165 options = 0;
5166 }
5167 return {
5168 name: "offset",
5169 options,
5170 async fn(state) {
5171 var _middlewareData$offse, _middlewareData$arrow;
5172 const {
5173 x: x2,
5174 y: y2,
5175 placement,
5176 middlewareData
5177 } = state;
5178 const diffCoords = await convertValueToCoords(state, options);
5179 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
5180 return {};
5181 }
5182 return {
5183 x: x2 + diffCoords.x,
5184 y: y2 + diffCoords.y,
5185 data: {
5186 ...diffCoords,
5187 placement
5188 }
5189 };
5190 }
5191 };
5192 };
5193 var shift = function(options) {
5194 if (options === void 0) {
5195 options = {};
5196 }
5197 return {
5198 name: "shift",
5199 options,
5200 async fn(state) {
5201 const {
5202 x: x2,
5203 y: y2,
5204 placement,
5205 platform: platform3
5206 } = state;
5207 const {
5208 mainAxis: checkMainAxis = true,
5209 crossAxis: checkCrossAxis = false,
5210 limiter = {
5211 fn: (_ref) => {
5212 let {
5213 x: x3,
5214 y: y3
5215 } = _ref;
5216 return {
5217 x: x3,
5218 y: y3
5219 };
5220 }
5221 },
5222 ...detectOverflowOptions
5223 } = evaluate(options, state);
5224 const coords = {
5225 x: x2,
5226 y: y2
5227 };
5228 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5229 const crossAxis = getSideAxis(getSide(placement));
5230 const mainAxis = getOppositeAxis(crossAxis);
5231 let mainAxisCoord = coords[mainAxis];
5232 let crossAxisCoord = coords[crossAxis];
5233 if (checkMainAxis) {
5234 const minSide = mainAxis === "y" ? "top" : "left";
5235 const maxSide = mainAxis === "y" ? "bottom" : "right";
5236 const min2 = mainAxisCoord + overflow[minSide];
5237 const max2 = mainAxisCoord - overflow[maxSide];
5238 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
5239 }
5240 if (checkCrossAxis) {
5241 const minSide = crossAxis === "y" ? "top" : "left";
5242 const maxSide = crossAxis === "y" ? "bottom" : "right";
5243 const min2 = crossAxisCoord + overflow[minSide];
5244 const max2 = crossAxisCoord - overflow[maxSide];
5245 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
5246 }
5247 const limitedCoords = limiter.fn({
5248 ...state,
5249 [mainAxis]: mainAxisCoord,
5250 [crossAxis]: crossAxisCoord
5251 });
5252 return {
5253 ...limitedCoords,
5254 data: {
5255 x: limitedCoords.x - x2,
5256 y: limitedCoords.y - y2,
5257 enabled: {
5258 [mainAxis]: checkMainAxis,
5259 [crossAxis]: checkCrossAxis
5260 }
5261 }
5262 };
5263 }
5264 };
5265 };
5266 var limitShift = function(options) {
5267 if (options === void 0) {
5268 options = {};
5269 }
5270 return {
5271 options,
5272 fn(state) {
5273 const {
5274 x: x2,
5275 y: y2,
5276 placement,
5277 rects,
5278 middlewareData
5279 } = state;
5280 const {
5281 offset: offset4 = 0,
5282 mainAxis: checkMainAxis = true,
5283 crossAxis: checkCrossAxis = true
5284 } = evaluate(options, state);
5285 const coords = {
5286 x: x2,
5287 y: y2
5288 };
5289 const crossAxis = getSideAxis(placement);
5290 const mainAxis = getOppositeAxis(crossAxis);
5291 let mainAxisCoord = coords[mainAxis];
5292 let crossAxisCoord = coords[crossAxis];
5293 const rawOffset = evaluate(offset4, state);
5294 const computedOffset = typeof rawOffset === "number" ? {
5295 mainAxis: rawOffset,
5296 crossAxis: 0
5297 } : {
5298 mainAxis: 0,
5299 crossAxis: 0,
5300 ...rawOffset
5301 };
5302 if (checkMainAxis) {
5303 const len = mainAxis === "y" ? "height" : "width";
5304 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
5305 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
5306 if (mainAxisCoord < limitMin) {
5307 mainAxisCoord = limitMin;
5308 } else if (mainAxisCoord > limitMax) {
5309 mainAxisCoord = limitMax;
5310 }
5311 }
5312 if (checkCrossAxis) {
5313 var _middlewareData$offse, _middlewareData$offse2;
5314 const len = mainAxis === "y" ? "width" : "height";
5315 const isOriginSide = originSides.has(getSide(placement));
5316 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);
5317 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);
5318 if (crossAxisCoord < limitMin) {
5319 crossAxisCoord = limitMin;
5320 } else if (crossAxisCoord > limitMax) {
5321 crossAxisCoord = limitMax;
5322 }
5323 }
5324 return {
5325 [mainAxis]: mainAxisCoord,
5326 [crossAxis]: crossAxisCoord
5327 };
5328 }
5329 };
5330 };
5331 var size = function(options) {
5332 if (options === void 0) {
5333 options = {};
5334 }
5335 return {
5336 name: "size",
5337 options,
5338 async fn(state) {
5339 var _state$middlewareData, _state$middlewareData2;
5340 const {
5341 placement,
5342 rects,
5343 platform: platform3,
5344 elements
5345 } = state;
5346 const {
5347 apply = () => {
5348 },
5349 ...detectOverflowOptions
5350 } = evaluate(options, state);
5351 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5352 const side = getSide(placement);
5353 const alignment = getAlignment(placement);
5354 const isYAxis = getSideAxis(placement) === "y";
5355 const {
5356 width,
5357 height
5358 } = rects.floating;
5359 let heightSide;
5360 let widthSide;
5361 if (side === "top" || side === "bottom") {
5362 heightSide = side;
5363 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
5364 } else {
5365 widthSide = side;
5366 heightSide = alignment === "end" ? "top" : "bottom";
5367 }
5368 const maximumClippingHeight = height - overflow.top - overflow.bottom;
5369 const maximumClippingWidth = width - overflow.left - overflow.right;
5370 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
5371 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
5372 const noShift = !state.middlewareData.shift;
5373 let availableHeight = overflowAvailableHeight;
5374 let availableWidth = overflowAvailableWidth;
5375 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
5376 availableWidth = maximumClippingWidth;
5377 }
5378 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
5379 availableHeight = maximumClippingHeight;
5380 }
5381 if (noShift && !alignment) {
5382 const xMin = max(overflow.left, 0);
5383 const xMax = max(overflow.right, 0);
5384 const yMin = max(overflow.top, 0);
5385 const yMax = max(overflow.bottom, 0);
5386 if (isYAxis) {
5387 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
5388 } else {
5389 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
5390 }
5391 }
5392 await apply({
5393 ...state,
5394 availableWidth,
5395 availableHeight
5396 });
5397 const nextDimensions = await platform3.getDimensions(elements.floating);
5398 if (width !== nextDimensions.width || height !== nextDimensions.height) {
5399 return {
5400 reset: {
5401 rects: true
5402 }
5403 };
5404 }
5405 return {};
5406 }
5407 };
5408 };
5409
5410 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
5411 function getCssDimensions(element) {
5412 const css = getComputedStyle2(element);
5413 let width = parseFloat(css.width) || 0;
5414 let height = parseFloat(css.height) || 0;
5415 const hasOffset = isHTMLElement(element);
5416 const offsetWidth = hasOffset ? element.offsetWidth : width;
5417 const offsetHeight = hasOffset ? element.offsetHeight : height;
5418 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5419 if (shouldFallback) {
5420 width = offsetWidth;
5421 height = offsetHeight;
5422 }
5423 return {
5424 width,
5425 height,
5426 $: shouldFallback
5427 };
5428 }
5429 function unwrapElement(element) {
5430 return !isElement(element) ? element.contextElement : element;
5431 }
5432 function getScale(element) {
5433 const domElement = unwrapElement(element);
5434 if (!isHTMLElement(domElement)) {
5435 return createCoords(1);
5436 }
5437 const rect = domElement.getBoundingClientRect();
5438 const {
5439 width,
5440 height,
5441 $: $2
5442 } = getCssDimensions(domElement);
5443 let x2 = ($2 ? round(rect.width) : rect.width) / width;
5444 let y2 = ($2 ? round(rect.height) : rect.height) / height;
5445 if (!x2 || !Number.isFinite(x2)) {
5446 x2 = 1;
5447 }
5448 if (!y2 || !Number.isFinite(y2)) {
5449 y2 = 1;
5450 }
5451 return {
5452 x: x2,
5453 y: y2
5454 };
5455 }
5456 var noOffsets = /* @__PURE__ */ createCoords(0);
5457 function getVisualOffsets(element) {
5458 const win = getWindow(element);
5459 if (!isWebKit() || !win.visualViewport) {
5460 return noOffsets;
5461 }
5462 return {
5463 x: win.visualViewport.offsetLeft,
5464 y: win.visualViewport.offsetTop
5465 };
5466 }
5467 function shouldAddVisualOffsets(element, isFixed2, floatingOffsetParent) {
5468 if (isFixed2 === void 0) {
5469 isFixed2 = false;
5470 }
5471 if (!floatingOffsetParent || isFixed2 && floatingOffsetParent !== getWindow(element)) {
5472 return false;
5473 }
5474 return isFixed2;
5475 }
5476 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5477 if (includeScale === void 0) {
5478 includeScale = false;
5479 }
5480 if (isFixedStrategy === void 0) {
5481 isFixedStrategy = false;
5482 }
5483 const clientRect = element.getBoundingClientRect();
5484 const domElement = unwrapElement(element);
5485 let scale = createCoords(1);
5486 if (includeScale) {
5487 if (offsetParent) {
5488 if (isElement(offsetParent)) {
5489 scale = getScale(offsetParent);
5490 }
5491 } else {
5492 scale = getScale(element);
5493 }
5494 }
5495 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5496 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5497 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5498 let width = clientRect.width / scale.x;
5499 let height = clientRect.height / scale.y;
5500 if (domElement) {
5501 const win = getWindow(domElement);
5502 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5503 let currentWin = win;
5504 let currentIFrame = getFrameElement(currentWin);
5505 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5506 const iframeScale = getScale(currentIFrame);
5507 const iframeRect = currentIFrame.getBoundingClientRect();
5508 const css = getComputedStyle2(currentIFrame);
5509 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5510 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5511 x2 *= iframeScale.x;
5512 y2 *= iframeScale.y;
5513 width *= iframeScale.x;
5514 height *= iframeScale.y;
5515 x2 += left;
5516 y2 += top;
5517 currentWin = getWindow(currentIFrame);
5518 currentIFrame = getFrameElement(currentWin);
5519 }
5520 }
5521 return rectToClientRect({
5522 width,
5523 height,
5524 x: x2,
5525 y: y2
5526 });
5527 }
5528 function getWindowScrollBarX(element, rect) {
5529 const leftScroll = getNodeScroll(element).scrollLeft;
5530 if (!rect) {
5531 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5532 }
5533 return rect.left + leftScroll;
5534 }
5535 function getHTMLOffset(documentElement, scroll) {
5536 const htmlRect = documentElement.getBoundingClientRect();
5537 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5538 const y2 = htmlRect.top + scroll.scrollTop;
5539 return {
5540 x: x2,
5541 y: y2
5542 };
5543 }
5544 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5545 let {
5546 elements,
5547 rect,
5548 offsetParent,
5549 strategy
5550 } = _ref;
5551 const isFixed2 = strategy === "fixed";
5552 const documentElement = getDocumentElement(offsetParent);
5553 const topLayer = elements ? isTopLayer(elements.floating) : false;
5554 if (offsetParent === documentElement || topLayer && isFixed2) {
5555 return rect;
5556 }
5557 let scroll = {
5558 scrollLeft: 0,
5559 scrollTop: 0
5560 };
5561 let scale = createCoords(1);
5562 const offsets = createCoords(0);
5563 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5564 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed2) {
5565 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5566 scroll = getNodeScroll(offsetParent);
5567 }
5568 if (isOffsetParentAnElement) {
5569 const offsetRect = getBoundingClientRect(offsetParent);
5570 scale = getScale(offsetParent);
5571 offsets.x = offsetRect.x + offsetParent.clientLeft;
5572 offsets.y = offsetRect.y + offsetParent.clientTop;
5573 }
5574 }
5575 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed2 ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5576 return {
5577 width: rect.width * scale.x,
5578 height: rect.height * scale.y,
5579 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5580 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5581 };
5582 }
5583 function getClientRects(element) {
5584 return Array.from(element.getClientRects());
5585 }
5586 function getDocumentRect(element) {
5587 const html = getDocumentElement(element);
5588 const scroll = getNodeScroll(element);
5589 const body = element.ownerDocument.body;
5590 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5591 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5592 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5593 const y2 = -scroll.scrollTop;
5594 if (getComputedStyle2(body).direction === "rtl") {
5595 x2 += max(html.clientWidth, body.clientWidth) - width;
5596 }
5597 return {
5598 width,
5599 height,
5600 x: x2,
5601 y: y2
5602 };
5603 }
5604 var SCROLLBAR_MAX = 25;
5605 function getViewportRect(element, strategy) {
5606 const win = getWindow(element);
5607 const html = getDocumentElement(element);
5608 const visualViewport = win.visualViewport;
5609 let width = html.clientWidth;
5610 let height = html.clientHeight;
5611 let x2 = 0;
5612 let y2 = 0;
5613 if (visualViewport) {
5614 width = visualViewport.width;
5615 height = visualViewport.height;
5616 const visualViewportBased = isWebKit();
5617 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5618 x2 = visualViewport.offsetLeft;
5619 y2 = visualViewport.offsetTop;
5620 }
5621 }
5622 const windowScrollbarX = getWindowScrollBarX(html);
5623 if (windowScrollbarX <= 0) {
5624 const doc = html.ownerDocument;
5625 const body = doc.body;
5626 const bodyStyles = getComputedStyle(body);
5627 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5628 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5629 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5630 width -= clippingStableScrollbarWidth;
5631 }
5632 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5633 width += windowScrollbarX;
5634 }
5635 return {
5636 width,
5637 height,
5638 x: x2,
5639 y: y2
5640 };
5641 }
5642 function getInnerBoundingClientRect(element, strategy) {
5643 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5644 const top = clientRect.top + element.clientTop;
5645 const left = clientRect.left + element.clientLeft;
5646 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5647 const width = element.clientWidth * scale.x;
5648 const height = element.clientHeight * scale.y;
5649 const x2 = left * scale.x;
5650 const y2 = top * scale.y;
5651 return {
5652 width,
5653 height,
5654 x: x2,
5655 y: y2
5656 };
5657 }
5658 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5659 let rect;
5660 if (clippingAncestor === "viewport") {
5661 rect = getViewportRect(element, strategy);
5662 } else if (clippingAncestor === "document") {
5663 rect = getDocumentRect(getDocumentElement(element));
5664 } else if (isElement(clippingAncestor)) {
5665 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5666 } else {
5667 const visualOffsets = getVisualOffsets(element);
5668 rect = {
5669 x: clippingAncestor.x - visualOffsets.x,
5670 y: clippingAncestor.y - visualOffsets.y,
5671 width: clippingAncestor.width,
5672 height: clippingAncestor.height
5673 };
5674 }
5675 return rectToClientRect(rect);
5676 }
5677 function hasFixedPositionAncestor(element, stopNode) {
5678 const parentNode = getParentNode(element);
5679 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5680 return false;
5681 }
5682 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5683 }
5684 function getClippingElementAncestors(element, cache) {
5685 const cachedResult = cache.get(element);
5686 if (cachedResult) {
5687 return cachedResult;
5688 }
5689 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5690 let currentContainingBlockComputedStyle = null;
5691 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5692 let currentNode = elementIsFixed ? getParentNode(element) : element;
5693 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5694 const computedStyle = getComputedStyle2(currentNode);
5695 const currentNodeIsContaining = isContainingBlock(currentNode);
5696 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5697 currentContainingBlockComputedStyle = null;
5698 }
5699 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5700 if (shouldDropCurrentNode) {
5701 result = result.filter((ancestor) => ancestor !== currentNode);
5702 } else {
5703 currentContainingBlockComputedStyle = computedStyle;
5704 }
5705 currentNode = getParentNode(currentNode);
5706 }
5707 cache.set(element, result);
5708 return result;
5709 }
5710 function getClippingRect(_ref) {
5711 let {
5712 element,
5713 boundary,
5714 rootBoundary,
5715 strategy
5716 } = _ref;
5717 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5718 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5719 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5720 let top = firstRect.top;
5721 let right = firstRect.right;
5722 let bottom = firstRect.bottom;
5723 let left = firstRect.left;
5724 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5725 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5726 top = max(rect.top, top);
5727 right = min(rect.right, right);
5728 bottom = min(rect.bottom, bottom);
5729 left = max(rect.left, left);
5730 }
5731 return {
5732 width: right - left,
5733 height: bottom - top,
5734 x: left,
5735 y: top
5736 };
5737 }
5738 function getDimensions(element) {
5739 const {
5740 width,
5741 height
5742 } = getCssDimensions(element);
5743 return {
5744 width,
5745 height
5746 };
5747 }
5748 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5749 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5750 const documentElement = getDocumentElement(offsetParent);
5751 const isFixed2 = strategy === "fixed";
5752 const rect = getBoundingClientRect(element, true, isFixed2, offsetParent);
5753 let scroll = {
5754 scrollLeft: 0,
5755 scrollTop: 0
5756 };
5757 const offsets = createCoords(0);
5758 function setLeftRTLScrollbarOffset() {
5759 offsets.x = getWindowScrollBarX(documentElement);
5760 }
5761 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed2) {
5762 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5763 scroll = getNodeScroll(offsetParent);
5764 }
5765 if (isOffsetParentAnElement) {
5766 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed2, offsetParent);
5767 offsets.x = offsetRect.x + offsetParent.clientLeft;
5768 offsets.y = offsetRect.y + offsetParent.clientTop;
5769 } else if (documentElement) {
5770 setLeftRTLScrollbarOffset();
5771 }
5772 }
5773 if (isFixed2 && !isOffsetParentAnElement && documentElement) {
5774 setLeftRTLScrollbarOffset();
5775 }
5776 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed2 ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5777 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5778 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5779 return {
5780 x: x2,
5781 y: y2,
5782 width: rect.width,
5783 height: rect.height
5784 };
5785 }
5786 function isStaticPositioned(element) {
5787 return getComputedStyle2(element).position === "static";
5788 }
5789 function getTrueOffsetParent(element, polyfill) {
5790 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5791 return null;
5792 }
5793 if (polyfill) {
5794 return polyfill(element);
5795 }
5796 let rawOffsetParent = element.offsetParent;
5797 if (getDocumentElement(element) === rawOffsetParent) {
5798 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5799 }
5800 return rawOffsetParent;
5801 }
5802 function getOffsetParent(element, polyfill) {
5803 const win = getWindow(element);
5804 if (isTopLayer(element)) {
5805 return win;
5806 }
5807 if (!isHTMLElement(element)) {
5808 let svgOffsetParent = getParentNode(element);
5809 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5810 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5811 return svgOffsetParent;
5812 }
5813 svgOffsetParent = getParentNode(svgOffsetParent);
5814 }
5815 return win;
5816 }
5817 let offsetParent = getTrueOffsetParent(element, polyfill);
5818 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5819 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5820 }
5821 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5822 return win;
5823 }
5824 return offsetParent || getContainingBlock(element) || win;
5825 }
5826 var getElementRects = async function(data) {
5827 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5828 const getDimensionsFn = this.getDimensions;
5829 const floatingDimensions = await getDimensionsFn(data.floating);
5830 return {
5831 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5832 floating: {
5833 x: 0,
5834 y: 0,
5835 width: floatingDimensions.width,
5836 height: floatingDimensions.height
5837 }
5838 };
5839 };
5840 function isRTL(element) {
5841 return getComputedStyle2(element).direction === "rtl";
5842 }
5843 var platform2 = {
5844 convertOffsetParentRelativeRectToViewportRelativeRect,
5845 getDocumentElement,
5846 getClippingRect,
5847 getOffsetParent,
5848 getElementRects,
5849 getClientRects,
5850 getDimensions,
5851 getScale,
5852 isElement,
5853 isRTL
5854 };
5855 function rectsAreEqual(a2, b2) {
5856 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5857 }
5858 function observeMove(element, onMove) {
5859 let io = null;
5860 let timeoutId;
5861 const root = getDocumentElement(element);
5862 function cleanup() {
5863 var _io;
5864 clearTimeout(timeoutId);
5865 (_io = io) == null || _io.disconnect();
5866 io = null;
5867 }
5868 function refresh(skip, threshold) {
5869 if (skip === void 0) {
5870 skip = false;
5871 }
5872 if (threshold === void 0) {
5873 threshold = 1;
5874 }
5875 cleanup();
5876 const elementRectForRootMargin = element.getBoundingClientRect();
5877 const {
5878 left,
5879 top,
5880 width,
5881 height
5882 } = elementRectForRootMargin;
5883 if (!skip) {
5884 onMove();
5885 }
5886 if (!width || !height) {
5887 return;
5888 }
5889 const insetTop = floor(top);
5890 const insetRight = floor(root.clientWidth - (left + width));
5891 const insetBottom = floor(root.clientHeight - (top + height));
5892 const insetLeft = floor(left);
5893 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5894 const options = {
5895 rootMargin,
5896 threshold: max(0, min(1, threshold)) || 1
5897 };
5898 let isFirstUpdate = true;
5899 function handleObserve(entries) {
5900 const ratio = entries[0].intersectionRatio;
5901 if (ratio !== threshold) {
5902 if (!isFirstUpdate) {
5903 return refresh();
5904 }
5905 if (!ratio) {
5906 timeoutId = setTimeout(() => {
5907 refresh(false, 1e-7);
5908 }, 1e3);
5909 } else {
5910 refresh(false, ratio);
5911 }
5912 }
5913 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5914 refresh();
5915 }
5916 isFirstUpdate = false;
5917 }
5918 try {
5919 io = new IntersectionObserver(handleObserve, {
5920 ...options,
5921 // Handle <iframe>s
5922 root: root.ownerDocument
5923 });
5924 } catch (_e) {
5925 io = new IntersectionObserver(handleObserve, options);
5926 }
5927 io.observe(element);
5928 }
5929 refresh(true);
5930 return cleanup;
5931 }
5932 function autoUpdate(reference, floating, update2, options) {
5933 if (options === void 0) {
5934 options = {};
5935 }
5936 const {
5937 ancestorScroll = true,
5938 ancestorResize = true,
5939 elementResize = typeof ResizeObserver === "function",
5940 layoutShift = typeof IntersectionObserver === "function",
5941 animationFrame = false
5942 } = options;
5943 const referenceEl = unwrapElement(reference);
5944 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5945 ancestors.forEach((ancestor) => {
5946 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5947 passive: true
5948 });
5949 ancestorResize && ancestor.addEventListener("resize", update2);
5950 });
5951 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5952 let reobserveFrame = -1;
5953 let resizeObserver = null;
5954 if (elementResize) {
5955 resizeObserver = new ResizeObserver((_ref) => {
5956 let [firstEntry] = _ref;
5957 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5958 resizeObserver.unobserve(floating);
5959 cancelAnimationFrame(reobserveFrame);
5960 reobserveFrame = requestAnimationFrame(() => {
5961 var _resizeObserver;
5962 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5963 });
5964 }
5965 update2();
5966 });
5967 if (referenceEl && !animationFrame) {
5968 resizeObserver.observe(referenceEl);
5969 }
5970 if (floating) {
5971 resizeObserver.observe(floating);
5972 }
5973 }
5974 let frameId;
5975 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5976 if (animationFrame) {
5977 frameLoop();
5978 }
5979 function frameLoop() {
5980 const nextRefRect = getBoundingClientRect(reference);
5981 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5982 update2();
5983 }
5984 prevRefRect = nextRefRect;
5985 frameId = requestAnimationFrame(frameLoop);
5986 }
5987 update2();
5988 return () => {
5989 var _resizeObserver2;
5990 ancestors.forEach((ancestor) => {
5991 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5992 ancestorResize && ancestor.removeEventListener("resize", update2);
5993 });
5994 cleanupIo == null || cleanupIo();
5995 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5996 resizeObserver = null;
5997 if (animationFrame) {
5998 cancelAnimationFrame(frameId);
5999 }
6000 };
6001 }
6002 var offset2 = offset;
6003 var shift2 = shift;
6004 var flip2 = flip;
6005 var size2 = size;
6006 var hide2 = hide;
6007 var limitShift2 = limitShift;
6008 var computePosition2 = (reference, floating, options) => {
6009 const cache = /* @__PURE__ */ new Map();
6010 const mergedOptions = {
6011 platform: platform2,
6012 ...options
6013 };
6014 const platformWithCache = {
6015 ...mergedOptions.platform,
6016 _c: cache
6017 };
6018 return computePosition(reference, floating, {
6019 ...mergedOptions,
6020 platform: platformWithCache
6021 });
6022 };
6023
6024 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
6025 var React25 = __toESM(require_react(), 1);
6026 var import_react2 = __toESM(require_react(), 1);
6027 var ReactDOM3 = __toESM(require_react_dom(), 1);
6028 var isClient = typeof document !== "undefined";
6029 var noop2 = function noop3() {
6030 };
6031 var index = isClient ? import_react2.useLayoutEffect : noop2;
6032 function deepEqual(a2, b2) {
6033 if (a2 === b2) {
6034 return true;
6035 }
6036 if (typeof a2 !== typeof b2) {
6037 return false;
6038 }
6039 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
6040 return true;
6041 }
6042 let length;
6043 let i2;
6044 let keys;
6045 if (a2 && b2 && typeof a2 === "object") {
6046 if (Array.isArray(a2)) {
6047 length = a2.length;
6048 if (length !== b2.length) return false;
6049 for (i2 = length; i2-- !== 0; ) {
6050 if (!deepEqual(a2[i2], b2[i2])) {
6051 return false;
6052 }
6053 }
6054 return true;
6055 }
6056 keys = Object.keys(a2);
6057 length = keys.length;
6058 if (length !== Object.keys(b2).length) {
6059 return false;
6060 }
6061 for (i2 = length; i2-- !== 0; ) {
6062 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
6063 return false;
6064 }
6065 }
6066 for (i2 = length; i2-- !== 0; ) {
6067 const key2 = keys[i2];
6068 if (key2 === "_owner" && a2.$$typeof) {
6069 continue;
6070 }
6071 if (!deepEqual(a2[key2], b2[key2])) {
6072 return false;
6073 }
6074 }
6075 return true;
6076 }
6077 return a2 !== a2 && b2 !== b2;
6078 }
6079 function getDPR(element) {
6080 if (typeof window === "undefined") {
6081 return 1;
6082 }
6083 const win = element.ownerDocument.defaultView || window;
6084 return win.devicePixelRatio || 1;
6085 }
6086 function roundByDPR(element, value) {
6087 const dpr = getDPR(element);
6088 return Math.round(value * dpr) / dpr;
6089 }
6090 function useLatestRef(value) {
6091 const ref = React25.useRef(value);
6092 index(() => {
6093 ref.current = value;
6094 });
6095 return ref;
6096 }
6097 function useFloating(options) {
6098 if (options === void 0) {
6099 options = {};
6100 }
6101 const {
6102 placement = "bottom",
6103 strategy = "absolute",
6104 middleware = [],
6105 platform: platform3,
6106 elements: {
6107 reference: externalReference,
6108 floating: externalFloating
6109 } = {},
6110 transform = true,
6111 whileElementsMounted,
6112 open
6113 } = options;
6114 const [data, setData] = React25.useState({
6115 x: 0,
6116 y: 0,
6117 strategy,
6118 placement,
6119 middlewareData: {},
6120 isPositioned: false
6121 });
6122 const [latestMiddleware, setLatestMiddleware] = React25.useState(middleware);
6123 if (!deepEqual(latestMiddleware, middleware)) {
6124 setLatestMiddleware(middleware);
6125 }
6126 const [_reference, _setReference] = React25.useState(null);
6127 const [_floating, _setFloating] = React25.useState(null);
6128 const setReference = React25.useCallback((node) => {
6129 if (node !== referenceRef.current) {
6130 referenceRef.current = node;
6131 _setReference(node);
6132 }
6133 }, []);
6134 const setFloating = React25.useCallback((node) => {
6135 if (node !== floatingRef.current) {
6136 floatingRef.current = node;
6137 _setFloating(node);
6138 }
6139 }, []);
6140 const referenceEl = externalReference || _reference;
6141 const floatingEl = externalFloating || _floating;
6142 const referenceRef = React25.useRef(null);
6143 const floatingRef = React25.useRef(null);
6144 const dataRef = React25.useRef(data);
6145 const hasWhileElementsMounted = whileElementsMounted != null;
6146 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
6147 const platformRef = useLatestRef(platform3);
6148 const openRef = useLatestRef(open);
6149 const update2 = React25.useCallback(() => {
6150 if (!referenceRef.current || !floatingRef.current) {
6151 return;
6152 }
6153 const config = {
6154 placement,
6155 strategy,
6156 middleware: latestMiddleware
6157 };
6158 if (platformRef.current) {
6159 config.platform = platformRef.current;
6160 }
6161 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
6162 const fullData = {
6163 ...data2,
6164 // The floating element's position may be recomputed while it's closed
6165 // but still mounted (such as when transitioning out). To ensure
6166 // `isPositioned` will be `false` initially on the next open, avoid
6167 // setting it to `true` when `open === false` (must be specified).
6168 isPositioned: openRef.current !== false
6169 };
6170 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
6171 dataRef.current = fullData;
6172 ReactDOM3.flushSync(() => {
6173 setData(fullData);
6174 });
6175 }
6176 });
6177 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
6178 index(() => {
6179 if (open === false && dataRef.current.isPositioned) {
6180 dataRef.current.isPositioned = false;
6181 setData((data2) => ({
6182 ...data2,
6183 isPositioned: false
6184 }));
6185 }
6186 }, [open]);
6187 const isMountedRef = React25.useRef(false);
6188 index(() => {
6189 isMountedRef.current = true;
6190 return () => {
6191 isMountedRef.current = false;
6192 };
6193 }, []);
6194 index(() => {
6195 if (referenceEl) referenceRef.current = referenceEl;
6196 if (floatingEl) floatingRef.current = floatingEl;
6197 if (referenceEl && floatingEl) {
6198 if (whileElementsMountedRef.current) {
6199 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
6200 }
6201 update2();
6202 }
6203 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
6204 const refs = React25.useMemo(() => ({
6205 reference: referenceRef,
6206 floating: floatingRef,
6207 setReference,
6208 setFloating
6209 }), [setReference, setFloating]);
6210 const elements = React25.useMemo(() => ({
6211 reference: referenceEl,
6212 floating: floatingEl
6213 }), [referenceEl, floatingEl]);
6214 const floatingStyles = React25.useMemo(() => {
6215 const initialStyles = {
6216 position: strategy,
6217 left: 0,
6218 top: 0
6219 };
6220 if (!elements.floating) {
6221 return initialStyles;
6222 }
6223 const x2 = roundByDPR(elements.floating, data.x);
6224 const y2 = roundByDPR(elements.floating, data.y);
6225 if (transform) {
6226 return {
6227 ...initialStyles,
6228 transform: "translate(" + x2 + "px, " + y2 + "px)",
6229 ...getDPR(elements.floating) >= 1.5 && {
6230 willChange: "transform"
6231 }
6232 };
6233 }
6234 return {
6235 position: strategy,
6236 left: x2,
6237 top: y2
6238 };
6239 }, [strategy, transform, elements.floating, data.x, data.y]);
6240 return React25.useMemo(() => ({
6241 ...data,
6242 update: update2,
6243 refs,
6244 elements,
6245 floatingStyles
6246 }), [data, update2, refs, elements, floatingStyles]);
6247 }
6248 var offset3 = (options, deps) => {
6249 const result = offset2(options);
6250 return {
6251 name: result.name,
6252 fn: result.fn,
6253 options: [options, deps]
6254 };
6255 };
6256 var shift3 = (options, deps) => {
6257 const result = shift2(options);
6258 return {
6259 name: result.name,
6260 fn: result.fn,
6261 options: [options, deps]
6262 };
6263 };
6264 var limitShift3 = (options, deps) => {
6265 const result = limitShift2(options);
6266 return {
6267 fn: result.fn,
6268 options: [options, deps]
6269 };
6270 };
6271 var flip3 = (options, deps) => {
6272 const result = flip2(options);
6273 return {
6274 name: result.name,
6275 fn: result.fn,
6276 options: [options, deps]
6277 };
6278 };
6279 var size3 = (options, deps) => {
6280 const result = size2(options);
6281 return {
6282 name: result.name,
6283 fn: result.fn,
6284 options: [options, deps]
6285 };
6286 };
6287 var hide3 = (options, deps) => {
6288 const result = hide2(options);
6289 return {
6290 name: result.name,
6291 fn: result.fn,
6292 options: [options, deps]
6293 };
6294 };
6295
6296 // node_modules/@base-ui/utils/esm/store/createSelector.js
6297 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
6298 if (other.length > 0) {
6299 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
6300 }
6301 let selector2;
6302 if (a2 && b2 && c2 && d2 && e2 && f2) {
6303 selector2 = (state, a1, a22, a3) => {
6304 const va = a2(state, a1, a22, a3);
6305 const vb = b2(state, a1, a22, a3);
6306 const vc = c2(state, a1, a22, a3);
6307 const vd = d2(state, a1, a22, a3);
6308 const ve = e2(state, a1, a22, a3);
6309 return f2(va, vb, vc, vd, ve, a1, a22, a3);
6310 };
6311 } else if (a2 && b2 && c2 && d2 && e2) {
6312 selector2 = (state, a1, a22, a3) => {
6313 const va = a2(state, a1, a22, a3);
6314 const vb = b2(state, a1, a22, a3);
6315 const vc = c2(state, a1, a22, a3);
6316 const vd = d2(state, a1, a22, a3);
6317 return e2(va, vb, vc, vd, a1, a22, a3);
6318 };
6319 } else if (a2 && b2 && c2 && d2) {
6320 selector2 = (state, a1, a22, a3) => {
6321 const va = a2(state, a1, a22, a3);
6322 const vb = b2(state, a1, a22, a3);
6323 const vc = c2(state, a1, a22, a3);
6324 return d2(va, vb, vc, a1, a22, a3);
6325 };
6326 } else if (a2 && b2 && c2) {
6327 selector2 = (state, a1, a22, a3) => {
6328 const va = a2(state, a1, a22, a3);
6329 const vb = b2(state, a1, a22, a3);
6330 return c2(va, vb, a1, a22, a3);
6331 };
6332 } else if (a2 && b2) {
6333 selector2 = (state, a1, a22, a3) => {
6334 const va = a2(state, a1, a22, a3);
6335 return b2(va, a1, a22, a3);
6336 };
6337 } else if (a2) {
6338 selector2 = a2;
6339 } else {
6340 throw (
6341 /* minify-error-disabled */
6342 new Error("Missing arguments")
6343 );
6344 }
6345 return selector2;
6346 };
6347
6348 // node_modules/@base-ui/utils/esm/store/useStore.js
6349 var React27 = __toESM(require_react(), 1);
6350 var import_shim = __toESM(require_shim(), 1);
6351 var import_with_selector = __toESM(require_with_selector(), 1);
6352
6353 // node_modules/@base-ui/utils/esm/fastHooks.js
6354 var React26 = __toESM(require_react(), 1);
6355 var hooks = [];
6356 var currentInstance = void 0;
6357 function getInstance() {
6358 return currentInstance;
6359 }
6360 function register(hook) {
6361 hooks.push(hook);
6362 }
6363 function fastComponent(fn) {
6364 const FastComponent = (props, forwardedRef) => {
6365 const instance = useRefWithInit(createInstance).current;
6366 let result;
6367 try {
6368 currentInstance = instance;
6369 for (const hook of hooks) {
6370 hook.before(instance);
6371 }
6372 result = fn(props, forwardedRef);
6373 for (const hook of hooks) {
6374 hook.after(instance);
6375 }
6376 instance.didInitialize = true;
6377 } finally {
6378 currentInstance = void 0;
6379 }
6380 return result;
6381 };
6382 FastComponent.displayName = fn.displayName || fn.name;
6383 return FastComponent;
6384 }
6385 function fastComponentRef(fn) {
6386 return /* @__PURE__ */ React26.forwardRef(fastComponent(fn));
6387 }
6388 function createInstance() {
6389 return {
6390 didInitialize: false
6391 };
6392 }
6393
6394 // node_modules/@base-ui/utils/esm/store/useStore.js
6395 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
6396 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
6397 function useStore(store, selector2, a1, a2, a3) {
6398 return useStoreImplementation(store, selector2, a1, a2, a3);
6399 }
6400 function useStoreR19(store, selector2, a1, a2, a3) {
6401 const getSelection = React27.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
6402 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
6403 }
6404 register({
6405 before(instance) {
6406 instance.syncIndex = 0;
6407 if (!instance.didInitialize) {
6408 instance.syncTick = 1;
6409 instance.syncHooks = [];
6410 instance.didChangeStore = true;
6411 instance.getSnapshot = () => {
6412 let didChange2 = false;
6413 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
6414 const hook = instance.syncHooks[i2];
6415 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
6416 if (hook.didChange || !Object.is(hook.value, value)) {
6417 didChange2 = true;
6418 hook.value = value;
6419 hook.didChange = false;
6420 }
6421 }
6422 if (didChange2) {
6423 instance.syncTick += 1;
6424 }
6425 return instance.syncTick;
6426 };
6427 }
6428 },
6429 after(instance) {
6430 if (instance.syncHooks.length > 0) {
6431 if (instance.didChangeStore) {
6432 instance.didChangeStore = false;
6433 instance.subscribe = (onStoreChange) => {
6434 const stores = /* @__PURE__ */ new Set();
6435 for (const hook of instance.syncHooks) {
6436 stores.add(hook.store);
6437 }
6438 const unsubscribes = [];
6439 for (const store of stores) {
6440 unsubscribes.push(store.subscribe(onStoreChange));
6441 }
6442 return () => {
6443 for (const unsubscribe of unsubscribes) {
6444 unsubscribe();
6445 }
6446 };
6447 };
6448 }
6449 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6450 }
6451 }
6452 });
6453 function useStoreFast(store, selector2, a1, a2, a3) {
6454 const instance = getInstance();
6455 if (!instance) {
6456 return useStoreR19(store, selector2, a1, a2, a3);
6457 }
6458 const index2 = instance.syncIndex;
6459 instance.syncIndex += 1;
6460 let hook;
6461 if (!instance.didInitialize) {
6462 hook = {
6463 store,
6464 selector: selector2,
6465 a1,
6466 a2,
6467 a3,
6468 value: selector2(store.getSnapshot(), a1, a2, a3),
6469 didChange: false
6470 };
6471 instance.syncHooks.push(hook);
6472 } else {
6473 hook = instance.syncHooks[index2];
6474 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6475 if (hook.store !== store) {
6476 instance.didChangeStore = true;
6477 }
6478 hook.store = store;
6479 hook.selector = selector2;
6480 hook.a1 = a1;
6481 hook.a2 = a2;
6482 hook.a3 = a3;
6483 hook.didChange = true;
6484 }
6485 }
6486 return hook.value;
6487 }
6488 function useStoreLegacy(store, selector2, a1, a2, a3) {
6489 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6490 }
6491
6492 // node_modules/@base-ui/utils/esm/store/Store.js
6493 var Store = class {
6494 /**
6495 * The current state of the store.
6496 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6497 * 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).
6498 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6499 *
6500 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6501 */
6502 // Internal state to handle recursive `setState()` calls
6503 constructor(state) {
6504 this.state = state;
6505 this.listeners = /* @__PURE__ */ new Set();
6506 this.updateTick = 0;
6507 }
6508 /**
6509 * Registers a listener that will be called whenever the store's state changes.
6510 *
6511 * @param fn The listener function to be called on state changes.
6512 * @returns A function to unsubscribe the listener.
6513 */
6514 subscribe = (fn) => {
6515 this.listeners.add(fn);
6516 return () => {
6517 this.listeners.delete(fn);
6518 };
6519 };
6520 /**
6521 * Returns the current state of the store.
6522 */
6523 getSnapshot = () => {
6524 return this.state;
6525 };
6526 /**
6527 * Updates the entire store's state and notifies all registered listeners.
6528 *
6529 * @param newState The new state to set for the store.
6530 */
6531 setState(newState) {
6532 if (this.state === newState) {
6533 return;
6534 }
6535 this.state = newState;
6536 this.updateTick += 1;
6537 const currentTick = this.updateTick;
6538 for (const listener of this.listeners) {
6539 if (currentTick !== this.updateTick) {
6540 return;
6541 }
6542 listener(newState);
6543 }
6544 }
6545 /**
6546 * Merges the provided changes into the current state and notifies listeners if there are changes.
6547 *
6548 * @param changes An object containing the changes to apply to the current state.
6549 */
6550 update(changes) {
6551 for (const key2 in changes) {
6552 if (!Object.is(this.state[key2], changes[key2])) {
6553 this.setState({
6554 ...this.state,
6555 ...changes
6556 });
6557 return;
6558 }
6559 }
6560 }
6561 /**
6562 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6563 *
6564 * @param key The key in the store's state to update.
6565 * @param value The new value to set for the specified key.
6566 */
6567 set(key2, value) {
6568 if (!Object.is(this.state[key2], value)) {
6569 this.setState({
6570 ...this.state,
6571 [key2]: value
6572 });
6573 }
6574 }
6575 /**
6576 * Gives the state a new reference and updates all registered listeners.
6577 */
6578 notifyAll() {
6579 const newState = {
6580 ...this.state
6581 };
6582 this.setState(newState);
6583 }
6584 use(selector2, a1, a2, a3) {
6585 return useStore(this, selector2, a1, a2, a3);
6586 }
6587 };
6588
6589 // node_modules/@base-ui/utils/esm/store/ReactStore.js
6590 var React28 = __toESM(require_react(), 1);
6591 var ReactStore = class extends Store {
6592 /**
6593 * Creates a new ReactStore instance.
6594 *
6595 * @param state Initial state of the store.
6596 * @param context Non-reactive context values.
6597 * @param selectors Optional selectors for use with `useState`.
6598 */
6599 constructor(state, context = {}, selectors4) {
6600 super(state);
6601 this.context = context;
6602 this.selectors = selectors4;
6603 }
6604 /**
6605 * Non-reactive values such as refs, callbacks, etc.
6606 */
6607 /**
6608 * Synchronizes a single external value into the store.
6609 *
6610 * Note that the while the value in `state` is updated immediately, the value returned
6611 * by `useState` is updated before the next render (similarly to React's `useState`).
6612 */
6613 useSyncedValue(key2, value) {
6614 React28.useDebugValue(key2);
6615 useIsoLayoutEffect(() => {
6616 if (this.state[key2] !== value) {
6617 this.set(key2, value);
6618 }
6619 }, [key2, value]);
6620 }
6621 /**
6622 * Synchronizes a single external value into the store and
6623 * cleans it up (sets to `undefined`) on unmount.
6624 *
6625 * Note that the while the value in `state` is updated immediately, the value returned
6626 * by `useState` is updated before the next render (similarly to React's `useState`).
6627 */
6628 useSyncedValueWithCleanup(key2, value) {
6629 const store = this;
6630 useIsoLayoutEffect(() => {
6631 if (store.state[key2] !== value) {
6632 store.set(key2, value);
6633 }
6634 return () => {
6635 store.set(key2, void 0);
6636 };
6637 }, [store, key2, value]);
6638 }
6639 /**
6640 * Synchronizes multiple external values into the store.
6641 *
6642 * Note that the while the values in `state` are updated immediately, the values returned
6643 * by `useState` are updated before the next render (similarly to React's `useState`).
6644 */
6645 useSyncedValues(statePart) {
6646 const store = this;
6647 if (true) {
6648 React28.useDebugValue(statePart, (p2) => Object.keys(p2));
6649 const keys = React28.useRef(Object.keys(statePart)).current;
6650 const nextKeys = Object.keys(statePart);
6651 if (keys.length !== nextKeys.length || keys.some((key2, index2) => key2 !== nextKeys[index2])) {
6652 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6653 }
6654 }
6655 const dependencies = Object.values(statePart);
6656 useIsoLayoutEffect(() => {
6657 store.update(statePart);
6658 }, [store, ...dependencies]);
6659 }
6660 /**
6661 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6662 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6663 */
6664 useControlledProp(key2, controlled) {
6665 React28.useDebugValue(key2);
6666 const isControlled = controlled !== void 0;
6667 useIsoLayoutEffect(() => {
6668 if (isControlled && !Object.is(this.state[key2], controlled)) {
6669 super.setState({
6670 ...this.state,
6671 [key2]: controlled
6672 });
6673 }
6674 }, [key2, controlled, isControlled]);
6675 if (true) {
6676 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6677 if (!cache.has(key2)) {
6678 cache.set(key2, isControlled);
6679 }
6680 const previouslyControlled = cache.get(key2);
6681 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6682 console.error(`A component is changing the ${isControlled ? "" : "un"}controlled state of ${key2.toString()} to be ${isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
6683 }
6684 }
6685 }
6686 /** Gets the current value from the store using a selector with the provided key.
6687 *
6688 * @param key Key of the selector to use.
6689 */
6690 select(key2, a1, a2, a3) {
6691 const selector2 = this.selectors[key2];
6692 return selector2(this.state, a1, a2, a3);
6693 }
6694 /**
6695 * Returns a value from the store's state using a selector function.
6696 * Used to subscribe to specific parts of the state.
6697 * This methods causes a rerender whenever the selected state changes.
6698 *
6699 * @param key Key of the selector to use.
6700 */
6701 useState(key2, a1, a2, a3) {
6702 React28.useDebugValue(key2);
6703 return useStore(this, this.selectors[key2], a1, a2, a3);
6704 }
6705 /**
6706 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6707 * and assigns it to the context.
6708 *
6709 * @param key Key of the event callback. Must be a function in the context.
6710 * @param fn Function to assign.
6711 */
6712 useContextCallback(key2, fn) {
6713 React28.useDebugValue(key2);
6714 const stableFunction = useStableCallback(fn ?? NOOP);
6715 this.context[key2] = stableFunction;
6716 }
6717 /**
6718 * Returns a stable setter function for a specific key in the store's state.
6719 * It's commonly used to pass as a ref callback to React elements.
6720 *
6721 * @param key Key of the state to set.
6722 */
6723 useStateSetter(key2) {
6724 const ref = React28.useRef(void 0);
6725 if (ref.current === void 0) {
6726 ref.current = (value) => {
6727 this.set(key2, value);
6728 };
6729 }
6730 return ref.current;
6731 }
6732 /**
6733 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6734 *
6735 * @param key Key of the selector to observe.
6736 * @param listener Listener function called when the selector result changes.
6737 */
6738 observe(selector2, listener) {
6739 let selectFn;
6740 if (typeof selector2 === "function") {
6741 selectFn = selector2;
6742 } else {
6743 selectFn = this.selectors[selector2];
6744 }
6745 let prevValue = selectFn(this.state);
6746 listener(prevValue, prevValue, this);
6747 return this.subscribe((nextState) => {
6748 const nextValue = selectFn(nextState);
6749 if (!Object.is(prevValue, nextValue)) {
6750 const oldValue = prevValue;
6751 prevValue = nextValue;
6752 listener(nextValue, oldValue, this);
6753 }
6754 });
6755 }
6756 };
6757
6758 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
6759 var selectors = {
6760 open: createSelector((state) => state.open),
6761 transitionStatus: createSelector((state) => state.transitionStatus),
6762 domReferenceElement: createSelector((state) => state.domReferenceElement),
6763 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6764 floatingElement: createSelector((state) => state.floatingElement),
6765 floatingId: createSelector((state) => state.floatingId)
6766 };
6767 var FloatingRootStore = class extends ReactStore {
6768 constructor(options) {
6769 const {
6770 syncOnly,
6771 nested,
6772 onOpenChange,
6773 triggerElements,
6774 ...initialState
6775 } = options;
6776 super({
6777 ...initialState,
6778 positionReference: initialState.referenceElement,
6779 domReferenceElement: initialState.referenceElement
6780 }, {
6781 onOpenChange,
6782 dataRef: {
6783 current: {}
6784 },
6785 events: createEventEmitter(),
6786 nested,
6787 triggerElements
6788 }, selectors);
6789 this.syncOnly = syncOnly;
6790 }
6791 /**
6792 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6793 */
6794 syncOpenEvent = (newOpen, event) => {
6795 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6796 // click events to upgrade a hover-open.
6797 event != null && isClickLikeEvent(event)) {
6798 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6799 }
6800 };
6801 /**
6802 * Runs the root-owned side effects for an open state change.
6803 */
6804 dispatchOpenChange = (newOpen, eventDetails) => {
6805 this.syncOpenEvent(newOpen, eventDetails.event);
6806 const details = {
6807 open: newOpen,
6808 reason: eventDetails.reason,
6809 nativeEvent: eventDetails.event,
6810 nested: this.context.nested,
6811 triggerElement: eventDetails.trigger
6812 };
6813 this.context.events.emit("openchange", details);
6814 };
6815 /**
6816 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6817 *
6818 * @param newOpen The new open state.
6819 * @param eventDetails Details about the event that triggered the open state change.
6820 */
6821 setOpen = (newOpen, eventDetails) => {
6822 if (this.syncOnly) {
6823 this.context.onOpenChange?.(newOpen, eventDetails);
6824 return;
6825 }
6826 this.dispatchOpenChange(newOpen, eventDetails);
6827 this.context.onOpenChange?.(newOpen, eventDetails);
6828 };
6829 };
6830
6831 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
6832 var React29 = __toESM(require_react(), 1);
6833 function useTriggerRegistration(id, store) {
6834 const registeredElementIdRef = React29.useRef(null);
6835 const registeredElementRef = React29.useRef(null);
6836 return React29.useCallback((element) => {
6837 if (id === void 0) {
6838 return;
6839 }
6840 if (registeredElementIdRef.current !== null) {
6841 const registeredId = registeredElementIdRef.current;
6842 const registeredElement = registeredElementRef.current;
6843 const currentElement = store.context.triggerElements.getById(registeredId);
6844 if (registeredElement && currentElement === registeredElement) {
6845 store.context.triggerElements.delete(registeredId);
6846 }
6847 registeredElementIdRef.current = null;
6848 registeredElementRef.current = null;
6849 }
6850 if (element !== null) {
6851 registeredElementIdRef.current = id;
6852 registeredElementRef.current = element;
6853 store.context.triggerElements.add(id, element);
6854 }
6855 }, [store, id]);
6856 }
6857 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6858 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6859 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6860 const registerTrigger = useStableCallback((element) => {
6861 baseRegisterTrigger(element);
6862 if (!element || !store.select("open")) {
6863 return;
6864 }
6865 const activeTriggerId = store.select("activeTriggerId");
6866 if (activeTriggerId === triggerId) {
6867 store.update({
6868 activeTriggerElement: element,
6869 ...stateUpdates
6870 });
6871 return;
6872 }
6873 if (activeTriggerId == null) {
6874 store.update({
6875 activeTriggerId: triggerId,
6876 activeTriggerElement: element,
6877 ...stateUpdates
6878 });
6879 }
6880 });
6881 useIsoLayoutEffect(() => {
6882 if (isMountedByThisTrigger) {
6883 store.update({
6884 activeTriggerElement: triggerElementRef.current,
6885 ...stateUpdates
6886 });
6887 }
6888 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6889 return {
6890 registerTrigger,
6891 isMountedByThisTrigger
6892 };
6893 }
6894 function useImplicitActiveTrigger(store) {
6895 const open = store.useState("open");
6896 useIsoLayoutEffect(() => {
6897 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
6898 const iteratorResult = store.context.triggerElements.entries().next();
6899 if (!iteratorResult.done) {
6900 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6901 store.update({
6902 activeTriggerId: implicitTriggerId,
6903 activeTriggerElement: implicitTriggerElement
6904 });
6905 }
6906 }
6907 }, [open, store]);
6908 }
6909 function useOpenStateTransitions(open, store, onUnmount) {
6910 const {
6911 mounted,
6912 setMounted,
6913 transitionStatus
6914 } = useTransitionStatus(open);
6915 store.useSyncedValues({
6916 mounted,
6917 transitionStatus
6918 });
6919 const forceUnmount = useStableCallback(() => {
6920 setMounted(false);
6921 store.update({
6922 activeTriggerId: null,
6923 activeTriggerElement: null,
6924 mounted: false
6925 });
6926 onUnmount?.();
6927 store.context.onOpenChangeComplete?.(false);
6928 });
6929 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6930 useOpenChangeComplete({
6931 enabled: !preventUnmountingOnClose,
6932 open,
6933 ref: store.context.popupRef,
6934 onComplete() {
6935 if (!open) {
6936 forceUnmount();
6937 }
6938 }
6939 });
6940 return {
6941 forceUnmount,
6942 transitionStatus
6943 };
6944 }
6945
6946 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
6947 var PopupTriggerMap = class {
6948 constructor() {
6949 this.elementsSet = /* @__PURE__ */ new Set();
6950 this.idMap = /* @__PURE__ */ new Map();
6951 }
6952 /**
6953 * Adds a trigger element with the given ID.
6954 *
6955 * Note: The provided element is assumed to not be registered under multiple IDs.
6956 */
6957 add(id, element) {
6958 const existingElement = this.idMap.get(id);
6959 if (existingElement === element) {
6960 return;
6961 }
6962 if (existingElement !== void 0) {
6963 this.elementsSet.delete(existingElement);
6964 }
6965 this.elementsSet.add(element);
6966 this.idMap.set(id, element);
6967 if (true) {
6968 if (this.elementsSet.size !== this.idMap.size) {
6969 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6970 }
6971 }
6972 }
6973 /**
6974 * Removes the trigger element with the given ID.
6975 */
6976 delete(id) {
6977 const element = this.idMap.get(id);
6978 if (element) {
6979 this.elementsSet.delete(element);
6980 this.idMap.delete(id);
6981 }
6982 }
6983 /**
6984 * Whether the given element is registered as a trigger.
6985 */
6986 hasElement(element) {
6987 return this.elementsSet.has(element);
6988 }
6989 /**
6990 * Whether there is a registered trigger element matching the given predicate.
6991 */
6992 hasMatchingElement(predicate) {
6993 for (const element of this.elementsSet) {
6994 if (predicate(element)) {
6995 return true;
6996 }
6997 }
6998 return false;
6999 }
7000 /**
7001 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
7002 */
7003 getById(id) {
7004 return this.idMap.get(id);
7005 }
7006 /**
7007 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
7008 */
7009 entries() {
7010 return this.idMap.entries();
7011 }
7012 /**
7013 * Returns an iterable of all registered trigger elements.
7014 */
7015 elements() {
7016 return this.elementsSet.values();
7017 }
7018 /**
7019 * Returns the number of registered trigger elements.
7020 */
7021 get size() {
7022 return this.idMap.size;
7023 }
7024 };
7025
7026 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
7027 function getEmptyRootContext() {
7028 return new FloatingRootStore({
7029 open: false,
7030 transitionStatus: void 0,
7031 floatingElement: null,
7032 referenceElement: null,
7033 triggerElements: new PopupTriggerMap(),
7034 floatingId: "",
7035 syncOnly: false,
7036 nested: false,
7037 onOpenChange: void 0
7038 });
7039 }
7040
7041 // node_modules/@base-ui/react/esm/utils/popups/store.js
7042 function createInitialPopupStoreState() {
7043 return {
7044 open: false,
7045 openProp: void 0,
7046 mounted: false,
7047 transitionStatus: void 0,
7048 floatingRootContext: getEmptyRootContext(),
7049 preventUnmountingOnClose: false,
7050 payload: void 0,
7051 activeTriggerId: null,
7052 activeTriggerElement: null,
7053 triggerIdProp: void 0,
7054 popupElement: null,
7055 positionerElement: null,
7056 activeTriggerProps: EMPTY_OBJECT,
7057 inactiveTriggerProps: EMPTY_OBJECT,
7058 popupProps: EMPTY_OBJECT
7059 };
7060 }
7061 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
7062 var popupStoreSelectors = {
7063 open: createSelector((state) => state.openProp ?? state.open),
7064 mounted: createSelector((state) => state.mounted),
7065 transitionStatus: createSelector((state) => state.transitionStatus),
7066 floatingRootContext: createSelector((state) => state.floatingRootContext),
7067 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
7068 payload: createSelector((state) => state.payload),
7069 activeTriggerId: activeTriggerIdSelector,
7070 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
7071 /**
7072 * Whether the trigger with the given ID was used to open the popup.
7073 */
7074 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
7075 /**
7076 * Whether the popup is open and was activated by a trigger with the given ID.
7077 */
7078 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
7079 /**
7080 * Whether the popup is mounted and was activated by a trigger with the given ID.
7081 */
7082 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
7083 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
7084 popupProps: createSelector((state) => state.popupProps),
7085 popupElement: createSelector((state) => state.popupElement),
7086 positionerElement: createSelector((state) => state.positionerElement)
7087 };
7088
7089 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
7090 function useFloatingRootContext(options) {
7091 const {
7092 open = false,
7093 onOpenChange,
7094 elements = {}
7095 } = options;
7096 const floatingId = useId();
7097 const nested = useFloatingParentNodeId() != null;
7098 if (true) {
7099 const optionDomReference = elements.reference;
7100 if (optionDomReference && !isElement(optionDomReference)) {
7101 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
7102 }
7103 }
7104 const store = useRefWithInit(() => new FloatingRootStore({
7105 open,
7106 transitionStatus: void 0,
7107 onOpenChange,
7108 referenceElement: elements.reference ?? null,
7109 floatingElement: elements.floating ?? null,
7110 triggerElements: new PopupTriggerMap(),
7111 floatingId,
7112 syncOnly: false,
7113 nested
7114 })).current;
7115 useIsoLayoutEffect(() => {
7116 const valuesToSync = {
7117 open,
7118 floatingId
7119 };
7120 if (elements.reference !== void 0) {
7121 valuesToSync.referenceElement = elements.reference;
7122 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
7123 }
7124 if (elements.floating !== void 0) {
7125 valuesToSync.floatingElement = elements.floating;
7126 }
7127 store.update(valuesToSync);
7128 }, [open, floatingId, elements.reference, elements.floating, store]);
7129 store.context.onOpenChange = onOpenChange;
7130 store.context.nested = nested;
7131 return store;
7132 }
7133
7134 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
7135 function useFloating2(options = {}) {
7136 const {
7137 nodeId,
7138 externalTree
7139 } = options;
7140 const internalRootStore = useFloatingRootContext(options);
7141 const rootContext = options.rootContext || internalRootStore;
7142 const rootContextElements = {
7143 reference: rootContext.useState("referenceElement"),
7144 floating: rootContext.useState("floatingElement"),
7145 domReference: rootContext.useState("domReferenceElement")
7146 };
7147 const [positionReference, setPositionReferenceRaw] = React30.useState(null);
7148 const domReferenceRef = React30.useRef(null);
7149 const tree = useFloatingTree(externalTree);
7150 useIsoLayoutEffect(() => {
7151 if (rootContextElements.domReference) {
7152 domReferenceRef.current = rootContextElements.domReference;
7153 }
7154 }, [rootContextElements.domReference]);
7155 const position = useFloating({
7156 ...options,
7157 elements: {
7158 ...rootContextElements,
7159 ...positionReference && {
7160 reference: positionReference
7161 }
7162 }
7163 });
7164 const setPositionReference = React30.useCallback((node) => {
7165 const computedPositionReference = isElement(node) ? {
7166 getBoundingClientRect: () => node.getBoundingClientRect(),
7167 getClientRects: () => node.getClientRects(),
7168 contextElement: node
7169 } : node;
7170 setPositionReferenceRaw(computedPositionReference);
7171 position.refs.setReference(computedPositionReference);
7172 }, [position.refs]);
7173 const [localDomReference, setLocalDomReference] = React30.useState(void 0);
7174 const [localFloatingElement, setLocalFloatingElement] = React30.useState(null);
7175 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
7176 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7177 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
7178 rootContext.useSyncedValue("floatingElement", localFloatingElement);
7179 const setReference = React30.useCallback((node) => {
7180 if (isElement(node) || node === null) {
7181 domReferenceRef.current = node;
7182 setLocalDomReference(node);
7183 }
7184 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7185 // `null` to support `positionReference` + an unstable `reference`
7186 // callback ref.
7187 node !== null && !isElement(node)) {
7188 position.refs.setReference(node);
7189 }
7190 }, [position.refs, setLocalDomReference]);
7191 const setFloating = React30.useCallback((node) => {
7192 setLocalFloatingElement(node);
7193 position.refs.setFloating(node);
7194 }, [position.refs]);
7195 const refs = React30.useMemo(() => ({
7196 ...position.refs,
7197 setReference,
7198 setFloating,
7199 setPositionReference,
7200 domReference: domReferenceRef
7201 }), [position.refs, setReference, setFloating, setPositionReference]);
7202 const elements = React30.useMemo(() => ({
7203 ...position.elements,
7204 domReference: rootContextElements.domReference
7205 }), [position.elements, rootContextElements.domReference]);
7206 const open = rootContext.useState("open");
7207 const floatingId = rootContext.useState("floatingId");
7208 const context = React30.useMemo(() => ({
7209 ...position,
7210 dataRef: rootContext.context.dataRef,
7211 open,
7212 onOpenChange: rootContext.setOpen,
7213 events: rootContext.context.events,
7214 floatingId,
7215 refs,
7216 elements,
7217 nodeId,
7218 rootStore: rootContext
7219 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
7220 useIsoLayoutEffect(() => {
7221 rootContext.context.dataRef.current.floatingContext = context;
7222 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
7223 if (node) {
7224 node.context = context;
7225 }
7226 });
7227 return React30.useMemo(() => ({
7228 ...position,
7229 context,
7230 refs,
7231 elements,
7232 rootStore: rootContext
7233 }), [position, refs, elements, context, rootContext]);
7234 }
7235
7236 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
7237 function useSyncedFloatingRootContext(options) {
7238 const {
7239 popupStore,
7240 treatPopupAsFloatingElement = false,
7241 onOpenChange
7242 } = options;
7243 const floatingId = useId();
7244 const nested = useFloatingParentNodeId() != null;
7245 const open = popupStore.useState("open");
7246 const referenceElement = popupStore.useState("activeTriggerElement");
7247 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
7248 const triggerElements = popupStore.context.triggerElements;
7249 const store = useRefWithInit(() => new FloatingRootStore({
7250 open,
7251 transitionStatus: void 0,
7252 referenceElement,
7253 floatingElement,
7254 triggerElements,
7255 onOpenChange,
7256 floatingId,
7257 syncOnly: true,
7258 nested
7259 })).current;
7260 useIsoLayoutEffect(() => {
7261 const valuesToSync = {
7262 open,
7263 floatingId,
7264 referenceElement,
7265 floatingElement
7266 };
7267 if (isElement(referenceElement)) {
7268 valuesToSync.domReferenceElement = referenceElement;
7269 }
7270 if (store.state.positionReference === store.state.referenceElement) {
7271 valuesToSync.positionReference = referenceElement;
7272 }
7273 store.update(valuesToSync);
7274 }, [open, floatingId, referenceElement, floatingElement, store]);
7275 store.context.onOpenChange = onOpenChange;
7276 store.context.nested = nested;
7277 return store;
7278 }
7279
7280 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
7281 var React31 = __toESM(require_react(), 1);
7282 var isMacSafari = isMac && isSafari;
7283 function useFocus(context, props = {}) {
7284 const store = "rootStore" in context ? context.rootStore : context;
7285 const {
7286 events: events2,
7287 dataRef
7288 } = store.context;
7289 const {
7290 enabled = true,
7291 delay
7292 } = props;
7293 const blockFocusRef = React31.useRef(false);
7294 const blockedReferenceRef = React31.useRef(null);
7295 const timeout = useTimeout();
7296 const keyboardModalityRef = React31.useRef(true);
7297 React31.useEffect(() => {
7298 const domReference = store.select("domReferenceElement");
7299 if (!enabled) {
7300 return void 0;
7301 }
7302 const win = getWindow(domReference);
7303 function onBlur() {
7304 const currentDomReference = store.select("domReferenceElement");
7305 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
7306 blockFocusRef.current = true;
7307 }
7308 }
7309 function onKeyDown() {
7310 keyboardModalityRef.current = true;
7311 }
7312 function onPointerDown() {
7313 keyboardModalityRef.current = false;
7314 }
7315 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7316 }, [store, enabled]);
7317 React31.useEffect(() => {
7318 if (!enabled) {
7319 return void 0;
7320 }
7321 function onOpenChangeLocal(details) {
7322 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7323 const referenceElement = store.select("domReferenceElement");
7324 if (isElement(referenceElement)) {
7325 blockedReferenceRef.current = referenceElement;
7326 blockFocusRef.current = true;
7327 }
7328 }
7329 }
7330 events2.on("openchange", onOpenChangeLocal);
7331 return () => {
7332 events2.off("openchange", onOpenChangeLocal);
7333 };
7334 }, [events2, enabled, store]);
7335 const reference = React31.useMemo(() => ({
7336 onMouseLeave() {
7337 blockFocusRef.current = false;
7338 blockedReferenceRef.current = null;
7339 },
7340 onFocus(event) {
7341 const focusTarget = event.currentTarget;
7342 if (blockFocusRef.current) {
7343 if (blockedReferenceRef.current === focusTarget) {
7344 return;
7345 }
7346 blockFocusRef.current = false;
7347 blockedReferenceRef.current = null;
7348 }
7349 const target = getTarget(event.nativeEvent);
7350 if (isElement(target)) {
7351 if (isMacSafari && !event.relatedTarget) {
7352 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7353 return;
7354 }
7355 } else if (!matchesFocusVisible(target)) {
7356 return;
7357 }
7358 }
7359 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7360 const {
7361 nativeEvent,
7362 currentTarget
7363 } = event;
7364 const delayValue = typeof delay === "function" ? delay() : delay;
7365 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7366 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7367 return;
7368 }
7369 timeout.start(delayValue, () => {
7370 if (blockFocusRef.current) {
7371 return;
7372 }
7373 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7374 });
7375 },
7376 onBlur(event) {
7377 blockFocusRef.current = false;
7378 blockedReferenceRef.current = null;
7379 const relatedTarget = event.relatedTarget;
7380 const nativeEvent = event.nativeEvent;
7381 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7382 timeout.start(0, () => {
7383 const domReference = store.select("domReferenceElement");
7384 const activeEl = activeElement(ownerDocument(domReference));
7385 if (!relatedTarget && activeEl === domReference) {
7386 return;
7387 }
7388 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7389 return;
7390 }
7391 const nextFocusedElement = relatedTarget ?? activeEl;
7392 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7393 return;
7394 }
7395 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7396 });
7397 }
7398 }), [dataRef, store, timeout, delay]);
7399 return React31.useMemo(() => enabled ? {
7400 reference,
7401 trigger: reference
7402 } : {}, [enabled, reference]);
7403 }
7404
7405 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
7406 var React32 = __toESM(require_react(), 1);
7407
7408 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
7409 var HoverInteraction = class _HoverInteraction {
7410 constructor() {
7411 this.pointerType = void 0;
7412 this.interactedInside = false;
7413 this.handler = void 0;
7414 this.blockMouseMove = true;
7415 this.performedPointerEventsMutation = false;
7416 this.pointerEventsScopeElement = null;
7417 this.pointerEventsReferenceElement = null;
7418 this.pointerEventsFloatingElement = null;
7419 this.restTimeoutPending = false;
7420 this.openChangeTimeout = new Timeout();
7421 this.restTimeout = new Timeout();
7422 this.handleCloseOptions = void 0;
7423 }
7424 static create() {
7425 return new _HoverInteraction();
7426 }
7427 dispose = () => {
7428 this.openChangeTimeout.clear();
7429 this.restTimeout.clear();
7430 };
7431 disposeEffect = () => {
7432 return this.dispose;
7433 };
7434 };
7435 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7436 function clearSafePolygonPointerEventsMutation(instance) {
7437 if (!instance.performedPointerEventsMutation) {
7438 return;
7439 }
7440 const scopeElement = instance.pointerEventsScopeElement;
7441 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7442 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7443 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7444 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7445 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7446 }
7447 instance.performedPointerEventsMutation = false;
7448 instance.pointerEventsScopeElement = null;
7449 instance.pointerEventsReferenceElement = null;
7450 instance.pointerEventsFloatingElement = null;
7451 }
7452 function applySafePolygonPointerEventsMutation(instance, options) {
7453 const {
7454 scopeElement,
7455 referenceElement,
7456 floatingElement
7457 } = options;
7458 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7459 if (existingOwner && existingOwner !== instance) {
7460 clearSafePolygonPointerEventsMutation(existingOwner);
7461 }
7462 clearSafePolygonPointerEventsMutation(instance);
7463 instance.performedPointerEventsMutation = true;
7464 instance.pointerEventsScopeElement = scopeElement;
7465 instance.pointerEventsReferenceElement = referenceElement;
7466 instance.pointerEventsFloatingElement = floatingElement;
7467 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7468 scopeElement.style.pointerEvents = "none";
7469 referenceElement.style.pointerEvents = "auto";
7470 floatingElement.style.pointerEvents = "auto";
7471 }
7472 function useHoverInteractionSharedState(store) {
7473 const instance = useRefWithInit(HoverInteraction.create).current;
7474 const data = store.context.dataRef.current;
7475 if (!data.hoverInteractionState) {
7476 data.hoverInteractionState = instance;
7477 }
7478 useOnMount(data.hoverInteractionState.disposeEffect);
7479 return data.hoverInteractionState;
7480 }
7481
7482 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
7483 function useHoverFloatingInteraction(context, parameters = {}) {
7484 const store = "rootStore" in context ? context.rootStore : context;
7485 const open = store.useState("open");
7486 const floatingElement = store.useState("floatingElement");
7487 const domReferenceElement = store.useState("domReferenceElement");
7488 const {
7489 dataRef
7490 } = store.context;
7491 const {
7492 enabled = true,
7493 closeDelay: closeDelayProp = 0,
7494 nodeId: nodeIdProp
7495 } = parameters;
7496 const instance = useHoverInteractionSharedState(store);
7497 const tree = useFloatingTree();
7498 const parentId = useFloatingParentNodeId();
7499 const isClickLikeOpenEvent2 = useStableCallback(() => {
7500 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7501 });
7502 const isHoverOpen = useStableCallback(() => {
7503 const type = dataRef.current.openEvent?.type;
7504 return type?.includes("mouse") && type !== "mousedown";
7505 });
7506 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
7507 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
7508 });
7509 const closeWithDelay = React32.useCallback((event) => {
7510 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7511 const close = () => {
7512 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7513 tree?.events.emit("floating.closed", event);
7514 };
7515 if (closeDelay) {
7516 instance.openChangeTimeout.start(closeDelay, close);
7517 } else {
7518 instance.openChangeTimeout.clear();
7519 close();
7520 }
7521 }, [closeDelayProp, store, instance, tree]);
7522 const clearPointerEvents = useStableCallback(() => {
7523 clearSafePolygonPointerEventsMutation(instance);
7524 });
7525 const handleInteractInside = useStableCallback((event) => {
7526 const target = getTarget(event);
7527 if (!isInteractiveElement(target)) {
7528 instance.interactedInside = false;
7529 return;
7530 }
7531 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7532 });
7533 useIsoLayoutEffect(() => {
7534 if (!open) {
7535 instance.pointerType = void 0;
7536 instance.restTimeoutPending = false;
7537 instance.interactedInside = false;
7538 clearPointerEvents();
7539 }
7540 }, [open, instance, clearPointerEvents]);
7541 React32.useEffect(() => {
7542 return clearPointerEvents;
7543 }, [clearPointerEvents]);
7544 useIsoLayoutEffect(() => {
7545 if (!enabled) {
7546 return void 0;
7547 }
7548 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7549 const ref = domReferenceElement;
7550 const floatingEl = floatingElement;
7551 const doc = ownerDocument(floatingElement);
7552 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7553 if (parentFloating) {
7554 parentFloating.style.pointerEvents = "";
7555 }
7556 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
7557 applySafePolygonPointerEventsMutation(instance, {
7558 scopeElement,
7559 referenceElement: ref,
7560 floatingElement: floatingEl
7561 });
7562 return () => {
7563 clearPointerEvents();
7564 };
7565 }
7566 return void 0;
7567 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7568 const childClosedTimeout = useTimeout();
7569 React32.useEffect(() => {
7570 if (!enabled) {
7571 return void 0;
7572 }
7573 function onFloatingMouseEnter() {
7574 instance.openChangeTimeout.clear();
7575 childClosedTimeout.clear();
7576 tree?.events.off("floating.closed", onNodeClosed);
7577 clearPointerEvents();
7578 }
7579 function onFloatingMouseLeave(event) {
7580 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
7581 tree.events.on("floating.closed", onNodeClosed);
7582 return;
7583 }
7584 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
7585 return;
7586 }
7587 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7588 const relatedTarget = event.relatedTarget;
7589 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7590 if (isMovingIntoDescendantFloating) {
7591 return;
7592 }
7593 if (instance.handler) {
7594 instance.handler(event);
7595 return;
7596 }
7597 clearPointerEvents();
7598 if (!isClickLikeOpenEvent2()) {
7599 closeWithDelay(event);
7600 }
7601 }
7602 function onNodeClosed(event) {
7603 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
7604 return;
7605 }
7606 childClosedTimeout.start(0, () => {
7607 tree.events.off("floating.closed", onNodeClosed);
7608 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7609 tree.events.emit("floating.closed", event);
7610 });
7611 }
7612 const floating = floatingElement;
7613 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7614 tree?.events.off("floating.closed", onNodeClosed);
7615 });
7616 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
7617 }
7618
7619 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
7620 var React33 = __toESM(require_react(), 1);
7621 var ReactDOM4 = __toESM(require_react_dom(), 1);
7622 var EMPTY_REF = {
7623 current: null
7624 };
7625 function useHoverReferenceInteraction(context, props = {}) {
7626 const store = "rootStore" in context ? context.rootStore : context;
7627 const {
7628 dataRef,
7629 events: events2
7630 } = store.context;
7631 const {
7632 enabled = true,
7633 delay = 0,
7634 handleClose = null,
7635 mouseOnly = false,
7636 restMs = 0,
7637 move = true,
7638 triggerElementRef = EMPTY_REF,
7639 externalTree,
7640 isActiveTrigger = true,
7641 getHandleCloseContext,
7642 isClosing
7643 } = props;
7644 const tree = useFloatingTree(externalTree);
7645 const instance = useHoverInteractionSharedState(store);
7646 const isHoverCloseActiveRef = React33.useRef(false);
7647 const handleCloseRef = useValueAsRef(handleClose);
7648 const delayRef = useValueAsRef(delay);
7649 const restMsRef = useValueAsRef(restMs);
7650 const enabledRef = useValueAsRef(enabled);
7651 const isClosingRef = useValueAsRef(isClosing);
7652 if (isActiveTrigger) {
7653 instance.handleCloseOptions = handleCloseRef.current?.__options;
7654 }
7655 const isClickLikeOpenEvent2 = useStableCallback(() => {
7656 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7657 });
7658 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
7659 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
7660 });
7661 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7662 const allTriggers = store.context.triggerElements;
7663 if (allTriggers.hasElement(currentTarget)) {
7664 return !currentDomReference || !contains(currentDomReference, currentTarget);
7665 }
7666 if (!isElement(target)) {
7667 return false;
7668 }
7669 const targetElement = target;
7670 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7671 });
7672 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
7673 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7674 if (closeDelay) {
7675 instance.openChangeTimeout.start(closeDelay, () => {
7676 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7677 tree?.events.emit("floating.closed", event);
7678 });
7679 } else if (runElseBranch) {
7680 instance.openChangeTimeout.clear();
7681 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7682 tree?.events.emit("floating.closed", event);
7683 }
7684 });
7685 const cleanupMouseMoveHandler = useStableCallback(() => {
7686 if (!instance.handler) {
7687 return;
7688 }
7689 const doc = ownerDocument(store.select("domReferenceElement"));
7690 doc.removeEventListener("mousemove", instance.handler);
7691 instance.handler = void 0;
7692 });
7693 const clearPointerEvents = useStableCallback(() => {
7694 clearSafePolygonPointerEventsMutation(instance);
7695 });
7696 React33.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7697 React33.useEffect(() => {
7698 if (!enabled) {
7699 return void 0;
7700 }
7701 function onOpenChangeLocal(details) {
7702 if (!details.open) {
7703 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7704 cleanupMouseMoveHandler();
7705 instance.openChangeTimeout.clear();
7706 instance.restTimeout.clear();
7707 instance.blockMouseMove = true;
7708 instance.restTimeoutPending = false;
7709 } else {
7710 isHoverCloseActiveRef.current = false;
7711 }
7712 }
7713 events2.on("openchange", onOpenChangeLocal);
7714 return () => {
7715 events2.off("openchange", onOpenChangeLocal);
7716 };
7717 }, [enabled, events2, instance, cleanupMouseMoveHandler]);
7718 React33.useEffect(() => {
7719 if (!enabled) {
7720 return void 0;
7721 }
7722 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7723 if (!isElement(trigger)) {
7724 return void 0;
7725 }
7726 function onMouseEnter(event) {
7727 instance.openChangeTimeout.clear();
7728 instance.blockMouseMove = false;
7729 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7730 return;
7731 }
7732 const restMsValue = getRestMs(restMsRef.current);
7733 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7734 const eventTarget = getTarget(event);
7735 const currentTarget = event.currentTarget ?? null;
7736 const currentDomReference = store.select("domReferenceElement");
7737 let triggerNode = currentTarget;
7738 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7739 for (const triggerElement of store.context.triggerElements.elements()) {
7740 if (contains(triggerElement, eventTarget)) {
7741 triggerNode = triggerElement;
7742 break;
7743 }
7744 }
7745 }
7746 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7747 triggerNode = currentDomReference;
7748 }
7749 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7750 const isOpen = store.select("open");
7751 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7752 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7753 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7754 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7755 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7756 const shouldOpen = !isOpen || isOverInactive;
7757 if (shouldOpenImmediately) {
7758 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7759 return;
7760 }
7761 if (isRestOnlyDelay) {
7762 return;
7763 }
7764 if (openDelay) {
7765 instance.openChangeTimeout.start(openDelay, () => {
7766 if (shouldOpen) {
7767 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7768 }
7769 });
7770 } else if (shouldOpen) {
7771 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7772 }
7773 }
7774 function onMouseLeave(event) {
7775 if (isClickLikeOpenEvent2()) {
7776 clearPointerEvents();
7777 return;
7778 }
7779 cleanupMouseMoveHandler();
7780 const domReferenceElement = store.select("domReferenceElement");
7781 const doc = ownerDocument(domReferenceElement);
7782 instance.restTimeout.clear();
7783 instance.restTimeoutPending = false;
7784 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7785 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
7786 if (ignoreRelatedTargetTrigger) {
7787 return;
7788 }
7789 if (handleCloseRef.current && handleCloseContextBase) {
7790 if (!store.select("open")) {
7791 instance.openChangeTimeout.clear();
7792 }
7793 const currentTrigger = triggerElementRef.current;
7794 instance.handler = handleCloseRef.current({
7795 ...handleCloseContextBase,
7796 tree,
7797 x: event.clientX,
7798 y: event.clientY,
7799 onClose() {
7800 clearPointerEvents();
7801 cleanupMouseMoveHandler();
7802 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7803 closeWithDelay(event, true);
7804 }
7805 }
7806 });
7807 doc.addEventListener("mousemove", instance.handler);
7808 instance.handler(event);
7809 return;
7810 }
7811 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7812 if (shouldClose) {
7813 closeWithDelay(event);
7814 }
7815 }
7816 if (move) {
7817 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7818 once: true
7819 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7820 }
7821 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7822 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
7823 return React33.useMemo(() => {
7824 if (!enabled) {
7825 return void 0;
7826 }
7827 function setPointerRef(event) {
7828 instance.pointerType = event.pointerType;
7829 }
7830 return {
7831 onPointerDown: setPointerRef,
7832 onPointerEnter: setPointerRef,
7833 onMouseMove(event) {
7834 const {
7835 nativeEvent
7836 } = event;
7837 const trigger = event.currentTarget;
7838 const currentDomReference = store.select("domReferenceElement");
7839 const currentOpen = store.select("open");
7840 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7841 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7842 return;
7843 }
7844 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7845 const floatingElement = store.select("floatingElement");
7846 if (floatingElement) {
7847 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7848 applySafePolygonPointerEventsMutation(instance, {
7849 scopeElement,
7850 referenceElement: trigger,
7851 floatingElement
7852 });
7853 }
7854 }
7855 const restMsValue = getRestMs(restMsRef.current);
7856 if (currentOpen && !isOverInactive || restMsValue === 0) {
7857 return;
7858 }
7859 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7860 return;
7861 }
7862 instance.restTimeout.clear();
7863 function handleMouseMove() {
7864 instance.restTimeoutPending = false;
7865 if (isClickLikeOpenEvent2()) {
7866 return;
7867 }
7868 const latestOpen = store.select("open");
7869 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
7870 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7871 }
7872 }
7873 if (instance.pointerType === "touch") {
7874 ReactDOM4.flushSync(() => {
7875 handleMouseMove();
7876 });
7877 } else if (isOverInactive && currentOpen) {
7878 handleMouseMove();
7879 } else {
7880 instance.restTimeoutPending = true;
7881 instance.restTimeout.start(restMsValue, handleMouseMove);
7882 }
7883 }
7884 };
7885 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
7886 }
7887
7888 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
7889 var React34 = __toESM(require_react(), 1);
7890 function useInteractions(propsList = []) {
7891 const referenceDeps = propsList.map((key2) => key2?.reference);
7892 const floatingDeps = propsList.map((key2) => key2?.floating);
7893 const itemDeps = propsList.map((key2) => key2?.item);
7894 const triggerDeps = propsList.map((key2) => key2?.trigger);
7895 const getReferenceProps = React34.useCallback(
7896 (userProps) => mergeProps2(userProps, propsList, "reference"),
7897 // eslint-disable-next-line react-hooks/exhaustive-deps
7898 referenceDeps
7899 );
7900 const getFloatingProps = React34.useCallback(
7901 (userProps) => mergeProps2(userProps, propsList, "floating"),
7902 // eslint-disable-next-line react-hooks/exhaustive-deps
7903 floatingDeps
7904 );
7905 const getItemProps = React34.useCallback(
7906 (userProps) => mergeProps2(userProps, propsList, "item"),
7907 // eslint-disable-next-line react-hooks/exhaustive-deps
7908 itemDeps
7909 );
7910 const getTriggerProps = React34.useCallback(
7911 (userProps) => mergeProps2(userProps, propsList, "trigger"),
7912 // eslint-disable-next-line react-hooks/exhaustive-deps
7913 triggerDeps
7914 );
7915 return React34.useMemo(() => ({
7916 getReferenceProps,
7917 getFloatingProps,
7918 getItemProps,
7919 getTriggerProps
7920 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
7921 }
7922 function mergeProps2(userProps, propsList, elementKey) {
7923 const eventHandlers = /* @__PURE__ */ new Map();
7924 const isItem2 = elementKey === "item";
7925 const outputProps = {};
7926 if (elementKey === "floating") {
7927 outputProps.tabIndex = -1;
7928 outputProps[FOCUSABLE_ATTRIBUTE] = "";
7929 }
7930 for (const key2 in userProps) {
7931 if (isItem2 && userProps) {
7932 if (key2 === ACTIVE_KEY || key2 === SELECTED_KEY) {
7933 continue;
7934 }
7935 }
7936 outputProps[key2] = userProps[key2];
7937 }
7938 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
7939 let props;
7940 const propsOrGetProps = propsList[i2]?.[elementKey];
7941 if (typeof propsOrGetProps === "function") {
7942 props = userProps ? propsOrGetProps(userProps) : null;
7943 } else {
7944 props = propsOrGetProps;
7945 }
7946 if (!props) {
7947 continue;
7948 }
7949 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
7950 }
7951 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
7952 return outputProps;
7953 }
7954 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
7955 for (const key2 in props) {
7956 const value = props[key2];
7957 if (isItem2 && (key2 === ACTIVE_KEY || key2 === SELECTED_KEY)) {
7958 continue;
7959 }
7960 if (!key2.startsWith("on")) {
7961 outputProps[key2] = value;
7962 } else {
7963 if (!eventHandlers.has(key2)) {
7964 eventHandlers.set(key2, []);
7965 }
7966 if (typeof value === "function") {
7967 eventHandlers.get(key2)?.push(value);
7968 outputProps[key2] = (...args) => {
7969 return eventHandlers.get(key2)?.map((fn) => fn(...args)).find((val) => val !== void 0);
7970 };
7971 }
7972 }
7973 }
7974 }
7975
7976 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useRole.js
7977 var React35 = __toESM(require_react(), 1);
7978 var componentRoleToAriaRoleMap = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", false]]);
7979 function useRole(context, props = {}) {
7980 const store = "rootStore" in context ? context.rootStore : context;
7981 const open = store.useState("open");
7982 const defaultFloatingId = store.useState("floatingId");
7983 const domReference = store.useState("domReferenceElement");
7984 const floatingElement = store.useState("floatingElement");
7985 const {
7986 role = "dialog"
7987 } = props;
7988 const defaultReferenceId = useId();
7989 const referenceId = domReference?.id || defaultReferenceId;
7990 const floatingId = React35.useMemo(() => getFloatingFocusElement(floatingElement)?.id || defaultFloatingId, [floatingElement, defaultFloatingId]);
7991 const ariaRole = componentRoleToAriaRoleMap.get(role) ?? role;
7992 const parentId = useFloatingParentNodeId();
7993 const isNested = parentId != null;
7994 const trigger = React35.useMemo(() => {
7995 if (ariaRole === "tooltip" || role === "label") {
7996 return EMPTY_OBJECT;
7997 }
7998 return {
7999 "aria-haspopup": ariaRole === "alertdialog" ? "dialog" : ariaRole,
8000 "aria-expanded": "false",
8001 ...ariaRole === "listbox" && {
8002 role: "combobox"
8003 },
8004 ...ariaRole === "menu" && isNested && {
8005 role: "menuitem"
8006 },
8007 ...role === "select" && {
8008 "aria-autocomplete": "none"
8009 },
8010 ...role === "combobox" && {
8011 "aria-autocomplete": "list"
8012 }
8013 };
8014 }, [ariaRole, isNested, role]);
8015 const reference = React35.useMemo(() => {
8016 if (ariaRole === "tooltip" || role === "label") {
8017 return {
8018 [`aria-${role === "label" ? "labelledby" : "describedby"}`]: open ? floatingId : void 0
8019 };
8020 }
8021 const triggerProps = trigger;
8022 return {
8023 ...triggerProps,
8024 "aria-expanded": open ? "true" : "false",
8025 "aria-controls": open ? floatingId : void 0,
8026 ...ariaRole === "menu" && {
8027 id: referenceId
8028 }
8029 };
8030 }, [ariaRole, floatingId, open, referenceId, role, trigger]);
8031 const floating = React35.useMemo(() => {
8032 const floatingProps = {
8033 id: floatingId,
8034 ...ariaRole && {
8035 role: ariaRole
8036 }
8037 };
8038 if (ariaRole === "tooltip" || role === "label") {
8039 return floatingProps;
8040 }
8041 return {
8042 ...floatingProps,
8043 ...ariaRole === "menu" && {
8044 "aria-labelledby": referenceId
8045 }
8046 };
8047 }, [ariaRole, floatingId, referenceId, role]);
8048 const item = React35.useCallback(({
8049 active,
8050 selected
8051 }) => {
8052 const commonProps = {
8053 role: "option",
8054 ...active && {
8055 id: `${floatingId}-fui-option`
8056 }
8057 };
8058 switch (role) {
8059 case "select":
8060 case "combobox":
8061 return {
8062 ...commonProps,
8063 "aria-selected": selected
8064 };
8065 default:
8066 }
8067 return {};
8068 }, [floatingId, role]);
8069 return React35.useMemo(() => ({
8070 reference,
8071 floating,
8072 item,
8073 trigger
8074 }), [reference, floating, trigger, item]);
8075 }
8076
8077 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
8078 var CURSOR_SPEED_THRESHOLD = 0.1;
8079 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
8080 var POLYGON_BUFFER = 0.5;
8081 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
8082 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
8083 }
8084 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
8085 let isInsideValue = false;
8086 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
8087 isInsideValue = !isInsideValue;
8088 }
8089 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
8090 isInsideValue = !isInsideValue;
8091 }
8092 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
8093 isInsideValue = !isInsideValue;
8094 }
8095 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
8096 isInsideValue = !isInsideValue;
8097 }
8098 return isInsideValue;
8099 }
8100 function isInsideRect(pointX, pointY, rect) {
8101 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
8102 }
8103 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
8104 const minX = Math.min(x1, x2);
8105 const maxX = Math.max(x1, x2);
8106 const minY = Math.min(y1, y2);
8107 const maxY = Math.max(y1, y2);
8108 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
8109 }
8110 function safePolygon(options = {}) {
8111 const {
8112 blockPointerEvents = false
8113 } = options;
8114 const timeout = new Timeout();
8115 const fn = ({
8116 x: x2,
8117 y: y2,
8118 placement,
8119 elements,
8120 onClose,
8121 nodeId,
8122 tree
8123 }) => {
8124 const side = placement?.split("-")[0];
8125 let hasLanded = false;
8126 let lastX = null;
8127 let lastY = null;
8128 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
8129 function isCursorMovingSlowly(nextX, nextY) {
8130 const currentTime = performance.now();
8131 const elapsedTime = currentTime - lastCursorTime;
8132 if (lastX === null || lastY === null || elapsedTime === 0) {
8133 lastX = nextX;
8134 lastY = nextY;
8135 lastCursorTime = currentTime;
8136 return false;
8137 }
8138 const deltaX = nextX - lastX;
8139 const deltaY = nextY - lastY;
8140 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
8141 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
8142 lastX = nextX;
8143 lastY = nextY;
8144 lastCursorTime = currentTime;
8145 return distanceSquared < thresholdSquared;
8146 }
8147 function close() {
8148 timeout.clear();
8149 onClose();
8150 }
8151 return function onMouseMove(event) {
8152 timeout.clear();
8153 const domReference = elements.domReference;
8154 const floating = elements.floating;
8155 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
8156 return void 0;
8157 }
8158 const {
8159 clientX,
8160 clientY
8161 } = event;
8162 const target = getTarget(event);
8163 const isLeave = event.type === "mouseleave";
8164 const isOverFloatingEl = contains(floating, target);
8165 const isOverReferenceEl = contains(domReference, target);
8166 if (isOverFloatingEl) {
8167 hasLanded = true;
8168 if (!isLeave) {
8169 return void 0;
8170 }
8171 }
8172 if (isOverReferenceEl) {
8173 hasLanded = false;
8174 if (!isLeave) {
8175 hasLanded = true;
8176 return void 0;
8177 }
8178 }
8179 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
8180 return void 0;
8181 }
8182 function hasOpenChildNode() {
8183 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
8184 }
8185 function closeIfNoOpenChild() {
8186 if (!hasOpenChildNode()) {
8187 close();
8188 }
8189 }
8190 if (hasOpenChildNode()) {
8191 return void 0;
8192 }
8193 const refRect = domReference.getBoundingClientRect();
8194 const rect = floating.getBoundingClientRect();
8195 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
8196 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
8197 const isFloatingWider = rect.width > refRect.width;
8198 const isFloatingTaller = rect.height > refRect.height;
8199 const left = (isFloatingWider ? refRect : rect).left;
8200 const right = (isFloatingWider ? refRect : rect).right;
8201 const top = (isFloatingTaller ? refRect : rect).top;
8202 const bottom = (isFloatingTaller ? refRect : rect).bottom;
8203 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) {
8204 closeIfNoOpenChild();
8205 return void 0;
8206 }
8207 let isInsideTroughRect = false;
8208 switch (side) {
8209 case "top":
8210 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
8211 break;
8212 case "bottom":
8213 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
8214 break;
8215 case "left":
8216 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
8217 break;
8218 case "right":
8219 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
8220 break;
8221 default:
8222 }
8223 if (isInsideTroughRect) {
8224 return void 0;
8225 }
8226 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
8227 closeIfNoOpenChild();
8228 return void 0;
8229 }
8230 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
8231 closeIfNoOpenChild();
8232 return void 0;
8233 }
8234 let isInsidePolygon = false;
8235 switch (side) {
8236 case "top": {
8237 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8238 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8239 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8240 const cursorPointY = y2 + POLYGON_BUFFER + 1;
8241 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
8242 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
8243 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8244 break;
8245 }
8246 case "bottom": {
8247 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8248 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8249 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8250 const cursorPointY = y2 - POLYGON_BUFFER;
8251 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
8252 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
8253 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8254 break;
8255 }
8256 case "left": {
8257 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8258 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8259 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8260 const cursorPointX = x2 + POLYGON_BUFFER + 1;
8261 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
8262 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
8263 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
8264 break;
8265 }
8266 case "right": {
8267 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8268 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8269 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8270 const cursorPointX = x2 - POLYGON_BUFFER;
8271 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
8272 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
8273 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
8274 break;
8275 }
8276 default:
8277 }
8278 if (!isInsidePolygon) {
8279 closeIfNoOpenChild();
8280 } else if (!hasLanded) {
8281 timeout.start(40, closeIfNoOpenChild);
8282 }
8283 return void 0;
8284 };
8285 };
8286 fn.__options = {
8287 ...options,
8288 blockPointerEvents
8289 };
8290 return fn;
8291 }
8292
8293 // node_modules/@base-ui/react/esm/utils/useOpenInteractionType.js
8294 var React38 = __toESM(require_react(), 1);
8295
8296 // node_modules/@base-ui/utils/esm/useEnhancedClickHandler.js
8297 var React36 = __toESM(require_react(), 1);
8298 function useEnhancedClickHandler(handler) {
8299 const lastClickInteractionTypeRef = React36.useRef("");
8300 const handlePointerDown = React36.useCallback((event) => {
8301 if (event.defaultPrevented) {
8302 return;
8303 }
8304 lastClickInteractionTypeRef.current = event.pointerType;
8305 handler(event, event.pointerType);
8306 }, [handler]);
8307 const handleClick = React36.useCallback((event) => {
8308 if (event.detail === 0) {
8309 handler(event, "keyboard");
8310 return;
8311 }
8312 if ("pointerType" in event) {
8313 handler(event, event.pointerType);
8314 } else {
8315 handler(event, lastClickInteractionTypeRef.current);
8316 }
8317 lastClickInteractionTypeRef.current = "";
8318 }, [handler]);
8319 return {
8320 onClick: handleClick,
8321 onPointerDown: handlePointerDown
8322 };
8323 }
8324
8325 // node_modules/@base-ui/react/esm/internals/useValueChanged.js
8326 var React37 = __toESM(require_react(), 1);
8327 function useValueChanged(value, onChange) {
8328 const valueRef = React37.useRef(value);
8329 const onChangeCallback = useStableCallback(onChange);
8330 useIsoLayoutEffect(() => {
8331 if (valueRef.current === value) {
8332 return;
8333 }
8334 onChangeCallback(valueRef.current);
8335 }, [value, onChangeCallback]);
8336 useIsoLayoutEffect(() => {
8337 valueRef.current = value;
8338 }, [value]);
8339 }
8340
8341 // node_modules/@base-ui/react/esm/utils/useOpenInteractionType.js
8342 function useOpenInteractionType(open) {
8343 const [openMethod, setOpenMethod] = React38.useState(null);
8344 const handleTriggerClick = useStableCallback((_, interactionType) => {
8345 if (!open) {
8346 setOpenMethod(interactionType || // On iOS Safari, the hitslop around touch targets means tapping outside an element's
8347 // bounds does not fire `pointerdown` but does fire `mousedown`. The `interactionType`
8348 // will be "" in that case.
8349 (isIOS ? "touch" : ""));
8350 }
8351 });
8352 useValueChanged(open, (previousOpen) => {
8353 if (previousOpen && !open) {
8354 setOpenMethod(null);
8355 }
8356 });
8357 const {
8358 onClick,
8359 onPointerDown
8360 } = useEnhancedClickHandler(handleTriggerClick);
8361 return React38.useMemo(() => ({
8362 openMethod,
8363 triggerProps: {
8364 onClick,
8365 onPointerDown
8366 }
8367 }), [openMethod, onClick, onPointerDown]);
8368 }
8369
8370 // node_modules/@base-ui/react/esm/dialog/root/useDialogRoot.js
8371 function useDialogRoot(params) {
8372 const {
8373 store,
8374 parentContext,
8375 actionsRef,
8376 isDrawer
8377 } = params;
8378 const open = store.useState("open");
8379 const disablePointerDismissal = store.useState("disablePointerDismissal");
8380 const modal = store.useState("modal");
8381 const popupElement = store.useState("popupElement");
8382 const {
8383 openMethod,
8384 triggerProps
8385 } = useOpenInteractionType(open);
8386 useImplicitActiveTrigger(store);
8387 const {
8388 forceUnmount
8389 } = useOpenStateTransitions(open, store);
8390 const handleImperativeClose = React39.useCallback(() => {
8391 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8392 }, [store]);
8393 React39.useImperativeHandle(actionsRef, () => ({
8394 unmount: forceUnmount,
8395 close: handleImperativeClose
8396 }), [forceUnmount, handleImperativeClose]);
8397 const floatingRootContext = useSyncedFloatingRootContext({
8398 popupStore: store,
8399 onOpenChange: store.setOpen,
8400 treatPopupAsFloatingElement: true
8401 });
8402 const [ownNestedOpenDialogs, setOwnNestedOpenDialogs] = React39.useState(0);
8403 const [ownNestedOpenDrawers, setOwnNestedOpenDrawers] = React39.useState(0);
8404 const isTopmost = ownNestedOpenDialogs === 0;
8405 const role = useRole(floatingRootContext);
8406 const dismiss = useDismiss(floatingRootContext, {
8407 outsidePressEvent() {
8408 if (store.context.internalBackdropRef.current || store.context.backdropRef.current) {
8409 return "intentional";
8410 }
8411 return {
8412 mouse: modal === "trap-focus" ? "sloppy" : "intentional",
8413 touch: "sloppy"
8414 };
8415 },
8416 outsidePress(event) {
8417 if (!store.context.outsidePressEnabledRef.current) {
8418 return false;
8419 }
8420 if ("button" in event && event.button !== 0) {
8421 return false;
8422 }
8423 if ("touches" in event && event.touches.length !== 1) {
8424 return false;
8425 }
8426 const target = getTarget(event);
8427 if (isTopmost && !disablePointerDismissal) {
8428 const eventTarget = target;
8429 if (modal) {
8430 return store.context.internalBackdropRef.current || store.context.backdropRef.current ? store.context.internalBackdropRef.current === eventTarget || store.context.backdropRef.current === eventTarget || contains(eventTarget, popupElement) && !eventTarget?.hasAttribute("data-base-ui-portal") : true;
8431 }
8432 return true;
8433 }
8434 return false;
8435 },
8436 escapeKey: isTopmost
8437 });
8438 useScrollLock(open && modal === true, popupElement);
8439 const {
8440 getReferenceProps,
8441 getFloatingProps,
8442 getTriggerProps
8443 } = useInteractions([role, dismiss]);
8444 store.useContextCallback("onNestedDialogOpen", (dialogCount, drawerCount) => {
8445 setOwnNestedOpenDialogs(dialogCount);
8446 setOwnNestedOpenDrawers(drawerCount);
8447 });
8448 store.useContextCallback("onNestedDialogClose", () => {
8449 setOwnNestedOpenDialogs(0);
8450 setOwnNestedOpenDrawers(0);
8451 });
8452 React39.useEffect(() => {
8453 if (parentContext?.onNestedDialogOpen && open) {
8454 parentContext.onNestedDialogOpen(ownNestedOpenDialogs + 1, ownNestedOpenDrawers + (isDrawer ? 1 : 0));
8455 }
8456 if (parentContext?.onNestedDialogClose && !open) {
8457 parentContext.onNestedDialogClose();
8458 }
8459 return () => {
8460 if (parentContext?.onNestedDialogClose && open) {
8461 parentContext.onNestedDialogClose();
8462 }
8463 };
8464 }, [isDrawer, open, ownNestedOpenDialogs, ownNestedOpenDrawers, parentContext]);
8465 const activeTriggerProps = React39.useMemo(() => getReferenceProps(triggerProps), [getReferenceProps, triggerProps]);
8466 const inactiveTriggerProps = React39.useMemo(() => getTriggerProps(triggerProps), [getTriggerProps, triggerProps]);
8467 const popupProps = React39.useMemo(() => getFloatingProps(), [getFloatingProps]);
8468 store.useSyncedValues({
8469 openMethod,
8470 activeTriggerProps,
8471 inactiveTriggerProps,
8472 popupProps,
8473 floatingRootContext,
8474 nestedOpenDialogCount: ownNestedOpenDialogs,
8475 nestedOpenDrawerCount: ownNestedOpenDrawers
8476 });
8477 }
8478
8479 // node_modules/@base-ui/react/esm/dialog/root/DialogRootContext.js
8480 var React40 = __toESM(require_react(), 1);
8481 var DialogRootContext = /* @__PURE__ */ React40.createContext(void 0);
8482 if (true) DialogRootContext.displayName = "DialogRootContext";
8483 function useDialogRootContext(optional) {
8484 const dialogRootContext = React40.useContext(DialogRootContext);
8485 if (optional === false && dialogRootContext === void 0) {
8486 throw new Error(true ? "Base UI: DialogRootContext is missing. Dialog parts must be placed within <Dialog.Root>." : formatErrorMessage_default(27));
8487 }
8488 return dialogRootContext;
8489 }
8490
8491 // node_modules/@base-ui/react/esm/dialog/store/DialogStore.js
8492 var React41 = __toESM(require_react(), 1);
8493 var selectors2 = {
8494 ...popupStoreSelectors,
8495 modal: createSelector((state) => state.modal),
8496 nested: createSelector((state) => state.nested),
8497 nestedOpenDialogCount: createSelector((state) => state.nestedOpenDialogCount),
8498 nestedOpenDrawerCount: createSelector((state) => state.nestedOpenDrawerCount),
8499 disablePointerDismissal: createSelector((state) => state.disablePointerDismissal),
8500 openMethod: createSelector((state) => state.openMethod),
8501 descriptionElementId: createSelector((state) => state.descriptionElementId),
8502 titleElementId: createSelector((state) => state.titleElementId),
8503 viewportElement: createSelector((state) => state.viewportElement),
8504 role: createSelector((state) => state.role)
8505 };
8506 var DialogStore = class _DialogStore extends ReactStore {
8507 constructor(initialState) {
8508 super(createInitialState(initialState), {
8509 popupRef: /* @__PURE__ */ React41.createRef(),
8510 backdropRef: /* @__PURE__ */ React41.createRef(),
8511 internalBackdropRef: /* @__PURE__ */ React41.createRef(),
8512 outsidePressEnabledRef: {
8513 current: true
8514 },
8515 triggerElements: new PopupTriggerMap(),
8516 onOpenChange: void 0,
8517 onOpenChangeComplete: void 0
8518 }, selectors2);
8519 }
8520 setOpen = (nextOpen, eventDetails) => {
8521 eventDetails.preventUnmountOnClose = () => {
8522 this.set("preventUnmountingOnClose", true);
8523 };
8524 if (!nextOpen && eventDetails.trigger == null && this.state.activeTriggerId != null) {
8525 eventDetails.trigger = this.state.activeTriggerElement ?? void 0;
8526 }
8527 this.context.onOpenChange?.(nextOpen, eventDetails);
8528 if (eventDetails.isCanceled) {
8529 return;
8530 }
8531 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8532 const updatedState = {
8533 open: nextOpen
8534 };
8535 const newTriggerId = eventDetails.trigger?.id ?? null;
8536 if (newTriggerId || nextOpen) {
8537 updatedState.activeTriggerId = newTriggerId;
8538 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
8539 }
8540 this.update(updatedState);
8541 };
8542 static useStore(externalStore, initialState) {
8543 const internalStore = useRefWithInit(() => {
8544 return new _DialogStore(initialState);
8545 }).current;
8546 return externalStore ?? internalStore;
8547 }
8548 };
8549 function createInitialState(initialState = {}) {
8550 return {
8551 ...createInitialPopupStoreState(),
8552 modal: true,
8553 disablePointerDismissal: false,
8554 popupElement: null,
8555 viewportElement: null,
8556 descriptionElementId: void 0,
8557 titleElementId: void 0,
8558 openMethod: null,
8559 nested: false,
8560 nestedOpenDialogCount: 0,
8561 nestedOpenDrawerCount: 0,
8562 role: "dialog",
8563 ...initialState
8564 };
8565 }
8566
8567 // node_modules/@base-ui/react/esm/dialog/root/DialogRoot.js
8568 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8569 var IsDrawerContext = /* @__PURE__ */ React42.createContext(false);
8570 if (true) IsDrawerContext.displayName = "IsDrawerContext";
8571 function DialogRoot(props) {
8572 const {
8573 children,
8574 open: openProp,
8575 defaultOpen = false,
8576 onOpenChange,
8577 onOpenChangeComplete,
8578 disablePointerDismissal = false,
8579 modal = true,
8580 actionsRef,
8581 handle,
8582 triggerId: triggerIdProp,
8583 defaultTriggerId: defaultTriggerIdProp = null
8584 } = props;
8585 const parentDialogRootContext = useDialogRootContext(true);
8586 const isDrawer = React42.useContext(IsDrawerContext);
8587 const nested = Boolean(parentDialogRootContext);
8588 const store = DialogStore.useStore(handle?.store, {
8589 open: defaultOpen,
8590 openProp,
8591 activeTriggerId: defaultTriggerIdProp,
8592 triggerIdProp,
8593 modal,
8594 disablePointerDismissal,
8595 nested
8596 });
8597 useOnFirstRender(() => {
8598 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8599 store.update({
8600 open: true,
8601 activeTriggerId: defaultTriggerIdProp
8602 });
8603 }
8604 });
8605 store.useControlledProp("openProp", openProp);
8606 store.useControlledProp("triggerIdProp", triggerIdProp);
8607 store.useSyncedValues({
8608 disablePointerDismissal,
8609 nested,
8610 modal
8611 });
8612 store.useContextCallback("onOpenChange", onOpenChange);
8613 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8614 const payload = store.useState("payload");
8615 useDialogRoot({
8616 store,
8617 actionsRef,
8618 parentContext: parentDialogRootContext?.store.context,
8619 isDrawer,
8620 onOpenChange,
8621 triggerIdProp
8622 });
8623 const contextValue = React42.useMemo(() => ({
8624 store
8625 }), [store]);
8626 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IsDrawerContext.Provider, {
8627 value: false,
8628 children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DialogRootContext.Provider, {
8629 value: contextValue,
8630 children: typeof children === "function" ? children({
8631 payload
8632 }) : children
8633 })
8634 });
8635 }
8636
8637 // node_modules/@base-ui/react/esm/alert-dialog/root/AlertDialogRoot.js
8638 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8639 function AlertDialogRoot(props) {
8640 const {
8641 children,
8642 open: openProp,
8643 defaultOpen = false,
8644 onOpenChange,
8645 onOpenChangeComplete,
8646 actionsRef,
8647 handle,
8648 triggerId: triggerIdProp,
8649 defaultTriggerId: defaultTriggerIdProp = null
8650 } = props;
8651 const parentDialogRootContext = useDialogRootContext(true);
8652 const nested = Boolean(parentDialogRootContext);
8653 const store = DialogStore.useStore(handle?.store, {
8654 open: defaultOpen,
8655 openProp,
8656 activeTriggerId: defaultTriggerIdProp,
8657 triggerIdProp,
8658 modal: true,
8659 disablePointerDismissal: true,
8660 nested,
8661 role: "alertdialog"
8662 });
8663 store.useControlledProp("openProp", openProp);
8664 store.useControlledProp("triggerIdProp", triggerIdProp);
8665 store.useSyncedValue("nested", nested);
8666 store.useContextCallback("onOpenChange", onOpenChange);
8667 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8668 const payload = store.useState("payload");
8669 useDialogRoot({
8670 store,
8671 actionsRef,
8672 parentContext: parentDialogRootContext?.store.context,
8673 isDrawer: false,
8674 onOpenChange,
8675 triggerIdProp
8676 });
8677 const contextValue = React43.useMemo(() => ({
8678 store
8679 }), [store]);
8680 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(IsDrawerContext.Provider, {
8681 value: false,
8682 children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DialogRootContext.Provider, {
8683 value: contextValue,
8684 children: typeof children === "function" ? children({
8685 payload
8686 }) : children
8687 })
8688 });
8689 }
8690
8691 // node_modules/@base-ui/react/esm/dialog/backdrop/DialogBackdrop.js
8692 var React44 = __toESM(require_react(), 1);
8693
8694 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
8695 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
8696 CommonPopupDataAttributes2["open"] = "data-open";
8697 CommonPopupDataAttributes2["closed"] = "data-closed";
8698 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
8699 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
8700 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
8701 CommonPopupDataAttributes2["side"] = "data-side";
8702 CommonPopupDataAttributes2["align"] = "data-align";
8703 return CommonPopupDataAttributes2;
8704 })({});
8705 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
8706 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
8707 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
8708 return CommonTriggerDataAttributes2;
8709 })({});
8710 var TRIGGER_HOOK = {
8711 [CommonTriggerDataAttributes.popupOpen]: ""
8712 };
8713 var PRESSABLE_TRIGGER_HOOK = {
8714 [CommonTriggerDataAttributes.popupOpen]: "",
8715 [CommonTriggerDataAttributes.pressed]: ""
8716 };
8717 var POPUP_OPEN_HOOK = {
8718 [CommonPopupDataAttributes.open]: ""
8719 };
8720 var POPUP_CLOSED_HOOK = {
8721 [CommonPopupDataAttributes.closed]: ""
8722 };
8723 var ANCHOR_HIDDEN_HOOK = {
8724 [CommonPopupDataAttributes.anchorHidden]: ""
8725 };
8726 var triggerOpenStateMapping = {
8727 open(value) {
8728 if (value) {
8729 return TRIGGER_HOOK;
8730 }
8731 return null;
8732 }
8733 };
8734 var popupStateMapping = {
8735 open(value) {
8736 if (value) {
8737 return POPUP_OPEN_HOOK;
8738 }
8739 return POPUP_CLOSED_HOOK;
8740 },
8741 anchorHidden(value) {
8742 if (value) {
8743 return ANCHOR_HIDDEN_HOOK;
8744 }
8745 return null;
8746 }
8747 };
8748
8749 // node_modules/@base-ui/react/esm/dialog/backdrop/DialogBackdrop.js
8750 var stateAttributesMapping = {
8751 ...popupStateMapping,
8752 ...transitionStatusMapping
8753 };
8754 var DialogBackdrop = /* @__PURE__ */ React44.forwardRef(function DialogBackdrop2(componentProps, forwardedRef) {
8755 const {
8756 render: render4,
8757 className,
8758 style,
8759 forceRender = false,
8760 ...elementProps
8761 } = componentProps;
8762 const {
8763 store
8764 } = useDialogRootContext();
8765 const open = store.useState("open");
8766 const nested = store.useState("nested");
8767 const mounted = store.useState("mounted");
8768 const transitionStatus = store.useState("transitionStatus");
8769 const state = {
8770 open,
8771 transitionStatus
8772 };
8773 return useRenderElement("div", componentProps, {
8774 state,
8775 ref: [store.context.backdropRef, forwardedRef],
8776 stateAttributesMapping,
8777 props: [{
8778 role: "presentation",
8779 hidden: !mounted,
8780 style: {
8781 userSelect: "none",
8782 WebkitUserSelect: "none"
8783 }
8784 }, elementProps],
8785 enabled: forceRender || !nested
8786 });
8787 });
8788 if (true) DialogBackdrop.displayName = "DialogBackdrop";
8789
8790 // node_modules/@base-ui/react/esm/dialog/close/DialogClose.js
8791 var React45 = __toESM(require_react(), 1);
8792 var DialogClose = /* @__PURE__ */ React45.forwardRef(function DialogClose2(componentProps, forwardedRef) {
8793 const {
8794 render: render4,
8795 className,
8796 disabled: disabled2 = false,
8797 nativeButton = true,
8798 style,
8799 ...elementProps
8800 } = componentProps;
8801 const {
8802 store
8803 } = useDialogRootContext();
8804 const open = store.useState("open");
8805 function handleClick(event) {
8806 if (open) {
8807 store.setOpen(false, createChangeEventDetails(reason_parts_exports.closePress, event.nativeEvent));
8808 }
8809 }
8810 const {
8811 getButtonProps,
8812 buttonRef
8813 } = useButton({
8814 disabled: disabled2,
8815 native: nativeButton
8816 });
8817 const state = {
8818 disabled: disabled2
8819 };
8820 return useRenderElement("button", componentProps, {
8821 state,
8822 ref: [forwardedRef, buttonRef],
8823 props: [{
8824 onClick: handleClick
8825 }, elementProps, getButtonProps]
8826 });
8827 });
8828 if (true) DialogClose.displayName = "DialogClose";
8829
8830 // node_modules/@base-ui/react/esm/dialog/description/DialogDescription.js
8831 var React46 = __toESM(require_react(), 1);
8832 var DialogDescription = /* @__PURE__ */ React46.forwardRef(function DialogDescription2(componentProps, forwardedRef) {
8833 const {
8834 render: render4,
8835 className,
8836 style,
8837 id: idProp,
8838 ...elementProps
8839 } = componentProps;
8840 const {
8841 store
8842 } = useDialogRootContext();
8843 const id = useBaseUiId(idProp);
8844 store.useSyncedValueWithCleanup("descriptionElementId", id);
8845 return useRenderElement("p", componentProps, {
8846 ref: forwardedRef,
8847 props: [{
8848 id
8849 }, elementProps]
8850 });
8851 });
8852 if (true) DialogDescription.displayName = "DialogDescription";
8853
8854 // node_modules/@base-ui/react/esm/dialog/popup/DialogPopup.js
8855 var React48 = __toESM(require_react(), 1);
8856
8857 // node_modules/@base-ui/react/esm/dialog/popup/DialogPopupCssVars.js
8858 var DialogPopupCssVars = /* @__PURE__ */ (function(DialogPopupCssVars2) {
8859 DialogPopupCssVars2["nestedDialogs"] = "--nested-dialogs";
8860 return DialogPopupCssVars2;
8861 })({});
8862
8863 // node_modules/@base-ui/react/esm/dialog/popup/DialogPopupDataAttributes.js
8864 var DialogPopupDataAttributes = (function(DialogPopupDataAttributes2) {
8865 DialogPopupDataAttributes2[DialogPopupDataAttributes2["open"] = CommonPopupDataAttributes.open] = "open";
8866 DialogPopupDataAttributes2[DialogPopupDataAttributes2["closed"] = CommonPopupDataAttributes.closed] = "closed";
8867 DialogPopupDataAttributes2[DialogPopupDataAttributes2["startingStyle"] = CommonPopupDataAttributes.startingStyle] = "startingStyle";
8868 DialogPopupDataAttributes2[DialogPopupDataAttributes2["endingStyle"] = CommonPopupDataAttributes.endingStyle] = "endingStyle";
8869 DialogPopupDataAttributes2["nested"] = "data-nested";
8870 DialogPopupDataAttributes2["nestedDialogOpen"] = "data-nested-dialog-open";
8871 return DialogPopupDataAttributes2;
8872 })({});
8873
8874 // node_modules/@base-ui/react/esm/dialog/portal/DialogPortalContext.js
8875 var React47 = __toESM(require_react(), 1);
8876 var DialogPortalContext = /* @__PURE__ */ React47.createContext(void 0);
8877 if (true) DialogPortalContext.displayName = "DialogPortalContext";
8878 function useDialogPortalContext() {
8879 const value = React47.useContext(DialogPortalContext);
8880 if (value === void 0) {
8881 throw new Error(true ? "Base UI: <Dialog.Portal> is missing." : formatErrorMessage_default(26));
8882 }
8883 return value;
8884 }
8885
8886 // node_modules/@base-ui/react/esm/dialog/popup/DialogPopup.js
8887 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8888 var stateAttributesMapping2 = {
8889 ...popupStateMapping,
8890 ...transitionStatusMapping,
8891 nestedDialogOpen(value) {
8892 return value ? {
8893 [DialogPopupDataAttributes.nestedDialogOpen]: ""
8894 } : null;
8895 }
8896 };
8897 var DialogPopup = /* @__PURE__ */ React48.forwardRef(function DialogPopup2(componentProps, forwardedRef) {
8898 const {
8899 className,
8900 finalFocus,
8901 initialFocus,
8902 render: render4,
8903 style,
8904 ...elementProps
8905 } = componentProps;
8906 const {
8907 store
8908 } = useDialogRootContext();
8909 const descriptionElementId = store.useState("descriptionElementId");
8910 const disablePointerDismissal = store.useState("disablePointerDismissal");
8911 const floatingRootContext = store.useState("floatingRootContext");
8912 const rootPopupProps = store.useState("popupProps");
8913 const modal = store.useState("modal");
8914 const mounted = store.useState("mounted");
8915 const nested = store.useState("nested");
8916 const nestedOpenDialogCount = store.useState("nestedOpenDialogCount");
8917 const open = store.useState("open");
8918 const openMethod = store.useState("openMethod");
8919 const titleElementId = store.useState("titleElementId");
8920 const transitionStatus = store.useState("transitionStatus");
8921 const role = store.useState("role");
8922 useDialogPortalContext();
8923 useOpenChangeComplete({
8924 open,
8925 ref: store.context.popupRef,
8926 onComplete() {
8927 if (open) {
8928 store.context.onOpenChangeComplete?.(true);
8929 }
8930 }
8931 });
8932 function defaultInitialFocus(interactionType) {
8933 if (interactionType === "touch") {
8934 return store.context.popupRef.current;
8935 }
8936 return true;
8937 }
8938 const resolvedInitialFocus = initialFocus === void 0 ? defaultInitialFocus : initialFocus;
8939 const nestedDialogOpen = nestedOpenDialogCount > 0;
8940 const state = {
8941 open,
8942 nested,
8943 transitionStatus,
8944 nestedDialogOpen
8945 };
8946 const element = useRenderElement("div", componentProps, {
8947 state,
8948 props: [rootPopupProps, {
8949 "aria-labelledby": titleElementId ?? void 0,
8950 "aria-describedby": descriptionElementId ?? void 0,
8951 role,
8952 tabIndex: -1,
8953 hidden: !mounted,
8954 onKeyDown(event) {
8955 if (COMPOSITE_KEYS.has(event.key)) {
8956 event.stopPropagation();
8957 }
8958 },
8959 style: {
8960 [DialogPopupCssVars.nestedDialogs]: nestedOpenDialogCount
8961 }
8962 }, elementProps],
8963 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
8964 stateAttributesMapping: stateAttributesMapping2
8965 });
8966 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingFocusManager, {
8967 context: floatingRootContext,
8968 openInteractionType: openMethod,
8969 disabled: !mounted,
8970 closeOnFocusOut: !disablePointerDismissal,
8971 initialFocus: resolvedInitialFocus,
8972 returnFocus: finalFocus,
8973 modal: modal !== false,
8974 restoreFocus: "popup",
8975 children: element
8976 });
8977 });
8978 if (true) DialogPopup.displayName = "DialogPopup";
8979
8980 // node_modules/@base-ui/react/esm/dialog/portal/DialogPortal.js
8981 var React50 = __toESM(require_react(), 1);
8982
8983 // node_modules/@base-ui/utils/esm/inertValue.js
8984 function inertValue(value) {
8985 if (isReactVersionAtLeast(19)) {
8986 return value;
8987 }
8988 return value ? "true" : void 0;
8989 }
8990
8991 // node_modules/@base-ui/react/esm/utils/InternalBackdrop.js
8992 var React49 = __toESM(require_react(), 1);
8993 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8994 var InternalBackdrop = /* @__PURE__ */ React49.forwardRef(function InternalBackdrop2(props, ref) {
8995 const {
8996 cutout,
8997 ...otherProps
8998 } = props;
8999 let clipPath;
9000 if (cutout) {
9001 const rect = cutout.getBoundingClientRect();
9002 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)`;
9003 }
9004 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {
9005 ref,
9006 role: "presentation",
9007 "data-base-ui-inert": "",
9008 ...otherProps,
9009 style: {
9010 position: "fixed",
9011 inset: 0,
9012 userSelect: "none",
9013 WebkitUserSelect: "none",
9014 clipPath
9015 }
9016 });
9017 });
9018 if (true) InternalBackdrop.displayName = "InternalBackdrop";
9019
9020 // node_modules/@base-ui/react/esm/dialog/portal/DialogPortal.js
9021 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9022 var DialogPortal = /* @__PURE__ */ React50.forwardRef(function DialogPortal2(props, forwardedRef) {
9023 const {
9024 keepMounted = false,
9025 ...portalProps
9026 } = props;
9027 const {
9028 store
9029 } = useDialogRootContext();
9030 const mounted = store.useState("mounted");
9031 const modal = store.useState("modal");
9032 const open = store.useState("open");
9033 const shouldRender = mounted || keepMounted;
9034 if (!shouldRender) {
9035 return null;
9036 }
9037 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DialogPortalContext.Provider, {
9038 value: keepMounted,
9039 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(FloatingPortal, {
9040 ref: forwardedRef,
9041 ...portalProps,
9042 children: [mounted && modal === true && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InternalBackdrop, {
9043 ref: store.context.internalBackdropRef,
9044 inert: inertValue(!open)
9045 }), props.children]
9046 })
9047 });
9048 });
9049 if (true) DialogPortal.displayName = "DialogPortal";
9050
9051 // node_modules/@base-ui/react/esm/dialog/title/DialogTitle.js
9052 var React51 = __toESM(require_react(), 1);
9053 var DialogTitle = /* @__PURE__ */ React51.forwardRef(function DialogTitle2(componentProps, forwardedRef) {
9054 const {
9055 render: render4,
9056 className,
9057 style,
9058 id: idProp,
9059 ...elementProps
9060 } = componentProps;
9061 const {
9062 store
9063 } = useDialogRootContext();
9064 const id = useBaseUiId(idProp);
9065 store.useSyncedValueWithCleanup("titleElementId", id);
9066 return useRenderElement("h2", componentProps, {
9067 ref: forwardedRef,
9068 props: [{
9069 id
9070 }, elementProps]
9071 });
9072 });
9073 if (true) DialogTitle.displayName = "DialogTitle";
9074
9075 // node_modules/@base-ui/react/esm/dialog/trigger/DialogTrigger.js
9076 var React52 = __toESM(require_react(), 1);
9077 var DialogTrigger = /* @__PURE__ */ React52.forwardRef(function DialogTrigger2(componentProps, forwardedRef) {
9078 const {
9079 render: render4,
9080 className,
9081 disabled: disabled2 = false,
9082 nativeButton = true,
9083 id: idProp,
9084 payload,
9085 handle,
9086 style,
9087 ...elementProps
9088 } = componentProps;
9089 const dialogRootContext = useDialogRootContext(true);
9090 const store = handle?.store ?? dialogRootContext?.store;
9091 if (!store) {
9092 throw new Error(true ? "Base UI: <Dialog.Trigger> must be used within <Dialog.Root> or provided with a handle." : formatErrorMessage_default(79));
9093 }
9094 const thisTriggerId = useBaseUiId(idProp);
9095 const floatingContext = store.useState("floatingRootContext");
9096 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9097 const triggerElementRef = React52.useRef(null);
9098 const {
9099 registerTrigger,
9100 isMountedByThisTrigger
9101 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9102 payload
9103 });
9104 const {
9105 getButtonProps,
9106 buttonRef
9107 } = useButton({
9108 disabled: disabled2,
9109 native: nativeButton
9110 });
9111 const click = useClick(floatingContext, {
9112 enabled: floatingContext != null
9113 });
9114 const localInteractionProps = useInteractions([click]);
9115 const state = {
9116 disabled: disabled2,
9117 open: isOpenedByThisTrigger
9118 };
9119 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9120 return useRenderElement("button", componentProps, {
9121 state,
9122 ref: [buttonRef, forwardedRef, registerTrigger, triggerElementRef],
9123 props: [localInteractionProps.getReferenceProps(), rootTriggerProps, {
9124 [CLICK_TRIGGER_IDENTIFIER]: "",
9125 id: thisTriggerId
9126 }, elementProps, getButtonProps],
9127 stateAttributesMapping: triggerOpenStateMapping
9128 });
9129 });
9130 if (true) DialogTrigger.displayName = "DialogTrigger";
9131
9132 // node_modules/@base-ui/react/esm/dialog/viewport/DialogViewport.js
9133 var React53 = __toESM(require_react(), 1);
9134
9135 // node_modules/@base-ui/react/esm/dialog/viewport/DialogViewportDataAttributes.js
9136 var DialogViewportDataAttributes = (function(DialogViewportDataAttributes2) {
9137 DialogViewportDataAttributes2[DialogViewportDataAttributes2["open"] = CommonPopupDataAttributes.open] = "open";
9138 DialogViewportDataAttributes2[DialogViewportDataAttributes2["closed"] = CommonPopupDataAttributes.closed] = "closed";
9139 DialogViewportDataAttributes2[DialogViewportDataAttributes2["startingStyle"] = CommonPopupDataAttributes.startingStyle] = "startingStyle";
9140 DialogViewportDataAttributes2[DialogViewportDataAttributes2["endingStyle"] = CommonPopupDataAttributes.endingStyle] = "endingStyle";
9141 DialogViewportDataAttributes2["nested"] = "data-nested";
9142 DialogViewportDataAttributes2["nestedDialogOpen"] = "data-nested-dialog-open";
9143 return DialogViewportDataAttributes2;
9144 })({});
9145
9146 // node_modules/@base-ui/react/esm/dialog/viewport/DialogViewport.js
9147 var stateAttributesMapping3 = {
9148 ...popupStateMapping,
9149 ...transitionStatusMapping,
9150 nested(value) {
9151 return value ? {
9152 [DialogViewportDataAttributes.nested]: ""
9153 } : null;
9154 },
9155 nestedDialogOpen(value) {
9156 return value ? {
9157 [DialogViewportDataAttributes.nestedDialogOpen]: ""
9158 } : null;
9159 }
9160 };
9161 var DialogViewport = /* @__PURE__ */ React53.forwardRef(function DialogViewport2(componentProps, forwardedRef) {
9162 const {
9163 className,
9164 render: render4,
9165 children,
9166 style,
9167 ...elementProps
9168 } = componentProps;
9169 const keepMounted = useDialogPortalContext();
9170 const {
9171 store
9172 } = useDialogRootContext();
9173 const open = store.useState("open");
9174 const nested = store.useState("nested");
9175 const transitionStatus = store.useState("transitionStatus");
9176 const nestedOpenDialogCount = store.useState("nestedOpenDialogCount");
9177 const mounted = store.useState("mounted");
9178 const nestedDialogOpen = nestedOpenDialogCount > 0;
9179 const state = {
9180 open,
9181 nested,
9182 transitionStatus,
9183 nestedDialogOpen
9184 };
9185 const shouldRender = keepMounted || mounted;
9186 return useRenderElement("div", componentProps, {
9187 enabled: shouldRender,
9188 state,
9189 ref: [forwardedRef, store.useStateSetter("viewportElement")],
9190 stateAttributesMapping: stateAttributesMapping3,
9191 props: [{
9192 role: "presentation",
9193 hidden: !mounted,
9194 style: {
9195 pointerEvents: !open ? "none" : void 0
9196 },
9197 children
9198 }, elementProps]
9199 });
9200 });
9201 if (true) DialogViewport.displayName = "DialogViewport";
9202
9203 // node_modules/@base-ui/react/esm/dialog/store/DialogHandle.js
9204 var DialogHandle = class {
9205 /**
9206 * Internal store holding the dialog state.
9207 * @internal
9208 */
9209 constructor(store) {
9210 this.store = store ?? new DialogStore();
9211 }
9212 /**
9213 * Opens the dialog and associates it with the trigger with the given id.
9214 * The trigger, if provided, must be a Dialog.Trigger component with this handle passed as a prop.
9215 *
9216 * This method should only be called in an event handler or an effect (not during rendering).
9217 *
9218 * @param triggerId ID of the trigger to associate with the dialog. If null, the dialog will open without a trigger association.
9219 */
9220 open(triggerId) {
9221 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9222 if (true) {
9223 if (triggerId && !triggerElement) {
9224 console.warn(`Base UI: DialogHandle.open: No trigger found with id "${triggerId}". The dialog will open, but the trigger will not be associated with the dialog.`);
9225 }
9226 }
9227 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9228 }
9229 /**
9230 * Opens the dialog and sets the payload.
9231 * Does not associate the dialog with any trigger.
9232 *
9233 * @param payload Payload to set when opening the dialog.
9234 */
9235 openWithPayload(payload) {
9236 this.store.set("payload", payload);
9237 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9238 }
9239 /**
9240 * Closes the dialog.
9241 */
9242 close() {
9243 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9244 }
9245 /**
9246 * Indicates whether the dialog is currently open.
9247 */
9248 get isOpen() {
9249 return this.store.state.open;
9250 }
9251 };
9252 function createDialogHandle() {
9253 return new DialogHandle();
9254 }
9255
9256 // node_modules/@base-ui/react/esm/alert-dialog/handle.js
9257 function createAlertDialogHandle() {
9258 return new DialogHandle(new DialogStore({
9259 modal: true,
9260 disablePointerDismissal: true,
9261 role: "alertdialog"
9262 }));
9263 }
9264
9265 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
9266 var React54 = __toESM(require_react(), 1);
9267
9268 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
9269 var baseArrow = (options) => ({
9270 name: "arrow",
9271 options,
9272 async fn(state) {
9273 const {
9274 x: x2,
9275 y: y2,
9276 placement,
9277 rects,
9278 platform: platform3,
9279 elements,
9280 middlewareData
9281 } = state;
9282 const {
9283 element,
9284 padding = 0,
9285 offsetParent = "real"
9286 } = evaluate(options, state) || {};
9287 if (element == null) {
9288 return {};
9289 }
9290 const paddingObject = getPaddingObject(padding);
9291 const coords = {
9292 x: x2,
9293 y: y2
9294 };
9295 const axis = getAlignmentAxis(placement);
9296 const length = getAxisLength(axis);
9297 const arrowDimensions = await platform3.getDimensions(element);
9298 const isYAxis = axis === "y";
9299 const minProp = isYAxis ? "top" : "left";
9300 const maxProp = isYAxis ? "bottom" : "right";
9301 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
9302 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
9303 const startDiff = coords[axis] - rects.reference[axis];
9304 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
9305 let clientSize = elements.floating[clientProp] || rects.floating[length];
9306 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
9307 clientSize = elements.floating[clientProp] || rects.floating[length];
9308 }
9309 const centerToReference = endDiff / 2 - startDiff / 2;
9310 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
9311 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
9312 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
9313 const min2 = minPadding;
9314 const max2 = clientSize - arrowDimensions[length] - maxPadding;
9315 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
9316 const offset4 = clamp(min2, center, max2);
9317 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
9318 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
9319 return {
9320 [axis]: coords[axis] + alignmentOffset,
9321 data: {
9322 [axis]: offset4,
9323 centerOffset: center - offset4 - alignmentOffset,
9324 ...shouldAddOffset && {
9325 alignmentOffset
9326 }
9327 },
9328 reset: shouldAddOffset
9329 };
9330 }
9331 });
9332 var arrow4 = (options, deps) => ({
9333 ...baseArrow(options),
9334 options: [options, deps]
9335 });
9336
9337 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
9338 var hide4 = {
9339 name: "hide",
9340 async fn(state) {
9341 const {
9342 width,
9343 height,
9344 x: x2,
9345 y: y2
9346 } = state.rects.reference;
9347 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
9348 const nativeHideResult = await hide3().fn(state);
9349 return {
9350 data: {
9351 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
9352 }
9353 };
9354 }
9355 };
9356
9357 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
9358 var DEFAULT_SIDES = {
9359 sideX: "left",
9360 sideY: "top"
9361 };
9362 var adaptiveOrigin = {
9363 name: "adaptiveOrigin",
9364 async fn(state) {
9365 const {
9366 x: rawX,
9367 y: rawY,
9368 rects: {
9369 floating: floatRect
9370 },
9371 elements: {
9372 floating
9373 },
9374 platform: platform3,
9375 strategy,
9376 placement
9377 } = state;
9378 const win = getWindow(floating);
9379 const styles = win.getComputedStyle(floating);
9380 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
9381 if (!hasTransition) {
9382 return {
9383 x: rawX,
9384 y: rawY,
9385 data: DEFAULT_SIDES
9386 };
9387 }
9388 const offsetParent = await platform3.getOffsetParent?.(floating);
9389 let offsetDimensions = {
9390 width: 0,
9391 height: 0
9392 };
9393 if (strategy === "fixed" && win?.visualViewport) {
9394 offsetDimensions = {
9395 width: win.visualViewport.width,
9396 height: win.visualViewport.height
9397 };
9398 } else if (offsetParent === win) {
9399 const doc = ownerDocument(floating);
9400 offsetDimensions = {
9401 width: doc.documentElement.clientWidth,
9402 height: doc.documentElement.clientHeight
9403 };
9404 } else if (await platform3.isElement?.(offsetParent)) {
9405 offsetDimensions = await platform3.getDimensions(offsetParent);
9406 }
9407 const currentSide = getSide(placement);
9408 let x2 = rawX;
9409 let y2 = rawY;
9410 if (currentSide === "left") {
9411 x2 = offsetDimensions.width - (rawX + floatRect.width);
9412 }
9413 if (currentSide === "top") {
9414 y2 = offsetDimensions.height - (rawY + floatRect.height);
9415 }
9416 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
9417 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
9418 return {
9419 x: x2,
9420 y: y2,
9421 data: {
9422 sideX,
9423 sideY
9424 }
9425 };
9426 }
9427 };
9428
9429 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
9430 function getLogicalSide(sideParam, renderedSide, isRtl) {
9431 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
9432 const logicalRight = isRtl ? "inline-start" : "inline-end";
9433 const logicalLeft = isRtl ? "inline-end" : "inline-start";
9434 return {
9435 top: "top",
9436 right: isLogicalSideParam ? logicalRight : "right",
9437 bottom: "bottom",
9438 left: isLogicalSideParam ? logicalLeft : "left"
9439 }[renderedSide];
9440 }
9441 function getOffsetData(state, sideParam, isRtl) {
9442 const {
9443 rects,
9444 placement
9445 } = state;
9446 const data = {
9447 side: getLogicalSide(sideParam, getSide(placement), isRtl),
9448 align: getAlignment(placement) || "center",
9449 anchor: {
9450 width: rects.reference.width,
9451 height: rects.reference.height
9452 },
9453 positioner: {
9454 width: rects.floating.width,
9455 height: rects.floating.height
9456 }
9457 };
9458 return data;
9459 }
9460 function useAnchorPositioning(params) {
9461 const {
9462 // Public parameters
9463 anchor,
9464 positionMethod = "absolute",
9465 side: sideParam = "bottom",
9466 sideOffset = 0,
9467 align = "center",
9468 alignOffset = 0,
9469 collisionBoundary,
9470 collisionPadding: collisionPaddingParam = 5,
9471 sticky = false,
9472 arrowPadding = 5,
9473 disableAnchorTracking = false,
9474 // Private parameters
9475 keepMounted = false,
9476 floatingRootContext,
9477 mounted,
9478 collisionAvoidance,
9479 shiftCrossAxis = false,
9480 nodeId,
9481 adaptiveOrigin: adaptiveOrigin2,
9482 lazyFlip = false,
9483 externalTree
9484 } = params;
9485 const [mountSide, setMountSide] = React54.useState(null);
9486 if (!mounted && mountSide !== null) {
9487 setMountSide(null);
9488 }
9489 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
9490 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
9491 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
9492 const anchorFn = typeof anchor === "function" ? anchor : void 0;
9493 const anchorFnCallback = useStableCallback(anchorFn);
9494 const anchorDep = anchorFn ? anchorFnCallback : anchor;
9495 const anchorValueRef = useValueAsRef(anchor);
9496 const mountedRef = useValueAsRef(mounted);
9497 const direction = useDirection();
9498 const isRtl = direction === "rtl";
9499 const side = mountSide || {
9500 top: "top",
9501 right: "right",
9502 bottom: "bottom",
9503 left: "left",
9504 "inline-end": isRtl ? "left" : "right",
9505 "inline-start": isRtl ? "right" : "left"
9506 }[sideParam];
9507 const placement = align === "center" ? side : `${side}-${align}`;
9508 let collisionPadding = collisionPaddingParam;
9509 const bias = 1;
9510 const biasTop = sideParam === "bottom" ? bias : 0;
9511 const biasBottom = sideParam === "top" ? bias : 0;
9512 const biasLeft = sideParam === "right" ? bias : 0;
9513 const biasRight = sideParam === "left" ? bias : 0;
9514 if (typeof collisionPadding === "number") {
9515 collisionPadding = {
9516 top: collisionPadding + biasTop,
9517 right: collisionPadding + biasRight,
9518 bottom: collisionPadding + biasBottom,
9519 left: collisionPadding + biasLeft
9520 };
9521 } else if (collisionPadding) {
9522 collisionPadding = {
9523 top: (collisionPadding.top || 0) + biasTop,
9524 right: (collisionPadding.right || 0) + biasRight,
9525 bottom: (collisionPadding.bottom || 0) + biasBottom,
9526 left: (collisionPadding.left || 0) + biasLeft
9527 };
9528 }
9529 const commonCollisionProps = {
9530 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
9531 padding: collisionPadding
9532 };
9533 const arrowRef = React54.useRef(null);
9534 const sideOffsetRef = useValueAsRef(sideOffset);
9535 const alignOffsetRef = useValueAsRef(alignOffset);
9536 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
9537 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
9538 const middleware = [offset3((state) => {
9539 const data = getOffsetData(state, sideParam, isRtl);
9540 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
9541 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
9542 return {
9543 mainAxis: sideAxis,
9544 crossAxis: alignAxis,
9545 alignmentAxis: alignAxis
9546 };
9547 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
9548 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
9549 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
9550 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
9551 ...commonCollisionProps,
9552 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
9553 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
9554 padding: {
9555 top: collisionPadding.top + bias,
9556 right: collisionPadding.right + bias,
9557 bottom: collisionPadding.bottom + bias,
9558 left: collisionPadding.left + bias
9559 },
9560 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
9561 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
9562 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
9563 });
9564 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
9565 const html = ownerDocument(data.elements.floating).documentElement;
9566 return {
9567 ...commonCollisionProps,
9568 // Use the Layout Viewport to avoid shifting around when pinch-zooming
9569 // for context menus.
9570 rootBoundary: shiftCrossAxis ? {
9571 x: 0,
9572 y: 0,
9573 width: html.clientWidth,
9574 height: html.clientHeight
9575 } : void 0,
9576 mainAxis: collisionAvoidanceAlign !== "none",
9577 crossAxis: crossAxisShiftEnabled,
9578 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
9579 if (!arrowRef.current) {
9580 return {};
9581 }
9582 const {
9583 width,
9584 height
9585 } = arrowRef.current.getBoundingClientRect();
9586 const sideAxis = getSideAxis(getSide(limitData.placement));
9587 const arrowSize = sideAxis === "y" ? width : height;
9588 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
9589 return {
9590 offset: arrowSize / 2 + offsetAmount / 2
9591 };
9592 })
9593 };
9594 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
9595 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
9596 middleware.push(shiftMiddleware, flipMiddleware);
9597 } else {
9598 middleware.push(flipMiddleware, shiftMiddleware);
9599 }
9600 middleware.push(size3({
9601 ...commonCollisionProps,
9602 apply({
9603 elements: {
9604 floating
9605 },
9606 availableWidth,
9607 availableHeight,
9608 rects
9609 }) {
9610 if (!mountedRef.current) {
9611 return;
9612 }
9613 const floatingStyle = floating.style;
9614 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
9615 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
9616 const dpr = getWindow(floating).devicePixelRatio || 1;
9617 const {
9618 x: x3,
9619 y: y3,
9620 width,
9621 height
9622 } = rects.reference;
9623 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
9624 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
9625 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
9626 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
9627 }
9628 }), arrow4(() => ({
9629 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
9630 // we'll create a fake element.
9631 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
9632 padding: arrowPadding,
9633 offsetParent: "floating"
9634 }), [arrowPadding]), {
9635 name: "transformOrigin",
9636 fn(state) {
9637 const {
9638 elements: elements2,
9639 middlewareData: middlewareData2,
9640 placement: renderedPlacement2,
9641 rects,
9642 y: y3
9643 } = state;
9644 const currentRenderedSide = getSide(renderedPlacement2);
9645 const currentRenderedAxis = getSideAxis(currentRenderedSide);
9646 const arrowEl = arrowRef.current;
9647 const arrowX = middlewareData2.arrow?.x || 0;
9648 const arrowY = middlewareData2.arrow?.y || 0;
9649 const arrowWidth = arrowEl?.clientWidth || 0;
9650 const arrowHeight = arrowEl?.clientHeight || 0;
9651 const transformX = arrowX + arrowWidth / 2;
9652 const transformY = arrowY + arrowHeight / 2;
9653 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
9654 const halfAnchorHeight = rects.reference.height / 2;
9655 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
9656 const isOverlappingAnchor = shiftY > sideOffsetValue;
9657 const adjacentTransformOrigin = {
9658 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
9659 bottom: `${transformX}px ${-sideOffsetValue}px`,
9660 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
9661 right: `${-sideOffsetValue}px ${transformY}px`
9662 }[currentRenderedSide];
9663 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
9664 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
9665 return {};
9666 }
9667 }, hide4, adaptiveOrigin2);
9668 useIsoLayoutEffect(() => {
9669 if (!mounted && floatingRootContext) {
9670 floatingRootContext.update({
9671 referenceElement: null,
9672 floatingElement: null,
9673 domReferenceElement: null,
9674 positionReference: null
9675 });
9676 }
9677 }, [mounted, floatingRootContext]);
9678 const autoUpdateOptions = React54.useMemo(() => ({
9679 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
9680 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
9681 }), [disableAnchorTracking]);
9682 const {
9683 refs,
9684 elements,
9685 x: x2,
9686 y: y2,
9687 middlewareData,
9688 update: update2,
9689 placement: renderedPlacement,
9690 context,
9691 isPositioned,
9692 floatingStyles: originalFloatingStyles
9693 } = useFloating2({
9694 rootContext: floatingRootContext,
9695 open: keepMounted ? mounted : void 0,
9696 placement,
9697 middleware,
9698 strategy: positionMethod,
9699 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
9700 nodeId,
9701 externalTree
9702 });
9703 const {
9704 sideX,
9705 sideY
9706 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
9707 const resolvedPosition = isPositioned ? positionMethod : "fixed";
9708 const floatingStyles = React54.useMemo(() => {
9709 const base = adaptiveOrigin2 ? {
9710 position: resolvedPosition,
9711 [sideX]: x2,
9712 [sideY]: y2
9713 } : {
9714 position: resolvedPosition,
9715 ...originalFloatingStyles
9716 };
9717 if (!isPositioned) {
9718 base.opacity = 0;
9719 }
9720 return base;
9721 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
9722 const registeredPositionReferenceRef = React54.useRef(null);
9723 useIsoLayoutEffect(() => {
9724 if (!mounted) {
9725 return;
9726 }
9727 const anchorValue = anchorValueRef.current;
9728 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
9729 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
9730 const finalAnchor = unwrappedElement || null;
9731 if (finalAnchor !== registeredPositionReferenceRef.current) {
9732 refs.setPositionReference(finalAnchor);
9733 registeredPositionReferenceRef.current = finalAnchor;
9734 }
9735 }, [mounted, refs, anchorDep, anchorValueRef]);
9736 React54.useEffect(() => {
9737 if (!mounted) {
9738 return;
9739 }
9740 const anchorValue = anchorValueRef.current;
9741 if (typeof anchorValue === "function") {
9742 return;
9743 }
9744 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
9745 refs.setPositionReference(anchorValue.current);
9746 registeredPositionReferenceRef.current = anchorValue.current;
9747 }
9748 }, [mounted, refs, anchorDep, anchorValueRef]);
9749 React54.useEffect(() => {
9750 if (keepMounted && mounted && elements.domReference && elements.floating) {
9751 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
9752 }
9753 return void 0;
9754 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
9755 const renderedSide = getSide(renderedPlacement);
9756 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
9757 const renderedAlign = getAlignment(renderedPlacement) || "center";
9758 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
9759 useIsoLayoutEffect(() => {
9760 if (lazyFlip && mounted && isPositioned) {
9761 setMountSide(renderedSide);
9762 }
9763 }, [lazyFlip, mounted, isPositioned, renderedSide]);
9764 const arrowStyles = React54.useMemo(() => ({
9765 position: "absolute",
9766 top: middlewareData.arrow?.y,
9767 left: middlewareData.arrow?.x
9768 }), [middlewareData.arrow]);
9769 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
9770 return React54.useMemo(() => ({
9771 positionerStyles: floatingStyles,
9772 arrowStyles,
9773 arrowRef,
9774 arrowUncentered,
9775 side: logicalRenderedSide,
9776 align: renderedAlign,
9777 physicalSide: renderedSide,
9778 anchorHidden,
9779 refs,
9780 context,
9781 isPositioned,
9782 update: update2
9783 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
9784 }
9785 function isRef(param) {
9786 return param != null && "current" in param;
9787 }
9788
9789 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
9790 function getDisabledMountTransitionStyles(transitionStatus) {
9791 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
9792 }
9793
9794 // node_modules/@base-ui/react/esm/utils/usePositioner.js
9795 function usePositioner(componentProps, state, {
9796 styles,
9797 transitionStatus,
9798 props,
9799 refs,
9800 hidden,
9801 inert = false
9802 }) {
9803 const style = {
9804 ...styles
9805 };
9806 if (inert) {
9807 style.pointerEvents = "none";
9808 }
9809 return useRenderElement("div", componentProps, {
9810 state,
9811 ref: refs,
9812 props: [{
9813 role: "presentation",
9814 hidden,
9815 style
9816 }, getDisabledMountTransitionStyles(transitionStatus), props],
9817 stateAttributesMapping: popupStateMapping
9818 });
9819 }
9820
9821 // node_modules/@base-ui/react/esm/button/Button.js
9822 var React55 = __toESM(require_react(), 1);
9823 var Button = /* @__PURE__ */ React55.forwardRef(function Button2(componentProps, forwardedRef) {
9824 const {
9825 render: render4,
9826 className,
9827 disabled: disabled2 = false,
9828 focusableWhenDisabled = false,
9829 nativeButton = true,
9830 style,
9831 ...elementProps
9832 } = componentProps;
9833 const {
9834 getButtonProps,
9835 buttonRef
9836 } = useButton({
9837 disabled: disabled2,
9838 focusableWhenDisabled,
9839 native: nativeButton
9840 });
9841 const state = {
9842 disabled: disabled2
9843 };
9844 return useRenderElement("button", componentProps, {
9845 state,
9846 ref: [forwardedRef, buttonRef],
9847 props: [elementProps, getButtonProps]
9848 });
9849 });
9850 if (true) Button.displayName = "Button";
9851
9852 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
9853 var React58 = __toESM(require_react(), 1);
9854 var ReactDOM5 = __toESM(require_react_dom(), 1);
9855
9856 // node_modules/@base-ui/utils/esm/usePreviousValue.js
9857 var React56 = __toESM(require_react(), 1);
9858 function usePreviousValue(value) {
9859 const [state, setState] = React56.useState({
9860 current: value,
9861 previous: null
9862 });
9863 if (value !== state.current) {
9864 setState({
9865 current: value,
9866 previous: state.current
9867 });
9868 }
9869 return state.previous;
9870 }
9871
9872 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
9873 var React57 = __toESM(require_react(), 1);
9874
9875 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
9876 function getCssDimensions2(element) {
9877 const css = getComputedStyle2(element);
9878 let width = parseFloat(css.width) || 0;
9879 let height = parseFloat(css.height) || 0;
9880 const hasOffset = isHTMLElement(element);
9881 const offsetWidth = hasOffset ? element.offsetWidth : width;
9882 const offsetHeight = hasOffset ? element.offsetHeight : height;
9883 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
9884 if (shouldFallback) {
9885 width = offsetWidth;
9886 height = offsetHeight;
9887 }
9888 return {
9889 width,
9890 height
9891 };
9892 }
9893
9894 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
9895 var DEFAULT_ENABLED = () => true;
9896 function usePopupAutoResize(parameters) {
9897 const {
9898 popupElement,
9899 positionerElement,
9900 content,
9901 mounted,
9902 enabled = DEFAULT_ENABLED,
9903 onMeasureLayout: onMeasureLayoutParam,
9904 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
9905 side,
9906 direction
9907 } = parameters;
9908 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
9909 const animationFrame = useAnimationFrame();
9910 const committedDimensionsRef = React57.useRef(null);
9911 const liveDimensionsRef = React57.useRef(null);
9912 const isInitialRenderRef = React57.useRef(true);
9913 const restoreAnchoringStylesRef = React57.useRef(NOOP);
9914 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
9915 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
9916 const anchoringStyles = React57.useMemo(() => {
9917 let isOriginSide = side === "top";
9918 let isPhysicalLeft = side === "left";
9919 if (direction === "rtl") {
9920 isOriginSide = isOriginSide || side === "inline-end";
9921 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
9922 } else {
9923 isOriginSide = isOriginSide || side === "inline-start";
9924 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
9925 }
9926 return isOriginSide ? {
9927 position: "absolute",
9928 [side === "top" ? "bottom" : "top"]: "0",
9929 [isPhysicalLeft ? "right" : "left"]: "0"
9930 } : EMPTY_OBJECT;
9931 }, [side, direction]);
9932 useIsoLayoutEffect(() => {
9933 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
9934 restoreAnchoringStylesRef.current = NOOP;
9935 isInitialRenderRef.current = true;
9936 committedDimensionsRef.current = null;
9937 liveDimensionsRef.current = null;
9938 return void 0;
9939 }
9940 if (!popupElement || !positionerElement) {
9941 return void 0;
9942 }
9943 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
9944 const observer = new ResizeObserver((entries) => {
9945 const entry = entries[0];
9946 if (entry) {
9947 liveDimensionsRef.current = {
9948 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
9949 height: Math.ceil(entry.borderBoxSize[0].blockSize)
9950 };
9951 }
9952 });
9953 observer.observe(popupElement);
9954 setPopupCssSize(popupElement, "auto");
9955 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
9956 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
9957 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
9958 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
9959 "--available-width": "max-content",
9960 "--available-height": "max-content"
9961 });
9962 function restoreMeasurementOverrides() {
9963 restorePopupPosition();
9964 restorePopupTransform();
9965 restorePositionerAvailableSize();
9966 }
9967 function restoreMeasurementOverridesIncludingScale() {
9968 restoreMeasurementOverrides();
9969 restorePopupScale();
9970 }
9971 onMeasureLayout?.();
9972 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
9973 setPositionerCssSize(positionerElement, "max-content");
9974 const dimensions = getCssDimensions2(popupElement);
9975 committedDimensionsRef.current = dimensions;
9976 setPositionerCssSize(positionerElement, dimensions);
9977 restoreMeasurementOverridesIncludingScale();
9978 onMeasureLayoutComplete?.(null, dimensions);
9979 isInitialRenderRef.current = false;
9980 return () => {
9981 observer.disconnect();
9982 restoreAnchoringStylesRef.current();
9983 restoreAnchoringStylesRef.current = NOOP;
9984 };
9985 }
9986 setPopupCssSize(popupElement, "auto");
9987 setPositionerCssSize(positionerElement, "max-content");
9988 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
9989 const newDimensions = getCssDimensions2(popupElement);
9990 committedDimensionsRef.current = newDimensions;
9991 if (!previousDimensions) {
9992 setPositionerCssSize(positionerElement, newDimensions);
9993 restoreMeasurementOverridesIncludingScale();
9994 onMeasureLayoutComplete?.(null, newDimensions);
9995 return () => {
9996 observer.disconnect();
9997 animationFrame.cancel();
9998 restoreAnchoringStylesRef.current();
9999 restoreAnchoringStylesRef.current = NOOP;
10000 };
10001 }
10002 setPopupCssSize(popupElement, previousDimensions);
10003 restoreMeasurementOverridesIncludingScale();
10004 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
10005 setPositionerCssSize(positionerElement, newDimensions);
10006 const abortController = new AbortController();
10007 animationFrame.request(() => {
10008 setPopupCssSize(popupElement, newDimensions);
10009 runOnceAnimationsFinish(() => {
10010 popupElement.style.setProperty("--popup-width", "auto");
10011 popupElement.style.setProperty("--popup-height", "auto");
10012 }, abortController.signal);
10013 });
10014 return () => {
10015 observer.disconnect();
10016 abortController.abort();
10017 animationFrame.cancel();
10018 restoreAnchoringStylesRef.current();
10019 restoreAnchoringStylesRef.current = NOOP;
10020 };
10021 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
10022 }
10023 function overrideElementStyle(element, property, value) {
10024 const originalValue = element.style.getPropertyValue(property);
10025 element.style.setProperty(property, value);
10026 return () => {
10027 element.style.setProperty(property, originalValue);
10028 };
10029 }
10030 function applyElementStyles(element, styles) {
10031 const restorers = [];
10032 for (const [key2, value] of Object.entries(styles)) {
10033 restorers.push(overrideElementStyle(element, key2, value));
10034 }
10035 return restorers.length ? () => {
10036 restorers.forEach((restore) => restore());
10037 } : NOOP;
10038 }
10039 function setPopupCssSize(popupElement, size4) {
10040 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
10041 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
10042 popupElement.style.setProperty("--popup-width", width);
10043 popupElement.style.setProperty("--popup-height", height);
10044 }
10045 function setPositionerCssSize(positionerElement, size4) {
10046 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
10047 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
10048 positionerElement.style.setProperty("--positioner-width", width);
10049 positionerElement.style.setProperty("--positioner-height", height);
10050 }
10051
10052 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
10053 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
10054 function usePopupViewport(parameters) {
10055 const {
10056 store,
10057 side,
10058 cssVars,
10059 children
10060 } = parameters;
10061 const direction = useDirection();
10062 const activeTrigger = store.useState("activeTriggerElement");
10063 const activeTriggerId = store.useState("activeTriggerId");
10064 const open = store.useState("open");
10065 const payload = store.useState("payload");
10066 const mounted = store.useState("mounted");
10067 const popupElement = store.useState("popupElement");
10068 const positionerElement = store.useState("positionerElement");
10069 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
10070 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
10071 const capturedNodeRef = React58.useRef(null);
10072 const [previousContentNode, setPreviousContentNode] = React58.useState(null);
10073 const [newTriggerOffset, setNewTriggerOffset] = React58.useState(null);
10074 const currentContainerRef = React58.useRef(null);
10075 const previousContainerRef = React58.useRef(null);
10076 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
10077 const cleanupFrame = useAnimationFrame();
10078 const [previousContentDimensions, setPreviousContentDimensions] = React58.useState(null);
10079 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React58.useState(false);
10080 useIsoLayoutEffect(() => {
10081 store.set("hasViewport", true);
10082 return () => {
10083 store.set("hasViewport", false);
10084 };
10085 }, [store]);
10086 const handleMeasureLayout = useStableCallback(() => {
10087 currentContainerRef.current?.style.setProperty("animation", "none");
10088 currentContainerRef.current?.style.setProperty("transition", "none");
10089 previousContainerRef.current?.style.setProperty("display", "none");
10090 });
10091 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
10092 currentContainerRef.current?.style.removeProperty("animation");
10093 currentContainerRef.current?.style.removeProperty("transition");
10094 previousContainerRef.current?.style.removeProperty("display");
10095 if (previousDimensions) {
10096 setPreviousContentDimensions(previousDimensions);
10097 }
10098 });
10099 const lastHandledTriggerRef = React58.useRef(null);
10100 useIsoLayoutEffect(() => {
10101 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
10102 setPreviousContentNode(capturedNodeRef.current);
10103 setShowStartingStyleAttribute(true);
10104 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
10105 setNewTriggerOffset(offset4);
10106 cleanupFrame.request(() => {
10107 ReactDOM5.flushSync(() => {
10108 setShowStartingStyleAttribute(false);
10109 });
10110 onAnimationsFinished(() => {
10111 setPreviousContentNode(null);
10112 setPreviousContentDimensions(null);
10113 capturedNodeRef.current = null;
10114 });
10115 });
10116 lastHandledTriggerRef.current = activeTrigger;
10117 }
10118 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
10119 useIsoLayoutEffect(() => {
10120 const source = currentContainerRef.current;
10121 if (!source) {
10122 return;
10123 }
10124 const wrapper = ownerDocument(source).createElement("div");
10125 for (const child of Array.from(source.childNodes)) {
10126 wrapper.appendChild(child.cloneNode(true));
10127 }
10128 capturedNodeRef.current = wrapper;
10129 });
10130 const isTransitioning = previousContentNode != null;
10131 let childrenToRender;
10132 if (!isTransitioning) {
10133 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
10134 "data-current": true,
10135 ref: currentContainerRef,
10136 children
10137 }, currentContentKey);
10138 } else {
10139 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(React58.Fragment, {
10140 children: [/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
10141 "data-previous": true,
10142 inert: inertValue(true),
10143 ref: previousContainerRef,
10144 style: {
10145 ...previousContentDimensions ? {
10146 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
10147 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
10148 } : null,
10149 position: "absolute"
10150 },
10151 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
10152 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
10153 "data-current": true,
10154 ref: currentContainerRef,
10155 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
10156 children
10157 }, currentContentKey)]
10158 });
10159 }
10160 useIsoLayoutEffect(() => {
10161 const container = previousContainerRef.current;
10162 if (!container || !previousContentNode) {
10163 return;
10164 }
10165 container.replaceChildren(...Array.from(previousContentNode.childNodes));
10166 }, [previousContentNode]);
10167 usePopupAutoResize({
10168 popupElement,
10169 positionerElement,
10170 mounted,
10171 content: payload,
10172 onMeasureLayout: handleMeasureLayout,
10173 onMeasureLayoutComplete: handleMeasureLayoutComplete,
10174 side,
10175 direction
10176 });
10177 const state = {
10178 activationDirection: getActivationDirection(newTriggerOffset),
10179 transitioning: isTransitioning
10180 };
10181 return {
10182 children: childrenToRender,
10183 state
10184 };
10185 }
10186 function getActivationDirection(offset4) {
10187 if (!offset4) {
10188 return void 0;
10189 }
10190 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
10191 }
10192 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
10193 if (value > tolerance) {
10194 return positiveLabel;
10195 }
10196 if (value < -tolerance) {
10197 return negativeLabel;
10198 }
10199 return "";
10200 }
10201 function calculateRelativePosition(from, to) {
10202 const fromRect = from.getBoundingClientRect();
10203 const toRect = to.getBoundingClientRect();
10204 const fromCenter = {
10205 x: fromRect.left + fromRect.width / 2,
10206 y: fromRect.top + fromRect.height / 2
10207 };
10208 const toCenter = {
10209 x: toRect.left + toRect.width / 2,
10210 y: toRect.top + toRect.height / 2
10211 };
10212 return {
10213 horizontal: toCenter.x - fromCenter.x,
10214 vertical: toCenter.y - fromCenter.y
10215 };
10216 }
10217 function usePopupContentKey(activeTriggerId, payload) {
10218 const [contentKey, setContentKey] = React58.useState(0);
10219 const previousActiveTriggerIdRef = React58.useRef(activeTriggerId);
10220 const previousPayloadRef = React58.useRef(payload);
10221 const pendingPayloadUpdateRef = React58.useRef(false);
10222 useIsoLayoutEffect(() => {
10223 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
10224 const previousPayload = previousPayloadRef.current;
10225 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
10226 const payloadChanged = payload !== previousPayload;
10227 if (triggerIdChanged) {
10228 setContentKey((value) => value + 1);
10229 pendingPayloadUpdateRef.current = !payloadChanged;
10230 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
10231 setContentKey((value) => value + 1);
10232 pendingPayloadUpdateRef.current = false;
10233 }
10234 previousActiveTriggerIdRef.current = activeTriggerId;
10235 previousPayloadRef.current = payload;
10236 }, [activeTriggerId, payload]);
10237 return `${activeTriggerId ?? "current"}-${contentKey}`;
10238 }
10239
10240 // node_modules/@base-ui/react/esm/dialog/index.parts.js
10241 var index_parts_exports2 = {};
10242 __export(index_parts_exports2, {
10243 Backdrop: () => DialogBackdrop,
10244 Close: () => DialogClose,
10245 Description: () => DialogDescription,
10246 Handle: () => DialogHandle,
10247 Popup: () => DialogPopup,
10248 Portal: () => DialogPortal,
10249 Root: () => DialogRoot,
10250 Title: () => DialogTitle,
10251 Trigger: () => DialogTrigger,
10252 Viewport: () => DialogViewport,
10253 createHandle: () => createDialogHandle
10254 });
10255
10256 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
10257 var React59 = __toESM(require_react(), 1);
10258 var ReactDOM6 = __toESM(require_react_dom(), 1);
10259 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
10260 var FloatingPortalLite = /* @__PURE__ */ React59.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
10261 const {
10262 children,
10263 container,
10264 className,
10265 render: render4,
10266 style,
10267 ...elementProps
10268 } = componentProps;
10269 const {
10270 portalNode,
10271 portalSubtree
10272 } = useFloatingPortalNode({
10273 container,
10274 ref: forwardedRef,
10275 componentProps,
10276 elementProps
10277 });
10278 if (!portalSubtree && !portalNode) {
10279 return null;
10280 }
10281 return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(React59.Fragment, {
10282 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
10283 });
10284 });
10285 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
10286
10287 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
10288 var index_parts_exports3 = {};
10289 __export(index_parts_exports3, {
10290 Arrow: () => TooltipArrow,
10291 Handle: () => TooltipHandle,
10292 Popup: () => TooltipPopup,
10293 Portal: () => TooltipPortal,
10294 Positioner: () => TooltipPositioner,
10295 Provider: () => TooltipProvider,
10296 Root: () => TooltipRoot,
10297 Trigger: () => TooltipTrigger,
10298 Viewport: () => TooltipViewport,
10299 createHandle: () => createTooltipHandle
10300 });
10301
10302 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
10303 var React62 = __toESM(require_react(), 1);
10304
10305 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
10306 var React60 = __toESM(require_react(), 1);
10307 var TooltipRootContext = /* @__PURE__ */ React60.createContext(void 0);
10308 if (true) TooltipRootContext.displayName = "TooltipRootContext";
10309 function useTooltipRootContext(optional) {
10310 const context = React60.useContext(TooltipRootContext);
10311 if (context === void 0 && !optional) {
10312 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
10313 }
10314 return context;
10315 }
10316
10317 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
10318 var React61 = __toESM(require_react(), 1);
10319 var ReactDOM7 = __toESM(require_react_dom(), 1);
10320 var selectors3 = {
10321 ...popupStoreSelectors,
10322 disabled: createSelector((state) => state.disabled),
10323 instantType: createSelector((state) => state.instantType),
10324 isInstantPhase: createSelector((state) => state.isInstantPhase),
10325 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
10326 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
10327 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
10328 closeOnClick: createSelector((state) => state.closeOnClick),
10329 closeDelay: createSelector((state) => state.closeDelay),
10330 hasViewport: createSelector((state) => state.hasViewport)
10331 };
10332 var TooltipStore = class _TooltipStore extends ReactStore {
10333 constructor(initialState) {
10334 super({
10335 ...createInitialState2(),
10336 ...initialState
10337 }, {
10338 popupRef: /* @__PURE__ */ React61.createRef(),
10339 onOpenChange: void 0,
10340 onOpenChangeComplete: void 0,
10341 triggerElements: new PopupTriggerMap()
10342 }, selectors3);
10343 }
10344 setOpen = (nextOpen, eventDetails) => {
10345 const reason = eventDetails.reason;
10346 const isHover = reason === reason_parts_exports.triggerHover;
10347 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
10348 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
10349 eventDetails.preventUnmountOnClose = () => {
10350 this.set("preventUnmountingOnClose", true);
10351 };
10352 this.context.onOpenChange?.(nextOpen, eventDetails);
10353 if (eventDetails.isCanceled) {
10354 return;
10355 }
10356 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
10357 const changeState = () => {
10358 const updatedState = {
10359 open: nextOpen,
10360 openChangeReason: reason
10361 };
10362 if (isFocusOpen) {
10363 updatedState.instantType = "focus";
10364 } else if (isDismissClose) {
10365 updatedState.instantType = "dismiss";
10366 } else if (reason === reason_parts_exports.triggerHover) {
10367 updatedState.instantType = void 0;
10368 }
10369 const newTriggerId = eventDetails.trigger?.id ?? null;
10370 if (newTriggerId || nextOpen) {
10371 updatedState.activeTriggerId = newTriggerId;
10372 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
10373 }
10374 this.update(updatedState);
10375 };
10376 if (isHover) {
10377 ReactDOM7.flushSync(changeState);
10378 } else {
10379 changeState();
10380 }
10381 };
10382 static useStore(externalStore, initialState) {
10383 const internalStore = useRefWithInit(() => {
10384 return new _TooltipStore(initialState);
10385 }).current;
10386 const store = externalStore ?? internalStore;
10387 const floatingRootContext = useSyncedFloatingRootContext({
10388 popupStore: store,
10389 onOpenChange: store.setOpen
10390 });
10391 store.state.floatingRootContext = floatingRootContext;
10392 return store;
10393 }
10394 };
10395 function createInitialState2() {
10396 return {
10397 ...createInitialPopupStoreState(),
10398 disabled: false,
10399 instantType: void 0,
10400 isInstantPhase: false,
10401 trackCursorAxis: "none",
10402 disableHoverablePopup: false,
10403 openChangeReason: null,
10404 closeOnClick: true,
10405 closeDelay: 0,
10406 hasViewport: false
10407 };
10408 }
10409
10410 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
10411 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
10412 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
10413 const {
10414 disabled: disabled2 = false,
10415 defaultOpen = false,
10416 open: openProp,
10417 disableHoverablePopup = false,
10418 trackCursorAxis = "none",
10419 actionsRef,
10420 onOpenChange,
10421 onOpenChangeComplete,
10422 handle,
10423 triggerId: triggerIdProp,
10424 defaultTriggerId: defaultTriggerIdProp = null,
10425 children
10426 } = props;
10427 const store = TooltipStore.useStore(handle?.store, {
10428 open: defaultOpen,
10429 openProp,
10430 activeTriggerId: defaultTriggerIdProp,
10431 triggerIdProp
10432 });
10433 useOnFirstRender(() => {
10434 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
10435 store.update({
10436 open: true,
10437 activeTriggerId: defaultTriggerIdProp
10438 });
10439 }
10440 });
10441 store.useControlledProp("openProp", openProp);
10442 store.useControlledProp("triggerIdProp", triggerIdProp);
10443 store.useContextCallback("onOpenChange", onOpenChange);
10444 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
10445 const openState = store.useState("open");
10446 const open = !disabled2 && openState;
10447 const activeTriggerId = store.useState("activeTriggerId");
10448 const payload = store.useState("payload");
10449 store.useSyncedValues({
10450 trackCursorAxis,
10451 disableHoverablePopup
10452 });
10453 useIsoLayoutEffect(() => {
10454 if (openState && disabled2) {
10455 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
10456 }
10457 }, [openState, disabled2, store]);
10458 store.useSyncedValue("disabled", disabled2);
10459 useImplicitActiveTrigger(store);
10460 const {
10461 forceUnmount,
10462 transitionStatus
10463 } = useOpenStateTransitions(open, store);
10464 const floatingRootContext = store.select("floatingRootContext");
10465 const isInstantPhase = store.useState("isInstantPhase");
10466 const instantType = store.useState("instantType");
10467 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
10468 const previousInstantTypeRef = React62.useRef(null);
10469 useIsoLayoutEffect(() => {
10470 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
10471 if (instantType !== "delay") {
10472 previousInstantTypeRef.current = instantType;
10473 }
10474 store.set("instantType", "delay");
10475 } else if (previousInstantTypeRef.current !== null) {
10476 store.set("instantType", previousInstantTypeRef.current);
10477 previousInstantTypeRef.current = null;
10478 }
10479 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
10480 useIsoLayoutEffect(() => {
10481 if (open) {
10482 if (activeTriggerId == null) {
10483 store.set("payload", void 0);
10484 }
10485 }
10486 }, [store, activeTriggerId, open]);
10487 const handleImperativeClose = React62.useCallback(() => {
10488 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
10489 }, [store]);
10490 React62.useImperativeHandle(actionsRef, () => ({
10491 unmount: forceUnmount,
10492 close: handleImperativeClose
10493 }), [forceUnmount, handleImperativeClose]);
10494 const dismiss = useDismiss(floatingRootContext, {
10495 enabled: !disabled2,
10496 referencePress: () => store.select("closeOnClick")
10497 });
10498 const clientPoint = useClientPoint(floatingRootContext, {
10499 enabled: !disabled2 && trackCursorAxis !== "none",
10500 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
10501 });
10502 const {
10503 getReferenceProps,
10504 getFloatingProps,
10505 getTriggerProps
10506 } = useInteractions([dismiss, clientPoint]);
10507 const activeTriggerProps = React62.useMemo(() => getReferenceProps(), [getReferenceProps]);
10508 const inactiveTriggerProps = React62.useMemo(() => getTriggerProps(), [getTriggerProps]);
10509 const popupProps = React62.useMemo(() => getFloatingProps(), [getFloatingProps]);
10510 store.useSyncedValues({
10511 activeTriggerProps,
10512 inactiveTriggerProps,
10513 popupProps
10514 });
10515 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipRootContext.Provider, {
10516 value: store,
10517 children: typeof children === "function" ? children({
10518 payload
10519 }) : children
10520 });
10521 });
10522 if (true) TooltipRoot.displayName = "TooltipRoot";
10523
10524 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
10525 var React64 = __toESM(require_react(), 1);
10526
10527 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
10528 var React63 = __toESM(require_react(), 1);
10529 var TooltipProviderContext = /* @__PURE__ */ React63.createContext(void 0);
10530 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
10531 function useTooltipProviderContext() {
10532 return React63.useContext(TooltipProviderContext);
10533 }
10534
10535 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
10536 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
10537 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
10538 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
10539 return TooltipTriggerDataAttributes2;
10540 })({});
10541
10542 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
10543 var OPEN_DELAY = 600;
10544
10545 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
10546 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
10547 const {
10548 className,
10549 render: render4,
10550 handle,
10551 payload,
10552 disabled: disabledProp,
10553 delay,
10554 closeOnClick = true,
10555 closeDelay,
10556 id: idProp,
10557 style,
10558 ...elementProps
10559 } = componentProps;
10560 const rootContext = useTooltipRootContext(true);
10561 const store = handle?.store ?? rootContext;
10562 if (!store) {
10563 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));
10564 }
10565 const thisTriggerId = useBaseUiId(idProp);
10566 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
10567 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
10568 const floatingRootContext = store.useState("floatingRootContext");
10569 const triggerElementRef = React64.useRef(null);
10570 const delayWithDefault = delay ?? OPEN_DELAY;
10571 const closeDelayWithDefault = closeDelay ?? 0;
10572 const {
10573 registerTrigger,
10574 isMountedByThisTrigger
10575 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
10576 payload,
10577 closeOnClick,
10578 closeDelay: closeDelayWithDefault
10579 });
10580 const providerContext = useTooltipProviderContext();
10581 const {
10582 delayRef,
10583 isInstantPhase,
10584 hasProvider
10585 } = useDelayGroup(floatingRootContext, {
10586 open: isOpenedByThisTrigger
10587 });
10588 store.useSyncedValue("isInstantPhase", isInstantPhase);
10589 const rootDisabled = store.useState("disabled");
10590 const disabled2 = disabledProp ?? rootDisabled;
10591 const trackCursorAxis = store.useState("trackCursorAxis");
10592 const disableHoverablePopup = store.useState("disableHoverablePopup");
10593 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
10594 enabled: !disabled2,
10595 mouseOnly: true,
10596 move: false,
10597 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
10598 restMs() {
10599 const providerDelay = providerContext?.delay;
10600 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
10601 let computedRestMs = delayWithDefault;
10602 if (hasProvider) {
10603 if (groupOpenValue !== 0) {
10604 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
10605 } else {
10606 computedRestMs = 0;
10607 }
10608 }
10609 return computedRestMs;
10610 },
10611 delay() {
10612 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
10613 let computedCloseDelay = closeDelayWithDefault;
10614 if (closeDelay == null && hasProvider) {
10615 computedCloseDelay = closeValue;
10616 }
10617 return {
10618 close: computedCloseDelay
10619 };
10620 },
10621 triggerElementRef,
10622 isActiveTrigger: isTriggerActive,
10623 isClosing: () => store.select("transitionStatus") === "ending"
10624 });
10625 const focusProps = useFocus(floatingRootContext, {
10626 enabled: !disabled2
10627 }).reference;
10628 const state = {
10629 open: isOpenedByThisTrigger
10630 };
10631 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
10632 const element = useRenderElement("button", componentProps, {
10633 state,
10634 ref: [forwardedRef, registerTrigger, triggerElementRef],
10635 props: [hoverProps, focusProps, rootTriggerProps, {
10636 onPointerDown() {
10637 store.set("closeOnClick", closeOnClick);
10638 },
10639 id: thisTriggerId,
10640 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
10641 }, elementProps],
10642 stateAttributesMapping: triggerOpenStateMapping
10643 });
10644 return element;
10645 });
10646 if (true) TooltipTrigger.displayName = "TooltipTrigger";
10647
10648 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
10649 var React66 = __toESM(require_react(), 1);
10650
10651 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
10652 var React65 = __toESM(require_react(), 1);
10653 var TooltipPortalContext = /* @__PURE__ */ React65.createContext(void 0);
10654 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
10655 function useTooltipPortalContext() {
10656 const value = React65.useContext(TooltipPortalContext);
10657 if (value === void 0) {
10658 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
10659 }
10660 return value;
10661 }
10662
10663 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
10664 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
10665 var TooltipPortal = /* @__PURE__ */ React66.forwardRef(function TooltipPortal2(props, forwardedRef) {
10666 const {
10667 keepMounted = false,
10668 ...portalProps
10669 } = props;
10670 const store = useTooltipRootContext();
10671 const mounted = store.useState("mounted");
10672 const shouldRender = mounted || keepMounted;
10673 if (!shouldRender) {
10674 return null;
10675 }
10676 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipPortalContext.Provider, {
10677 value: keepMounted,
10678 children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FloatingPortalLite, {
10679 ref: forwardedRef,
10680 ...portalProps
10681 })
10682 });
10683 });
10684 if (true) TooltipPortal.displayName = "TooltipPortal";
10685
10686 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
10687 var React68 = __toESM(require_react(), 1);
10688
10689 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
10690 var React67 = __toESM(require_react(), 1);
10691 var TooltipPositionerContext = /* @__PURE__ */ React67.createContext(void 0);
10692 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
10693 function useTooltipPositionerContext() {
10694 const context = React67.useContext(TooltipPositionerContext);
10695 if (context === void 0) {
10696 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
10697 }
10698 return context;
10699 }
10700
10701 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
10702 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
10703 var TooltipPositioner = /* @__PURE__ */ React68.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
10704 const {
10705 render: render4,
10706 className,
10707 anchor,
10708 positionMethod = "absolute",
10709 side = "top",
10710 align = "center",
10711 sideOffset = 0,
10712 alignOffset = 0,
10713 collisionBoundary = "clipping-ancestors",
10714 collisionPadding = 5,
10715 arrowPadding = 5,
10716 sticky = false,
10717 disableAnchorTracking = false,
10718 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
10719 style,
10720 ...elementProps
10721 } = componentProps;
10722 const store = useTooltipRootContext();
10723 const keepMounted = useTooltipPortalContext();
10724 const open = store.useState("open");
10725 const mounted = store.useState("mounted");
10726 const trackCursorAxis = store.useState("trackCursorAxis");
10727 const disableHoverablePopup = store.useState("disableHoverablePopup");
10728 const floatingRootContext = store.useState("floatingRootContext");
10729 const instantType = store.useState("instantType");
10730 const transitionStatus = store.useState("transitionStatus");
10731 const hasViewport = store.useState("hasViewport");
10732 const positioning = useAnchorPositioning({
10733 anchor,
10734 positionMethod,
10735 floatingRootContext,
10736 mounted,
10737 side,
10738 sideOffset,
10739 align,
10740 alignOffset,
10741 collisionBoundary,
10742 collisionPadding,
10743 sticky,
10744 arrowPadding,
10745 disableAnchorTracking,
10746 keepMounted,
10747 collisionAvoidance,
10748 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
10749 });
10750 const state = React68.useMemo(() => ({
10751 open,
10752 side: positioning.side,
10753 align: positioning.align,
10754 anchorHidden: positioning.anchorHidden,
10755 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
10756 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
10757 const element = usePositioner(componentProps, state, {
10758 styles: positioning.positionerStyles,
10759 transitionStatus,
10760 props: elementProps,
10761 refs: [forwardedRef, store.useStateSetter("positionerElement")],
10762 hidden: !mounted,
10763 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
10764 });
10765 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TooltipPositionerContext.Provider, {
10766 value: positioning,
10767 children: element
10768 });
10769 });
10770 if (true) TooltipPositioner.displayName = "TooltipPositioner";
10771
10772 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
10773 var React69 = __toESM(require_react(), 1);
10774 var stateAttributesMapping4 = {
10775 ...popupStateMapping,
10776 ...transitionStatusMapping
10777 };
10778 var TooltipPopup = /* @__PURE__ */ React69.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
10779 const {
10780 className,
10781 render: render4,
10782 style,
10783 ...elementProps
10784 } = componentProps;
10785 const store = useTooltipRootContext();
10786 const {
10787 side,
10788 align
10789 } = useTooltipPositionerContext();
10790 const open = store.useState("open");
10791 const instantType = store.useState("instantType");
10792 const transitionStatus = store.useState("transitionStatus");
10793 const popupProps = store.useState("popupProps");
10794 const floatingContext = store.useState("floatingRootContext");
10795 useOpenChangeComplete({
10796 open,
10797 ref: store.context.popupRef,
10798 onComplete() {
10799 if (open) {
10800 store.context.onOpenChangeComplete?.(true);
10801 }
10802 }
10803 });
10804 const disabled2 = store.useState("disabled");
10805 const closeDelay = store.useState("closeDelay");
10806 useHoverFloatingInteraction(floatingContext, {
10807 enabled: !disabled2,
10808 closeDelay
10809 });
10810 const state = {
10811 open,
10812 side,
10813 align,
10814 instant: instantType,
10815 transitionStatus
10816 };
10817 const element = useRenderElement("div", componentProps, {
10818 state,
10819 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
10820 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
10821 stateAttributesMapping: stateAttributesMapping4
10822 });
10823 return element;
10824 });
10825 if (true) TooltipPopup.displayName = "TooltipPopup";
10826
10827 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
10828 var React70 = __toESM(require_react(), 1);
10829 var TooltipArrow = /* @__PURE__ */ React70.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
10830 const {
10831 className,
10832 render: render4,
10833 style,
10834 ...elementProps
10835 } = componentProps;
10836 const store = useTooltipRootContext();
10837 const open = store.useState("open");
10838 const instantType = store.useState("instantType");
10839 const {
10840 arrowRef,
10841 side,
10842 align,
10843 arrowUncentered,
10844 arrowStyles
10845 } = useTooltipPositionerContext();
10846 const state = {
10847 open,
10848 side,
10849 align,
10850 uncentered: arrowUncentered,
10851 instant: instantType
10852 };
10853 const element = useRenderElement("div", componentProps, {
10854 state,
10855 ref: [forwardedRef, arrowRef],
10856 props: [{
10857 style: arrowStyles,
10858 "aria-hidden": true
10859 }, elementProps],
10860 stateAttributesMapping: popupStateMapping
10861 });
10862 return element;
10863 });
10864 if (true) TooltipArrow.displayName = "TooltipArrow";
10865
10866 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
10867 var React71 = __toESM(require_react(), 1);
10868 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
10869 var TooltipProvider = function TooltipProvider2(props) {
10870 const {
10871 delay,
10872 closeDelay,
10873 timeout = 400
10874 } = props;
10875 const contextValue = React71.useMemo(() => ({
10876 delay,
10877 closeDelay
10878 }), [delay, closeDelay]);
10879 const delayValue = React71.useMemo(() => ({
10880 open: delay,
10881 close: closeDelay
10882 }), [delay, closeDelay]);
10883 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipProviderContext.Provider, {
10884 value: contextValue,
10885 children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FloatingDelayGroup, {
10886 delay: delayValue,
10887 timeoutMs: timeout,
10888 children: props.children
10889 })
10890 });
10891 };
10892 if (true) TooltipProvider.displayName = "TooltipProvider";
10893
10894 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
10895 var React72 = __toESM(require_react(), 1);
10896
10897 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
10898 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
10899 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
10900 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
10901 return TooltipViewportCssVars2;
10902 })({});
10903
10904 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
10905 var stateAttributesMapping5 = {
10906 activationDirection: (value) => value ? {
10907 "data-activation-direction": value
10908 } : null
10909 };
10910 var TooltipViewport = /* @__PURE__ */ React72.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
10911 const {
10912 render: render4,
10913 className,
10914 style,
10915 children,
10916 ...elementProps
10917 } = componentProps;
10918 const store = useTooltipRootContext();
10919 const positioner = useTooltipPositionerContext();
10920 const instantType = store.useState("instantType");
10921 const {
10922 children: childrenToRender,
10923 state: viewportState
10924 } = usePopupViewport({
10925 store,
10926 side: positioner.side,
10927 cssVars: TooltipViewportCssVars,
10928 children
10929 });
10930 const state = {
10931 activationDirection: viewportState.activationDirection,
10932 transitioning: viewportState.transitioning,
10933 instant: instantType
10934 };
10935 return useRenderElement("div", componentProps, {
10936 state,
10937 ref: forwardedRef,
10938 props: [elementProps, {
10939 children: childrenToRender
10940 }],
10941 stateAttributesMapping: stateAttributesMapping5
10942 });
10943 });
10944 if (true) TooltipViewport.displayName = "TooltipViewport";
10945
10946 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
10947 var TooltipHandle = class {
10948 /**
10949 * Internal store holding the tooltip state.
10950 * @internal
10951 */
10952 constructor() {
10953 this.store = new TooltipStore();
10954 }
10955 /**
10956 * Opens the tooltip and associates it with the trigger with the given ID.
10957 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
10958 *
10959 * This method should only be called in an event handler or an effect (not during rendering).
10960 *
10961 * @param triggerId ID of the trigger to associate with the tooltip.
10962 */
10963 open(triggerId) {
10964 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
10965 if (triggerId && !triggerElement) {
10966 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
10967 }
10968 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
10969 }
10970 /**
10971 * Closes the tooltip.
10972 */
10973 close() {
10974 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
10975 }
10976 /**
10977 * Indicates whether the tooltip is currently open.
10978 */
10979 get isOpen() {
10980 return this.store.state.open;
10981 }
10982 };
10983 function createTooltipHandle() {
10984 return new TooltipHandle();
10985 }
10986
10987 // node_modules/@base-ui/react/esm/use-render/useRender.js
10988 function useRender(params) {
10989 return useRenderElement(params.defaultTagName ?? "div", params, params);
10990 }
10991
10992 // packages/ui/build-module/text/text.mjs
10993 var import_element11 = __toESM(require_element(), 1);
10994 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
10995 function getRuntime() {
10996 const globalScope = globalThis;
10997 if (globalScope.__wpStyleRuntime) {
10998 return globalScope.__wpStyleRuntime;
10999 }
11000 globalScope.__wpStyleRuntime = {
11001 documents: /* @__PURE__ */ new Map(),
11002 styles: /* @__PURE__ */ new Map(),
11003 injectedStyles: /* @__PURE__ */ new WeakMap()
11004 };
11005 if (typeof document !== "undefined") {
11006 registerDocument(document);
11007 }
11008 return globalScope.__wpStyleRuntime;
11009 }
11010 function documentContainsStyleHash(targetDocument, hash) {
11011 if (!targetDocument.head) {
11012 return false;
11013 }
11014 for (const style of targetDocument.head.querySelectorAll(
11015 `style[${STYLE_HASH_ATTRIBUTE}]`
11016 )) {
11017 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
11018 return true;
11019 }
11020 }
11021 return false;
11022 }
11023 function injectStyle(targetDocument, hash, css) {
11024 if (!targetDocument.head) {
11025 return;
11026 }
11027 const runtime = getRuntime();
11028 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11029 if (!injectedStyles) {
11030 injectedStyles = /* @__PURE__ */ new Set();
11031 runtime.injectedStyles.set(targetDocument, injectedStyles);
11032 }
11033 if (injectedStyles.has(hash)) {
11034 return;
11035 }
11036 if (documentContainsStyleHash(targetDocument, hash)) {
11037 injectedStyles.add(hash);
11038 return;
11039 }
11040 const style = targetDocument.createElement("style");
11041 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
11042 style.appendChild(targetDocument.createTextNode(css));
11043 targetDocument.head.appendChild(style);
11044 injectedStyles.add(hash);
11045 }
11046 function registerDocument(targetDocument) {
11047 const runtime = getRuntime();
11048 runtime.documents.set(
11049 targetDocument,
11050 (runtime.documents.get(targetDocument) ?? 0) + 1
11051 );
11052 for (const [hash, css] of runtime.styles) {
11053 injectStyle(targetDocument, hash, css);
11054 }
11055 return () => {
11056 const count = runtime.documents.get(targetDocument);
11057 if (count === void 0) {
11058 return;
11059 }
11060 if (count <= 1) {
11061 runtime.documents.delete(targetDocument);
11062 return;
11063 }
11064 runtime.documents.set(targetDocument, count - 1);
11065 };
11066 }
11067 function registerStyle(hash, css) {
11068 const runtime = getRuntime();
11069 runtime.styles.set(hash, css);
11070 for (const targetDocument of runtime.documents.keys()) {
11071 injectStyle(targetDocument, hash, css);
11072 }
11073 }
11074 if (typeof process === "undefined" || true) {
11075 registerStyle("0c8601dd83", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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)}}');
11076 }
11077 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" };
11078 if (typeof process === "undefined" || true) {
11079 registerStyle("1fb29d3a3c", "._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,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
11080 }
11081 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" };
11082 var Text = (0, import_element11.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
11083 const element = useRender({
11084 render: render4,
11085 defaultTagName: "span",
11086 ref,
11087 props: mergeProps(props, {
11088 className: clsx_default(
11089 style_default.text,
11090 global_css_defense_default.heading,
11091 global_css_defense_default.p,
11092 style_default[variant],
11093 className
11094 )
11095 })
11096 });
11097 return element;
11098 });
11099
11100 // packages/ui/build-module/button/button.mjs
11101 var import_element12 = __toESM(require_element(), 1);
11102 var import_i18n = __toESM(require_i18n(), 1);
11103 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
11104 import { speak } from "@wordpress/a11y";
11105 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
11106 function getRuntime2() {
11107 const globalScope = globalThis;
11108 if (globalScope.__wpStyleRuntime) {
11109 return globalScope.__wpStyleRuntime;
11110 }
11111 globalScope.__wpStyleRuntime = {
11112 documents: /* @__PURE__ */ new Map(),
11113 styles: /* @__PURE__ */ new Map(),
11114 injectedStyles: /* @__PURE__ */ new WeakMap()
11115 };
11116 if (typeof document !== "undefined") {
11117 registerDocument2(document);
11118 }
11119 return globalScope.__wpStyleRuntime;
11120 }
11121 function documentContainsStyleHash2(targetDocument, hash) {
11122 if (!targetDocument.head) {
11123 return false;
11124 }
11125 for (const style of targetDocument.head.querySelectorAll(
11126 `style[${STYLE_HASH_ATTRIBUTE2}]`
11127 )) {
11128 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
11129 return true;
11130 }
11131 }
11132 return false;
11133 }
11134 function injectStyle2(targetDocument, hash, css) {
11135 if (!targetDocument.head) {
11136 return;
11137 }
11138 const runtime = getRuntime2();
11139 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11140 if (!injectedStyles) {
11141 injectedStyles = /* @__PURE__ */ new Set();
11142 runtime.injectedStyles.set(targetDocument, injectedStyles);
11143 }
11144 if (injectedStyles.has(hash)) {
11145 return;
11146 }
11147 if (documentContainsStyleHash2(targetDocument, hash)) {
11148 injectedStyles.add(hash);
11149 return;
11150 }
11151 const style = targetDocument.createElement("style");
11152 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
11153 style.appendChild(targetDocument.createTextNode(css));
11154 targetDocument.head.appendChild(style);
11155 injectedStyles.add(hash);
11156 }
11157 function registerDocument2(targetDocument) {
11158 const runtime = getRuntime2();
11159 runtime.documents.set(
11160 targetDocument,
11161 (runtime.documents.get(targetDocument) ?? 0) + 1
11162 );
11163 for (const [hash, css] of runtime.styles) {
11164 injectStyle2(targetDocument, hash, css);
11165 }
11166 return () => {
11167 const count = runtime.documents.get(targetDocument);
11168 if (count === void 0) {
11169 return;
11170 }
11171 if (count <= 1) {
11172 runtime.documents.delete(targetDocument);
11173 return;
11174 }
11175 runtime.documents.set(targetDocument, count - 1);
11176 };
11177 }
11178 function registerStyle2(hash, css) {
11179 const runtime = getRuntime2();
11180 runtime.styles.set(hash, css);
11181 for (const targetDocument of runtime.documents.keys()) {
11182 injectStyle2(targetDocument, hash, css);
11183 }
11184 }
11185 if (typeof process === "undefined" || true) {
11186 registerStyle2("26d90ece4e", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:499;--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-strong-disabled,#8d8d8d);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:40px;--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-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);cursor:var(--wpds-cursor-control,pointer);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);height:var(--wp-ui-button-height);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);min-width:var(--wp-ui-button-min-width);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-decoration:none;@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:#0000;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:#0000;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);inset-inline-start:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:24px}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:32px}._914b42f315c0e580__is-loading{color:#0000;&:not([data-disabled]):is(:hover,:active,:focus){color:#0000}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}[aria-pressed=true].ad0619a3217c6a5b__is-minimal.e722a8f96726aa99__is-neutral{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-strong,#2d2d2d);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-strong,#f0f0f0)}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}');
11187 }
11188 var style_default2 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "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" };
11189 if (typeof process === "undefined" || true) {
11190 registerStyle2("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
11191 }
11192 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
11193 if (typeof process === "undefined" || true) {
11194 registerStyle2("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}");
11195 }
11196 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" };
11197 if (typeof process === "undefined" || true) {
11198 registerStyle2("1fb29d3a3c", "._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,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
11199 }
11200 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" };
11201 var Button3 = (0, import_element12.forwardRef)(
11202 function Button22({
11203 tone = "brand",
11204 variant = "solid",
11205 size: size4 = "default",
11206 className,
11207 focusableWhenDisabled = true,
11208 disabled: disabled2,
11209 loading,
11210 loadingAnnouncement = (0, import_i18n.__)("Loading"),
11211 children,
11212 ...props
11213 }, ref) {
11214 const mergedClassName = clsx_default(
11215 global_css_defense_default2.button,
11216 resets_default["box-sizing"],
11217 focus_default["outset-ring--focus-except-active"],
11218 variant !== "unstyled" && style_default2.button,
11219 style_default2[`is-${tone}`],
11220 style_default2[`is-${variant}`],
11221 style_default2[`is-${size4}`],
11222 loading && style_default2["is-loading"],
11223 className
11224 );
11225 (0, import_element12.useEffect)(() => {
11226 if (loading && loadingAnnouncement) {
11227 speak(loadingAnnouncement);
11228 }
11229 }, [loading, loadingAnnouncement]);
11230 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
11231 Button,
11232 {
11233 ref,
11234 className: mergedClassName,
11235 focusableWhenDisabled,
11236 disabled: disabled2 ?? loading,
11237 ...props,
11238 children
11239 }
11240 );
11241 }
11242 );
11243
11244 // packages/ui/build-module/button/icon.mjs
11245 var import_element14 = __toESM(require_element(), 1);
11246
11247 // packages/ui/build-module/icon/icon.mjs
11248 var import_element13 = __toESM(require_element(), 1);
11249 var import_primitives = __toESM(require_primitives(), 1);
11250 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
11251 var Icon = (0, import_element13.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
11252 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
11253 import_primitives.SVG,
11254 {
11255 ref,
11256 fill: "currentColor",
11257 ...icon.props,
11258 ...restProps,
11259 width: size4,
11260 height: size4
11261 }
11262 );
11263 });
11264
11265 // packages/ui/build-module/button/icon.mjs
11266 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
11267 var ButtonIcon = (0, import_element14.forwardRef)(
11268 function ButtonIcon2({ icon, ...props }, ref) {
11269 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
11270 Icon,
11271 {
11272 ref,
11273 icon,
11274 viewBox: "4 4 16 16",
11275 size: 16,
11276 ...props
11277 }
11278 );
11279 }
11280 );
11281
11282 // packages/ui/build-module/button/index.mjs
11283 ButtonIcon.displayName = "Button.Icon";
11284 var Button4 = Object.assign(Button3, {
11285 /**
11286 * An icon component specifically designed to work well when rendered inside
11287 * a `Button` component.
11288 */
11289 Icon: ButtonIcon
11290 });
11291
11292 // packages/ui/build-module/card/index.mjs
11293 var card_exports = {};
11294 __export(card_exports, {
11295 Content: () => Content,
11296 FullBleed: () => FullBleed,
11297 Header: () => Header,
11298 Root: () => Root,
11299 Title: () => Title
11300 });
11301
11302 // packages/ui/build-module/card/root.mjs
11303 var import_element15 = __toESM(require_element(), 1);
11304 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
11305 function getRuntime3() {
11306 const globalScope = globalThis;
11307 if (globalScope.__wpStyleRuntime) {
11308 return globalScope.__wpStyleRuntime;
11309 }
11310 globalScope.__wpStyleRuntime = {
11311 documents: /* @__PURE__ */ new Map(),
11312 styles: /* @__PURE__ */ new Map(),
11313 injectedStyles: /* @__PURE__ */ new WeakMap()
11314 };
11315 if (typeof document !== "undefined") {
11316 registerDocument3(document);
11317 }
11318 return globalScope.__wpStyleRuntime;
11319 }
11320 function documentContainsStyleHash3(targetDocument, hash) {
11321 if (!targetDocument.head) {
11322 return false;
11323 }
11324 for (const style of targetDocument.head.querySelectorAll(
11325 `style[${STYLE_HASH_ATTRIBUTE3}]`
11326 )) {
11327 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
11328 return true;
11329 }
11330 }
11331 return false;
11332 }
11333 function injectStyle3(targetDocument, hash, css) {
11334 if (!targetDocument.head) {
11335 return;
11336 }
11337 const runtime = getRuntime3();
11338 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11339 if (!injectedStyles) {
11340 injectedStyles = /* @__PURE__ */ new Set();
11341 runtime.injectedStyles.set(targetDocument, injectedStyles);
11342 }
11343 if (injectedStyles.has(hash)) {
11344 return;
11345 }
11346 if (documentContainsStyleHash3(targetDocument, hash)) {
11347 injectedStyles.add(hash);
11348 return;
11349 }
11350 const style = targetDocument.createElement("style");
11351 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
11352 style.appendChild(targetDocument.createTextNode(css));
11353 targetDocument.head.appendChild(style);
11354 injectedStyles.add(hash);
11355 }
11356 function registerDocument3(targetDocument) {
11357 const runtime = getRuntime3();
11358 runtime.documents.set(
11359 targetDocument,
11360 (runtime.documents.get(targetDocument) ?? 0) + 1
11361 );
11362 for (const [hash, css] of runtime.styles) {
11363 injectStyle3(targetDocument, hash, css);
11364 }
11365 return () => {
11366 const count = runtime.documents.get(targetDocument);
11367 if (count === void 0) {
11368 return;
11369 }
11370 if (count <= 1) {
11371 runtime.documents.delete(targetDocument);
11372 return;
11373 }
11374 runtime.documents.set(targetDocument, count - 1);
11375 };
11376 }
11377 function registerStyle3(hash, css) {
11378 const runtime = getRuntime3();
11379 runtime.styles.set(hash, css);
11380 for (const targetDocument of runtime.documents.keys()) {
11381 injectStyle3(targetDocument, hash, css);
11382 }
11383 }
11384 if (typeof process === "undefined" || true) {
11385 registerStyle3("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
11386 }
11387 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
11388 if (typeof process === "undefined" || true) {
11389 registerStyle3("14f5e9ddeb", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}");
11390 }
11391 var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
11392 var Root = (0, import_element15.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
11393 const mergedClassName = clsx_default(style_default3.root, resets_default2["box-sizing"]);
11394 const element = useRender({
11395 defaultTagName: "div",
11396 render: render4,
11397 ref,
11398 props: mergeProps({ className: mergedClassName }, restProps)
11399 });
11400 return element;
11401 });
11402
11403 // packages/ui/build-module/card/header.mjs
11404 var import_element16 = __toESM(require_element(), 1);
11405 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
11406 function getRuntime4() {
11407 const globalScope = globalThis;
11408 if (globalScope.__wpStyleRuntime) {
11409 return globalScope.__wpStyleRuntime;
11410 }
11411 globalScope.__wpStyleRuntime = {
11412 documents: /* @__PURE__ */ new Map(),
11413 styles: /* @__PURE__ */ new Map(),
11414 injectedStyles: /* @__PURE__ */ new WeakMap()
11415 };
11416 if (typeof document !== "undefined") {
11417 registerDocument4(document);
11418 }
11419 return globalScope.__wpStyleRuntime;
11420 }
11421 function documentContainsStyleHash4(targetDocument, hash) {
11422 if (!targetDocument.head) {
11423 return false;
11424 }
11425 for (const style of targetDocument.head.querySelectorAll(
11426 `style[${STYLE_HASH_ATTRIBUTE4}]`
11427 )) {
11428 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
11429 return true;
11430 }
11431 }
11432 return false;
11433 }
11434 function injectStyle4(targetDocument, hash, css) {
11435 if (!targetDocument.head) {
11436 return;
11437 }
11438 const runtime = getRuntime4();
11439 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11440 if (!injectedStyles) {
11441 injectedStyles = /* @__PURE__ */ new Set();
11442 runtime.injectedStyles.set(targetDocument, injectedStyles);
11443 }
11444 if (injectedStyles.has(hash)) {
11445 return;
11446 }
11447 if (documentContainsStyleHash4(targetDocument, hash)) {
11448 injectedStyles.add(hash);
11449 return;
11450 }
11451 const style = targetDocument.createElement("style");
11452 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
11453 style.appendChild(targetDocument.createTextNode(css));
11454 targetDocument.head.appendChild(style);
11455 injectedStyles.add(hash);
11456 }
11457 function registerDocument4(targetDocument) {
11458 const runtime = getRuntime4();
11459 runtime.documents.set(
11460 targetDocument,
11461 (runtime.documents.get(targetDocument) ?? 0) + 1
11462 );
11463 for (const [hash, css] of runtime.styles) {
11464 injectStyle4(targetDocument, hash, css);
11465 }
11466 return () => {
11467 const count = runtime.documents.get(targetDocument);
11468 if (count === void 0) {
11469 return;
11470 }
11471 if (count <= 1) {
11472 runtime.documents.delete(targetDocument);
11473 return;
11474 }
11475 runtime.documents.set(targetDocument, count - 1);
11476 };
11477 }
11478 function registerStyle4(hash, css) {
11479 const runtime = getRuntime4();
11480 runtime.styles.set(hash, css);
11481 for (const targetDocument of runtime.documents.keys()) {
11482 injectStyle4(targetDocument, hash, css);
11483 }
11484 }
11485 if (typeof process === "undefined" || true) {
11486 registerStyle4("14f5e9ddeb", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}");
11487 }
11488 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
11489 var Header = (0, import_element16.forwardRef)(
11490 function CardHeader({ render: render4, ...props }, ref) {
11491 const element = useRender({
11492 defaultTagName: "div",
11493 render: render4,
11494 ref,
11495 props: mergeProps({ className: style_default4.header }, props)
11496 });
11497 return element;
11498 }
11499 );
11500
11501 // packages/ui/build-module/card/content.mjs
11502 var import_element17 = __toESM(require_element(), 1);
11503 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
11504 function getRuntime5() {
11505 const globalScope = globalThis;
11506 if (globalScope.__wpStyleRuntime) {
11507 return globalScope.__wpStyleRuntime;
11508 }
11509 globalScope.__wpStyleRuntime = {
11510 documents: /* @__PURE__ */ new Map(),
11511 styles: /* @__PURE__ */ new Map(),
11512 injectedStyles: /* @__PURE__ */ new WeakMap()
11513 };
11514 if (typeof document !== "undefined") {
11515 registerDocument5(document);
11516 }
11517 return globalScope.__wpStyleRuntime;
11518 }
11519 function documentContainsStyleHash5(targetDocument, hash) {
11520 if (!targetDocument.head) {
11521 return false;
11522 }
11523 for (const style of targetDocument.head.querySelectorAll(
11524 `style[${STYLE_HASH_ATTRIBUTE5}]`
11525 )) {
11526 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
11527 return true;
11528 }
11529 }
11530 return false;
11531 }
11532 function injectStyle5(targetDocument, hash, css) {
11533 if (!targetDocument.head) {
11534 return;
11535 }
11536 const runtime = getRuntime5();
11537 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11538 if (!injectedStyles) {
11539 injectedStyles = /* @__PURE__ */ new Set();
11540 runtime.injectedStyles.set(targetDocument, injectedStyles);
11541 }
11542 if (injectedStyles.has(hash)) {
11543 return;
11544 }
11545 if (documentContainsStyleHash5(targetDocument, hash)) {
11546 injectedStyles.add(hash);
11547 return;
11548 }
11549 const style = targetDocument.createElement("style");
11550 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
11551 style.appendChild(targetDocument.createTextNode(css));
11552 targetDocument.head.appendChild(style);
11553 injectedStyles.add(hash);
11554 }
11555 function registerDocument5(targetDocument) {
11556 const runtime = getRuntime5();
11557 runtime.documents.set(
11558 targetDocument,
11559 (runtime.documents.get(targetDocument) ?? 0) + 1
11560 );
11561 for (const [hash, css] of runtime.styles) {
11562 injectStyle5(targetDocument, hash, css);
11563 }
11564 return () => {
11565 const count = runtime.documents.get(targetDocument);
11566 if (count === void 0) {
11567 return;
11568 }
11569 if (count <= 1) {
11570 runtime.documents.delete(targetDocument);
11571 return;
11572 }
11573 runtime.documents.set(targetDocument, count - 1);
11574 };
11575 }
11576 function registerStyle5(hash, css) {
11577 const runtime = getRuntime5();
11578 runtime.styles.set(hash, css);
11579 for (const targetDocument of runtime.documents.keys()) {
11580 injectStyle5(targetDocument, hash, css);
11581 }
11582 }
11583 if (typeof process === "undefined" || true) {
11584 registerStyle5("14f5e9ddeb", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}");
11585 }
11586 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
11587 var Content = (0, import_element17.forwardRef)(
11588 function CardContent({ render: render4, ...props }, ref) {
11589 const element = useRender({
11590 defaultTagName: "div",
11591 render: render4,
11592 ref,
11593 props: mergeProps({ className: style_default5.content }, props)
11594 });
11595 return element;
11596 }
11597 );
11598
11599 // packages/ui/build-module/card/full-bleed.mjs
11600 var import_element18 = __toESM(require_element(), 1);
11601 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
11602 function getRuntime6() {
11603 const globalScope = globalThis;
11604 if (globalScope.__wpStyleRuntime) {
11605 return globalScope.__wpStyleRuntime;
11606 }
11607 globalScope.__wpStyleRuntime = {
11608 documents: /* @__PURE__ */ new Map(),
11609 styles: /* @__PURE__ */ new Map(),
11610 injectedStyles: /* @__PURE__ */ new WeakMap()
11611 };
11612 if (typeof document !== "undefined") {
11613 registerDocument6(document);
11614 }
11615 return globalScope.__wpStyleRuntime;
11616 }
11617 function documentContainsStyleHash6(targetDocument, hash) {
11618 if (!targetDocument.head) {
11619 return false;
11620 }
11621 for (const style of targetDocument.head.querySelectorAll(
11622 `style[${STYLE_HASH_ATTRIBUTE6}]`
11623 )) {
11624 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
11625 return true;
11626 }
11627 }
11628 return false;
11629 }
11630 function injectStyle6(targetDocument, hash, css) {
11631 if (!targetDocument.head) {
11632 return;
11633 }
11634 const runtime = getRuntime6();
11635 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11636 if (!injectedStyles) {
11637 injectedStyles = /* @__PURE__ */ new Set();
11638 runtime.injectedStyles.set(targetDocument, injectedStyles);
11639 }
11640 if (injectedStyles.has(hash)) {
11641 return;
11642 }
11643 if (documentContainsStyleHash6(targetDocument, hash)) {
11644 injectedStyles.add(hash);
11645 return;
11646 }
11647 const style = targetDocument.createElement("style");
11648 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
11649 style.appendChild(targetDocument.createTextNode(css));
11650 targetDocument.head.appendChild(style);
11651 injectedStyles.add(hash);
11652 }
11653 function registerDocument6(targetDocument) {
11654 const runtime = getRuntime6();
11655 runtime.documents.set(
11656 targetDocument,
11657 (runtime.documents.get(targetDocument) ?? 0) + 1
11658 );
11659 for (const [hash, css] of runtime.styles) {
11660 injectStyle6(targetDocument, hash, css);
11661 }
11662 return () => {
11663 const count = runtime.documents.get(targetDocument);
11664 if (count === void 0) {
11665 return;
11666 }
11667 if (count <= 1) {
11668 runtime.documents.delete(targetDocument);
11669 return;
11670 }
11671 runtime.documents.set(targetDocument, count - 1);
11672 };
11673 }
11674 function registerStyle6(hash, css) {
11675 const runtime = getRuntime6();
11676 runtime.styles.set(hash, css);
11677 for (const targetDocument of runtime.documents.keys()) {
11678 injectStyle6(targetDocument, hash, css);
11679 }
11680 }
11681 if (typeof process === "undefined" || true) {
11682 registerStyle6("14f5e9ddeb", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}");
11683 }
11684 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
11685 var FullBleed = (0, import_element18.forwardRef)(
11686 function CardFullBleed({ render: render4, ...props }, ref) {
11687 const element = useRender({
11688 defaultTagName: "div",
11689 render: render4,
11690 ref,
11691 props: mergeProps(
11692 { className: style_default6.fullbleed },
11693 props
11694 )
11695 });
11696 return element;
11697 }
11698 );
11699
11700 // packages/ui/build-module/card/title.mjs
11701 var import_element19 = __toESM(require_element(), 1);
11702 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
11703 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", {});
11704 var Title = (0, import_element19.forwardRef)(
11705 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
11706 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
11707 Text,
11708 {
11709 ref,
11710 variant: "heading-lg",
11711 render: render4,
11712 ...props,
11713 children
11714 }
11715 );
11716 }
11717 );
11718
11719 // packages/icons/build-module/library/arrow-down.mjs
11720 var import_primitives2 = __toESM(require_primitives(), 1);
11721 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
11722 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives2.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
11723
11724 // packages/icons/build-module/library/arrow-left.mjs
11725 var import_primitives3 = __toESM(require_primitives(), 1);
11726 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
11727 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
11728
11729 // packages/icons/build-module/library/arrow-right.mjs
11730 var import_primitives4 = __toESM(require_primitives(), 1);
11731 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
11732 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
11733
11734 // packages/icons/build-module/library/arrow-up.mjs
11735 var import_primitives5 = __toESM(require_primitives(), 1);
11736 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
11737 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
11738
11739 // packages/icons/build-module/library/block-table.mjs
11740 var import_primitives6 = __toESM(require_primitives(), 1);
11741 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
11742 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives6.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
11743
11744 // packages/icons/build-module/library/category.mjs
11745 var import_primitives7 = __toESM(require_primitives(), 1);
11746 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
11747 var category_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives7.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
11748
11749 // packages/icons/build-module/library/caution.mjs
11750 var import_primitives8 = __toESM(require_primitives(), 1);
11751 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
11752 var caution_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives8.Path, { 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" }) });
11753
11754 // packages/icons/build-module/library/check.mjs
11755 var import_primitives9 = __toESM(require_primitives(), 1);
11756 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
11757 var check_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives9.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
11758
11759 // packages/icons/build-module/library/close-small.mjs
11760 var import_primitives10 = __toESM(require_primitives(), 1);
11761 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
11762 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives10.Path, { d: "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" }) });
11763
11764 // packages/icons/build-module/library/close.mjs
11765 var import_primitives11 = __toESM(require_primitives(), 1);
11766 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
11767 var close_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives11.Path, { d: "m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" }) });
11768
11769 // packages/icons/build-module/library/cog.mjs
11770 var import_primitives12 = __toESM(require_primitives(), 1);
11771 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
11772 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives12.Path, { 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" }) });
11773
11774 // packages/icons/build-module/library/envelope.mjs
11775 var import_primitives13 = __toESM(require_primitives(), 1);
11776 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
11777 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives13.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
11778
11779 // packages/icons/build-module/library/error.mjs
11780 var import_primitives14 = __toESM(require_primitives(), 1);
11781 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
11782 var error_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives14.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.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" }) });
11783
11784 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
11785 var import_primitives15 = __toESM(require_primitives(), 1);
11786 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
11787 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives15.Path, { 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" }) });
11788
11789 // packages/icons/build-module/library/format-list-bullets.mjs
11790 var import_primitives16 = __toESM(require_primitives(), 1);
11791 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
11792 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives16.Path, { 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" }) });
11793
11794 // packages/icons/build-module/library/funnel.mjs
11795 var import_primitives17 = __toESM(require_primitives(), 1);
11796 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
11797 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives17.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
11798
11799 // packages/icons/build-module/library/home.mjs
11800 var import_primitives18 = __toESM(require_primitives(), 1);
11801 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
11802 var home_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives18.Path, { d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z" }) });
11803
11804 // packages/icons/build-module/library/info.mjs
11805 var import_primitives19 = __toESM(require_primitives(), 1);
11806 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
11807 var info_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives19.Path, { 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" }) });
11808
11809 // packages/icons/build-module/library/link.mjs
11810 var import_primitives20 = __toESM(require_primitives(), 1);
11811 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
11812 var link_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives20.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) });
11813
11814 // packages/icons/build-module/library/mobile.mjs
11815 var import_primitives21 = __toESM(require_primitives(), 1);
11816 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
11817 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives21.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) });
11818
11819 // packages/icons/build-module/library/more-vertical.mjs
11820 var import_primitives22 = __toESM(require_primitives(), 1);
11821 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
11822 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
11823
11824 // packages/icons/build-module/library/next.mjs
11825 var import_primitives23 = __toESM(require_primitives(), 1);
11826 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
11827 var next_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives23.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });
11828
11829 // packages/icons/build-module/library/previous.mjs
11830 var import_primitives24 = __toESM(require_primitives(), 1);
11831 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
11832 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives24.Path, { d: "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" }) });
11833
11834 // packages/icons/build-module/library/published.mjs
11835 var import_primitives25 = __toESM(require_primitives(), 1);
11836 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11837 var published_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives25.Path, { 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" }) });
11838
11839 // packages/icons/build-module/library/scheduled.mjs
11840 var import_primitives26 = __toESM(require_primitives(), 1);
11841 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
11842 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives26.Path, { 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" }) });
11843
11844 // packages/icons/build-module/library/search.mjs
11845 var import_primitives27 = __toESM(require_primitives(), 1);
11846 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11847 var search_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives27.Path, { 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" }) });
11848
11849 // packages/icons/build-module/library/seen.mjs
11850 var import_primitives28 = __toESM(require_primitives(), 1);
11851 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11852 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives28.Path, { d: "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" }) });
11853
11854 // packages/icons/build-module/library/unseen.mjs
11855 var import_primitives29 = __toESM(require_primitives(), 1);
11856 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11857 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives29.Path, { d: "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" }) });
11858
11859 // packages/ui/build-module/alert-dialog/index.mjs
11860 var alert_dialog_exports = {};
11861 __export(alert_dialog_exports, {
11862 Popup: () => Popup,
11863 Portal: () => Portal,
11864 Root: () => Root2,
11865 Trigger: () => Trigger
11866 });
11867
11868 // packages/ui/build-module/alert-dialog/root.mjs
11869 var import_element21 = __toESM(require_element(), 1);
11870 import { speak as speak2 } from "@wordpress/a11y";
11871
11872 // packages/ui/build-module/alert-dialog/context.mjs
11873 var import_element20 = __toESM(require_element(), 1);
11874 var noop4 = async () => {
11875 };
11876 var AlertDialogContext = (0, import_element20.createContext)({
11877 phase: "idle",
11878 showSpinner: false,
11879 errorMessage: void 0,
11880 confirm: noop4
11881 });
11882
11883 // packages/ui/build-module/alert-dialog/root.mjs
11884 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11885 function isThenable(value) {
11886 return value !== null && value !== void 0 && typeof value.then === "function";
11887 }
11888 function Root2({
11889 children,
11890 open: openProp,
11891 onOpenChange,
11892 defaultOpen,
11893 onConfirm
11894 }) {
11895 const [internalOpen, setInternalOpen] = (0, import_element21.useState)(defaultOpen ?? false);
11896 const [phase, setPhase] = (0, import_element21.useState)("idle");
11897 const [showSpinner, setShowSpinner] = (0, import_element21.useState)(false);
11898 const [errorMessage, setErrorMessage] = (0, import_element21.useState)();
11899 const actionsRef = (0, import_element21.useRef)(null);
11900 const onConfirmRef = (0, import_element21.useRef)(onConfirm);
11901 onConfirmRef.current = onConfirm;
11902 const phaseRef = (0, import_element21.useRef)(phase);
11903 phaseRef.current = phase;
11904 const confirmIdRef = (0, import_element21.useRef)(0);
11905 const effectiveOpen = openProp ?? internalOpen;
11906 (0, import_element21.useEffect)(() => {
11907 if (effectiveOpen && phase === "closing") {
11908 phaseRef.current = "idle";
11909 setPhase("idle");
11910 setShowSpinner(false);
11911 }
11912 }, [effectiveOpen, phase]);
11913 const handleOpenChange = (0, import_element21.useCallback)(
11914 (nextOpen, eventDetails) => {
11915 if (!nextOpen && phaseRef.current === "pending") {
11916 return;
11917 }
11918 if (!nextOpen && phaseRef.current === "idle") {
11919 phaseRef.current = "closing";
11920 setPhase("closing");
11921 }
11922 setInternalOpen(nextOpen);
11923 onOpenChange?.(nextOpen, eventDetails);
11924 },
11925 [onOpenChange]
11926 );
11927 const confirm = (0, import_element21.useCallback)(async () => {
11928 if (phaseRef.current !== "idle") {
11929 return;
11930 }
11931 phaseRef.current = "pending";
11932 setPhase("pending");
11933 setErrorMessage(void 0);
11934 const id = ++confirmIdRef.current;
11935 try {
11936 const rawResult = onConfirmRef.current?.();
11937 if (isThenable(rawResult)) {
11938 setShowSpinner(true);
11939 }
11940 const result = await Promise.resolve(rawResult);
11941 if (confirmIdRef.current !== id) {
11942 return;
11943 }
11944 if (result?.error) {
11945 phaseRef.current = "idle";
11946 setPhase("idle");
11947 setShowSpinner(false);
11948 setErrorMessage(result.error);
11949 speak2(result.error, "assertive");
11950 return;
11951 }
11952 const shouldClose = result?.close !== false;
11953 if (shouldClose) {
11954 phaseRef.current = "closing";
11955 setPhase("closing");
11956 actionsRef.current?.close();
11957 } else {
11958 phaseRef.current = "idle";
11959 setPhase("idle");
11960 setShowSpinner(false);
11961 }
11962 } catch (error2) {
11963 if (confirmIdRef.current !== id) {
11964 return;
11965 }
11966 phaseRef.current = "idle";
11967 setPhase("idle");
11968 setShowSpinner(false);
11969 console.error(error2);
11970 }
11971 }, []);
11972 const handleOpenChangeComplete = (0, import_element21.useCallback)((open) => {
11973 if (!open) {
11974 confirmIdRef.current++;
11975 phaseRef.current = "idle";
11976 setPhase("idle");
11977 setShowSpinner(false);
11978 setErrorMessage(void 0);
11979 }
11980 }, []);
11981 const contextValue = (0, import_element21.useMemo)(
11982 () => ({
11983 phase,
11984 showSpinner,
11985 errorMessage,
11986 confirm
11987 }),
11988 [phase, showSpinner, errorMessage, confirm]
11989 );
11990 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11991 index_parts_exports.Root,
11992 {
11993 open: effectiveOpen,
11994 defaultOpen,
11995 onOpenChange: handleOpenChange,
11996 onOpenChangeComplete: handleOpenChangeComplete,
11997 actionsRef,
11998 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(AlertDialogContext.Provider, { value: contextValue, children })
11999 }
12000 );
12001 }
12002
12003 // packages/ui/build-module/alert-dialog/trigger.mjs
12004 var import_element22 = __toESM(require_element(), 1);
12005 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
12006 var Trigger = (0, import_element22.forwardRef)(
12007 function AlertDialogTrigger(props, ref) {
12008 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(index_parts_exports.Trigger, { ref, ...props });
12009 }
12010 );
12011
12012 // packages/ui/build-module/alert-dialog/popup.mjs
12013 var import_element28 = __toESM(require_element(), 1);
12014 var import_compose = __toESM(require_compose(), 1);
12015 var import_i18n2 = __toESM(require_i18n(), 1);
12016 var import_theme = __toESM(require_theme(), 1);
12017
12018 // packages/ui/build-module/utils/render-slot-with-children.mjs
12019 var import_element23 = __toESM(require_element(), 1);
12020 function renderSlotWithChildren(slot, defaultSlot, children) {
12021 return (0, import_element23.cloneElement)(slot ?? defaultSlot, { children });
12022 }
12023
12024 // packages/ui/build-module/utils/use-deprioritized-initial-focus.mjs
12025 var import_element24 = __toESM(require_element(), 1);
12026
12027 // node_modules/tabbable/dist/index.esm.js
12028 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] *)"];
12029 var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
12030 var NoElement = typeof Element === "undefined";
12031 var matches = NoElement ? function() {
12032 } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
12033 var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
12034 var _element$getRootNode;
12035 return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
12036 } : function(element) {
12037 return element === null || element === void 0 ? void 0 : element.ownerDocument;
12038 };
12039 var _isInert = function isInert(node, lookUp) {
12040 var _node$getAttribute;
12041 if (lookUp === void 0) {
12042 lookUp = true;
12043 }
12044 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");
12045 var inert = inertAtt === "" || inertAtt === "true";
12046 var result = inert || lookUp && node && // closest does not exist on shadow roots, so we fall back to a manual
12047 // lookup upward, in case it is not defined.
12048 (typeof node.closest === "function" ? node.closest("[inert]") : _isInert(node.parentNode));
12049 return result;
12050 };
12051 var isContentEditable = function isContentEditable2(node) {
12052 var _node$getAttribute2;
12053 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");
12054 return attValue === "" || attValue === "true";
12055 };
12056 var getCandidates = function getCandidates2(el, includeContainer, filter) {
12057 if (_isInert(el)) {
12058 return [];
12059 }
12060 var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
12061 if (includeContainer && matches.call(el, candidateSelector)) {
12062 candidates.unshift(el);
12063 }
12064 candidates = candidates.filter(filter);
12065 return candidates;
12066 };
12067 var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
12068 var candidates = [];
12069 var elementsToCheck = Array.from(elements);
12070 while (elementsToCheck.length) {
12071 var element = elementsToCheck.shift();
12072 if (_isInert(element, false)) {
12073 continue;
12074 }
12075 if (element.tagName === "SLOT") {
12076 var assigned = element.assignedElements();
12077 var content = assigned.length ? assigned : element.children;
12078 var nestedCandidates = _getCandidatesIteratively(content, true, options);
12079 if (options.flatten) {
12080 candidates.push.apply(candidates, nestedCandidates);
12081 } else {
12082 candidates.push({
12083 scopeParent: element,
12084 candidates: nestedCandidates
12085 });
12086 }
12087 } else {
12088 var validCandidate = matches.call(element, candidateSelector);
12089 if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
12090 candidates.push(element);
12091 }
12092 var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
12093 typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
12094 var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
12095 if (shadowRoot && validShadowRoot) {
12096 var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
12097 if (options.flatten) {
12098 candidates.push.apply(candidates, _nestedCandidates);
12099 } else {
12100 candidates.push({
12101 scopeParent: element,
12102 candidates: _nestedCandidates
12103 });
12104 }
12105 } else {
12106 elementsToCheck.unshift.apply(elementsToCheck, element.children);
12107 }
12108 }
12109 }
12110 return candidates;
12111 };
12112 var hasTabIndex = function hasTabIndex2(node) {
12113 return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
12114 };
12115 var getTabIndex2 = function getTabIndex3(node) {
12116 if (!node) {
12117 throw new Error("No node provided");
12118 }
12119 if (node.tabIndex < 0) {
12120 if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
12121 return 0;
12122 }
12123 }
12124 return node.tabIndex;
12125 };
12126 var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
12127 var tabIndex = getTabIndex2(node);
12128 if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
12129 return 0;
12130 }
12131 return tabIndex;
12132 };
12133 var sortOrderedTabbables = function sortOrderedTabbables2(a2, b2) {
12134 return a2.tabIndex === b2.tabIndex ? a2.documentOrder - b2.documentOrder : a2.tabIndex - b2.tabIndex;
12135 };
12136 var isInput = function isInput2(node) {
12137 return node.tagName === "INPUT";
12138 };
12139 var isHiddenInput = function isHiddenInput2(node) {
12140 return isInput(node) && node.type === "hidden";
12141 };
12142 var isDetailsWithSummary = function isDetailsWithSummary2(node) {
12143 var r3 = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
12144 return child.tagName === "SUMMARY";
12145 });
12146 return r3;
12147 };
12148 var getCheckedRadio = function getCheckedRadio2(nodes, form) {
12149 for (var i2 = 0; i2 < nodes.length; i2++) {
12150 if (nodes[i2].checked && nodes[i2].form === form) {
12151 return nodes[i2];
12152 }
12153 }
12154 };
12155 var isTabbableRadio2 = function isTabbableRadio3(node) {
12156 if (!node.name) {
12157 return true;
12158 }
12159 var radioScope = node.form || getRootNode(node);
12160 var queryRadios = function queryRadios2(name) {
12161 return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
12162 };
12163 var radioSet;
12164 if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
12165 radioSet = queryRadios(window.CSS.escape(node.name));
12166 } else {
12167 try {
12168 radioSet = queryRadios(node.name);
12169 } catch (err) {
12170 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);
12171 return false;
12172 }
12173 }
12174 var checked = getCheckedRadio(radioSet, node.form);
12175 return !checked || checked === node;
12176 };
12177 var isRadio = function isRadio2(node) {
12178 return isInput(node) && node.type === "radio";
12179 };
12180 var isNonTabbableRadio = function isNonTabbableRadio2(node) {
12181 return isRadio(node) && !isTabbableRadio2(node);
12182 };
12183 var isNodeAttached = function isNodeAttached2(node) {
12184 var _nodeRoot;
12185 var nodeRoot = node && getRootNode(node);
12186 var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
12187 var attached = false;
12188 if (nodeRoot && nodeRoot !== node) {
12189 var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
12190 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));
12191 while (!attached && nodeRootHost) {
12192 var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
12193 nodeRoot = getRootNode(nodeRootHost);
12194 nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
12195 attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
12196 }
12197 }
12198 return attached;
12199 };
12200 var isZeroArea = function isZeroArea2(node) {
12201 var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
12202 return width === 0 && height === 0;
12203 };
12204 var isHidden = function isHidden2(node, _ref) {
12205 var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
12206 if (displayCheck === "full-native") {
12207 if ("checkVisibility" in node) {
12208 var visible = node.checkVisibility({
12209 // Checking opacity might be desirable for some use cases, but natively,
12210 // opacity zero elements _are_ focusable and tabbable.
12211 checkOpacity: false,
12212 opacityProperty: false,
12213 contentVisibilityAuto: true,
12214 visibilityProperty: true,
12215 // This is an alias for `visibilityProperty`. Contemporary browsers
12216 // support both. However, this alias has wider browser support (Chrome
12217 // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
12218 // we include it anyway.
12219 checkVisibilityCSS: true
12220 });
12221 return !visible;
12222 }
12223 }
12224 if (getComputedStyle(node).visibility === "hidden") {
12225 return true;
12226 }
12227 var isDirectSummary = matches.call(node, "details>summary:first-of-type");
12228 var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
12229 if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
12230 return true;
12231 }
12232 if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
12233 // Element#checkVisibility is unsupported
12234 displayCheck === "full-native" || displayCheck === "legacy-full") {
12235 if (typeof getShadowRoot === "function") {
12236 var originalNode = node;
12237 while (node) {
12238 var parentElement = node.parentElement;
12239 var rootNode = getRootNode(node);
12240 if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
12241 return isZeroArea(node);
12242 } else if (node.assignedSlot) {
12243 node = node.assignedSlot;
12244 } else if (!parentElement && rootNode !== node.ownerDocument) {
12245 node = rootNode.host;
12246 } else {
12247 node = parentElement;
12248 }
12249 }
12250 node = originalNode;
12251 }
12252 if (isNodeAttached(node)) {
12253 return !node.getClientRects().length;
12254 }
12255 if (displayCheck !== "legacy-full") {
12256 return true;
12257 }
12258 } else if (displayCheck === "non-zero-area") {
12259 return isZeroArea(node);
12260 }
12261 return false;
12262 };
12263 var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
12264 if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
12265 var parentNode = node.parentElement;
12266 while (parentNode) {
12267 if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
12268 for (var i2 = 0; i2 < parentNode.children.length; i2++) {
12269 var child = parentNode.children.item(i2);
12270 if (child.tagName === "LEGEND") {
12271 return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
12272 }
12273 }
12274 return true;
12275 }
12276 parentNode = parentNode.parentElement;
12277 }
12278 }
12279 return false;
12280 };
12281 var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
12282 if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
12283 isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
12284 return false;
12285 }
12286 return true;
12287 };
12288 var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
12289 if (isNonTabbableRadio(node) || getTabIndex2(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
12290 return false;
12291 }
12292 return true;
12293 };
12294 var isShadowRootTabbable = function isShadowRootTabbable2(shadowHostNode) {
12295 var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
12296 if (isNaN(tabIndex) || tabIndex >= 0) {
12297 return true;
12298 }
12299 return false;
12300 };
12301 var _sortByOrder = function sortByOrder(candidates) {
12302 var regularTabbables = [];
12303 var orderedTabbables = [];
12304 candidates.forEach(function(item, i2) {
12305 var isScope = !!item.scopeParent;
12306 var element = isScope ? item.scopeParent : item;
12307 var candidateTabindex = getSortOrderTabIndex(element, isScope);
12308 var elements = isScope ? _sortByOrder(item.candidates) : element;
12309 if (candidateTabindex === 0) {
12310 isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
12311 } else {
12312 orderedTabbables.push({
12313 documentOrder: i2,
12314 tabIndex: candidateTabindex,
12315 item,
12316 isScope,
12317 content: elements
12318 });
12319 }
12320 });
12321 return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
12322 sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
12323 return acc;
12324 }, []).concat(regularTabbables);
12325 };
12326 var tabbable2 = function tabbable3(container, options) {
12327 options = options || {};
12328 var candidates;
12329 if (options.getShadowRoot) {
12330 candidates = _getCandidatesIteratively([container], options.includeContainer, {
12331 filter: isNodeMatchingSelectorTabbable.bind(null, options),
12332 flatten: false,
12333 getShadowRoot: options.getShadowRoot,
12334 shadowRootFilter: isShadowRootTabbable
12335 });
12336 } else {
12337 candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
12338 }
12339 return _sortByOrder(candidates);
12340 };
12341
12342 // packages/ui/build-module/utils/use-deprioritized-initial-focus.mjs
12343 var getTabbableOptions = () => ({
12344 getShadowRoot: true,
12345 displayCheck: typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
12346 });
12347 function useDeprioritizedInitialFocus({
12348 initialFocus,
12349 deprioritizedAttributes
12350 }) {
12351 const popupRef = (0, import_element24.useRef)(null);
12352 let resolvedInitialFocus = initialFocus;
12353 if (initialFocus === void 0 || initialFocus === true) {
12354 resolvedInitialFocus = (interactionType) => {
12355 if (interactionType === "touch") {
12356 return popupRef.current ?? true;
12357 }
12358 const popup = popupRef.current;
12359 if (!popup) {
12360 return true;
12361 }
12362 const tabbables = tabbable2(popup, getTabbableOptions());
12363 for (const el of tabbables) {
12364 if (el instanceof HTMLElement && !deprioritizedAttributes.some(
12365 (attr2) => el.hasAttribute(attr2)
12366 )) {
12367 return el;
12368 }
12369 }
12370 return true;
12371 };
12372 }
12373 return { resolvedInitialFocus, popupRef };
12374 }
12375
12376 // packages/ui/build-module/utils/use-overlay-scroll-state-attributes.mjs
12377 var import_element25 = __toESM(require_element(), 1);
12378 var SCROLL_CONTAINER_ATTR = "data-wp-ui-overlay-scroll-container";
12379 var SCROLLED_FROM_TOP_ATTR = "data-wp-ui-overlay-scrolled-from-top";
12380 var SCROLLED_FROM_BOTTOM_ATTR = "data-wp-ui-overlay-scrolled-from-bottom";
12381 var SCROLL_TABBABLE_FLAG_ATTR = "data-wp-ui-overlay-scroll-tabbable";
12382 var SCROLL_END_EPSILON = 1;
12383 function reconcileTabbableFlag(el) {
12384 if (el.hasAttribute(SCROLL_TABBABLE_FLAG_ATTR) && el.getAttribute("tabindex") !== "0") {
12385 el.removeAttribute(SCROLL_TABBABLE_FLAG_ATTR);
12386 }
12387 }
12388 function updateScrollAttributes(el) {
12389 const { scrollTop, clientHeight, scrollHeight } = el;
12390 const overflows = scrollHeight - clientHeight > SCROLL_END_EPSILON;
12391 el.toggleAttribute(SCROLLED_FROM_TOP_ATTR, scrollTop > 0);
12392 el.toggleAttribute(
12393 SCROLLED_FROM_BOTTOM_ATTR,
12394 scrollTop + clientHeight < scrollHeight - SCROLL_END_EPSILON
12395 );
12396 reconcileTabbableFlag(el);
12397 if (overflows) {
12398 if (!el.hasAttribute(SCROLL_TABBABLE_FLAG_ATTR) && el.getAttribute("tabindex") === null) {
12399 el.setAttribute("tabindex", "0");
12400 el.setAttribute(SCROLL_TABBABLE_FLAG_ATTR, "");
12401 }
12402 } else if (el.hasAttribute(SCROLL_TABBABLE_FLAG_ATTR)) {
12403 el.removeAttribute("tabindex");
12404 el.removeAttribute(SCROLL_TABBABLE_FLAG_ATTR);
12405 }
12406 }
12407 var HOOK_OWNED_ATTRS = [
12408 SCROLL_CONTAINER_ATTR,
12409 SCROLLED_FROM_TOP_ATTR,
12410 SCROLLED_FROM_BOTTOM_ATTR
12411 ];
12412 function cleanupScrollAttributes(el) {
12413 for (const attr2 of HOOK_OWNED_ATTRS) {
12414 el.removeAttribute(attr2);
12415 }
12416 reconcileTabbableFlag(el);
12417 if (el.hasAttribute(SCROLL_TABBABLE_FLAG_ATTR)) {
12418 el.removeAttribute("tabindex");
12419 el.removeAttribute(SCROLL_TABBABLE_FLAG_ATTR);
12420 }
12421 }
12422 function useOverlayScrollStateAttributes(onScroll) {
12423 const [node, setNode] = (0, import_element25.useState)(null);
12424 const ref = (0, import_element25.useCallback)((el) => {
12425 setNode(el);
12426 }, []);
12427 (0, import_element25.useLayoutEffect)(() => {
12428 if (!node) {
12429 return;
12430 }
12431 node.setAttribute(SCROLL_CONTAINER_ATTR, "");
12432 updateScrollAttributes(node);
12433 if (typeof ResizeObserver === "undefined") {
12434 return () => {
12435 cleanupScrollAttributes(node);
12436 };
12437 }
12438 const resizeObserver = new ResizeObserver(() => {
12439 updateScrollAttributes(node);
12440 });
12441 resizeObserver.observe(node);
12442 for (const child of Array.from(node.children)) {
12443 resizeObserver.observe(child);
12444 }
12445 let mutationObserver;
12446 if (typeof MutationObserver !== "undefined") {
12447 mutationObserver = new MutationObserver((records) => {
12448 for (const record of records) {
12449 if (record.target === node) {
12450 for (const added of Array.from(record.addedNodes)) {
12451 if (added instanceof Element) {
12452 resizeObserver.observe(added);
12453 }
12454 }
12455 for (const removed of Array.from(
12456 record.removedNodes
12457 )) {
12458 if (removed instanceof Element) {
12459 resizeObserver.unobserve(removed);
12460 }
12461 }
12462 }
12463 }
12464 updateScrollAttributes(node);
12465 });
12466 mutationObserver.observe(node, {
12467 childList: true
12468 });
12469 }
12470 return () => {
12471 resizeObserver.disconnect();
12472 mutationObserver?.disconnect();
12473 cleanupScrollAttributes(node);
12474 };
12475 }, [node]);
12476 const handleScroll = (0, import_element25.useCallback)(
12477 (event) => {
12478 updateScrollAttributes(event.currentTarget);
12479 onScroll?.(event);
12480 },
12481 [onScroll]
12482 );
12483 return { ref, onScroll: handleScroll };
12484 }
12485
12486 // packages/ui/build-module/lock-unlock.mjs
12487 var import_private_apis = __toESM(require_private_apis(), 1);
12488 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
12489 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
12490 "@wordpress/ui"
12491 );
12492
12493 // packages/ui/build-module/stack/stack.mjs
12494 var import_element26 = __toESM(require_element(), 1);
12495 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
12496 function getRuntime7() {
12497 const globalScope = globalThis;
12498 if (globalScope.__wpStyleRuntime) {
12499 return globalScope.__wpStyleRuntime;
12500 }
12501 globalScope.__wpStyleRuntime = {
12502 documents: /* @__PURE__ */ new Map(),
12503 styles: /* @__PURE__ */ new Map(),
12504 injectedStyles: /* @__PURE__ */ new WeakMap()
12505 };
12506 if (typeof document !== "undefined") {
12507 registerDocument7(document);
12508 }
12509 return globalScope.__wpStyleRuntime;
12510 }
12511 function documentContainsStyleHash7(targetDocument, hash) {
12512 if (!targetDocument.head) {
12513 return false;
12514 }
12515 for (const style of targetDocument.head.querySelectorAll(
12516 `style[${STYLE_HASH_ATTRIBUTE7}]`
12517 )) {
12518 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
12519 return true;
12520 }
12521 }
12522 return false;
12523 }
12524 function injectStyle7(targetDocument, hash, css) {
12525 if (!targetDocument.head) {
12526 return;
12527 }
12528 const runtime = getRuntime7();
12529 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12530 if (!injectedStyles) {
12531 injectedStyles = /* @__PURE__ */ new Set();
12532 runtime.injectedStyles.set(targetDocument, injectedStyles);
12533 }
12534 if (injectedStyles.has(hash)) {
12535 return;
12536 }
12537 if (documentContainsStyleHash7(targetDocument, hash)) {
12538 injectedStyles.add(hash);
12539 return;
12540 }
12541 const style = targetDocument.createElement("style");
12542 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
12543 style.appendChild(targetDocument.createTextNode(css));
12544 targetDocument.head.appendChild(style);
12545 injectedStyles.add(hash);
12546 }
12547 function registerDocument7(targetDocument) {
12548 const runtime = getRuntime7();
12549 runtime.documents.set(
12550 targetDocument,
12551 (runtime.documents.get(targetDocument) ?? 0) + 1
12552 );
12553 for (const [hash, css] of runtime.styles) {
12554 injectStyle7(targetDocument, hash, css);
12555 }
12556 return () => {
12557 const count = runtime.documents.get(targetDocument);
12558 if (count === void 0) {
12559 return;
12560 }
12561 if (count <= 1) {
12562 runtime.documents.delete(targetDocument);
12563 return;
12564 }
12565 runtime.documents.set(targetDocument, count - 1);
12566 };
12567 }
12568 function registerStyle7(hash, css) {
12569 const runtime = getRuntime7();
12570 runtime.styles.set(hash, css);
12571 for (const targetDocument of runtime.documents.keys()) {
12572 injectStyle7(targetDocument, hash, css);
12573 }
12574 }
12575 if (typeof process === "undefined" || true) {
12576 registerStyle7("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
12577 }
12578 var style_default7 = { "stack": "_19ce0419607e1896__stack" };
12579 var gapTokens = {
12580 xs: "var(--wpds-dimension-gap-xs, 4px)",
12581 sm: "var(--wpds-dimension-gap-sm, 8px)",
12582 md: "var(--wpds-dimension-gap-md, 12px)",
12583 lg: "var(--wpds-dimension-gap-lg, 16px)",
12584 xl: "var(--wpds-dimension-gap-xl, 24px)",
12585 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
12586 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
12587 };
12588 var Stack = (0, import_element26.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
12589 const style = {
12590 gap: gap && gapTokens[gap],
12591 alignItems: align,
12592 justifyContent: justify,
12593 flexDirection: direction,
12594 flexWrap: wrap
12595 };
12596 const element = useRender({
12597 render: render4,
12598 ref,
12599 props: mergeProps(props, { style, className: style_default7.stack })
12600 });
12601 return element;
12602 });
12603
12604 // packages/ui/build-module/alert-dialog/portal.mjs
12605 var import_element27 = __toESM(require_element(), 1);
12606 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
12607 var Portal = (0, import_element27.forwardRef)(
12608 function AlertDialogPortal(props, ref) {
12609 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(index_parts_exports.Portal, { ref, ...props });
12610 }
12611 );
12612
12613 // packages/ui/build-module/alert-dialog/popup.mjs
12614 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
12615 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
12616 function getRuntime8() {
12617 const globalScope = globalThis;
12618 if (globalScope.__wpStyleRuntime) {
12619 return globalScope.__wpStyleRuntime;
12620 }
12621 globalScope.__wpStyleRuntime = {
12622 documents: /* @__PURE__ */ new Map(),
12623 styles: /* @__PURE__ */ new Map(),
12624 injectedStyles: /* @__PURE__ */ new WeakMap()
12625 };
12626 if (typeof document !== "undefined") {
12627 registerDocument8(document);
12628 }
12629 return globalScope.__wpStyleRuntime;
12630 }
12631 function documentContainsStyleHash8(targetDocument, hash) {
12632 if (!targetDocument.head) {
12633 return false;
12634 }
12635 for (const style of targetDocument.head.querySelectorAll(
12636 `style[${STYLE_HASH_ATTRIBUTE8}]`
12637 )) {
12638 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
12639 return true;
12640 }
12641 }
12642 return false;
12643 }
12644 function injectStyle8(targetDocument, hash, css) {
12645 if (!targetDocument.head) {
12646 return;
12647 }
12648 const runtime = getRuntime8();
12649 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12650 if (!injectedStyles) {
12651 injectedStyles = /* @__PURE__ */ new Set();
12652 runtime.injectedStyles.set(targetDocument, injectedStyles);
12653 }
12654 if (injectedStyles.has(hash)) {
12655 return;
12656 }
12657 if (documentContainsStyleHash8(targetDocument, hash)) {
12658 injectedStyles.add(hash);
12659 return;
12660 }
12661 const style = targetDocument.createElement("style");
12662 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
12663 style.appendChild(targetDocument.createTextNode(css));
12664 targetDocument.head.appendChild(style);
12665 injectedStyles.add(hash);
12666 }
12667 function registerDocument8(targetDocument) {
12668 const runtime = getRuntime8();
12669 runtime.documents.set(
12670 targetDocument,
12671 (runtime.documents.get(targetDocument) ?? 0) + 1
12672 );
12673 for (const [hash, css] of runtime.styles) {
12674 injectStyle8(targetDocument, hash, css);
12675 }
12676 return () => {
12677 const count = runtime.documents.get(targetDocument);
12678 if (count === void 0) {
12679 return;
12680 }
12681 if (count <= 1) {
12682 runtime.documents.delete(targetDocument);
12683 return;
12684 }
12685 runtime.documents.set(targetDocument, count - 1);
12686 };
12687 }
12688 function registerStyle8(hash, css) {
12689 const runtime = getRuntime8();
12690 runtime.styles.set(hash, css);
12691 for (const targetDocument of runtime.documents.keys()) {
12692 injectStyle8(targetDocument, hash, css);
12693 }
12694 }
12695 if (typeof process === "undefined" || true) {
12696 registerStyle8("a400076f01", '@layer wp-ui-components{.f1c50237c4787636__header{min-height:32px;padding-block:var(--wpds-dimension-padding-2xl,24px) var(--wpds-dimension-gap-lg,16px)}._579f95efdec92a66__footer,.f1c50237c4787636__header{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}._579f95efdec92a66__footer{justify-content:flex-end;padding-block:var(--wpds-dimension-gap-lg,16px) var(--wpds-dimension-padding-2xl,24px)}._5371cc08aad82574__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--_gcd-heading-margin:0 auto 0 0;color:var(--wpds-color-fg-content-neutral,#1e1e1e);margin-inline-end:auto;&:dir(rtl){--_gcd-heading-margin:0 0 0 auto}}._766d9011d37ce2d9__content{flex:1 1 auto;min-block-size:0;overflow-block:auto;overflow-inline:hidden;padding:var(--wpds-dimension-padding-2xl,24px);&:focus-visible{outline-offset:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*-1)}}.f1c50237c4787636__header:has(~._766d9011d37ce2d9__content){border-block-end:1px solid #0000;padding-block-end:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}.f1c50237c4787636__header~._766d9011d37ce2d9__content{padding-block-start:0}._766d9011d37ce2d9__content~._579f95efdec92a66__footer{border-block-start:1px solid #0000;padding-block-start:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}._766d9011d37ce2d9__content:has(~._579f95efdec92a66__footer){padding-block-end:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header{padding-inline:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header:first-child,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header:first-child{padding-block-start:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer{padding-inline:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer:last-child,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer:last-child{padding-block-end:0}.f1c50237c4787636__header:has(~[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-top]){border-block-end-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-bottom]~._579f95efdec92a66__footer{border-block-start-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-modal] [data-wp-ui-overlay-scroll-container]{overscroll-behavior:contain}}@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}._8acaa98861620d4d__popup{--viewport-inset:var(--wpds-dimension-padding-2xl,24px);background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);left:50%;line-height:var(--wpds-typography-line-height-md,24px);max-height:calc(100dvh - var(--viewport-inset)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:hidden;position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--viewport-inset)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)),transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1))}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100dvh}}._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup{border-color:#0000}@media (forced-colors:active){._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup,._8acaa98861620d4d__popup{border-color:CanvasText}}._76fb3b28fcbd45fc__header [data-wp-ui-dialog-close-icon]{margin-inline-start:auto}.d9d6da914ef0a77c__description{margin-bottom:var(--wpds-dimension-gap-lg,16px)}}');
12697 }
12698 var style_default8 = { "backdrop": "_074affe4c56b4f2f__backdrop", "popup": "_8acaa98861620d4d__popup", "is-small": "_7acfa67ebf092988__is-small", "is-medium": "_1eeeed880cb5769d__is-medium", "is-large": "_99f900b2267e22d0__is-large", "is-stretch": "b49f7ff9c06fe387__is-stretch", "is-full": "dcd4c2f5036cbf1a__is-full", "header": "_76fb3b28fcbd45fc__header f1c50237c4787636__header", "footer": "_00eeb4f220cddae3__footer _579f95efdec92a66__footer", "title": "f636832002af749e__title _5371cc08aad82574__title", "content": "_101038da9af7162f__content _766d9011d37ce2d9__content", "description": "d9d6da914ef0a77c__description" };
12699 if (typeof process === "undefined" || true) {
12700 registerStyle8("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}");
12701 }
12702 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" };
12703 if (typeof process === "undefined" || true) {
12704 registerStyle8("538652eb41", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f1c50237c4787636__header{min-height:32px;padding-block:var(--wpds-dimension-padding-2xl,24px) var(--wpds-dimension-gap-lg,16px)}._579f95efdec92a66__footer,.f1c50237c4787636__header{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}._579f95efdec92a66__footer{justify-content:flex-end;padding-block:var(--wpds-dimension-gap-lg,16px) var(--wpds-dimension-padding-2xl,24px)}._5371cc08aad82574__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--_gcd-heading-margin:0 auto 0 0;color:var(--wpds-color-fg-content-neutral,#1e1e1e);margin-inline-end:auto;&:dir(rtl){--_gcd-heading-margin:0 0 0 auto}}._766d9011d37ce2d9__content{flex:1 1 auto;min-block-size:0;overflow-block:auto;overflow-inline:hidden;padding:var(--wpds-dimension-padding-2xl,24px);&:focus-visible{outline-offset:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*-1)}}.f1c50237c4787636__header:has(~._766d9011d37ce2d9__content){border-block-end:1px solid #0000;padding-block-end:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}.f1c50237c4787636__header~._766d9011d37ce2d9__content{padding-block-start:0}._766d9011d37ce2d9__content~._579f95efdec92a66__footer{border-block-start:1px solid #0000;padding-block-start:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}._766d9011d37ce2d9__content:has(~._579f95efdec92a66__footer){padding-block-end:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header{padding-inline:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header:first-child,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header:first-child{padding-block-start:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer{padding-inline:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer:last-child,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer:last-child{padding-block-end:0}.f1c50237c4787636__header:has(~[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-top]){border-block-end-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-bottom]~._579f95efdec92a66__footer{border-block-start-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-modal] [data-wp-ui-overlay-scroll-container]{overscroll-behavior:contain}}");
12705 }
12706 var overlay_chrome_default = { "header": "f1c50237c4787636__header", "footer": "_579f95efdec92a66__footer", "title": "_5371cc08aad82574__title", "content": "_766d9011d37ce2d9__content" };
12707 if (typeof process === "undefined" || true) {
12708 registerStyle8("ea48258a83", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.dbff6618234a2a93__error-message{align-self:flex-end;color:var(--wpds-color-fg-content-error,#470000)}._66cf5fe0c6a030bd__footer-column{align-items:stretch;flex-direction:column;gap:var(--wpds-dimension-gap-md,12px);justify-content:flex-start}}@layer wp-ui-compositions{._2ddc2fc9155a1dad__irreversible-action{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-error-strong,#cc1818);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-error-strong-active,#b90000);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-error-strong,#f2efef);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-error-strong-active,#f2efef)}}");
12709 }
12710 var style_default22 = { "error-message": "dbff6618234a2a93__error-message", "footer-column": "_66cf5fe0c6a030bd__footer-column", "irreversible-action": "_2ddc2fc9155a1dad__irreversible-action" };
12711 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
12712 var Popup = (0, import_element28.forwardRef)(
12713 function AlertDialogPopup({
12714 className,
12715 portal,
12716 intent = "default",
12717 title,
12718 description,
12719 children,
12720 confirmButtonText = (0, import_i18n2.__)("OK"),
12721 cancelButtonText = (0, import_i18n2.__)("Cancel"),
12722 stickyHeader = true,
12723 stickyFooter = true,
12724 initialFocus,
12725 finalFocus,
12726 ...props
12727 }, ref) {
12728 const { phase, showSpinner, errorMessage, confirm } = (0, import_element28.useContext)(AlertDialogContext);
12729 const { ref: scrollStateRef, onScroll } = useOverlayScrollStateAttributes();
12730 const { resolvedInitialFocus, popupRef } = useDeprioritizedInitialFocus(
12731 {
12732 initialFocus,
12733 deprioritizedAttributes: [SCROLL_CONTAINER_ATTR]
12734 }
12735 );
12736 const mergedRef = (0, import_compose.useMergeRefs)([ref, popupRef]);
12737 const confirmClassName = intent === "irreversible" ? style_default22["irreversible-action"] : void 0;
12738 const buttonsDisabled = phase !== "idle" || void 0;
12739 const headerElement = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: overlay_chrome_default.header, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12740 Text,
12741 {
12742 variant: "heading-xl",
12743 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(index_parts_exports.Title, {}),
12744 className: overlay_chrome_default.title,
12745 children: title
12746 }
12747 ) });
12748 const footerElement = /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12749 "div",
12750 {
12751 className: clsx_default(
12752 overlay_chrome_default.footer,
12753 style_default22["footer-column"]
12754 ),
12755 children: [
12756 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12757 Stack,
12758 {
12759 direction: "row",
12760 gap: "sm",
12761 justify: "flex-end",
12762 align: "center",
12763 children: [
12764 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12765 index_parts_exports.Close,
12766 {
12767 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Button4, { variant: "minimal" }),
12768 disabled: buttonsDisabled,
12769 children: cancelButtonText
12770 }
12771 ),
12772 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12773 Button4,
12774 {
12775 className: confirmClassName,
12776 onClick: confirm,
12777 loading: showSpinner || void 0,
12778 disabled: buttonsDisabled,
12779 children: confirmButtonText
12780 }
12781 )
12782 ]
12783 }
12784 ),
12785 errorMessage && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12786 Text,
12787 {
12788 variant: "body-sm",
12789 className: style_default22["error-message"],
12790 children: errorMessage
12791 }
12792 )
12793 ]
12794 }
12795 );
12796 const portalChildren = /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
12797 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(index_parts_exports.Backdrop, { className: style_default8.backdrop }),
12798 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12799 index_parts_exports.Popup,
12800 {
12801 ref: mergedRef,
12802 className: clsx_default(
12803 style_default8.popup,
12804 className,
12805 style_default8["is-medium"]
12806 ),
12807 initialFocus: resolvedInitialFocus,
12808 finalFocus,
12809 ...props,
12810 "data-wp-ui-overlay-modal": "",
12811 children: [
12812 stickyHeader && headerElement,
12813 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12814 "div",
12815 {
12816 ref: scrollStateRef,
12817 className: clsx_default(
12818 overlay_chrome_default.content,
12819 focus_default2["outset-ring--focus-visible"]
12820 ),
12821 onScroll,
12822 children: [
12823 !stickyHeader && headerElement,
12824 description && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12825 Text,
12826 {
12827 variant: "body-md",
12828 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(index_parts_exports.Description, {}),
12829 children: description
12830 }
12831 ),
12832 children,
12833 !stickyFooter && footerElement
12834 ]
12835 }
12836 ),
12837 stickyFooter && footerElement
12838 ]
12839 }
12840 ) })
12841 ] });
12842 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Portal, {}), portalChildren);
12843 }
12844 );
12845
12846 // packages/ui/build-module/dialog/index.mjs
12847 var dialog_exports = {};
12848 __export(dialog_exports, {
12849 Action: () => Action,
12850 CloseIcon: () => CloseIcon,
12851 Content: () => Content2,
12852 Description: () => Description,
12853 Footer: () => Footer,
12854 Header: () => Header2,
12855 Popup: () => Popup3,
12856 Portal: () => Portal3,
12857 Root: () => Root4,
12858 Title: () => Title2,
12859 Trigger: () => Trigger3
12860 });
12861
12862 // packages/ui/build-module/dialog/action.mjs
12863 var import_element29 = __toESM(require_element(), 1);
12864 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
12865 var Action = (0, import_element29.forwardRef)(
12866 function DialogAction({ render: render4, disabled: disabled2, loading, ...props }, ref) {
12867 const resolvedDisabled = disabled2 ?? loading;
12868 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
12869 index_parts_exports2.Close,
12870 {
12871 ref,
12872 render: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Button4, { render: render4, loading }),
12873 disabled: resolvedDisabled,
12874 ...props
12875 }
12876 );
12877 }
12878 );
12879
12880 // packages/ui/build-module/dialog/close-icon.mjs
12881 var import_element35 = __toESM(require_element(), 1);
12882 var import_i18n3 = __toESM(require_i18n(), 1);
12883
12884 // packages/ui/build-module/icon-button/icon-button.mjs
12885 var import_element34 = __toESM(require_element(), 1);
12886
12887 // packages/ui/build-module/tooltip/popup.mjs
12888 var import_element32 = __toESM(require_element(), 1);
12889 var import_theme2 = __toESM(require_theme(), 1);
12890
12891 // packages/ui/build-module/tooltip/portal.mjs
12892 var import_element30 = __toESM(require_element(), 1);
12893 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
12894 var Portal2 = (0, import_element30.forwardRef)(
12895 function TooltipPortal3(props, ref) {
12896 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(index_parts_exports3.Portal, { ref, ...props });
12897 }
12898 );
12899
12900 // packages/ui/build-module/tooltip/positioner.mjs
12901 var import_element31 = __toESM(require_element(), 1);
12902 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
12903 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
12904 function getRuntime9() {
12905 const globalScope = globalThis;
12906 if (globalScope.__wpStyleRuntime) {
12907 return globalScope.__wpStyleRuntime;
12908 }
12909 globalScope.__wpStyleRuntime = {
12910 documents: /* @__PURE__ */ new Map(),
12911 styles: /* @__PURE__ */ new Map(),
12912 injectedStyles: /* @__PURE__ */ new WeakMap()
12913 };
12914 if (typeof document !== "undefined") {
12915 registerDocument9(document);
12916 }
12917 return globalScope.__wpStyleRuntime;
12918 }
12919 function documentContainsStyleHash9(targetDocument, hash) {
12920 if (!targetDocument.head) {
12921 return false;
12922 }
12923 for (const style of targetDocument.head.querySelectorAll(
12924 `style[${STYLE_HASH_ATTRIBUTE9}]`
12925 )) {
12926 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
12927 return true;
12928 }
12929 }
12930 return false;
12931 }
12932 function injectStyle9(targetDocument, hash, css) {
12933 if (!targetDocument.head) {
12934 return;
12935 }
12936 const runtime = getRuntime9();
12937 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12938 if (!injectedStyles) {
12939 injectedStyles = /* @__PURE__ */ new Set();
12940 runtime.injectedStyles.set(targetDocument, injectedStyles);
12941 }
12942 if (injectedStyles.has(hash)) {
12943 return;
12944 }
12945 if (documentContainsStyleHash9(targetDocument, hash)) {
12946 injectedStyles.add(hash);
12947 return;
12948 }
12949 const style = targetDocument.createElement("style");
12950 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
12951 style.appendChild(targetDocument.createTextNode(css));
12952 targetDocument.head.appendChild(style);
12953 injectedStyles.add(hash);
12954 }
12955 function registerDocument9(targetDocument) {
12956 const runtime = getRuntime9();
12957 runtime.documents.set(
12958 targetDocument,
12959 (runtime.documents.get(targetDocument) ?? 0) + 1
12960 );
12961 for (const [hash, css] of runtime.styles) {
12962 injectStyle9(targetDocument, hash, css);
12963 }
12964 return () => {
12965 const count = runtime.documents.get(targetDocument);
12966 if (count === void 0) {
12967 return;
12968 }
12969 if (count <= 1) {
12970 runtime.documents.delete(targetDocument);
12971 return;
12972 }
12973 runtime.documents.set(targetDocument, count - 1);
12974 };
12975 }
12976 function registerStyle9(hash, css) {
12977 const runtime = getRuntime9();
12978 runtime.styles.set(hash, css);
12979 for (const targetDocument of runtime.documents.keys()) {
12980 injectStyle9(targetDocument, hash, css);
12981 }
12982 }
12983 if (typeof process === "undefined" || true) {
12984 registerStyle9("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
12985 }
12986 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
12987 if (typeof process === "undefined" || true) {
12988 registerStyle9("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
12989 }
12990 var style_default9 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
12991 var Positioner = (0, import_element31.forwardRef)(
12992 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
12993 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12994 index_parts_exports3.Positioner,
12995 {
12996 ref,
12997 align,
12998 side,
12999 sideOffset,
13000 ...props,
13001 className: clsx_default(
13002 resets_default3["box-sizing"],
13003 style_default9.positioner,
13004 className
13005 )
13006 }
13007 );
13008 }
13009 );
13010
13011 // packages/ui/build-module/tooltip/popup.mjs
13012 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13013 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
13014 function getRuntime10() {
13015 const globalScope = globalThis;
13016 if (globalScope.__wpStyleRuntime) {
13017 return globalScope.__wpStyleRuntime;
13018 }
13019 globalScope.__wpStyleRuntime = {
13020 documents: /* @__PURE__ */ new Map(),
13021 styles: /* @__PURE__ */ new Map(),
13022 injectedStyles: /* @__PURE__ */ new WeakMap()
13023 };
13024 if (typeof document !== "undefined") {
13025 registerDocument10(document);
13026 }
13027 return globalScope.__wpStyleRuntime;
13028 }
13029 function documentContainsStyleHash10(targetDocument, hash) {
13030 if (!targetDocument.head) {
13031 return false;
13032 }
13033 for (const style of targetDocument.head.querySelectorAll(
13034 `style[${STYLE_HASH_ATTRIBUTE10}]`
13035 )) {
13036 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
13037 return true;
13038 }
13039 }
13040 return false;
13041 }
13042 function injectStyle10(targetDocument, hash, css) {
13043 if (!targetDocument.head) {
13044 return;
13045 }
13046 const runtime = getRuntime10();
13047 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13048 if (!injectedStyles) {
13049 injectedStyles = /* @__PURE__ */ new Set();
13050 runtime.injectedStyles.set(targetDocument, injectedStyles);
13051 }
13052 if (injectedStyles.has(hash)) {
13053 return;
13054 }
13055 if (documentContainsStyleHash10(targetDocument, hash)) {
13056 injectedStyles.add(hash);
13057 return;
13058 }
13059 const style = targetDocument.createElement("style");
13060 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
13061 style.appendChild(targetDocument.createTextNode(css));
13062 targetDocument.head.appendChild(style);
13063 injectedStyles.add(hash);
13064 }
13065 function registerDocument10(targetDocument) {
13066 const runtime = getRuntime10();
13067 runtime.documents.set(
13068 targetDocument,
13069 (runtime.documents.get(targetDocument) ?? 0) + 1
13070 );
13071 for (const [hash, css] of runtime.styles) {
13072 injectStyle10(targetDocument, hash, css);
13073 }
13074 return () => {
13075 const count = runtime.documents.get(targetDocument);
13076 if (count === void 0) {
13077 return;
13078 }
13079 if (count <= 1) {
13080 runtime.documents.delete(targetDocument);
13081 return;
13082 }
13083 runtime.documents.set(targetDocument, count - 1);
13084 };
13085 }
13086 function registerStyle10(hash, css) {
13087 const runtime = getRuntime10();
13088 runtime.styles.set(hash, css);
13089 for (const targetDocument of runtime.documents.keys()) {
13090 injectStyle10(targetDocument, hash, css);
13091 }
13092 }
13093 if (typeof process === "undefined" || true) {
13094 registerStyle10("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
13095 }
13096 var style_default10 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
13097 var ThemeProvider2 = unlock(import_theme2.privateApis).ThemeProvider;
13098 var Popup2 = (0, import_element32.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
13099 const popupContent = (
13100 /* This should ideally use whatever dark color makes sense,
13101 * and not be hardcoded to #1e1e1e. The solutions would be to:
13102 * - review the design of the tooltip, in case we want to stop
13103 * hardcoding it to a dark background
13104 * - create new semantic tokens as needed (aliasing either the
13105 * "inverted bg" or "perma-dark bg" private tokens) and have
13106 * Tooltip.Popup use them;
13107 * - remove the hardcoded `bg` setting from the `ThemeProvider`
13108 * below
13109 */
13110 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ThemeProvider2, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13111 index_parts_exports3.Popup,
13112 {
13113 ref,
13114 className: clsx_default(style_default10.popup, className),
13115 ...props,
13116 children
13117 }
13118 ) })
13119 );
13120 const positionedPopup = renderSlotWithChildren(
13121 positioner,
13122 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Positioner, {}),
13123 popupContent
13124 );
13125 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Portal2, {}), positionedPopup);
13126 });
13127
13128 // packages/ui/build-module/tooltip/trigger.mjs
13129 var import_element33 = __toESM(require_element(), 1);
13130 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13131 var Trigger2 = (0, import_element33.forwardRef)(
13132 function TooltipTrigger3(props, ref) {
13133 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(index_parts_exports3.Trigger, { ref, ...props });
13134 }
13135 );
13136
13137 // packages/ui/build-module/tooltip/root.mjs
13138 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13139 function Root3(props) {
13140 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(index_parts_exports3.Root, { ...props });
13141 }
13142
13143 // packages/ui/build-module/tooltip/provider.mjs
13144 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13145 function Provider({ ...props }) {
13146 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(index_parts_exports3.Provider, { ...props });
13147 }
13148
13149 // packages/ui/build-module/icon-button/icon-button.mjs
13150 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13151 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
13152 function getRuntime11() {
13153 const globalScope = globalThis;
13154 if (globalScope.__wpStyleRuntime) {
13155 return globalScope.__wpStyleRuntime;
13156 }
13157 globalScope.__wpStyleRuntime = {
13158 documents: /* @__PURE__ */ new Map(),
13159 styles: /* @__PURE__ */ new Map(),
13160 injectedStyles: /* @__PURE__ */ new WeakMap()
13161 };
13162 if (typeof document !== "undefined") {
13163 registerDocument11(document);
13164 }
13165 return globalScope.__wpStyleRuntime;
13166 }
13167 function documentContainsStyleHash11(targetDocument, hash) {
13168 if (!targetDocument.head) {
13169 return false;
13170 }
13171 for (const style of targetDocument.head.querySelectorAll(
13172 `style[${STYLE_HASH_ATTRIBUTE11}]`
13173 )) {
13174 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
13175 return true;
13176 }
13177 }
13178 return false;
13179 }
13180 function injectStyle11(targetDocument, hash, css) {
13181 if (!targetDocument.head) {
13182 return;
13183 }
13184 const runtime = getRuntime11();
13185 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13186 if (!injectedStyles) {
13187 injectedStyles = /* @__PURE__ */ new Set();
13188 runtime.injectedStyles.set(targetDocument, injectedStyles);
13189 }
13190 if (injectedStyles.has(hash)) {
13191 return;
13192 }
13193 if (documentContainsStyleHash11(targetDocument, hash)) {
13194 injectedStyles.add(hash);
13195 return;
13196 }
13197 const style = targetDocument.createElement("style");
13198 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
13199 style.appendChild(targetDocument.createTextNode(css));
13200 targetDocument.head.appendChild(style);
13201 injectedStyles.add(hash);
13202 }
13203 function registerDocument11(targetDocument) {
13204 const runtime = getRuntime11();
13205 runtime.documents.set(
13206 targetDocument,
13207 (runtime.documents.get(targetDocument) ?? 0) + 1
13208 );
13209 for (const [hash, css] of runtime.styles) {
13210 injectStyle11(targetDocument, hash, css);
13211 }
13212 return () => {
13213 const count = runtime.documents.get(targetDocument);
13214 if (count === void 0) {
13215 return;
13216 }
13217 if (count <= 1) {
13218 runtime.documents.delete(targetDocument);
13219 return;
13220 }
13221 runtime.documents.set(targetDocument, count - 1);
13222 };
13223 }
13224 function registerStyle11(hash, css) {
13225 const runtime = getRuntime11();
13226 runtime.styles.set(hash, css);
13227 for (const targetDocument of runtime.documents.keys()) {
13228 injectStyle11(targetDocument, hash, css);
13229 }
13230 }
13231 if (typeof process === "undefined" || true) {
13232 registerStyle11("358a2a646a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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}}");
13233 }
13234 var style_default11 = { "icon-button": "_28cfdc260e755391__icon-button", "icon": "f1c70d719989a85a__icon" };
13235 var IconButton = (0, import_element34.forwardRef)(
13236 function IconButton2({
13237 label,
13238 className,
13239 // Prevent accidental forwarding of `children`
13240 children: _children,
13241 disabled: disabled2,
13242 focusableWhenDisabled,
13243 icon,
13244 size: size4,
13245 shortcut,
13246 positioner,
13247 ...restProps
13248 }, ref) {
13249 const classes = clsx_default(style_default11["icon-button"], className);
13250 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Root3, { children: [
13251 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13252 Trigger2,
13253 {
13254 ref,
13255 disabled: disabled2 && !focusableWhenDisabled,
13256 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13257 Button4,
13258 {
13259 ...restProps,
13260 size: size4,
13261 "aria-label": label,
13262 "aria-keyshortcuts": shortcut?.ariaKeyShortcut,
13263 disabled: disabled2,
13264 focusableWhenDisabled
13265 }
13266 ),
13267 className: classes,
13268 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13269 Icon,
13270 {
13271 icon,
13272 size: 24,
13273 className: style_default11.icon
13274 }
13275 )
13276 }
13277 ),
13278 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Popup2, { positioner, children: [
13279 label,
13280 shortcut && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13281 " ",
13282 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { "aria-hidden": "true", children: shortcut.displayShortcut })
13283 ] })
13284 ] })
13285 ] }) });
13286 }
13287 );
13288
13289 // packages/ui/build-module/dialog/close-icon.mjs
13290 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13291 var CloseIcon = (0, import_element35.forwardRef)(
13292 function DialogCloseIcon({ icon, label, ...props }, ref) {
13293 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13294 index_parts_exports2.Close,
13295 {
13296 ref,
13297 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13298 IconButton,
13299 {
13300 variant: "minimal",
13301 size: "compact",
13302 tone: "neutral",
13303 ...props,
13304 icon: icon ?? close_default,
13305 label: label ?? (0, import_i18n3.__)("Close"),
13306 "data-wp-ui-dialog-close-icon": ""
13307 }
13308 )
13309 }
13310 );
13311 }
13312 );
13313
13314 // packages/ui/build-module/dialog/content.mjs
13315 var import_element36 = __toESM(require_element(), 1);
13316 var import_compose2 = __toESM(require_compose(), 1);
13317 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
13318 function getRuntime12() {
13319 const globalScope = globalThis;
13320 if (globalScope.__wpStyleRuntime) {
13321 return globalScope.__wpStyleRuntime;
13322 }
13323 globalScope.__wpStyleRuntime = {
13324 documents: /* @__PURE__ */ new Map(),
13325 styles: /* @__PURE__ */ new Map(),
13326 injectedStyles: /* @__PURE__ */ new WeakMap()
13327 };
13328 if (typeof document !== "undefined") {
13329 registerDocument12(document);
13330 }
13331 return globalScope.__wpStyleRuntime;
13332 }
13333 function documentContainsStyleHash12(targetDocument, hash) {
13334 if (!targetDocument.head) {
13335 return false;
13336 }
13337 for (const style of targetDocument.head.querySelectorAll(
13338 `style[${STYLE_HASH_ATTRIBUTE12}]`
13339 )) {
13340 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
13341 return true;
13342 }
13343 }
13344 return false;
13345 }
13346 function injectStyle12(targetDocument, hash, css) {
13347 if (!targetDocument.head) {
13348 return;
13349 }
13350 const runtime = getRuntime12();
13351 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13352 if (!injectedStyles) {
13353 injectedStyles = /* @__PURE__ */ new Set();
13354 runtime.injectedStyles.set(targetDocument, injectedStyles);
13355 }
13356 if (injectedStyles.has(hash)) {
13357 return;
13358 }
13359 if (documentContainsStyleHash12(targetDocument, hash)) {
13360 injectedStyles.add(hash);
13361 return;
13362 }
13363 const style = targetDocument.createElement("style");
13364 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
13365 style.appendChild(targetDocument.createTextNode(css));
13366 targetDocument.head.appendChild(style);
13367 injectedStyles.add(hash);
13368 }
13369 function registerDocument12(targetDocument) {
13370 const runtime = getRuntime12();
13371 runtime.documents.set(
13372 targetDocument,
13373 (runtime.documents.get(targetDocument) ?? 0) + 1
13374 );
13375 for (const [hash, css] of runtime.styles) {
13376 injectStyle12(targetDocument, hash, css);
13377 }
13378 return () => {
13379 const count = runtime.documents.get(targetDocument);
13380 if (count === void 0) {
13381 return;
13382 }
13383 if (count <= 1) {
13384 runtime.documents.delete(targetDocument);
13385 return;
13386 }
13387 runtime.documents.set(targetDocument, count - 1);
13388 };
13389 }
13390 function registerStyle12(hash, css) {
13391 const runtime = getRuntime12();
13392 runtime.styles.set(hash, css);
13393 for (const targetDocument of runtime.documents.keys()) {
13394 injectStyle12(targetDocument, hash, css);
13395 }
13396 }
13397 if (typeof process === "undefined" || true) {
13398 registerStyle12("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}");
13399 }
13400 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" };
13401 if (typeof process === "undefined" || true) {
13402 registerStyle12("a400076f01", '@layer wp-ui-components{.f1c50237c4787636__header{min-height:32px;padding-block:var(--wpds-dimension-padding-2xl,24px) var(--wpds-dimension-gap-lg,16px)}._579f95efdec92a66__footer,.f1c50237c4787636__header{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}._579f95efdec92a66__footer{justify-content:flex-end;padding-block:var(--wpds-dimension-gap-lg,16px) var(--wpds-dimension-padding-2xl,24px)}._5371cc08aad82574__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--_gcd-heading-margin:0 auto 0 0;color:var(--wpds-color-fg-content-neutral,#1e1e1e);margin-inline-end:auto;&:dir(rtl){--_gcd-heading-margin:0 0 0 auto}}._766d9011d37ce2d9__content{flex:1 1 auto;min-block-size:0;overflow-block:auto;overflow-inline:hidden;padding:var(--wpds-dimension-padding-2xl,24px);&:focus-visible{outline-offset:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*-1)}}.f1c50237c4787636__header:has(~._766d9011d37ce2d9__content){border-block-end:1px solid #0000;padding-block-end:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}.f1c50237c4787636__header~._766d9011d37ce2d9__content{padding-block-start:0}._766d9011d37ce2d9__content~._579f95efdec92a66__footer{border-block-start:1px solid #0000;padding-block-start:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}._766d9011d37ce2d9__content:has(~._579f95efdec92a66__footer){padding-block-end:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header{padding-inline:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header:first-child,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header:first-child{padding-block-start:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer{padding-inline:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer:last-child,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer:last-child{padding-block-end:0}.f1c50237c4787636__header:has(~[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-top]){border-block-end-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-bottom]~._579f95efdec92a66__footer{border-block-start-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-modal] [data-wp-ui-overlay-scroll-container]{overscroll-behavior:contain}}@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}._8acaa98861620d4d__popup{--viewport-inset:var(--wpds-dimension-padding-2xl,24px);background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);left:50%;line-height:var(--wpds-typography-line-height-md,24px);max-height:calc(100dvh - var(--viewport-inset)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:hidden;position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--viewport-inset)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)),transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1))}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100dvh}}._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup{border-color:#0000}@media (forced-colors:active){._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup,._8acaa98861620d4d__popup{border-color:CanvasText}}._76fb3b28fcbd45fc__header [data-wp-ui-dialog-close-icon]{margin-inline-start:auto}.d9d6da914ef0a77c__description{margin-bottom:var(--wpds-dimension-gap-lg,16px)}}');
13403 }
13404 var style_default12 = { "backdrop": "_074affe4c56b4f2f__backdrop", "popup": "_8acaa98861620d4d__popup", "is-small": "_7acfa67ebf092988__is-small", "is-medium": "_1eeeed880cb5769d__is-medium", "is-large": "_99f900b2267e22d0__is-large", "is-stretch": "b49f7ff9c06fe387__is-stretch", "is-full": "dcd4c2f5036cbf1a__is-full", "header": "_76fb3b28fcbd45fc__header f1c50237c4787636__header", "footer": "_00eeb4f220cddae3__footer _579f95efdec92a66__footer", "title": "f636832002af749e__title _5371cc08aad82574__title", "content": "_101038da9af7162f__content _766d9011d37ce2d9__content", "description": "d9d6da914ef0a77c__description" };
13405 var Content2 = (0, import_element36.forwardRef)(
13406 function DialogContent({ className, render: render4, onScroll, ...props }, ref) {
13407 const { ref: scrollStateRef, onScroll: scrollStateOnScroll } = useOverlayScrollStateAttributes(onScroll);
13408 const mergedRef = (0, import_compose2.useMergeRefs)([ref, scrollStateRef]);
13409 const element = useRender({
13410 defaultTagName: "div",
13411 render: render4,
13412 ref: mergedRef,
13413 props: mergeProps(props, {
13414 className: clsx_default(
13415 style_default12.content,
13416 focus_default3["outset-ring--focus-visible"],
13417 className
13418 ),
13419 onScroll: scrollStateOnScroll
13420 })
13421 });
13422 return element;
13423 }
13424 );
13425
13426 // packages/ui/build-module/dialog/description.mjs
13427 var import_element37 = __toESM(require_element(), 1);
13428 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13429 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
13430 function getRuntime13() {
13431 const globalScope = globalThis;
13432 if (globalScope.__wpStyleRuntime) {
13433 return globalScope.__wpStyleRuntime;
13434 }
13435 globalScope.__wpStyleRuntime = {
13436 documents: /* @__PURE__ */ new Map(),
13437 styles: /* @__PURE__ */ new Map(),
13438 injectedStyles: /* @__PURE__ */ new WeakMap()
13439 };
13440 if (typeof document !== "undefined") {
13441 registerDocument13(document);
13442 }
13443 return globalScope.__wpStyleRuntime;
13444 }
13445 function documentContainsStyleHash13(targetDocument, hash) {
13446 if (!targetDocument.head) {
13447 return false;
13448 }
13449 for (const style of targetDocument.head.querySelectorAll(
13450 `style[${STYLE_HASH_ATTRIBUTE13}]`
13451 )) {
13452 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
13453 return true;
13454 }
13455 }
13456 return false;
13457 }
13458 function injectStyle13(targetDocument, hash, css) {
13459 if (!targetDocument.head) {
13460 return;
13461 }
13462 const runtime = getRuntime13();
13463 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13464 if (!injectedStyles) {
13465 injectedStyles = /* @__PURE__ */ new Set();
13466 runtime.injectedStyles.set(targetDocument, injectedStyles);
13467 }
13468 if (injectedStyles.has(hash)) {
13469 return;
13470 }
13471 if (documentContainsStyleHash13(targetDocument, hash)) {
13472 injectedStyles.add(hash);
13473 return;
13474 }
13475 const style = targetDocument.createElement("style");
13476 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
13477 style.appendChild(targetDocument.createTextNode(css));
13478 targetDocument.head.appendChild(style);
13479 injectedStyles.add(hash);
13480 }
13481 function registerDocument13(targetDocument) {
13482 const runtime = getRuntime13();
13483 runtime.documents.set(
13484 targetDocument,
13485 (runtime.documents.get(targetDocument) ?? 0) + 1
13486 );
13487 for (const [hash, css] of runtime.styles) {
13488 injectStyle13(targetDocument, hash, css);
13489 }
13490 return () => {
13491 const count = runtime.documents.get(targetDocument);
13492 if (count === void 0) {
13493 return;
13494 }
13495 if (count <= 1) {
13496 runtime.documents.delete(targetDocument);
13497 return;
13498 }
13499 runtime.documents.set(targetDocument, count - 1);
13500 };
13501 }
13502 function registerStyle13(hash, css) {
13503 const runtime = getRuntime13();
13504 runtime.styles.set(hash, css);
13505 for (const targetDocument of runtime.documents.keys()) {
13506 injectStyle13(targetDocument, hash, css);
13507 }
13508 }
13509 if (typeof process === "undefined" || true) {
13510 registerStyle13("a400076f01", '@layer wp-ui-components{.f1c50237c4787636__header{min-height:32px;padding-block:var(--wpds-dimension-padding-2xl,24px) var(--wpds-dimension-gap-lg,16px)}._579f95efdec92a66__footer,.f1c50237c4787636__header{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}._579f95efdec92a66__footer{justify-content:flex-end;padding-block:var(--wpds-dimension-gap-lg,16px) var(--wpds-dimension-padding-2xl,24px)}._5371cc08aad82574__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--_gcd-heading-margin:0 auto 0 0;color:var(--wpds-color-fg-content-neutral,#1e1e1e);margin-inline-end:auto;&:dir(rtl){--_gcd-heading-margin:0 0 0 auto}}._766d9011d37ce2d9__content{flex:1 1 auto;min-block-size:0;overflow-block:auto;overflow-inline:hidden;padding:var(--wpds-dimension-padding-2xl,24px);&:focus-visible{outline-offset:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*-1)}}.f1c50237c4787636__header:has(~._766d9011d37ce2d9__content){border-block-end:1px solid #0000;padding-block-end:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}.f1c50237c4787636__header~._766d9011d37ce2d9__content{padding-block-start:0}._766d9011d37ce2d9__content~._579f95efdec92a66__footer{border-block-start:1px solid #0000;padding-block-start:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}._766d9011d37ce2d9__content:has(~._579f95efdec92a66__footer){padding-block-end:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header{padding-inline:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header:first-child,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header:first-child{padding-block-start:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer{padding-inline:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer:last-child,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer:last-child{padding-block-end:0}.f1c50237c4787636__header:has(~[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-top]){border-block-end-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-bottom]~._579f95efdec92a66__footer{border-block-start-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-modal] [data-wp-ui-overlay-scroll-container]{overscroll-behavior:contain}}@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}._8acaa98861620d4d__popup{--viewport-inset:var(--wpds-dimension-padding-2xl,24px);background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);left:50%;line-height:var(--wpds-typography-line-height-md,24px);max-height:calc(100dvh - var(--viewport-inset)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:hidden;position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--viewport-inset)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)),transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1))}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100dvh}}._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup{border-color:#0000}@media (forced-colors:active){._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup,._8acaa98861620d4d__popup{border-color:CanvasText}}._76fb3b28fcbd45fc__header [data-wp-ui-dialog-close-icon]{margin-inline-start:auto}.d9d6da914ef0a77c__description{margin-bottom:var(--wpds-dimension-gap-lg,16px)}}');
13511 }
13512 var style_default13 = { "backdrop": "_074affe4c56b4f2f__backdrop", "popup": "_8acaa98861620d4d__popup", "is-small": "_7acfa67ebf092988__is-small", "is-medium": "_1eeeed880cb5769d__is-medium", "is-large": "_99f900b2267e22d0__is-large", "is-stretch": "b49f7ff9c06fe387__is-stretch", "is-full": "dcd4c2f5036cbf1a__is-full", "header": "_76fb3b28fcbd45fc__header f1c50237c4787636__header", "footer": "_00eeb4f220cddae3__footer _579f95efdec92a66__footer", "title": "f636832002af749e__title _5371cc08aad82574__title", "content": "_101038da9af7162f__content _766d9011d37ce2d9__content", "description": "d9d6da914ef0a77c__description" };
13513 var Description = (0, import_element37.forwardRef)(
13514 function DialogDescription3({ children, ...props }, ref) {
13515 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13516 Text,
13517 {
13518 ref,
13519 variant: "body-md",
13520 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(index_parts_exports2.Description, { ...props }),
13521 className: style_default13.description,
13522 children
13523 }
13524 );
13525 }
13526 );
13527
13528 // packages/ui/build-module/dialog/footer.mjs
13529 var import_element38 = __toESM(require_element(), 1);
13530 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
13531 function getRuntime14() {
13532 const globalScope = globalThis;
13533 if (globalScope.__wpStyleRuntime) {
13534 return globalScope.__wpStyleRuntime;
13535 }
13536 globalScope.__wpStyleRuntime = {
13537 documents: /* @__PURE__ */ new Map(),
13538 styles: /* @__PURE__ */ new Map(),
13539 injectedStyles: /* @__PURE__ */ new WeakMap()
13540 };
13541 if (typeof document !== "undefined") {
13542 registerDocument14(document);
13543 }
13544 return globalScope.__wpStyleRuntime;
13545 }
13546 function documentContainsStyleHash14(targetDocument, hash) {
13547 if (!targetDocument.head) {
13548 return false;
13549 }
13550 for (const style of targetDocument.head.querySelectorAll(
13551 `style[${STYLE_HASH_ATTRIBUTE14}]`
13552 )) {
13553 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
13554 return true;
13555 }
13556 }
13557 return false;
13558 }
13559 function injectStyle14(targetDocument, hash, css) {
13560 if (!targetDocument.head) {
13561 return;
13562 }
13563 const runtime = getRuntime14();
13564 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13565 if (!injectedStyles) {
13566 injectedStyles = /* @__PURE__ */ new Set();
13567 runtime.injectedStyles.set(targetDocument, injectedStyles);
13568 }
13569 if (injectedStyles.has(hash)) {
13570 return;
13571 }
13572 if (documentContainsStyleHash14(targetDocument, hash)) {
13573 injectedStyles.add(hash);
13574 return;
13575 }
13576 const style = targetDocument.createElement("style");
13577 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
13578 style.appendChild(targetDocument.createTextNode(css));
13579 targetDocument.head.appendChild(style);
13580 injectedStyles.add(hash);
13581 }
13582 function registerDocument14(targetDocument) {
13583 const runtime = getRuntime14();
13584 runtime.documents.set(
13585 targetDocument,
13586 (runtime.documents.get(targetDocument) ?? 0) + 1
13587 );
13588 for (const [hash, css] of runtime.styles) {
13589 injectStyle14(targetDocument, hash, css);
13590 }
13591 return () => {
13592 const count = runtime.documents.get(targetDocument);
13593 if (count === void 0) {
13594 return;
13595 }
13596 if (count <= 1) {
13597 runtime.documents.delete(targetDocument);
13598 return;
13599 }
13600 runtime.documents.set(targetDocument, count - 1);
13601 };
13602 }
13603 function registerStyle14(hash, css) {
13604 const runtime = getRuntime14();
13605 runtime.styles.set(hash, css);
13606 for (const targetDocument of runtime.documents.keys()) {
13607 injectStyle14(targetDocument, hash, css);
13608 }
13609 }
13610 if (typeof process === "undefined" || true) {
13611 registerStyle14("a400076f01", '@layer wp-ui-components{.f1c50237c4787636__header{min-height:32px;padding-block:var(--wpds-dimension-padding-2xl,24px) var(--wpds-dimension-gap-lg,16px)}._579f95efdec92a66__footer,.f1c50237c4787636__header{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}._579f95efdec92a66__footer{justify-content:flex-end;padding-block:var(--wpds-dimension-gap-lg,16px) var(--wpds-dimension-padding-2xl,24px)}._5371cc08aad82574__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--_gcd-heading-margin:0 auto 0 0;color:var(--wpds-color-fg-content-neutral,#1e1e1e);margin-inline-end:auto;&:dir(rtl){--_gcd-heading-margin:0 0 0 auto}}._766d9011d37ce2d9__content{flex:1 1 auto;min-block-size:0;overflow-block:auto;overflow-inline:hidden;padding:var(--wpds-dimension-padding-2xl,24px);&:focus-visible{outline-offset:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*-1)}}.f1c50237c4787636__header:has(~._766d9011d37ce2d9__content){border-block-end:1px solid #0000;padding-block-end:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}.f1c50237c4787636__header~._766d9011d37ce2d9__content{padding-block-start:0}._766d9011d37ce2d9__content~._579f95efdec92a66__footer{border-block-start:1px solid #0000;padding-block-start:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}._766d9011d37ce2d9__content:has(~._579f95efdec92a66__footer){padding-block-end:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header{padding-inline:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header:first-child,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header:first-child{padding-block-start:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer{padding-inline:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer:last-child,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer:last-child{padding-block-end:0}.f1c50237c4787636__header:has(~[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-top]){border-block-end-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-bottom]~._579f95efdec92a66__footer{border-block-start-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-modal] [data-wp-ui-overlay-scroll-container]{overscroll-behavior:contain}}@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}._8acaa98861620d4d__popup{--viewport-inset:var(--wpds-dimension-padding-2xl,24px);background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);left:50%;line-height:var(--wpds-typography-line-height-md,24px);max-height:calc(100dvh - var(--viewport-inset)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:hidden;position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--viewport-inset)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)),transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1))}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100dvh}}._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup{border-color:#0000}@media (forced-colors:active){._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup,._8acaa98861620d4d__popup{border-color:CanvasText}}._76fb3b28fcbd45fc__header [data-wp-ui-dialog-close-icon]{margin-inline-start:auto}.d9d6da914ef0a77c__description{margin-bottom:var(--wpds-dimension-gap-lg,16px)}}');
13612 }
13613 var style_default14 = { "backdrop": "_074affe4c56b4f2f__backdrop", "popup": "_8acaa98861620d4d__popup", "is-small": "_7acfa67ebf092988__is-small", "is-medium": "_1eeeed880cb5769d__is-medium", "is-large": "_99f900b2267e22d0__is-large", "is-stretch": "b49f7ff9c06fe387__is-stretch", "is-full": "dcd4c2f5036cbf1a__is-full", "header": "_76fb3b28fcbd45fc__header f1c50237c4787636__header", "footer": "_00eeb4f220cddae3__footer _579f95efdec92a66__footer", "title": "f636832002af749e__title _5371cc08aad82574__title", "content": "_101038da9af7162f__content _766d9011d37ce2d9__content", "description": "d9d6da914ef0a77c__description" };
13614 var Footer = (0, import_element38.forwardRef)(function DialogFooter({ className, render: render4, ...props }, ref) {
13615 const element = useRender({
13616 defaultTagName: "footer",
13617 render: render4,
13618 ref,
13619 props: mergeProps(props, {
13620 className: clsx_default(style_default14.footer, className)
13621 })
13622 });
13623 return element;
13624 });
13625
13626 // packages/ui/build-module/dialog/header.mjs
13627 var import_element39 = __toESM(require_element(), 1);
13628 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash";
13629 function getRuntime15() {
13630 const globalScope = globalThis;
13631 if (globalScope.__wpStyleRuntime) {
13632 return globalScope.__wpStyleRuntime;
13633 }
13634 globalScope.__wpStyleRuntime = {
13635 documents: /* @__PURE__ */ new Map(),
13636 styles: /* @__PURE__ */ new Map(),
13637 injectedStyles: /* @__PURE__ */ new WeakMap()
13638 };
13639 if (typeof document !== "undefined") {
13640 registerDocument15(document);
13641 }
13642 return globalScope.__wpStyleRuntime;
13643 }
13644 function documentContainsStyleHash15(targetDocument, hash) {
13645 if (!targetDocument.head) {
13646 return false;
13647 }
13648 for (const style of targetDocument.head.querySelectorAll(
13649 `style[${STYLE_HASH_ATTRIBUTE15}]`
13650 )) {
13651 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) {
13652 return true;
13653 }
13654 }
13655 return false;
13656 }
13657 function injectStyle15(targetDocument, hash, css) {
13658 if (!targetDocument.head) {
13659 return;
13660 }
13661 const runtime = getRuntime15();
13662 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13663 if (!injectedStyles) {
13664 injectedStyles = /* @__PURE__ */ new Set();
13665 runtime.injectedStyles.set(targetDocument, injectedStyles);
13666 }
13667 if (injectedStyles.has(hash)) {
13668 return;
13669 }
13670 if (documentContainsStyleHash15(targetDocument, hash)) {
13671 injectedStyles.add(hash);
13672 return;
13673 }
13674 const style = targetDocument.createElement("style");
13675 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash);
13676 style.appendChild(targetDocument.createTextNode(css));
13677 targetDocument.head.appendChild(style);
13678 injectedStyles.add(hash);
13679 }
13680 function registerDocument15(targetDocument) {
13681 const runtime = getRuntime15();
13682 runtime.documents.set(
13683 targetDocument,
13684 (runtime.documents.get(targetDocument) ?? 0) + 1
13685 );
13686 for (const [hash, css] of runtime.styles) {
13687 injectStyle15(targetDocument, hash, css);
13688 }
13689 return () => {
13690 const count = runtime.documents.get(targetDocument);
13691 if (count === void 0) {
13692 return;
13693 }
13694 if (count <= 1) {
13695 runtime.documents.delete(targetDocument);
13696 return;
13697 }
13698 runtime.documents.set(targetDocument, count - 1);
13699 };
13700 }
13701 function registerStyle15(hash, css) {
13702 const runtime = getRuntime15();
13703 runtime.styles.set(hash, css);
13704 for (const targetDocument of runtime.documents.keys()) {
13705 injectStyle15(targetDocument, hash, css);
13706 }
13707 }
13708 if (typeof process === "undefined" || true) {
13709 registerStyle15("a400076f01", '@layer wp-ui-components{.f1c50237c4787636__header{min-height:32px;padding-block:var(--wpds-dimension-padding-2xl,24px) var(--wpds-dimension-gap-lg,16px)}._579f95efdec92a66__footer,.f1c50237c4787636__header{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}._579f95efdec92a66__footer{justify-content:flex-end;padding-block:var(--wpds-dimension-gap-lg,16px) var(--wpds-dimension-padding-2xl,24px)}._5371cc08aad82574__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--_gcd-heading-margin:0 auto 0 0;color:var(--wpds-color-fg-content-neutral,#1e1e1e);margin-inline-end:auto;&:dir(rtl){--_gcd-heading-margin:0 0 0 auto}}._766d9011d37ce2d9__content{flex:1 1 auto;min-block-size:0;overflow-block:auto;overflow-inline:hidden;padding:var(--wpds-dimension-padding-2xl,24px);&:focus-visible{outline-offset:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*-1)}}.f1c50237c4787636__header:has(~._766d9011d37ce2d9__content){border-block-end:1px solid #0000;padding-block-end:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}.f1c50237c4787636__header~._766d9011d37ce2d9__content{padding-block-start:0}._766d9011d37ce2d9__content~._579f95efdec92a66__footer{border-block-start:1px solid #0000;padding-block-start:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}._766d9011d37ce2d9__content:has(~._579f95efdec92a66__footer){padding-block-end:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header{padding-inline:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header:first-child,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header:first-child{padding-block-start:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer{padding-inline:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer:last-child,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer:last-child{padding-block-end:0}.f1c50237c4787636__header:has(~[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-top]){border-block-end-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-bottom]~._579f95efdec92a66__footer{border-block-start-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-modal] [data-wp-ui-overlay-scroll-container]{overscroll-behavior:contain}}@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}._8acaa98861620d4d__popup{--viewport-inset:var(--wpds-dimension-padding-2xl,24px);background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);left:50%;line-height:var(--wpds-typography-line-height-md,24px);max-height:calc(100dvh - var(--viewport-inset)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:hidden;position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--viewport-inset)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)),transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1))}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100dvh}}._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup{border-color:#0000}@media (forced-colors:active){._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup,._8acaa98861620d4d__popup{border-color:CanvasText}}._76fb3b28fcbd45fc__header [data-wp-ui-dialog-close-icon]{margin-inline-start:auto}.d9d6da914ef0a77c__description{margin-bottom:var(--wpds-dimension-gap-lg,16px)}}');
13710 }
13711 var style_default15 = { "backdrop": "_074affe4c56b4f2f__backdrop", "popup": "_8acaa98861620d4d__popup", "is-small": "_7acfa67ebf092988__is-small", "is-medium": "_1eeeed880cb5769d__is-medium", "is-large": "_99f900b2267e22d0__is-large", "is-stretch": "b49f7ff9c06fe387__is-stretch", "is-full": "dcd4c2f5036cbf1a__is-full", "header": "_76fb3b28fcbd45fc__header f1c50237c4787636__header", "footer": "_00eeb4f220cddae3__footer _579f95efdec92a66__footer", "title": "f636832002af749e__title _5371cc08aad82574__title", "content": "_101038da9af7162f__content _766d9011d37ce2d9__content", "description": "d9d6da914ef0a77c__description" };
13712 var Header2 = (0, import_element39.forwardRef)(function DialogHeader({ className, render: render4, ...props }, ref) {
13713 const element = useRender({
13714 defaultTagName: "header",
13715 render: render4,
13716 ref,
13717 props: mergeProps(props, {
13718 className: clsx_default(style_default15.header, className)
13719 })
13720 });
13721 return element;
13722 });
13723
13724 // packages/ui/build-module/dialog/popup.mjs
13725 var import_element44 = __toESM(require_element(), 1);
13726 var import_compose3 = __toESM(require_compose(), 1);
13727 var import_theme3 = __toESM(require_theme(), 1);
13728
13729 // packages/ui/build-module/utils/create-overlay-modal-context.mjs
13730 var import_element40 = __toESM(require_element(), 1);
13731 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13732 function createOverlayModalContext(initialValue) {
13733 const OverlayModalContext = (0, import_element40.createContext)(initialValue);
13734 function OverlayModalProvider({
13735 modal,
13736 children
13737 }) {
13738 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(OverlayModalContext.Provider, { value: modal, children });
13739 }
13740 function useOverlayModal() {
13741 return (0, import_element40.useContext)(OverlayModalContext);
13742 }
13743 return {
13744 Provider: OverlayModalProvider,
13745 useModal: useOverlayModal
13746 };
13747 }
13748
13749 // packages/ui/build-module/utils/create-overlay-title-validation.mjs
13750 var import_element42 = __toESM(require_element(), 1);
13751
13752 // packages/ui/build-module/utils/use-schedule-validation.mjs
13753 var import_element41 = __toESM(require_element(), 1);
13754 function useScheduleValidation(validate) {
13755 const validateRef = (0, import_element41.useRef)(validate);
13756 validateRef.current = validate;
13757 const timerRef = (0, import_element41.useRef)(null);
13758 const unmountedRef = (0, import_element41.useRef)(false);
13759 const scheduleValidation = (0, import_element41.useCallback)(() => {
13760 if (unmountedRef.current) {
13761 return;
13762 }
13763 if (timerRef.current) {
13764 clearTimeout(timerRef.current);
13765 }
13766 timerRef.current = setTimeout(() => {
13767 validateRef.current();
13768 timerRef.current = null;
13769 }, 0);
13770 }, []);
13771 (0, import_element41.useEffect)(() => {
13772 unmountedRef.current = false;
13773 return () => {
13774 unmountedRef.current = true;
13775 if (timerRef.current) {
13776 clearTimeout(timerRef.current);
13777 }
13778 };
13779 }, []);
13780 return scheduleValidation;
13781 }
13782
13783 // packages/ui/build-module/utils/create-overlay-title-validation.mjs
13784 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13785 var VALIDATION_ENABLED = true;
13786 function createOverlayTitleValidation(componentName) {
13787 const componentNameLowerCase = componentName.toLowerCase();
13788 const OverlayValidationContext = VALIDATION_ENABLED ? (0, import_element42.createContext)(null) : null;
13789 function useValidationContextDev() {
13790 return (0, import_element42.useContext)(OverlayValidationContext);
13791 }
13792 function useValidationContextProd() {
13793 return null;
13794 }
13795 const useValidationContext = VALIDATION_ENABLED ? useValidationContextDev : useValidationContextProd;
13796 function ValidationProviderDev({
13797 children
13798 }) {
13799 const titleElementRef = (0, import_element42.useRef)(null);
13800 const scheduleValidation = useScheduleValidation(() => {
13801 const titleElement = titleElementRef.current;
13802 if (!titleElement) {
13803 throw new Error(
13804 `${componentName}: Missing <${componentName}.Title>. For accessibility, every ${componentNameLowerCase} requires a title. If needed, the title can be visually hidden but must not be omitted.`
13805 );
13806 }
13807 const textContent = titleElement.textContent?.trim();
13808 if (!textContent) {
13809 throw new Error(
13810 `${componentName}: <${componentName}.Title> cannot be empty. Provide meaningful text content for the ${componentNameLowerCase} title.`
13811 );
13812 }
13813 });
13814 const registerTitle = (0, import_element42.useCallback)(
13815 (element) => {
13816 titleElementRef.current = element;
13817 scheduleValidation();
13818 return () => {
13819 titleElementRef.current = null;
13820 scheduleValidation();
13821 };
13822 },
13823 [scheduleValidation]
13824 );
13825 const contextValue = (0, import_element42.useMemo)(
13826 () => ({ registerTitle }),
13827 [registerTitle]
13828 );
13829 (0, import_element42.useEffect)(() => {
13830 scheduleValidation();
13831 }, [scheduleValidation]);
13832 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(OverlayValidationContext.Provider, { value: contextValue, children });
13833 }
13834 function ValidationProviderProd({
13835 children
13836 }) {
13837 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_jsx_runtime64.Fragment, { children });
13838 }
13839 const ValidationProvider = VALIDATION_ENABLED ? ValidationProviderDev : ValidationProviderProd;
13840 return {
13841 ValidationProvider,
13842 useValidationContext
13843 };
13844 }
13845
13846 // packages/ui/build-module/dialog/context.mjs
13847 var dialogModal = createOverlayModalContext(true);
13848 var DialogModalProvider = dialogModal.Provider;
13849 var useDialogModal = dialogModal.useModal;
13850 var dialogTitleValidation = createOverlayTitleValidation("Dialog");
13851 var useDialogValidationContext = dialogTitleValidation.useValidationContext;
13852 var DialogValidationProvider = dialogTitleValidation.ValidationProvider;
13853
13854 // packages/ui/build-module/dialog/portal.mjs
13855 var import_element43 = __toESM(require_element(), 1);
13856 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13857 var Portal3 = (0, import_element43.forwardRef)(
13858 function DialogPortal3(props, ref) {
13859 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(index_parts_exports2.Portal, { ref, ...props });
13860 }
13861 );
13862
13863 // packages/ui/build-module/dialog/popup.mjs
13864 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13865 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash";
13866 function getRuntime16() {
13867 const globalScope = globalThis;
13868 if (globalScope.__wpStyleRuntime) {
13869 return globalScope.__wpStyleRuntime;
13870 }
13871 globalScope.__wpStyleRuntime = {
13872 documents: /* @__PURE__ */ new Map(),
13873 styles: /* @__PURE__ */ new Map(),
13874 injectedStyles: /* @__PURE__ */ new WeakMap()
13875 };
13876 if (typeof document !== "undefined") {
13877 registerDocument16(document);
13878 }
13879 return globalScope.__wpStyleRuntime;
13880 }
13881 function documentContainsStyleHash16(targetDocument, hash) {
13882 if (!targetDocument.head) {
13883 return false;
13884 }
13885 for (const style of targetDocument.head.querySelectorAll(
13886 `style[${STYLE_HASH_ATTRIBUTE16}]`
13887 )) {
13888 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) {
13889 return true;
13890 }
13891 }
13892 return false;
13893 }
13894 function injectStyle16(targetDocument, hash, css) {
13895 if (!targetDocument.head) {
13896 return;
13897 }
13898 const runtime = getRuntime16();
13899 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13900 if (!injectedStyles) {
13901 injectedStyles = /* @__PURE__ */ new Set();
13902 runtime.injectedStyles.set(targetDocument, injectedStyles);
13903 }
13904 if (injectedStyles.has(hash)) {
13905 return;
13906 }
13907 if (documentContainsStyleHash16(targetDocument, hash)) {
13908 injectedStyles.add(hash);
13909 return;
13910 }
13911 const style = targetDocument.createElement("style");
13912 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash);
13913 style.appendChild(targetDocument.createTextNode(css));
13914 targetDocument.head.appendChild(style);
13915 injectedStyles.add(hash);
13916 }
13917 function registerDocument16(targetDocument) {
13918 const runtime = getRuntime16();
13919 runtime.documents.set(
13920 targetDocument,
13921 (runtime.documents.get(targetDocument) ?? 0) + 1
13922 );
13923 for (const [hash, css] of runtime.styles) {
13924 injectStyle16(targetDocument, hash, css);
13925 }
13926 return () => {
13927 const count = runtime.documents.get(targetDocument);
13928 if (count === void 0) {
13929 return;
13930 }
13931 if (count <= 1) {
13932 runtime.documents.delete(targetDocument);
13933 return;
13934 }
13935 runtime.documents.set(targetDocument, count - 1);
13936 };
13937 }
13938 function registerStyle16(hash, css) {
13939 const runtime = getRuntime16();
13940 runtime.styles.set(hash, css);
13941 for (const targetDocument of runtime.documents.keys()) {
13942 injectStyle16(targetDocument, hash, css);
13943 }
13944 }
13945 if (typeof process === "undefined" || true) {
13946 registerStyle16("a400076f01", '@layer wp-ui-components{.f1c50237c4787636__header{min-height:32px;padding-block:var(--wpds-dimension-padding-2xl,24px) var(--wpds-dimension-gap-lg,16px)}._579f95efdec92a66__footer,.f1c50237c4787636__header{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}._579f95efdec92a66__footer{justify-content:flex-end;padding-block:var(--wpds-dimension-gap-lg,16px) var(--wpds-dimension-padding-2xl,24px)}._5371cc08aad82574__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--_gcd-heading-margin:0 auto 0 0;color:var(--wpds-color-fg-content-neutral,#1e1e1e);margin-inline-end:auto;&:dir(rtl){--_gcd-heading-margin:0 0 0 auto}}._766d9011d37ce2d9__content{flex:1 1 auto;min-block-size:0;overflow-block:auto;overflow-inline:hidden;padding:var(--wpds-dimension-padding-2xl,24px);&:focus-visible{outline-offset:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*-1)}}.f1c50237c4787636__header:has(~._766d9011d37ce2d9__content){border-block-end:1px solid #0000;padding-block-end:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}.f1c50237c4787636__header~._766d9011d37ce2d9__content{padding-block-start:0}._766d9011d37ce2d9__content~._579f95efdec92a66__footer{border-block-start:1px solid #0000;padding-block-start:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}._766d9011d37ce2d9__content:has(~._579f95efdec92a66__footer){padding-block-end:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header{padding-inline:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header:first-child,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header:first-child{padding-block-start:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer{padding-inline:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer:last-child,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer:last-child{padding-block-end:0}.f1c50237c4787636__header:has(~[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-top]){border-block-end-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-bottom]~._579f95efdec92a66__footer{border-block-start-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-modal] [data-wp-ui-overlay-scroll-container]{overscroll-behavior:contain}}@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}._8acaa98861620d4d__popup{--viewport-inset:var(--wpds-dimension-padding-2xl,24px);background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);left:50%;line-height:var(--wpds-typography-line-height-md,24px);max-height:calc(100dvh - var(--viewport-inset)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:hidden;position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--viewport-inset)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)),transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1))}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100dvh}}._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup{border-color:#0000}@media (forced-colors:active){._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup,._8acaa98861620d4d__popup{border-color:CanvasText}}._76fb3b28fcbd45fc__header [data-wp-ui-dialog-close-icon]{margin-inline-start:auto}.d9d6da914ef0a77c__description{margin-bottom:var(--wpds-dimension-gap-lg,16px)}}');
13947 }
13948 var style_default16 = { "backdrop": "_074affe4c56b4f2f__backdrop", "popup": "_8acaa98861620d4d__popup", "is-small": "_7acfa67ebf092988__is-small", "is-medium": "_1eeeed880cb5769d__is-medium", "is-large": "_99f900b2267e22d0__is-large", "is-stretch": "b49f7ff9c06fe387__is-stretch", "is-full": "dcd4c2f5036cbf1a__is-full", "header": "_76fb3b28fcbd45fc__header f1c50237c4787636__header", "footer": "_00eeb4f220cddae3__footer _579f95efdec92a66__footer", "title": "f636832002af749e__title _5371cc08aad82574__title", "content": "_101038da9af7162f__content _766d9011d37ce2d9__content", "description": "d9d6da914ef0a77c__description" };
13949 var ThemeProvider3 = unlock(import_theme3.privateApis).ThemeProvider;
13950 var CLOSE_ICON_ATTR = "data-wp-ui-dialog-close-icon";
13951 var Popup3 = (0, import_element44.forwardRef)(function DialogPopup3({
13952 className,
13953 portal,
13954 children,
13955 size: size4 = "medium",
13956 initialFocus,
13957 finalFocus,
13958 ...props
13959 }, ref) {
13960 const { resolvedInitialFocus, popupRef } = useDeprioritizedInitialFocus({
13961 initialFocus,
13962 deprioritizedAttributes: [CLOSE_ICON_ATTR, SCROLL_CONTAINER_ATTR]
13963 });
13964 const mergedRef = (0, import_compose3.useMergeRefs)([ref, popupRef]);
13965 const modal = useDialogModal();
13966 const portalChildren = /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13967 modal === true && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13968 index_parts_exports2.Backdrop,
13969 {
13970 className: style_default16.backdrop,
13971 "data-testid": "dialog-backdrop"
13972 }
13973 ),
13974 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ThemeProvider3, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13975 index_parts_exports2.Popup,
13976 {
13977 ref: mergedRef,
13978 className: clsx_default(
13979 style_default16.popup,
13980 className,
13981 style_default16[`is-${size4}`]
13982 ),
13983 initialFocus: resolvedInitialFocus,
13984 finalFocus,
13985 ...props,
13986 "data-wp-ui-overlay-modal": modal === true ? "" : void 0,
13987 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DialogValidationProvider, { children })
13988 }
13989 ) })
13990 ] });
13991 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Portal3, {}), portalChildren);
13992 });
13993
13994 // packages/ui/build-module/dialog/root.mjs
13995 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
13996 function Root4({ modal = true, children, ...props }) {
13997 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(index_parts_exports2.Root, { modal, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DialogModalProvider, { modal, children }) });
13998 }
13999
14000 // packages/ui/build-module/dialog/title.mjs
14001 var import_compose4 = __toESM(require_compose(), 1);
14002 var import_element45 = __toESM(require_element(), 1);
14003 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14004 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash";
14005 function getRuntime17() {
14006 const globalScope = globalThis;
14007 if (globalScope.__wpStyleRuntime) {
14008 return globalScope.__wpStyleRuntime;
14009 }
14010 globalScope.__wpStyleRuntime = {
14011 documents: /* @__PURE__ */ new Map(),
14012 styles: /* @__PURE__ */ new Map(),
14013 injectedStyles: /* @__PURE__ */ new WeakMap()
14014 };
14015 if (typeof document !== "undefined") {
14016 registerDocument17(document);
14017 }
14018 return globalScope.__wpStyleRuntime;
14019 }
14020 function documentContainsStyleHash17(targetDocument, hash) {
14021 if (!targetDocument.head) {
14022 return false;
14023 }
14024 for (const style of targetDocument.head.querySelectorAll(
14025 `style[${STYLE_HASH_ATTRIBUTE17}]`
14026 )) {
14027 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) {
14028 return true;
14029 }
14030 }
14031 return false;
14032 }
14033 function injectStyle17(targetDocument, hash, css) {
14034 if (!targetDocument.head) {
14035 return;
14036 }
14037 const runtime = getRuntime17();
14038 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14039 if (!injectedStyles) {
14040 injectedStyles = /* @__PURE__ */ new Set();
14041 runtime.injectedStyles.set(targetDocument, injectedStyles);
14042 }
14043 if (injectedStyles.has(hash)) {
14044 return;
14045 }
14046 if (documentContainsStyleHash17(targetDocument, hash)) {
14047 injectedStyles.add(hash);
14048 return;
14049 }
14050 const style = targetDocument.createElement("style");
14051 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash);
14052 style.appendChild(targetDocument.createTextNode(css));
14053 targetDocument.head.appendChild(style);
14054 injectedStyles.add(hash);
14055 }
14056 function registerDocument17(targetDocument) {
14057 const runtime = getRuntime17();
14058 runtime.documents.set(
14059 targetDocument,
14060 (runtime.documents.get(targetDocument) ?? 0) + 1
14061 );
14062 for (const [hash, css] of runtime.styles) {
14063 injectStyle17(targetDocument, hash, css);
14064 }
14065 return () => {
14066 const count = runtime.documents.get(targetDocument);
14067 if (count === void 0) {
14068 return;
14069 }
14070 if (count <= 1) {
14071 runtime.documents.delete(targetDocument);
14072 return;
14073 }
14074 runtime.documents.set(targetDocument, count - 1);
14075 };
14076 }
14077 function registerStyle17(hash, css) {
14078 const runtime = getRuntime17();
14079 runtime.styles.set(hash, css);
14080 for (const targetDocument of runtime.documents.keys()) {
14081 injectStyle17(targetDocument, hash, css);
14082 }
14083 }
14084 if (typeof process === "undefined" || true) {
14085 registerStyle17("a400076f01", '@layer wp-ui-components{.f1c50237c4787636__header{min-height:32px;padding-block:var(--wpds-dimension-padding-2xl,24px) var(--wpds-dimension-gap-lg,16px)}._579f95efdec92a66__footer,.f1c50237c4787636__header{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}._579f95efdec92a66__footer{justify-content:flex-end;padding-block:var(--wpds-dimension-gap-lg,16px) var(--wpds-dimension-padding-2xl,24px)}._5371cc08aad82574__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--_gcd-heading-margin:0 auto 0 0;color:var(--wpds-color-fg-content-neutral,#1e1e1e);margin-inline-end:auto;&:dir(rtl){--_gcd-heading-margin:0 0 0 auto}}._766d9011d37ce2d9__content{flex:1 1 auto;min-block-size:0;overflow-block:auto;overflow-inline:hidden;padding:var(--wpds-dimension-padding-2xl,24px);&:focus-visible{outline-offset:calc(var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px))*-1)}}.f1c50237c4787636__header:has(~._766d9011d37ce2d9__content){border-block-end:1px solid #0000;padding-block-end:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}.f1c50237c4787636__header~._766d9011d37ce2d9__content{padding-block-start:0}._766d9011d37ce2d9__content~._579f95efdec92a66__footer{border-block-start:1px solid #0000;padding-block-start:calc(var(--wpds-dimension-gap-lg, 16px) - 1px)}._766d9011d37ce2d9__content:has(~._579f95efdec92a66__footer){padding-block-end:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header{padding-inline:0}._766d9011d37ce2d9__content>.f1c50237c4787636__header:first-child,._766d9011d37ce2d9__content>[data-drawer-content]>.f1c50237c4787636__header:first-child{padding-block-start:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer{padding-inline:0}._766d9011d37ce2d9__content>._579f95efdec92a66__footer:last-child,._766d9011d37ce2d9__content>[data-drawer-content]>._579f95efdec92a66__footer:last-child{padding-block-end:0}.f1c50237c4787636__header:has(~[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-top]){border-block-end-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-scroll-container][data-wp-ui-overlay-scrolled-from-bottom]~._579f95efdec92a66__footer{border-block-start-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}[data-wp-ui-overlay-modal] [data-wp-ui-overlay-scroll-container]{overscroll-behavior:contain}}@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}._8acaa98861620d4d__popup{--viewport-inset:var(--wpds-dimension-padding-2xl,24px);background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-md,13px);left:50%;line-height:var(--wpds-typography-line-height-md,24px);max-height:calc(100dvh - var(--viewport-inset)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:hidden;position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--viewport-inset)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)),transform var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1))}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100dvh}}._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup{border-color:#0000}@media (forced-colors:active){._074affe4c56b4f2f__backdrop~* ._8acaa98861620d4d__popup,._8acaa98861620d4d__popup{border-color:CanvasText}}._76fb3b28fcbd45fc__header [data-wp-ui-dialog-close-icon]{margin-inline-start:auto}.d9d6da914ef0a77c__description{margin-bottom:var(--wpds-dimension-gap-lg,16px)}}');
14086 }
14087 var style_default17 = { "backdrop": "_074affe4c56b4f2f__backdrop", "popup": "_8acaa98861620d4d__popup", "is-small": "_7acfa67ebf092988__is-small", "is-medium": "_1eeeed880cb5769d__is-medium", "is-large": "_99f900b2267e22d0__is-large", "is-stretch": "b49f7ff9c06fe387__is-stretch", "is-full": "dcd4c2f5036cbf1a__is-full", "header": "_76fb3b28fcbd45fc__header f1c50237c4787636__header", "footer": "_00eeb4f220cddae3__footer _579f95efdec92a66__footer", "title": "f636832002af749e__title _5371cc08aad82574__title", "content": "_101038da9af7162f__content _766d9011d37ce2d9__content", "description": "d9d6da914ef0a77c__description" };
14088 var Title2 = (0, import_element45.forwardRef)(
14089 function DialogTitle3({ children, ...props }, forwardedRef) {
14090 const validationContext = useDialogValidationContext();
14091 const internalRef = (0, import_element45.useRef)(null);
14092 const mergedRef = (0, import_compose4.useMergeRefs)([internalRef, forwardedRef]);
14093 (0, import_element45.useEffect)(() => {
14094 if (validationContext) {
14095 return validationContext.registerTitle(internalRef.current);
14096 }
14097 return void 0;
14098 }, [validationContext]);
14099 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14100 Text,
14101 {
14102 ref: mergedRef,
14103 variant: "heading-xl",
14104 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(index_parts_exports2.Title, { ...props }),
14105 className: style_default17.title,
14106 children
14107 }
14108 );
14109 }
14110 );
14111
14112 // packages/ui/build-module/dialog/trigger.mjs
14113 var import_element46 = __toESM(require_element(), 1);
14114 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14115 var Trigger3 = (0, import_element46.forwardRef)(
14116 function DialogTrigger3(props, ref) {
14117 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(index_parts_exports2.Trigger, { ref, ...props });
14118 }
14119 );
14120
14121 // packages/ui/build-module/empty-state/index.mjs
14122 var empty_state_exports = {};
14123 __export(empty_state_exports, {
14124 Actions: () => Actions,
14125 Description: () => Description2,
14126 Icon: () => Icon3,
14127 Root: () => Root5,
14128 Title: () => Title3,
14129 Visual: () => Visual
14130 });
14131
14132 // packages/ui/build-module/empty-state/root.mjs
14133 var import_element47 = __toESM(require_element(), 1);
14134 var STYLE_HASH_ATTRIBUTE18 = "data-wp-hash";
14135 function getRuntime18() {
14136 const globalScope = globalThis;
14137 if (globalScope.__wpStyleRuntime) {
14138 return globalScope.__wpStyleRuntime;
14139 }
14140 globalScope.__wpStyleRuntime = {
14141 documents: /* @__PURE__ */ new Map(),
14142 styles: /* @__PURE__ */ new Map(),
14143 injectedStyles: /* @__PURE__ */ new WeakMap()
14144 };
14145 if (typeof document !== "undefined") {
14146 registerDocument18(document);
14147 }
14148 return globalScope.__wpStyleRuntime;
14149 }
14150 function documentContainsStyleHash18(targetDocument, hash) {
14151 if (!targetDocument.head) {
14152 return false;
14153 }
14154 for (const style of targetDocument.head.querySelectorAll(
14155 `style[${STYLE_HASH_ATTRIBUTE18}]`
14156 )) {
14157 if (style.getAttribute(STYLE_HASH_ATTRIBUTE18) === hash) {
14158 return true;
14159 }
14160 }
14161 return false;
14162 }
14163 function injectStyle18(targetDocument, hash, css) {
14164 if (!targetDocument.head) {
14165 return;
14166 }
14167 const runtime = getRuntime18();
14168 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14169 if (!injectedStyles) {
14170 injectedStyles = /* @__PURE__ */ new Set();
14171 runtime.injectedStyles.set(targetDocument, injectedStyles);
14172 }
14173 if (injectedStyles.has(hash)) {
14174 return;
14175 }
14176 if (documentContainsStyleHash18(targetDocument, hash)) {
14177 injectedStyles.add(hash);
14178 return;
14179 }
14180 const style = targetDocument.createElement("style");
14181 style.setAttribute(STYLE_HASH_ATTRIBUTE18, hash);
14182 style.appendChild(targetDocument.createTextNode(css));
14183 targetDocument.head.appendChild(style);
14184 injectedStyles.add(hash);
14185 }
14186 function registerDocument18(targetDocument) {
14187 const runtime = getRuntime18();
14188 runtime.documents.set(
14189 targetDocument,
14190 (runtime.documents.get(targetDocument) ?? 0) + 1
14191 );
14192 for (const [hash, css] of runtime.styles) {
14193 injectStyle18(targetDocument, hash, css);
14194 }
14195 return () => {
14196 const count = runtime.documents.get(targetDocument);
14197 if (count === void 0) {
14198 return;
14199 }
14200 if (count <= 1) {
14201 runtime.documents.delete(targetDocument);
14202 return;
14203 }
14204 runtime.documents.set(targetDocument, count - 1);
14205 };
14206 }
14207 function registerStyle18(hash, css) {
14208 const runtime = getRuntime18();
14209 runtime.styles.set(hash, css);
14210 for (const targetDocument of runtime.documents.keys()) {
14211 injectStyle18(targetDocument, hash, css);
14212 }
14213 }
14214 if (typeof process === "undefined" || true) {
14215 registerStyle18("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
14216 }
14217 var style_default18 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
14218 var Root5 = (0, import_element47.forwardRef)(
14219 function EmptyStateRoot({ render: render4, ...props }, ref) {
14220 const className = clsx_default(style_default18.root);
14221 const element = useRender({
14222 defaultTagName: "div",
14223 render: render4,
14224 ref,
14225 props: mergeProps({ className }, props)
14226 });
14227 return element;
14228 }
14229 );
14230
14231 // packages/ui/build-module/empty-state/visual.mjs
14232 var import_element48 = __toESM(require_element(), 1);
14233 var STYLE_HASH_ATTRIBUTE19 = "data-wp-hash";
14234 function getRuntime19() {
14235 const globalScope = globalThis;
14236 if (globalScope.__wpStyleRuntime) {
14237 return globalScope.__wpStyleRuntime;
14238 }
14239 globalScope.__wpStyleRuntime = {
14240 documents: /* @__PURE__ */ new Map(),
14241 styles: /* @__PURE__ */ new Map(),
14242 injectedStyles: /* @__PURE__ */ new WeakMap()
14243 };
14244 if (typeof document !== "undefined") {
14245 registerDocument19(document);
14246 }
14247 return globalScope.__wpStyleRuntime;
14248 }
14249 function documentContainsStyleHash19(targetDocument, hash) {
14250 if (!targetDocument.head) {
14251 return false;
14252 }
14253 for (const style of targetDocument.head.querySelectorAll(
14254 `style[${STYLE_HASH_ATTRIBUTE19}]`
14255 )) {
14256 if (style.getAttribute(STYLE_HASH_ATTRIBUTE19) === hash) {
14257 return true;
14258 }
14259 }
14260 return false;
14261 }
14262 function injectStyle19(targetDocument, hash, css) {
14263 if (!targetDocument.head) {
14264 return;
14265 }
14266 const runtime = getRuntime19();
14267 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14268 if (!injectedStyles) {
14269 injectedStyles = /* @__PURE__ */ new Set();
14270 runtime.injectedStyles.set(targetDocument, injectedStyles);
14271 }
14272 if (injectedStyles.has(hash)) {
14273 return;
14274 }
14275 if (documentContainsStyleHash19(targetDocument, hash)) {
14276 injectedStyles.add(hash);
14277 return;
14278 }
14279 const style = targetDocument.createElement("style");
14280 style.setAttribute(STYLE_HASH_ATTRIBUTE19, hash);
14281 style.appendChild(targetDocument.createTextNode(css));
14282 targetDocument.head.appendChild(style);
14283 injectedStyles.add(hash);
14284 }
14285 function registerDocument19(targetDocument) {
14286 const runtime = getRuntime19();
14287 runtime.documents.set(
14288 targetDocument,
14289 (runtime.documents.get(targetDocument) ?? 0) + 1
14290 );
14291 for (const [hash, css] of runtime.styles) {
14292 injectStyle19(targetDocument, hash, css);
14293 }
14294 return () => {
14295 const count = runtime.documents.get(targetDocument);
14296 if (count === void 0) {
14297 return;
14298 }
14299 if (count <= 1) {
14300 runtime.documents.delete(targetDocument);
14301 return;
14302 }
14303 runtime.documents.set(targetDocument, count - 1);
14304 };
14305 }
14306 function registerStyle19(hash, css) {
14307 const runtime = getRuntime19();
14308 runtime.styles.set(hash, css);
14309 for (const targetDocument of runtime.documents.keys()) {
14310 injectStyle19(targetDocument, hash, css);
14311 }
14312 }
14313 if (typeof process === "undefined" || true) {
14314 registerStyle19("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
14315 }
14316 var style_default19 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
14317 var Visual = (0, import_element48.forwardRef)(
14318 function EmptyStateVisual({ render: render4, ...props }, ref) {
14319 const className = clsx_default(style_default19.visual);
14320 const element = useRender({
14321 defaultTagName: "div",
14322 render: render4,
14323 ref,
14324 props: mergeProps({ className }, props)
14325 });
14326 return element;
14327 }
14328 );
14329
14330 // packages/ui/build-module/empty-state/icon.mjs
14331 var import_element49 = __toESM(require_element(), 1);
14332 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
14333 var STYLE_HASH_ATTRIBUTE20 = "data-wp-hash";
14334 function getRuntime20() {
14335 const globalScope = globalThis;
14336 if (globalScope.__wpStyleRuntime) {
14337 return globalScope.__wpStyleRuntime;
14338 }
14339 globalScope.__wpStyleRuntime = {
14340 documents: /* @__PURE__ */ new Map(),
14341 styles: /* @__PURE__ */ new Map(),
14342 injectedStyles: /* @__PURE__ */ new WeakMap()
14343 };
14344 if (typeof document !== "undefined") {
14345 registerDocument20(document);
14346 }
14347 return globalScope.__wpStyleRuntime;
14348 }
14349 function documentContainsStyleHash20(targetDocument, hash) {
14350 if (!targetDocument.head) {
14351 return false;
14352 }
14353 for (const style of targetDocument.head.querySelectorAll(
14354 `style[${STYLE_HASH_ATTRIBUTE20}]`
14355 )) {
14356 if (style.getAttribute(STYLE_HASH_ATTRIBUTE20) === hash) {
14357 return true;
14358 }
14359 }
14360 return false;
14361 }
14362 function injectStyle20(targetDocument, hash, css) {
14363 if (!targetDocument.head) {
14364 return;
14365 }
14366 const runtime = getRuntime20();
14367 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14368 if (!injectedStyles) {
14369 injectedStyles = /* @__PURE__ */ new Set();
14370 runtime.injectedStyles.set(targetDocument, injectedStyles);
14371 }
14372 if (injectedStyles.has(hash)) {
14373 return;
14374 }
14375 if (documentContainsStyleHash20(targetDocument, hash)) {
14376 injectedStyles.add(hash);
14377 return;
14378 }
14379 const style = targetDocument.createElement("style");
14380 style.setAttribute(STYLE_HASH_ATTRIBUTE20, hash);
14381 style.appendChild(targetDocument.createTextNode(css));
14382 targetDocument.head.appendChild(style);
14383 injectedStyles.add(hash);
14384 }
14385 function registerDocument20(targetDocument) {
14386 const runtime = getRuntime20();
14387 runtime.documents.set(
14388 targetDocument,
14389 (runtime.documents.get(targetDocument) ?? 0) + 1
14390 );
14391 for (const [hash, css] of runtime.styles) {
14392 injectStyle20(targetDocument, hash, css);
14393 }
14394 return () => {
14395 const count = runtime.documents.get(targetDocument);
14396 if (count === void 0) {
14397 return;
14398 }
14399 if (count <= 1) {
14400 runtime.documents.delete(targetDocument);
14401 return;
14402 }
14403 runtime.documents.set(targetDocument, count - 1);
14404 };
14405 }
14406 function registerStyle20(hash, css) {
14407 const runtime = getRuntime20();
14408 runtime.styles.set(hash, css);
14409 for (const targetDocument of runtime.documents.keys()) {
14410 injectStyle20(targetDocument, hash, css);
14411 }
14412 }
14413 if (typeof process === "undefined" || true) {
14414 registerStyle20("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
14415 }
14416 var style_default20 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
14417 var Icon3 = (0, import_element49.forwardRef)(
14418 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
14419 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14420 Visual,
14421 {
14422 ref,
14423 className: clsx_default(style_default20.icon, className),
14424 ...restProps,
14425 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Icon, { icon })
14426 }
14427 );
14428 }
14429 );
14430
14431 // packages/ui/build-module/empty-state/title.mjs
14432 var import_element50 = __toESM(require_element(), 1);
14433 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
14434 var STYLE_HASH_ATTRIBUTE21 = "data-wp-hash";
14435 function getRuntime21() {
14436 const globalScope = globalThis;
14437 if (globalScope.__wpStyleRuntime) {
14438 return globalScope.__wpStyleRuntime;
14439 }
14440 globalScope.__wpStyleRuntime = {
14441 documents: /* @__PURE__ */ new Map(),
14442 styles: /* @__PURE__ */ new Map(),
14443 injectedStyles: /* @__PURE__ */ new WeakMap()
14444 };
14445 if (typeof document !== "undefined") {
14446 registerDocument21(document);
14447 }
14448 return globalScope.__wpStyleRuntime;
14449 }
14450 function documentContainsStyleHash21(targetDocument, hash) {
14451 if (!targetDocument.head) {
14452 return false;
14453 }
14454 for (const style of targetDocument.head.querySelectorAll(
14455 `style[${STYLE_HASH_ATTRIBUTE21}]`
14456 )) {
14457 if (style.getAttribute(STYLE_HASH_ATTRIBUTE21) === hash) {
14458 return true;
14459 }
14460 }
14461 return false;
14462 }
14463 function injectStyle21(targetDocument, hash, css) {
14464 if (!targetDocument.head) {
14465 return;
14466 }
14467 const runtime = getRuntime21();
14468 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14469 if (!injectedStyles) {
14470 injectedStyles = /* @__PURE__ */ new Set();
14471 runtime.injectedStyles.set(targetDocument, injectedStyles);
14472 }
14473 if (injectedStyles.has(hash)) {
14474 return;
14475 }
14476 if (documentContainsStyleHash21(targetDocument, hash)) {
14477 injectedStyles.add(hash);
14478 return;
14479 }
14480 const style = targetDocument.createElement("style");
14481 style.setAttribute(STYLE_HASH_ATTRIBUTE21, hash);
14482 style.appendChild(targetDocument.createTextNode(css));
14483 targetDocument.head.appendChild(style);
14484 injectedStyles.add(hash);
14485 }
14486 function registerDocument21(targetDocument) {
14487 const runtime = getRuntime21();
14488 runtime.documents.set(
14489 targetDocument,
14490 (runtime.documents.get(targetDocument) ?? 0) + 1
14491 );
14492 for (const [hash, css] of runtime.styles) {
14493 injectStyle21(targetDocument, hash, css);
14494 }
14495 return () => {
14496 const count = runtime.documents.get(targetDocument);
14497 if (count === void 0) {
14498 return;
14499 }
14500 if (count <= 1) {
14501 runtime.documents.delete(targetDocument);
14502 return;
14503 }
14504 runtime.documents.set(targetDocument, count - 1);
14505 };
14506 }
14507 function registerStyle21(hash, css) {
14508 const runtime = getRuntime21();
14509 runtime.styles.set(hash, css);
14510 for (const targetDocument of runtime.documents.keys()) {
14511 injectStyle21(targetDocument, hash, css);
14512 }
14513 }
14514 if (typeof process === "undefined" || true) {
14515 registerStyle21("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
14516 }
14517 var style_default21 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
14518 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("h2", {});
14519 var Title3 = (0, import_element50.forwardRef)(
14520 function EmptyStateTitle({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
14521 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14522 Text,
14523 {
14524 ref,
14525 variant: "heading-lg",
14526 render: render4,
14527 className: clsx_default(style_default21.title, className),
14528 ...props,
14529 children
14530 }
14531 );
14532 }
14533 );
14534
14535 // packages/ui/build-module/empty-state/description.mjs
14536 var import_element51 = __toESM(require_element(), 1);
14537 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
14538 var STYLE_HASH_ATTRIBUTE22 = "data-wp-hash";
14539 function getRuntime22() {
14540 const globalScope = globalThis;
14541 if (globalScope.__wpStyleRuntime) {
14542 return globalScope.__wpStyleRuntime;
14543 }
14544 globalScope.__wpStyleRuntime = {
14545 documents: /* @__PURE__ */ new Map(),
14546 styles: /* @__PURE__ */ new Map(),
14547 injectedStyles: /* @__PURE__ */ new WeakMap()
14548 };
14549 if (typeof document !== "undefined") {
14550 registerDocument22(document);
14551 }
14552 return globalScope.__wpStyleRuntime;
14553 }
14554 function documentContainsStyleHash22(targetDocument, hash) {
14555 if (!targetDocument.head) {
14556 return false;
14557 }
14558 for (const style of targetDocument.head.querySelectorAll(
14559 `style[${STYLE_HASH_ATTRIBUTE22}]`
14560 )) {
14561 if (style.getAttribute(STYLE_HASH_ATTRIBUTE22) === hash) {
14562 return true;
14563 }
14564 }
14565 return false;
14566 }
14567 function injectStyle22(targetDocument, hash, css) {
14568 if (!targetDocument.head) {
14569 return;
14570 }
14571 const runtime = getRuntime22();
14572 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14573 if (!injectedStyles) {
14574 injectedStyles = /* @__PURE__ */ new Set();
14575 runtime.injectedStyles.set(targetDocument, injectedStyles);
14576 }
14577 if (injectedStyles.has(hash)) {
14578 return;
14579 }
14580 if (documentContainsStyleHash22(targetDocument, hash)) {
14581 injectedStyles.add(hash);
14582 return;
14583 }
14584 const style = targetDocument.createElement("style");
14585 style.setAttribute(STYLE_HASH_ATTRIBUTE22, hash);
14586 style.appendChild(targetDocument.createTextNode(css));
14587 targetDocument.head.appendChild(style);
14588 injectedStyles.add(hash);
14589 }
14590 function registerDocument22(targetDocument) {
14591 const runtime = getRuntime22();
14592 runtime.documents.set(
14593 targetDocument,
14594 (runtime.documents.get(targetDocument) ?? 0) + 1
14595 );
14596 for (const [hash, css] of runtime.styles) {
14597 injectStyle22(targetDocument, hash, css);
14598 }
14599 return () => {
14600 const count = runtime.documents.get(targetDocument);
14601 if (count === void 0) {
14602 return;
14603 }
14604 if (count <= 1) {
14605 runtime.documents.delete(targetDocument);
14606 return;
14607 }
14608 runtime.documents.set(targetDocument, count - 1);
14609 };
14610 }
14611 function registerStyle22(hash, css) {
14612 const runtime = getRuntime22();
14613 runtime.styles.set(hash, css);
14614 for (const targetDocument of runtime.documents.keys()) {
14615 injectStyle22(targetDocument, hash, css);
14616 }
14617 }
14618 if (typeof process === "undefined" || true) {
14619 registerStyle22("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
14620 }
14621 var style_default23 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
14622 var DEFAULT_TAG3 = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", {});
14623 var Description2 = (0, import_element51.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG3, className, children, ...props }, ref) {
14624 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14625 Text,
14626 {
14627 ref,
14628 variant: "body-md",
14629 render: render4,
14630 className: clsx_default(style_default23.description, className),
14631 ...props,
14632 children
14633 }
14634 );
14635 });
14636
14637 // packages/ui/build-module/empty-state/actions.mjs
14638 var import_element52 = __toESM(require_element(), 1);
14639 var STYLE_HASH_ATTRIBUTE23 = "data-wp-hash";
14640 function getRuntime23() {
14641 const globalScope = globalThis;
14642 if (globalScope.__wpStyleRuntime) {
14643 return globalScope.__wpStyleRuntime;
14644 }
14645 globalScope.__wpStyleRuntime = {
14646 documents: /* @__PURE__ */ new Map(),
14647 styles: /* @__PURE__ */ new Map(),
14648 injectedStyles: /* @__PURE__ */ new WeakMap()
14649 };
14650 if (typeof document !== "undefined") {
14651 registerDocument23(document);
14652 }
14653 return globalScope.__wpStyleRuntime;
14654 }
14655 function documentContainsStyleHash23(targetDocument, hash) {
14656 if (!targetDocument.head) {
14657 return false;
14658 }
14659 for (const style of targetDocument.head.querySelectorAll(
14660 `style[${STYLE_HASH_ATTRIBUTE23}]`
14661 )) {
14662 if (style.getAttribute(STYLE_HASH_ATTRIBUTE23) === hash) {
14663 return true;
14664 }
14665 }
14666 return false;
14667 }
14668 function injectStyle23(targetDocument, hash, css) {
14669 if (!targetDocument.head) {
14670 return;
14671 }
14672 const runtime = getRuntime23();
14673 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14674 if (!injectedStyles) {
14675 injectedStyles = /* @__PURE__ */ new Set();
14676 runtime.injectedStyles.set(targetDocument, injectedStyles);
14677 }
14678 if (injectedStyles.has(hash)) {
14679 return;
14680 }
14681 if (documentContainsStyleHash23(targetDocument, hash)) {
14682 injectedStyles.add(hash);
14683 return;
14684 }
14685 const style = targetDocument.createElement("style");
14686 style.setAttribute(STYLE_HASH_ATTRIBUTE23, hash);
14687 style.appendChild(targetDocument.createTextNode(css));
14688 targetDocument.head.appendChild(style);
14689 injectedStyles.add(hash);
14690 }
14691 function registerDocument23(targetDocument) {
14692 const runtime = getRuntime23();
14693 runtime.documents.set(
14694 targetDocument,
14695 (runtime.documents.get(targetDocument) ?? 0) + 1
14696 );
14697 for (const [hash, css] of runtime.styles) {
14698 injectStyle23(targetDocument, hash, css);
14699 }
14700 return () => {
14701 const count = runtime.documents.get(targetDocument);
14702 if (count === void 0) {
14703 return;
14704 }
14705 if (count <= 1) {
14706 runtime.documents.delete(targetDocument);
14707 return;
14708 }
14709 runtime.documents.set(targetDocument, count - 1);
14710 };
14711 }
14712 function registerStyle23(hash, css) {
14713 const runtime = getRuntime23();
14714 runtime.styles.set(hash, css);
14715 for (const targetDocument of runtime.documents.keys()) {
14716 injectStyle23(targetDocument, hash, css);
14717 }
14718 }
14719 if (typeof process === "undefined" || true) {
14720 registerStyle23("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
14721 }
14722 var style_default24 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
14723 var Actions = (0, import_element52.forwardRef)(
14724 function EmptyStateActions({ render: render4, ...props }, ref) {
14725 const className = clsx_default(style_default24.actions);
14726 const element = useRender({
14727 defaultTagName: "div",
14728 render: render4,
14729 ref,
14730 props: mergeProps({ className }, props)
14731 });
14732 return element;
14733 }
14734 );
14735
14736 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
14737 var import_element53 = __toESM(require_element(), 1);
14738 var STYLE_HASH_ATTRIBUTE24 = "data-wp-hash";
14739 function getRuntime24() {
14740 const globalScope = globalThis;
14741 if (globalScope.__wpStyleRuntime) {
14742 return globalScope.__wpStyleRuntime;
14743 }
14744 globalScope.__wpStyleRuntime = {
14745 documents: /* @__PURE__ */ new Map(),
14746 styles: /* @__PURE__ */ new Map(),
14747 injectedStyles: /* @__PURE__ */ new WeakMap()
14748 };
14749 if (typeof document !== "undefined") {
14750 registerDocument24(document);
14751 }
14752 return globalScope.__wpStyleRuntime;
14753 }
14754 function documentContainsStyleHash24(targetDocument, hash) {
14755 if (!targetDocument.head) {
14756 return false;
14757 }
14758 for (const style of targetDocument.head.querySelectorAll(
14759 `style[${STYLE_HASH_ATTRIBUTE24}]`
14760 )) {
14761 if (style.getAttribute(STYLE_HASH_ATTRIBUTE24) === hash) {
14762 return true;
14763 }
14764 }
14765 return false;
14766 }
14767 function injectStyle24(targetDocument, hash, css) {
14768 if (!targetDocument.head) {
14769 return;
14770 }
14771 const runtime = getRuntime24();
14772 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14773 if (!injectedStyles) {
14774 injectedStyles = /* @__PURE__ */ new Set();
14775 runtime.injectedStyles.set(targetDocument, injectedStyles);
14776 }
14777 if (injectedStyles.has(hash)) {
14778 return;
14779 }
14780 if (documentContainsStyleHash24(targetDocument, hash)) {
14781 injectedStyles.add(hash);
14782 return;
14783 }
14784 const style = targetDocument.createElement("style");
14785 style.setAttribute(STYLE_HASH_ATTRIBUTE24, hash);
14786 style.appendChild(targetDocument.createTextNode(css));
14787 targetDocument.head.appendChild(style);
14788 injectedStyles.add(hash);
14789 }
14790 function registerDocument24(targetDocument) {
14791 const runtime = getRuntime24();
14792 runtime.documents.set(
14793 targetDocument,
14794 (runtime.documents.get(targetDocument) ?? 0) + 1
14795 );
14796 for (const [hash, css] of runtime.styles) {
14797 injectStyle24(targetDocument, hash, css);
14798 }
14799 return () => {
14800 const count = runtime.documents.get(targetDocument);
14801 if (count === void 0) {
14802 return;
14803 }
14804 if (count <= 1) {
14805 runtime.documents.delete(targetDocument);
14806 return;
14807 }
14808 runtime.documents.set(targetDocument, count - 1);
14809 };
14810 }
14811 function registerStyle24(hash, css) {
14812 const runtime = getRuntime24();
14813 runtime.styles.set(hash, css);
14814 for (const targetDocument of runtime.documents.keys()) {
14815 injectStyle24(targetDocument, hash, css);
14816 }
14817 }
14818 if (typeof process === "undefined" || true) {
14819 registerStyle24("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}");
14820 }
14821 var style_default25 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
14822 var VisuallyHidden = (0, import_element53.forwardRef)(
14823 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
14824 const element = useRender({
14825 render: render4,
14826 ref,
14827 props: mergeProps(
14828 { className: style_default25["visually-hidden"] },
14829 restProps,
14830 {
14831 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
14832 "data-visually-hidden": ""
14833 }
14834 )
14835 });
14836 return element;
14837 }
14838 );
14839
14840 // packages/ui/build-module/link/link.mjs
14841 var import_element54 = __toESM(require_element(), 1);
14842 var import_i18n4 = __toESM(require_i18n(), 1);
14843 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
14844 var STYLE_HASH_ATTRIBUTE25 = "data-wp-hash";
14845 function getRuntime25() {
14846 const globalScope = globalThis;
14847 if (globalScope.__wpStyleRuntime) {
14848 return globalScope.__wpStyleRuntime;
14849 }
14850 globalScope.__wpStyleRuntime = {
14851 documents: /* @__PURE__ */ new Map(),
14852 styles: /* @__PURE__ */ new Map(),
14853 injectedStyles: /* @__PURE__ */ new WeakMap()
14854 };
14855 if (typeof document !== "undefined") {
14856 registerDocument25(document);
14857 }
14858 return globalScope.__wpStyleRuntime;
14859 }
14860 function documentContainsStyleHash25(targetDocument, hash) {
14861 if (!targetDocument.head) {
14862 return false;
14863 }
14864 for (const style of targetDocument.head.querySelectorAll(
14865 `style[${STYLE_HASH_ATTRIBUTE25}]`
14866 )) {
14867 if (style.getAttribute(STYLE_HASH_ATTRIBUTE25) === hash) {
14868 return true;
14869 }
14870 }
14871 return false;
14872 }
14873 function injectStyle25(targetDocument, hash, css) {
14874 if (!targetDocument.head) {
14875 return;
14876 }
14877 const runtime = getRuntime25();
14878 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14879 if (!injectedStyles) {
14880 injectedStyles = /* @__PURE__ */ new Set();
14881 runtime.injectedStyles.set(targetDocument, injectedStyles);
14882 }
14883 if (injectedStyles.has(hash)) {
14884 return;
14885 }
14886 if (documentContainsStyleHash25(targetDocument, hash)) {
14887 injectedStyles.add(hash);
14888 return;
14889 }
14890 const style = targetDocument.createElement("style");
14891 style.setAttribute(STYLE_HASH_ATTRIBUTE25, hash);
14892 style.appendChild(targetDocument.createTextNode(css));
14893 targetDocument.head.appendChild(style);
14894 injectedStyles.add(hash);
14895 }
14896 function registerDocument25(targetDocument) {
14897 const runtime = getRuntime25();
14898 runtime.documents.set(
14899 targetDocument,
14900 (runtime.documents.get(targetDocument) ?? 0) + 1
14901 );
14902 for (const [hash, css] of runtime.styles) {
14903 injectStyle25(targetDocument, hash, css);
14904 }
14905 return () => {
14906 const count = runtime.documents.get(targetDocument);
14907 if (count === void 0) {
14908 return;
14909 }
14910 if (count <= 1) {
14911 runtime.documents.delete(targetDocument);
14912 return;
14913 }
14914 runtime.documents.set(targetDocument, count - 1);
14915 };
14916 }
14917 function registerStyle25(hash, css) {
14918 const runtime = getRuntime25();
14919 runtime.styles.set(hash, css);
14920 for (const targetDocument of runtime.documents.keys()) {
14921 injectStyle25(targetDocument, hash, css);
14922 }
14923 }
14924 if (typeof process === "undefined" || true) {
14925 registerStyle25("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
14926 }
14927 var resets_default4 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
14928 if (typeof process === "undefined" || true) {
14929 registerStyle25("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}");
14930 }
14931 var focus_default4 = { "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" };
14932 if (typeof process === "undefined" || true) {
14933 registerStyle25("90a23568f8", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-regular,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}');
14934 }
14935 var style_default26 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
14936 if (typeof process === "undefined" || true) {
14937 registerStyle25("1fb29d3a3c", "._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,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
14938 }
14939 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" };
14940 var Link = (0, import_element54.forwardRef)(function Link2({
14941 children,
14942 variant = "default",
14943 tone = "brand",
14944 openInNewTab = false,
14945 render: render4,
14946 className,
14947 ...props
14948 }, ref) {
14949 const element = useRender({
14950 render: render4,
14951 defaultTagName: "a",
14952 ref,
14953 props: mergeProps(props, {
14954 className: clsx_default(
14955 global_css_defense_default3.a,
14956 resets_default4["box-sizing"],
14957 focus_default4["outset-ring--focus"],
14958 variant !== "unstyled" && style_default26.link,
14959 variant !== "unstyled" && style_default26[`is-${tone}`],
14960 variant === "unstyled" && style_default26["is-unstyled"],
14961 className
14962 ),
14963 target: openInNewTab ? "_blank" : void 0,
14964 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
14965 children,
14966 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
14967 "span",
14968 {
14969 className: style_default26["link-icon"],
14970 role: "img",
14971 "aria-label": (
14972 /* translators: accessibility text appended to link text */
14973 (0, import_i18n4.__)("(opens in a new tab)")
14974 )
14975 }
14976 )
14977 ] })
14978 })
14979 });
14980 return element;
14981 });
14982
14983 // packages/ui/build-module/notice/index.mjs
14984 var notice_exports = {};
14985 __export(notice_exports, {
14986 ActionButton: () => ActionButton,
14987 ActionLink: () => ActionLink,
14988 Actions: () => Actions2,
14989 CloseIcon: () => CloseIcon2,
14990 Description: () => Description3,
14991 Root: () => Root6,
14992 Title: () => Title4
14993 });
14994
14995 // packages/ui/build-module/notice/root.mjs
14996 var import_element55 = __toESM(require_element(), 1);
14997 import { speak as speak3 } from "@wordpress/a11y";
14998 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
14999 var STYLE_HASH_ATTRIBUTE26 = "data-wp-hash";
15000 function getRuntime26() {
15001 const globalScope = globalThis;
15002 if (globalScope.__wpStyleRuntime) {
15003 return globalScope.__wpStyleRuntime;
15004 }
15005 globalScope.__wpStyleRuntime = {
15006 documents: /* @__PURE__ */ new Map(),
15007 styles: /* @__PURE__ */ new Map(),
15008 injectedStyles: /* @__PURE__ */ new WeakMap()
15009 };
15010 if (typeof document !== "undefined") {
15011 registerDocument26(document);
15012 }
15013 return globalScope.__wpStyleRuntime;
15014 }
15015 function documentContainsStyleHash26(targetDocument, hash) {
15016 if (!targetDocument.head) {
15017 return false;
15018 }
15019 for (const style of targetDocument.head.querySelectorAll(
15020 `style[${STYLE_HASH_ATTRIBUTE26}]`
15021 )) {
15022 if (style.getAttribute(STYLE_HASH_ATTRIBUTE26) === hash) {
15023 return true;
15024 }
15025 }
15026 return false;
15027 }
15028 function injectStyle26(targetDocument, hash, css) {
15029 if (!targetDocument.head) {
15030 return;
15031 }
15032 const runtime = getRuntime26();
15033 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15034 if (!injectedStyles) {
15035 injectedStyles = /* @__PURE__ */ new Set();
15036 runtime.injectedStyles.set(targetDocument, injectedStyles);
15037 }
15038 if (injectedStyles.has(hash)) {
15039 return;
15040 }
15041 if (documentContainsStyleHash26(targetDocument, hash)) {
15042 injectedStyles.add(hash);
15043 return;
15044 }
15045 const style = targetDocument.createElement("style");
15046 style.setAttribute(STYLE_HASH_ATTRIBUTE26, hash);
15047 style.appendChild(targetDocument.createTextNode(css));
15048 targetDocument.head.appendChild(style);
15049 injectedStyles.add(hash);
15050 }
15051 function registerDocument26(targetDocument) {
15052 const runtime = getRuntime26();
15053 runtime.documents.set(
15054 targetDocument,
15055 (runtime.documents.get(targetDocument) ?? 0) + 1
15056 );
15057 for (const [hash, css] of runtime.styles) {
15058 injectStyle26(targetDocument, hash, css);
15059 }
15060 return () => {
15061 const count = runtime.documents.get(targetDocument);
15062 if (count === void 0) {
15063 return;
15064 }
15065 if (count <= 1) {
15066 runtime.documents.delete(targetDocument);
15067 return;
15068 }
15069 runtime.documents.set(targetDocument, count - 1);
15070 };
15071 }
15072 function registerStyle26(hash, css) {
15073 const runtime = getRuntime26();
15074 runtime.styles.set(hash, css);
15075 for (const targetDocument of runtime.documents.keys()) {
15076 injectStyle26(targetDocument, hash, css);
15077 }
15078 }
15079 if (typeof process === "undefined" || true) {
15080 registerStyle26("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
15081 }
15082 var resets_default5 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
15083 if (typeof process === "undefined" || true) {
15084 registerStyle26("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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 wp-ui-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,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15085 }
15086 var style_default27 = { "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" };
15087 var icons = {
15088 neutral: null,
15089 info: info_default,
15090 warning: caution_default,
15091 success: published_default,
15092 error: error_default
15093 };
15094 function getDefaultPoliteness(intent) {
15095 return intent === "error" ? "assertive" : "polite";
15096 }
15097 function safeRenderToString(message2) {
15098 if (!message2) {
15099 return void 0;
15100 }
15101 if (typeof message2 === "string") {
15102 return message2;
15103 }
15104 try {
15105 return (0, import_element55.renderToString)(message2);
15106 } catch {
15107 return void 0;
15108 }
15109 }
15110 function useSpokenMessage(message2, politeness) {
15111 const spokenMessage = safeRenderToString(message2);
15112 (0, import_element55.useEffect)(() => {
15113 if (spokenMessage) {
15114 speak3(spokenMessage, politeness);
15115 }
15116 }, [spokenMessage, politeness]);
15117 }
15118 var Root6 = (0, import_element55.forwardRef)(function Notice({
15119 intent = "neutral",
15120 children,
15121 icon,
15122 spokenMessage = children,
15123 politeness = getDefaultPoliteness(intent),
15124 render: render4,
15125 ...restProps
15126 }, ref) {
15127 useSpokenMessage(spokenMessage, politeness);
15128 const iconElement = icon === null ? null : icon ?? icons[intent];
15129 const mergedClassName = clsx_default(
15130 style_default27.notice,
15131 style_default27[`is-${intent}`],
15132 resets_default5["box-sizing"]
15133 );
15134 const element = useRender({
15135 defaultTagName: "div",
15136 render: render4,
15137 ref,
15138 props: mergeProps(
15139 {
15140 className: mergedClassName,
15141 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [
15142 children,
15143 iconElement && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
15144 Icon,
15145 {
15146 className: style_default27.icon,
15147 icon: iconElement
15148 }
15149 )
15150 ] })
15151 },
15152 restProps
15153 )
15154 });
15155 return element;
15156 });
15157
15158 // packages/ui/build-module/notice/title.mjs
15159 var import_element56 = __toESM(require_element(), 1);
15160 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
15161 var STYLE_HASH_ATTRIBUTE27 = "data-wp-hash";
15162 function getRuntime27() {
15163 const globalScope = globalThis;
15164 if (globalScope.__wpStyleRuntime) {
15165 return globalScope.__wpStyleRuntime;
15166 }
15167 globalScope.__wpStyleRuntime = {
15168 documents: /* @__PURE__ */ new Map(),
15169 styles: /* @__PURE__ */ new Map(),
15170 injectedStyles: /* @__PURE__ */ new WeakMap()
15171 };
15172 if (typeof document !== "undefined") {
15173 registerDocument27(document);
15174 }
15175 return globalScope.__wpStyleRuntime;
15176 }
15177 function documentContainsStyleHash27(targetDocument, hash) {
15178 if (!targetDocument.head) {
15179 return false;
15180 }
15181 for (const style of targetDocument.head.querySelectorAll(
15182 `style[${STYLE_HASH_ATTRIBUTE27}]`
15183 )) {
15184 if (style.getAttribute(STYLE_HASH_ATTRIBUTE27) === hash) {
15185 return true;
15186 }
15187 }
15188 return false;
15189 }
15190 function injectStyle27(targetDocument, hash, css) {
15191 if (!targetDocument.head) {
15192 return;
15193 }
15194 const runtime = getRuntime27();
15195 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15196 if (!injectedStyles) {
15197 injectedStyles = /* @__PURE__ */ new Set();
15198 runtime.injectedStyles.set(targetDocument, injectedStyles);
15199 }
15200 if (injectedStyles.has(hash)) {
15201 return;
15202 }
15203 if (documentContainsStyleHash27(targetDocument, hash)) {
15204 injectedStyles.add(hash);
15205 return;
15206 }
15207 const style = targetDocument.createElement("style");
15208 style.setAttribute(STYLE_HASH_ATTRIBUTE27, hash);
15209 style.appendChild(targetDocument.createTextNode(css));
15210 targetDocument.head.appendChild(style);
15211 injectedStyles.add(hash);
15212 }
15213 function registerDocument27(targetDocument) {
15214 const runtime = getRuntime27();
15215 runtime.documents.set(
15216 targetDocument,
15217 (runtime.documents.get(targetDocument) ?? 0) + 1
15218 );
15219 for (const [hash, css] of runtime.styles) {
15220 injectStyle27(targetDocument, hash, css);
15221 }
15222 return () => {
15223 const count = runtime.documents.get(targetDocument);
15224 if (count === void 0) {
15225 return;
15226 }
15227 if (count <= 1) {
15228 runtime.documents.delete(targetDocument);
15229 return;
15230 }
15231 runtime.documents.set(targetDocument, count - 1);
15232 };
15233 }
15234 function registerStyle27(hash, css) {
15235 const runtime = getRuntime27();
15236 runtime.styles.set(hash, css);
15237 for (const targetDocument of runtime.documents.keys()) {
15238 injectStyle27(targetDocument, hash, css);
15239 }
15240 }
15241 if (typeof process === "undefined" || true) {
15242 registerStyle27("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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 wp-ui-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,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15243 }
15244 var style_default28 = { "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" };
15245 var Title4 = (0, import_element56.forwardRef)(
15246 function NoticeTitle({ className, ...props }, ref) {
15247 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15248 Text,
15249 {
15250 ref,
15251 variant: "heading-md",
15252 className: clsx_default(style_default28.title, className),
15253 ...props
15254 }
15255 );
15256 }
15257 );
15258
15259 // packages/ui/build-module/notice/description.mjs
15260 var import_element57 = __toESM(require_element(), 1);
15261 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15262 var STYLE_HASH_ATTRIBUTE28 = "data-wp-hash";
15263 function getRuntime28() {
15264 const globalScope = globalThis;
15265 if (globalScope.__wpStyleRuntime) {
15266 return globalScope.__wpStyleRuntime;
15267 }
15268 globalScope.__wpStyleRuntime = {
15269 documents: /* @__PURE__ */ new Map(),
15270 styles: /* @__PURE__ */ new Map(),
15271 injectedStyles: /* @__PURE__ */ new WeakMap()
15272 };
15273 if (typeof document !== "undefined") {
15274 registerDocument28(document);
15275 }
15276 return globalScope.__wpStyleRuntime;
15277 }
15278 function documentContainsStyleHash28(targetDocument, hash) {
15279 if (!targetDocument.head) {
15280 return false;
15281 }
15282 for (const style of targetDocument.head.querySelectorAll(
15283 `style[${STYLE_HASH_ATTRIBUTE28}]`
15284 )) {
15285 if (style.getAttribute(STYLE_HASH_ATTRIBUTE28) === hash) {
15286 return true;
15287 }
15288 }
15289 return false;
15290 }
15291 function injectStyle28(targetDocument, hash, css) {
15292 if (!targetDocument.head) {
15293 return;
15294 }
15295 const runtime = getRuntime28();
15296 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15297 if (!injectedStyles) {
15298 injectedStyles = /* @__PURE__ */ new Set();
15299 runtime.injectedStyles.set(targetDocument, injectedStyles);
15300 }
15301 if (injectedStyles.has(hash)) {
15302 return;
15303 }
15304 if (documentContainsStyleHash28(targetDocument, hash)) {
15305 injectedStyles.add(hash);
15306 return;
15307 }
15308 const style = targetDocument.createElement("style");
15309 style.setAttribute(STYLE_HASH_ATTRIBUTE28, hash);
15310 style.appendChild(targetDocument.createTextNode(css));
15311 targetDocument.head.appendChild(style);
15312 injectedStyles.add(hash);
15313 }
15314 function registerDocument28(targetDocument) {
15315 const runtime = getRuntime28();
15316 runtime.documents.set(
15317 targetDocument,
15318 (runtime.documents.get(targetDocument) ?? 0) + 1
15319 );
15320 for (const [hash, css] of runtime.styles) {
15321 injectStyle28(targetDocument, hash, css);
15322 }
15323 return () => {
15324 const count = runtime.documents.get(targetDocument);
15325 if (count === void 0) {
15326 return;
15327 }
15328 if (count <= 1) {
15329 runtime.documents.delete(targetDocument);
15330 return;
15331 }
15332 runtime.documents.set(targetDocument, count - 1);
15333 };
15334 }
15335 function registerStyle28(hash, css) {
15336 const runtime = getRuntime28();
15337 runtime.styles.set(hash, css);
15338 for (const targetDocument of runtime.documents.keys()) {
15339 injectStyle28(targetDocument, hash, css);
15340 }
15341 }
15342 if (typeof process === "undefined" || true) {
15343 registerStyle28("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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 wp-ui-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,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15344 }
15345 var style_default29 = { "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" };
15346 var Description3 = (0, import_element57.forwardRef)(
15347 function NoticeDescription({ className, ...props }, ref) {
15348 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15349 Text,
15350 {
15351 ref,
15352 variant: "body-md",
15353 className: clsx_default(style_default29.description, className),
15354 ...props
15355 }
15356 );
15357 }
15358 );
15359
15360 // packages/ui/build-module/notice/actions.mjs
15361 var import_element58 = __toESM(require_element(), 1);
15362 var STYLE_HASH_ATTRIBUTE29 = "data-wp-hash";
15363 function getRuntime29() {
15364 const globalScope = globalThis;
15365 if (globalScope.__wpStyleRuntime) {
15366 return globalScope.__wpStyleRuntime;
15367 }
15368 globalScope.__wpStyleRuntime = {
15369 documents: /* @__PURE__ */ new Map(),
15370 styles: /* @__PURE__ */ new Map(),
15371 injectedStyles: /* @__PURE__ */ new WeakMap()
15372 };
15373 if (typeof document !== "undefined") {
15374 registerDocument29(document);
15375 }
15376 return globalScope.__wpStyleRuntime;
15377 }
15378 function documentContainsStyleHash29(targetDocument, hash) {
15379 if (!targetDocument.head) {
15380 return false;
15381 }
15382 for (const style of targetDocument.head.querySelectorAll(
15383 `style[${STYLE_HASH_ATTRIBUTE29}]`
15384 )) {
15385 if (style.getAttribute(STYLE_HASH_ATTRIBUTE29) === hash) {
15386 return true;
15387 }
15388 }
15389 return false;
15390 }
15391 function injectStyle29(targetDocument, hash, css) {
15392 if (!targetDocument.head) {
15393 return;
15394 }
15395 const runtime = getRuntime29();
15396 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15397 if (!injectedStyles) {
15398 injectedStyles = /* @__PURE__ */ new Set();
15399 runtime.injectedStyles.set(targetDocument, injectedStyles);
15400 }
15401 if (injectedStyles.has(hash)) {
15402 return;
15403 }
15404 if (documentContainsStyleHash29(targetDocument, hash)) {
15405 injectedStyles.add(hash);
15406 return;
15407 }
15408 const style = targetDocument.createElement("style");
15409 style.setAttribute(STYLE_HASH_ATTRIBUTE29, hash);
15410 style.appendChild(targetDocument.createTextNode(css));
15411 targetDocument.head.appendChild(style);
15412 injectedStyles.add(hash);
15413 }
15414 function registerDocument29(targetDocument) {
15415 const runtime = getRuntime29();
15416 runtime.documents.set(
15417 targetDocument,
15418 (runtime.documents.get(targetDocument) ?? 0) + 1
15419 );
15420 for (const [hash, css] of runtime.styles) {
15421 injectStyle29(targetDocument, hash, css);
15422 }
15423 return () => {
15424 const count = runtime.documents.get(targetDocument);
15425 if (count === void 0) {
15426 return;
15427 }
15428 if (count <= 1) {
15429 runtime.documents.delete(targetDocument);
15430 return;
15431 }
15432 runtime.documents.set(targetDocument, count - 1);
15433 };
15434 }
15435 function registerStyle29(hash, css) {
15436 const runtime = getRuntime29();
15437 runtime.styles.set(hash, css);
15438 for (const targetDocument of runtime.documents.keys()) {
15439 injectStyle29(targetDocument, hash, css);
15440 }
15441 }
15442 if (typeof process === "undefined" || true) {
15443 registerStyle29("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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 wp-ui-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,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15444 }
15445 var style_default30 = { "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" };
15446 var Actions2 = (0, import_element58.forwardRef)(
15447 function NoticeActions({ render: render4, ...props }, ref) {
15448 const element = useRender({
15449 defaultTagName: "div",
15450 render: render4,
15451 ref,
15452 props: mergeProps(
15453 {
15454 className: style_default30.actions
15455 },
15456 props
15457 )
15458 });
15459 return element;
15460 }
15461 );
15462
15463 // packages/ui/build-module/notice/close-icon.mjs
15464 var import_element59 = __toESM(require_element(), 1);
15465 var import_i18n5 = __toESM(require_i18n(), 1);
15466 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15467 var STYLE_HASH_ATTRIBUTE30 = "data-wp-hash";
15468 function getRuntime30() {
15469 const globalScope = globalThis;
15470 if (globalScope.__wpStyleRuntime) {
15471 return globalScope.__wpStyleRuntime;
15472 }
15473 globalScope.__wpStyleRuntime = {
15474 documents: /* @__PURE__ */ new Map(),
15475 styles: /* @__PURE__ */ new Map(),
15476 injectedStyles: /* @__PURE__ */ new WeakMap()
15477 };
15478 if (typeof document !== "undefined") {
15479 registerDocument30(document);
15480 }
15481 return globalScope.__wpStyleRuntime;
15482 }
15483 function documentContainsStyleHash30(targetDocument, hash) {
15484 if (!targetDocument.head) {
15485 return false;
15486 }
15487 for (const style of targetDocument.head.querySelectorAll(
15488 `style[${STYLE_HASH_ATTRIBUTE30}]`
15489 )) {
15490 if (style.getAttribute(STYLE_HASH_ATTRIBUTE30) === hash) {
15491 return true;
15492 }
15493 }
15494 return false;
15495 }
15496 function injectStyle30(targetDocument, hash, css) {
15497 if (!targetDocument.head) {
15498 return;
15499 }
15500 const runtime = getRuntime30();
15501 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15502 if (!injectedStyles) {
15503 injectedStyles = /* @__PURE__ */ new Set();
15504 runtime.injectedStyles.set(targetDocument, injectedStyles);
15505 }
15506 if (injectedStyles.has(hash)) {
15507 return;
15508 }
15509 if (documentContainsStyleHash30(targetDocument, hash)) {
15510 injectedStyles.add(hash);
15511 return;
15512 }
15513 const style = targetDocument.createElement("style");
15514 style.setAttribute(STYLE_HASH_ATTRIBUTE30, hash);
15515 style.appendChild(targetDocument.createTextNode(css));
15516 targetDocument.head.appendChild(style);
15517 injectedStyles.add(hash);
15518 }
15519 function registerDocument30(targetDocument) {
15520 const runtime = getRuntime30();
15521 runtime.documents.set(
15522 targetDocument,
15523 (runtime.documents.get(targetDocument) ?? 0) + 1
15524 );
15525 for (const [hash, css] of runtime.styles) {
15526 injectStyle30(targetDocument, hash, css);
15527 }
15528 return () => {
15529 const count = runtime.documents.get(targetDocument);
15530 if (count === void 0) {
15531 return;
15532 }
15533 if (count <= 1) {
15534 runtime.documents.delete(targetDocument);
15535 return;
15536 }
15537 runtime.documents.set(targetDocument, count - 1);
15538 };
15539 }
15540 function registerStyle30(hash, css) {
15541 const runtime = getRuntime30();
15542 runtime.styles.set(hash, css);
15543 for (const targetDocument of runtime.documents.keys()) {
15544 injectStyle30(targetDocument, hash, css);
15545 }
15546 }
15547 if (typeof process === "undefined" || true) {
15548 registerStyle30("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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 wp-ui-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,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15549 }
15550 var style_default31 = { "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" };
15551 var CloseIcon2 = (0, import_element59.forwardRef)(
15552 function NoticeCloseIcon({ className, icon = close_small_default, label = (0, import_i18n5.__)("Dismiss"), ...props }, ref) {
15553 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15554 IconButton,
15555 {
15556 ...props,
15557 ref,
15558 className: clsx_default(style_default31["close-icon"], className),
15559 variant: "minimal",
15560 size: "small",
15561 tone: "neutral",
15562 icon,
15563 label
15564 }
15565 );
15566 }
15567 );
15568
15569 // packages/ui/build-module/notice/action-button.mjs
15570 var import_element60 = __toESM(require_element(), 1);
15571 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
15572 var STYLE_HASH_ATTRIBUTE31 = "data-wp-hash";
15573 function getRuntime31() {
15574 const globalScope = globalThis;
15575 if (globalScope.__wpStyleRuntime) {
15576 return globalScope.__wpStyleRuntime;
15577 }
15578 globalScope.__wpStyleRuntime = {
15579 documents: /* @__PURE__ */ new Map(),
15580 styles: /* @__PURE__ */ new Map(),
15581 injectedStyles: /* @__PURE__ */ new WeakMap()
15582 };
15583 if (typeof document !== "undefined") {
15584 registerDocument31(document);
15585 }
15586 return globalScope.__wpStyleRuntime;
15587 }
15588 function documentContainsStyleHash31(targetDocument, hash) {
15589 if (!targetDocument.head) {
15590 return false;
15591 }
15592 for (const style of targetDocument.head.querySelectorAll(
15593 `style[${STYLE_HASH_ATTRIBUTE31}]`
15594 )) {
15595 if (style.getAttribute(STYLE_HASH_ATTRIBUTE31) === hash) {
15596 return true;
15597 }
15598 }
15599 return false;
15600 }
15601 function injectStyle31(targetDocument, hash, css) {
15602 if (!targetDocument.head) {
15603 return;
15604 }
15605 const runtime = getRuntime31();
15606 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15607 if (!injectedStyles) {
15608 injectedStyles = /* @__PURE__ */ new Set();
15609 runtime.injectedStyles.set(targetDocument, injectedStyles);
15610 }
15611 if (injectedStyles.has(hash)) {
15612 return;
15613 }
15614 if (documentContainsStyleHash31(targetDocument, hash)) {
15615 injectedStyles.add(hash);
15616 return;
15617 }
15618 const style = targetDocument.createElement("style");
15619 style.setAttribute(STYLE_HASH_ATTRIBUTE31, hash);
15620 style.appendChild(targetDocument.createTextNode(css));
15621 targetDocument.head.appendChild(style);
15622 injectedStyles.add(hash);
15623 }
15624 function registerDocument31(targetDocument) {
15625 const runtime = getRuntime31();
15626 runtime.documents.set(
15627 targetDocument,
15628 (runtime.documents.get(targetDocument) ?? 0) + 1
15629 );
15630 for (const [hash, css] of runtime.styles) {
15631 injectStyle31(targetDocument, hash, css);
15632 }
15633 return () => {
15634 const count = runtime.documents.get(targetDocument);
15635 if (count === void 0) {
15636 return;
15637 }
15638 if (count <= 1) {
15639 runtime.documents.delete(targetDocument);
15640 return;
15641 }
15642 runtime.documents.set(targetDocument, count - 1);
15643 };
15644 }
15645 function registerStyle31(hash, css) {
15646 const runtime = getRuntime31();
15647 runtime.styles.set(hash, css);
15648 for (const targetDocument of runtime.documents.keys()) {
15649 injectStyle31(targetDocument, hash, css);
15650 }
15651 }
15652 if (typeof process === "undefined" || true) {
15653 registerStyle31("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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 wp-ui-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,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15654 }
15655 var style_default32 = { "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" };
15656 var ActionButton = (0, import_element60.forwardRef)(
15657 function NoticeActionButton({ className, loading, loadingAnnouncement, variant, ...props }, ref) {
15658 const loadingProps = loading !== void 0 ? { loading, loadingAnnouncement: loadingAnnouncement ?? "" } : {};
15659 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15660 Button4,
15661 {
15662 ...props,
15663 ...loadingProps,
15664 ref,
15665 size: "compact",
15666 tone: "neutral",
15667 variant,
15668 className: clsx_default(
15669 style_default32["action-button"],
15670 style_default32[`is-action-button-${variant}`],
15671 className
15672 )
15673 }
15674 );
15675 }
15676 );
15677
15678 // packages/ui/build-module/notice/action-link.mjs
15679 var import_element61 = __toESM(require_element(), 1);
15680 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15681 var STYLE_HASH_ATTRIBUTE32 = "data-wp-hash";
15682 function getRuntime32() {
15683 const globalScope = globalThis;
15684 if (globalScope.__wpStyleRuntime) {
15685 return globalScope.__wpStyleRuntime;
15686 }
15687 globalScope.__wpStyleRuntime = {
15688 documents: /* @__PURE__ */ new Map(),
15689 styles: /* @__PURE__ */ new Map(),
15690 injectedStyles: /* @__PURE__ */ new WeakMap()
15691 };
15692 if (typeof document !== "undefined") {
15693 registerDocument32(document);
15694 }
15695 return globalScope.__wpStyleRuntime;
15696 }
15697 function documentContainsStyleHash32(targetDocument, hash) {
15698 if (!targetDocument.head) {
15699 return false;
15700 }
15701 for (const style of targetDocument.head.querySelectorAll(
15702 `style[${STYLE_HASH_ATTRIBUTE32}]`
15703 )) {
15704 if (style.getAttribute(STYLE_HASH_ATTRIBUTE32) === hash) {
15705 return true;
15706 }
15707 }
15708 return false;
15709 }
15710 function injectStyle32(targetDocument, hash, css) {
15711 if (!targetDocument.head) {
15712 return;
15713 }
15714 const runtime = getRuntime32();
15715 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15716 if (!injectedStyles) {
15717 injectedStyles = /* @__PURE__ */ new Set();
15718 runtime.injectedStyles.set(targetDocument, injectedStyles);
15719 }
15720 if (injectedStyles.has(hash)) {
15721 return;
15722 }
15723 if (documentContainsStyleHash32(targetDocument, hash)) {
15724 injectedStyles.add(hash);
15725 return;
15726 }
15727 const style = targetDocument.createElement("style");
15728 style.setAttribute(STYLE_HASH_ATTRIBUTE32, hash);
15729 style.appendChild(targetDocument.createTextNode(css));
15730 targetDocument.head.appendChild(style);
15731 injectedStyles.add(hash);
15732 }
15733 function registerDocument32(targetDocument) {
15734 const runtime = getRuntime32();
15735 runtime.documents.set(
15736 targetDocument,
15737 (runtime.documents.get(targetDocument) ?? 0) + 1
15738 );
15739 for (const [hash, css] of runtime.styles) {
15740 injectStyle32(targetDocument, hash, css);
15741 }
15742 return () => {
15743 const count = runtime.documents.get(targetDocument);
15744 if (count === void 0) {
15745 return;
15746 }
15747 if (count <= 1) {
15748 runtime.documents.delete(targetDocument);
15749 return;
15750 }
15751 runtime.documents.set(targetDocument, count - 1);
15752 };
15753 }
15754 function registerStyle32(hash, css) {
15755 const runtime = getRuntime32();
15756 runtime.styles.set(hash, css);
15757 for (const targetDocument of runtime.documents.keys()) {
15758 injectStyle32(targetDocument, hash, css);
15759 }
15760 }
15761 if (typeof process === "undefined" || true) {
15762 registerStyle32("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-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 wp-ui-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,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15763 }
15764 var style_default33 = { "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" };
15765 var ActionLink = (0, import_element61.forwardRef)(
15766 function NoticeActionLink({ className, render: render4, ...props }, ref) {
15767 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15768 Text,
15769 {
15770 ref,
15771 className: clsx_default(style_default33["action-link"], className),
15772 ...props,
15773 variant: "body-md",
15774 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Link, { tone: "neutral", variant: "default", render: render4 })
15775 }
15776 );
15777 }
15778 );
15779
15780 // packages/admin-ui/build-module/navigable-region/index.mjs
15781 var import_element62 = __toESM(require_element(), 1);
15782 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
15783 var NavigableRegion = (0, import_element62.forwardRef)(
15784 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
15785 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15786 Tag,
15787 {
15788 ref,
15789 className: clsx_default("admin-ui-navigable-region", className),
15790 "aria-label": ariaLabel,
15791 role: "region",
15792 tabIndex: "-1",
15793 ...props,
15794 children
15795 }
15796 );
15797 }
15798 );
15799 NavigableRegion.displayName = "NavigableRegion";
15800 var navigable_region_default = NavigableRegion;
15801
15802 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
15803 var import_components = __toESM(require_components(), 1);
15804 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");
15805
15806 // packages/admin-ui/build-module/page/header.mjs
15807 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
15808 var STYLE_HASH_ATTRIBUTE33 = "data-wp-hash";
15809 function getRuntime33() {
15810 const globalScope = globalThis;
15811 if (globalScope.__wpStyleRuntime) {
15812 return globalScope.__wpStyleRuntime;
15813 }
15814 globalScope.__wpStyleRuntime = {
15815 documents: /* @__PURE__ */ new Map(),
15816 styles: /* @__PURE__ */ new Map(),
15817 injectedStyles: /* @__PURE__ */ new WeakMap()
15818 };
15819 if (typeof document !== "undefined") {
15820 registerDocument33(document);
15821 }
15822 return globalScope.__wpStyleRuntime;
15823 }
15824 function documentContainsStyleHash33(targetDocument, hash) {
15825 if (!targetDocument.head) {
15826 return false;
15827 }
15828 for (const style of targetDocument.head.querySelectorAll(
15829 `style[${STYLE_HASH_ATTRIBUTE33}]`
15830 )) {
15831 if (style.getAttribute(STYLE_HASH_ATTRIBUTE33) === hash) {
15832 return true;
15833 }
15834 }
15835 return false;
15836 }
15837 function injectStyle33(targetDocument, hash, css) {
15838 if (!targetDocument.head) {
15839 return;
15840 }
15841 const runtime = getRuntime33();
15842 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15843 if (!injectedStyles) {
15844 injectedStyles = /* @__PURE__ */ new Set();
15845 runtime.injectedStyles.set(targetDocument, injectedStyles);
15846 }
15847 if (injectedStyles.has(hash)) {
15848 return;
15849 }
15850 if (documentContainsStyleHash33(targetDocument, hash)) {
15851 injectedStyles.add(hash);
15852 return;
15853 }
15854 const style = targetDocument.createElement("style");
15855 style.setAttribute(STYLE_HASH_ATTRIBUTE33, hash);
15856 style.appendChild(targetDocument.createTextNode(css));
15857 targetDocument.head.appendChild(style);
15858 injectedStyles.add(hash);
15859 }
15860 function registerDocument33(targetDocument) {
15861 const runtime = getRuntime33();
15862 runtime.documents.set(
15863 targetDocument,
15864 (runtime.documents.get(targetDocument) ?? 0) + 1
15865 );
15866 for (const [hash, css] of runtime.styles) {
15867 injectStyle33(targetDocument, hash, css);
15868 }
15869 return () => {
15870 const count = runtime.documents.get(targetDocument);
15871 if (count === void 0) {
15872 return;
15873 }
15874 if (count <= 1) {
15875 runtime.documents.delete(targetDocument);
15876 return;
15877 }
15878 runtime.documents.set(targetDocument, count - 1);
15879 };
15880 }
15881 function registerStyle33(hash, css) {
15882 const runtime = getRuntime33();
15883 runtime.styles.set(hash, css);
15884 for (const targetDocument of runtime.documents.keys()) {
15885 injectStyle33(targetDocument, hash, css);
15886 }
15887 }
15888 if (typeof process === "undefined" || true) {
15889 registerStyle33("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);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:calc(var(--wpds-dimension-base, 4px)*8)}.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:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{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-fg-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)}}");
15890 }
15891 var style_default34 = { "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" };
15892 function Header3({
15893 headingLevel = 1,
15894 breadcrumbs,
15895 badges,
15896 visual,
15897 title,
15898 subTitle,
15899 actions,
15900 showSidebarToggle = true
15901 }) {
15902 const HeadingTag = `h${headingLevel}`;
15903 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(Stack, { direction: "column", className: style_default34.header, children: [
15904 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
15905 Stack,
15906 {
15907 className: style_default34["header-content"],
15908 direction: "row",
15909 gap: "sm",
15910 justify: "space-between",
15911 children: [
15912 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
15913 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15914 SidebarToggleSlot,
15915 {
15916 bubblesVirtually: true,
15917 className: style_default34["sidebar-toggle-slot"]
15918 }
15919 ),
15920 visual && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15921 "div",
15922 {
15923 className: style_default34["header-visual"],
15924 "aria-hidden": "true",
15925 children: visual
15926 }
15927 ),
15928 title && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15929 Text,
15930 {
15931 className: style_default34["header-title"],
15932 render: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(HeadingTag, {}),
15933 variant: "heading-lg",
15934 children: title
15935 }
15936 ),
15937 breadcrumbs,
15938 badges
15939 ] }),
15940 actions && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15941 Stack,
15942 {
15943 align: "center",
15944 className: style_default34["header-actions"],
15945 direction: "row",
15946 gap: "sm",
15947 children: actions
15948 }
15949 )
15950 ]
15951 }
15952 ),
15953 subTitle && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15954 Text,
15955 {
15956 render: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", {}),
15957 variant: "body-md",
15958 className: style_default34["header-subtitle"],
15959 children: subTitle
15960 }
15961 )
15962 ] });
15963 }
15964
15965 // packages/admin-ui/build-module/page/index.mjs
15966 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
15967 var STYLE_HASH_ATTRIBUTE34 = "data-wp-hash";
15968 function getRuntime34() {
15969 const globalScope = globalThis;
15970 if (globalScope.__wpStyleRuntime) {
15971 return globalScope.__wpStyleRuntime;
15972 }
15973 globalScope.__wpStyleRuntime = {
15974 documents: /* @__PURE__ */ new Map(),
15975 styles: /* @__PURE__ */ new Map(),
15976 injectedStyles: /* @__PURE__ */ new WeakMap()
15977 };
15978 if (typeof document !== "undefined") {
15979 registerDocument34(document);
15980 }
15981 return globalScope.__wpStyleRuntime;
15982 }
15983 function documentContainsStyleHash34(targetDocument, hash) {
15984 if (!targetDocument.head) {
15985 return false;
15986 }
15987 for (const style of targetDocument.head.querySelectorAll(
15988 `style[${STYLE_HASH_ATTRIBUTE34}]`
15989 )) {
15990 if (style.getAttribute(STYLE_HASH_ATTRIBUTE34) === hash) {
15991 return true;
15992 }
15993 }
15994 return false;
15995 }
15996 function injectStyle34(targetDocument, hash, css) {
15997 if (!targetDocument.head) {
15998 return;
15999 }
16000 const runtime = getRuntime34();
16001 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16002 if (!injectedStyles) {
16003 injectedStyles = /* @__PURE__ */ new Set();
16004 runtime.injectedStyles.set(targetDocument, injectedStyles);
16005 }
16006 if (injectedStyles.has(hash)) {
16007 return;
16008 }
16009 if (documentContainsStyleHash34(targetDocument, hash)) {
16010 injectedStyles.add(hash);
16011 return;
16012 }
16013 const style = targetDocument.createElement("style");
16014 style.setAttribute(STYLE_HASH_ATTRIBUTE34, hash);
16015 style.appendChild(targetDocument.createTextNode(css));
16016 targetDocument.head.appendChild(style);
16017 injectedStyles.add(hash);
16018 }
16019 function registerDocument34(targetDocument) {
16020 const runtime = getRuntime34();
16021 runtime.documents.set(
16022 targetDocument,
16023 (runtime.documents.get(targetDocument) ?? 0) + 1
16024 );
16025 for (const [hash, css] of runtime.styles) {
16026 injectStyle34(targetDocument, hash, css);
16027 }
16028 return () => {
16029 const count = runtime.documents.get(targetDocument);
16030 if (count === void 0) {
16031 return;
16032 }
16033 if (count <= 1) {
16034 runtime.documents.delete(targetDocument);
16035 return;
16036 }
16037 runtime.documents.set(targetDocument, count - 1);
16038 };
16039 }
16040 function registerStyle34(hash, css) {
16041 const runtime = getRuntime34();
16042 runtime.styles.set(hash, css);
16043 for (const targetDocument of runtime.documents.keys()) {
16044 injectStyle34(targetDocument, hash, css);
16045 }
16046 }
16047 if (typeof process === "undefined" || true) {
16048 registerStyle34("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);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:calc(var(--wpds-dimension-base, 4px)*8)}.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:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{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-fg-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)}}");
16049 }
16050 var style_default35 = { "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" };
16051 function Page({
16052 headingLevel,
16053 breadcrumbs,
16054 badges,
16055 visual,
16056 title,
16057 subTitle,
16058 children,
16059 className,
16060 actions,
16061 ariaLabel,
16062 hasPadding = false,
16063 showSidebarToggle = true
16064 }) {
16065 const classes = clsx_default(style_default35.page, className);
16066 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
16067 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
16068 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
16069 Header3,
16070 {
16071 headingLevel,
16072 breadcrumbs,
16073 badges,
16074 visual,
16075 title,
16076 subTitle,
16077 actions,
16078 showSidebarToggle
16079 }
16080 ),
16081 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
16082 "div",
16083 {
16084 className: clsx_default(
16085 style_default35.content,
16086 style_default35["has-padding"]
16087 ),
16088 children
16089 }
16090 ) : children
16091 ] });
16092 }
16093 Page.SidebarToggleFill = SidebarToggleFill;
16094 var page_default = Page;
16095
16096 // routes/dashboard/stage.tsx
16097 var import_data8 = __toESM(require_data());
16098 var import_element132 = __toESM(require_element());
16099 var import_i18n55 = __toESM(require_i18n());
16100 var import_notices = __toESM(require_notices());
16101
16102 // routes/dashboard/hooks/use-dashboard-layout/use-dashboard-layout.ts
16103 var import_api_fetch = __toESM(require_api_fetch());
16104 var import_data = __toESM(require_data());
16105 var import_preferences = __toESM(require_preferences());
16106 var SCOPE = "core/dashboard";
16107 var KEY = "dashboardLayout";
16108 function useDashboardLayout(dashboardName) {
16109 const layout = (0, import_data.useSelect)(
16110 (select) => select(import_preferences.store).get(SCOPE, KEY) ?? [],
16111 []
16112 );
16113 const { set: set3 } = (0, import_data.useDispatch)(import_preferences.store);
16114 function setLayout(newLayout) {
16115 void set3(SCOPE, KEY, newLayout);
16116 }
16117 async function resetLayout() {
16118 const fresh = await (0, import_api_fetch.default)({
16119 path: `/wp/v2/dashboards/${dashboardName}/default-layout`
16120 });
16121 void set3(SCOPE, KEY, fresh);
16122 }
16123 return [layout, setLayout, resetLayout];
16124 }
16125
16126 // routes/dashboard/widget-dashboard/context/dashboard-context.tsx
16127 var import_es6 = __toESM(require_es6());
16128 var import_element63 = __toESM(require_element());
16129 var import_jsx_runtime83 = __toESM(require_jsx_runtime());
16130 var DEFAULT_GRID = {
16131 minColumnWidth: 350,
16132 rowHeight: 200,
16133 spacing: 4
16134 };
16135 var DEFAULT_RESOLVE_WIDGET_MODULE = (moduleId) => import(
16136 /* webpackIgnore: true */
16137 moduleId
16138 );
16139 function canonicalize(layout) {
16140 const indexed = layout.map((widget, index2) => ({
16141 widget,
16142 order: widget.placement?.order ?? index2
16143 }));
16144 indexed.sort((a2, b2) => a2.order - b2.order);
16145 return indexed.map(({ widget }) => {
16146 if (!widget.placement) {
16147 return widget;
16148 }
16149 const { order: _stripped, ...placement } = widget.placement;
16150 return { ...widget, placement };
16151 });
16152 }
16153 var Context = (0, import_element63.createContext)(null);
16154 function useDashboardInternalContext() {
16155 const ctx8 = (0, import_element63.useContext)(Context);
16156 if (!ctx8) {
16157 throw new Error(
16158 "Dashboard compound used outside a WidgetDashboard subtree."
16159 );
16160 }
16161 return ctx8;
16162 }
16163 function WidgetDashboardProvider({
16164 widgetTypes,
16165 layout: committedLayout,
16166 onLayoutChange,
16167 onLayoutReset,
16168 editMode = false,
16169 onEditChange,
16170 resolveWidgetModule = DEFAULT_RESOLVE_WIDGET_MODULE,
16171 gridSettings = DEFAULT_GRID,
16172 children
16173 }) {
16174 const [stagingLayout, setStagingLayout] = (0, import_element63.useState)(committedLayout);
16175 (0, import_element63.useEffect)(() => {
16176 setStagingLayout(committedLayout);
16177 }, [committedLayout]);
16178 const hasUncommittedChanges = (0, import_element63.useMemo)(
16179 () => !(0, import_es6.default)(
16180 canonicalize(committedLayout),
16181 canonicalize(stagingLayout)
16182 ),
16183 [committedLayout, stagingLayout]
16184 );
16185 const commitLayout = (0, import_element63.useCallback)(() => {
16186 if (hasUncommittedChanges) {
16187 onLayoutChange(canonicalize(stagingLayout));
16188 }
16189 onEditChange?.(false);
16190 }, [hasUncommittedChanges, onLayoutChange, stagingLayout, onEditChange]);
16191 const cancelLayout = (0, import_element63.useCallback)(() => {
16192 setStagingLayout(committedLayout);
16193 onEditChange?.(false);
16194 }, [committedLayout, onEditChange]);
16195 (0, import_element63.useEffect)(() => {
16196 if (stagingLayout.length === 0) {
16197 onEditChange?.(true);
16198 }
16199 }, [stagingLayout.length === 0]);
16200 const value = (0, import_element63.useMemo)(
16201 () => ({
16202 widgetTypes,
16203 layout: stagingLayout,
16204 onLayoutChange: setStagingLayout,
16205 onLayoutReset,
16206 commitLayout,
16207 cancelLayout,
16208 hasUncommittedChanges,
16209 editMode,
16210 onEditChange,
16211 resolveWidgetModule,
16212 gridSettings
16213 }),
16214 [
16215 widgetTypes,
16216 stagingLayout,
16217 onLayoutReset,
16218 commitLayout,
16219 cancelLayout,
16220 hasUncommittedChanges,
16221 editMode,
16222 onEditChange,
16223 resolveWidgetModule,
16224 gridSettings
16225 ]
16226 );
16227 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Context.Provider, { value, children });
16228 }
16229
16230 // routes/dashboard/widget-dashboard/context/ui-context.tsx
16231 var import_element64 = __toESM(require_element());
16232 var import_jsx_runtime84 = __toESM(require_jsx_runtime());
16233 var Context2 = (0, import_element64.createContext)(null);
16234 function useDashboardUIContext() {
16235 const ctx8 = (0, import_element64.useContext)(Context2);
16236 if (!ctx8) {
16237 throw new Error(
16238 "Dashboard compound used outside a WidgetDashboard subtree."
16239 );
16240 }
16241 return ctx8;
16242 }
16243 function WidgetDashboardUIProvider({ children }) {
16244 const [inserterOpen, setInserterOpen] = (0, import_element64.useState)(false);
16245 const value = (0, import_element64.useMemo)(
16246 () => ({ inserterOpen, setInserterOpen }),
16247 [inserterOpen]
16248 );
16249 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Context2.Provider, { value, children });
16250 }
16251
16252 // routes/dashboard/widget-dashboard/components/actions/actions.tsx
16253 var import_element65 = __toESM(require_element());
16254 var import_i18n7 = __toESM(require_i18n());
16255
16256 // packages/style-runtime/src/index.ts
16257 var STYLE_HASH_ATTRIBUTE35 = "data-wp-hash";
16258 function getRuntime35() {
16259 const globalScope = globalThis;
16260 if (globalScope.__wpStyleRuntime) {
16261 return globalScope.__wpStyleRuntime;
16262 }
16263 globalScope.__wpStyleRuntime = {
16264 documents: /* @__PURE__ */ new Map(),
16265 styles: /* @__PURE__ */ new Map(),
16266 injectedStyles: /* @__PURE__ */ new WeakMap()
16267 };
16268 if (typeof document !== "undefined") {
16269 registerDocument35(document);
16270 }
16271 return globalScope.__wpStyleRuntime;
16272 }
16273 function documentContainsStyleHash35(targetDocument, hash) {
16274 if (!targetDocument.head) {
16275 return false;
16276 }
16277 for (const style of targetDocument.head.querySelectorAll(
16278 `style[${STYLE_HASH_ATTRIBUTE35}]`
16279 )) {
16280 if (style.getAttribute(STYLE_HASH_ATTRIBUTE35) === hash) {
16281 return true;
16282 }
16283 }
16284 return false;
16285 }
16286 function injectStyle35(targetDocument, hash, css) {
16287 if (!targetDocument.head) {
16288 return;
16289 }
16290 const runtime = getRuntime35();
16291 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16292 if (!injectedStyles) {
16293 injectedStyles = /* @__PURE__ */ new Set();
16294 runtime.injectedStyles.set(targetDocument, injectedStyles);
16295 }
16296 if (injectedStyles.has(hash)) {
16297 return;
16298 }
16299 if (documentContainsStyleHash35(targetDocument, hash)) {
16300 injectedStyles.add(hash);
16301 return;
16302 }
16303 const style = targetDocument.createElement("style");
16304 style.setAttribute(STYLE_HASH_ATTRIBUTE35, hash);
16305 style.appendChild(targetDocument.createTextNode(css));
16306 targetDocument.head.appendChild(style);
16307 injectedStyles.add(hash);
16308 }
16309 function registerDocument35(targetDocument) {
16310 const runtime = getRuntime35();
16311 runtime.documents.set(
16312 targetDocument,
16313 (runtime.documents.get(targetDocument) ?? 0) + 1
16314 );
16315 for (const [hash, css] of runtime.styles) {
16316 injectStyle35(targetDocument, hash, css);
16317 }
16318 return () => {
16319 const count = runtime.documents.get(targetDocument);
16320 if (count === void 0) {
16321 return;
16322 }
16323 if (count <= 1) {
16324 runtime.documents.delete(targetDocument);
16325 return;
16326 }
16327 runtime.documents.set(targetDocument, count - 1);
16328 };
16329 }
16330 function registerStyle35(hash, css) {
16331 const runtime = getRuntime35();
16332 runtime.styles.set(hash, css);
16333 for (const targetDocument of runtime.documents.keys()) {
16334 injectStyle35(targetDocument, hash, css);
16335 }
16336 }
16337
16338 // routes/dashboard/widget-dashboard/components/actions/actions.module.css
16339 if (typeof process === "undefined" || true) {
16340 registerStyle35("616d83d5a3", ".a6e8ada13acc9f11__editActionsExit,.aa9a2b8bca16d3d4__editActionsEnter{display:inline-flex;gap:var(--wp--preset--spacing--20);transform-origin:right center}@media not (prefers-reduced-motion){.a6e8ada13acc9f11__editActionsExit,.aa9a2b8bca16d3d4__editActionsEnter{will-change:opacity,transform}.aa9a2b8bca16d3d4__editActionsEnter{animation:_6ad9417d3c8378ea__actions-slide-in var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)) forwards}.a6e8ada13acc9f11__editActionsExit{animation:ca863286783f6f27__actions-fold-out var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes _6ad9417d3c8378ea__actions-slide-in{0%{opacity:0;transform:translateX(12px) scaleX(.92)}to{opacity:1;transform:translateX(0) scaleX(1)}}@keyframes ca863286783f6f27__actions-fold-out{0%{opacity:1;transform:translateX(0) scaleX(1)}to{opacity:0;transform:translateX(12px) scaleX(.92)}}}");
16341 }
16342 var actions_default = { "editActionsEnter": "aa9a2b8bca16d3d4__editActionsEnter", "editActionsExit": "a6e8ada13acc9f11__editActionsExit", "actions-slide-in": "_6ad9417d3c8378ea__actions-slide-in", "actions-fold-out": "ca863286783f6f27__actions-fold-out" };
16343
16344 // routes/dashboard/widget-dashboard/components/more-actions-dropdown/more-actions-dropdown.tsx
16345 var import_components2 = __toESM(require_components());
16346 var import_i18n6 = __toESM(require_i18n());
16347
16348 // routes/dashboard/lock-unlock.ts
16349 var import_private_apis2 = __toESM(require_private_apis());
16350 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
16351 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
16352 "@wordpress/routes"
16353 );
16354
16355 // routes/dashboard/widget-dashboard/components/more-actions-dropdown/more-actions-dropdown.tsx
16356 var import_jsx_runtime85 = __toESM(require_jsx_runtime());
16357 var { Menu } = unlock2(import_components2.privateApis);
16358 function MoreActionsDropdown({
16359 items
16360 }) {
16361 if (items.length === 0) {
16362 return null;
16363 }
16364 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(Menu, { children: [
16365 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
16366 Menu.TriggerButton,
16367 {
16368 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
16369 IconButton,
16370 {
16371 icon: more_vertical_default,
16372 label: (0, import_i18n6.__)("More options"),
16373 variant: "minimal",
16374 tone: "brand",
16375 size: "compact"
16376 }
16377 )
16378 }
16379 ),
16380 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Menu.Group, { children: items.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
16381 Menu.Item,
16382 {
16383 disabled: item.disabled,
16384 onClick: item.onClick,
16385 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Button4, { variant: "minimal", tone: "neutral" }),
16386 children: item.label
16387 },
16388 index2
16389 )) }) })
16390 ] });
16391 }
16392
16393 // routes/dashboard/widget-dashboard/components/actions/actions.tsx
16394 var import_jsx_runtime86 = __toESM(require_jsx_runtime());
16395 function Actions3() {
16396 const {
16397 editMode,
16398 onEditChange,
16399 onLayoutReset,
16400 commitLayout,
16401 cancelLayout,
16402 hasUncommittedChanges
16403 } = useDashboardInternalContext();
16404 const [isEditActionsMounted, setIsEditActionsMounted] = (0, import_element65.useState)(editMode);
16405 const [isExitingEditActions, setIsExitingEditActions] = (0, import_element65.useState)(false);
16406 (0, import_element65.useEffect)(() => {
16407 if (editMode) {
16408 setIsEditActionsMounted(true);
16409 setIsExitingEditActions(false);
16410 return;
16411 }
16412 if (!isEditActionsMounted) {
16413 return;
16414 }
16415 setIsExitingEditActions(true);
16416 const exitTimeout = setTimeout(() => {
16417 setIsEditActionsMounted(false);
16418 setIsExitingEditActions(false);
16419 }, 220);
16420 return () => clearTimeout(exitTimeout);
16421 }, [editMode, isEditActionsMounted]);
16422 const { setInserterOpen } = useDashboardUIContext();
16423 const [isResetDialogOpen, setIsResetDialogOpen] = (0, import_element65.useState)(false);
16424 const handleEditMode = (0, import_element65.useCallback)(() => {
16425 onEditChange?.(!editMode);
16426 }, [editMode, onEditChange]);
16427 const insert = (0, import_element65.useCallback)(() => {
16428 setInserterOpen(true);
16429 }, [setInserterOpen]);
16430 const cancel = (0, import_element65.useCallback)(() => {
16431 cancelLayout();
16432 }, [cancelLayout]);
16433 const done = (0, import_element65.useCallback)(() => {
16434 commitLayout();
16435 }, [commitLayout]);
16436 const moreActionsItems = [
16437 {
16438 label: (0, import_i18n7.__)("Reset to default"),
16439 onClick: () => setIsResetDialogOpen(true),
16440 disabled: !onLayoutReset
16441 }
16442 ];
16443 if (!onEditChange) {
16444 return null;
16445 }
16446 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Stack, { direction: "row", gap: "sm", children: [
16447 isEditActionsMounted ? /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
16448 Stack,
16449 {
16450 direction: "row",
16451 gap: "sm",
16452 className: isExitingEditActions ? actions_default.editActionsExit : actions_default.editActionsEnter,
16453 children: [
16454 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16455 Button4,
16456 {
16457 variant: "minimal",
16458 tone: "brand",
16459 size: "compact",
16460 onClick: insert,
16461 children: (0, import_i18n7.__)("Add widgets")
16462 }
16463 ),
16464 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16465 Button4,
16466 {
16467 variant: "minimal",
16468 tone: "brand",
16469 size: "compact",
16470 onClick: cancel,
16471 children: (0, import_i18n7.__)("Cancel")
16472 }
16473 ),
16474 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16475 Button4,
16476 {
16477 variant: "solid",
16478 tone: "brand",
16479 size: "compact",
16480 onClick: done,
16481 disabled: !hasUncommittedChanges,
16482 children: (0, import_i18n7.__)("Done")
16483 }
16484 )
16485 ]
16486 }
16487 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16488 Button4,
16489 {
16490 variant: "outline",
16491 tone: "brand",
16492 size: "compact",
16493 onClick: handleEditMode,
16494 children: (0, import_i18n7.__)("Customize")
16495 }
16496 ),
16497 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(MoreActionsDropdown, { items: moreActionsItems }),
16498 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16499 alert_dialog_exports.Root,
16500 {
16501 open: isResetDialogOpen,
16502 onOpenChange: setIsResetDialogOpen,
16503 onConfirm: async () => {
16504 await onLayoutReset?.();
16505 onEditChange?.(false);
16506 setIsResetDialogOpen(false);
16507 },
16508 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16509 alert_dialog_exports.Popup,
16510 {
16511 intent: "irreversible",
16512 title: (0, import_i18n7.__)("Reset dashboard to default?"),
16513 description: (0, import_i18n7.__)(
16514 "All customizations will be permanently lost."
16515 ),
16516 confirmButtonText: (0, import_i18n7.__)("Reset")
16517 }
16518 )
16519 }
16520 )
16521 ] });
16522 }
16523
16524 // routes/dashboard/widget-dashboard/components/inserter/inserter.tsx
16525 var import_element124 = __toESM(require_element());
16526 var import_i18n51 = __toESM(require_i18n());
16527
16528 // routes/dashboard/widget-dashboard/utils/create-dashboard-widget/create-dashboard-widget.ts
16529 var DEFAULT_PLACEMENT = {
16530 width: 1,
16531 height: 2,
16532 order: 0
16533 };
16534 function createDashboardWidget(widgetType, initialAttributes) {
16535 return {
16536 uuid: crypto.randomUUID(),
16537 type: widgetType.name,
16538 attributes: initialAttributes ?? widgetType.example?.attributes,
16539 placement: DEFAULT_PLACEMENT
16540 };
16541 }
16542
16543 // packages/dataviews/build-module/components/dataviews-context/index.mjs
16544 var import_element66 = __toESM(require_element(), 1);
16545
16546 // packages/dataviews/build-module/constants.mjs
16547 var import_i18n8 = __toESM(require_i18n(), 1);
16548 var OPERATOR_IS_ANY = "isAny";
16549 var OPERATOR_IS_NONE = "isNone";
16550 var OPERATOR_IS_ALL = "isAll";
16551 var OPERATOR_IS_NOT_ALL = "isNotAll";
16552 var OPERATOR_BETWEEN = "between";
16553 var OPERATOR_IN_THE_PAST = "inThePast";
16554 var OPERATOR_OVER = "over";
16555 var OPERATOR_IS = "is";
16556 var OPERATOR_IS_NOT = "isNot";
16557 var OPERATOR_LESS_THAN = "lessThan";
16558 var OPERATOR_GREATER_THAN = "greaterThan";
16559 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
16560 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
16561 var OPERATOR_BEFORE = "before";
16562 var OPERATOR_AFTER = "after";
16563 var OPERATOR_BEFORE_INC = "beforeInc";
16564 var OPERATOR_AFTER_INC = "afterInc";
16565 var OPERATOR_CONTAINS = "contains";
16566 var OPERATOR_NOT_CONTAINS = "notContains";
16567 var OPERATOR_STARTS_WITH = "startsWith";
16568 var OPERATOR_ON = "on";
16569 var OPERATOR_NOT_ON = "notOn";
16570 var SORTING_DIRECTIONS = ["asc", "desc"];
16571 var sortArrows = { asc: "\u2191", desc: "\u2193" };
16572 var sortValues = { asc: "ascending", desc: "descending" };
16573 var sortLabels = {
16574 asc: (0, import_i18n8.__)("Sort ascending"),
16575 desc: (0, import_i18n8.__)("Sort descending")
16576 };
16577 var sortIcons = {
16578 asc: arrow_up_default,
16579 desc: arrow_down_default
16580 };
16581 var LAYOUT_TABLE = "table";
16582 var LAYOUT_GRID = "grid";
16583 var LAYOUT_LIST = "list";
16584 var LAYOUT_ACTIVITY = "activity";
16585 var LAYOUT_PICKER_GRID = "pickerGrid";
16586 var LAYOUT_PICKER_TABLE = "pickerTable";
16587
16588 // packages/dataviews/build-module/components/dataviews-context/index.mjs
16589 var DataViewsContext = (0, import_element66.createContext)({
16590 view: { type: LAYOUT_TABLE },
16591 onChangeView: () => {
16592 },
16593 fields: [],
16594 data: [],
16595 paginationInfo: {
16596 totalItems: 0,
16597 totalPages: 0
16598 },
16599 selection: [],
16600 onChangeSelection: () => {
16601 },
16602 setOpenedFilter: () => {
16603 },
16604 openedFilter: null,
16605 getItemId: (item) => item.id,
16606 isItemClickable: () => true,
16607 renderItemLink: void 0,
16608 containerWidth: 0,
16609 containerRef: (0, import_element66.createRef)(),
16610 resizeObserverRef: () => {
16611 },
16612 defaultLayouts: { list: {}, grid: {}, table: {} },
16613 filters: [],
16614 isShowingFilter: false,
16615 setIsShowingFilter: () => {
16616 },
16617 hasInitiallyLoaded: false,
16618 config: {
16619 perPageSizes: []
16620 },
16621 intersectionObserver: null
16622 });
16623 DataViewsContext.displayName = "DataViewsContext";
16624 var dataviews_context_default = DataViewsContext;
16625
16626 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
16627 var import_i18n28 = __toESM(require_i18n(), 1);
16628
16629 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
16630 var import_i18n16 = __toESM(require_i18n(), 1);
16631 var import_components8 = __toESM(require_components(), 1);
16632 var import_element74 = __toESM(require_element(), 1);
16633 var import_keycodes = __toESM(require_keycodes(), 1);
16634
16635 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
16636 var import_components3 = __toESM(require_components(), 1);
16637 var import_i18n9 = __toESM(require_i18n(), 1);
16638 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
16639 function DataViewsSelectionCheckbox({
16640 selection,
16641 onChangeSelection,
16642 item,
16643 getItemId: getItemId2,
16644 titleField,
16645 disabled: disabled2,
16646 ...extraProps
16647 }) {
16648 const id = getItemId2(item);
16649 const isInSelectionArray = selection.includes(id);
16650 const checked = !disabled2 && isInSelectionArray;
16651 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n9.__)("(no title)");
16652 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
16653 import_components3.CheckboxControl,
16654 {
16655 className: "dataviews-selection-checkbox",
16656 "aria-label": selectionLabel,
16657 "aria-disabled": disabled2,
16658 checked,
16659 onChange: () => {
16660 if (disabled2) {
16661 return;
16662 }
16663 onChangeSelection(
16664 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
16665 );
16666 },
16667 ...extraProps
16668 }
16669 );
16670 }
16671
16672 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
16673 var import_components4 = __toESM(require_components(), 1);
16674 var import_i18n10 = __toESM(require_i18n(), 1);
16675 var import_element67 = __toESM(require_element(), 1);
16676 var import_data2 = __toESM(require_data(), 1);
16677 var import_compose5 = __toESM(require_compose(), 1);
16678
16679 // packages/dataviews/build-module/lock-unlock.mjs
16680 var import_private_apis3 = __toESM(require_private_apis(), 1);
16681 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
16682 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
16683 "@wordpress/dataviews"
16684 );
16685
16686 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
16687 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
16688 var { Menu: Menu2, kebabCase } = unlock3(import_components4.privateApis);
16689 function ButtonTrigger({
16690 action,
16691 onClick,
16692 items,
16693 variant
16694 }) {
16695 const label = typeof action.label === "string" ? action.label : action.label(items);
16696 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16697 import_components4.Button,
16698 {
16699 disabled: !!action.disabled,
16700 accessibleWhenDisabled: true,
16701 size: "compact",
16702 variant,
16703 onClick,
16704 children: label
16705 }
16706 );
16707 }
16708 function MenuItemTrigger({
16709 action,
16710 onClick,
16711 items
16712 }) {
16713 const label = typeof action.label === "string" ? action.label : action.label(items);
16714 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Menu2.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Menu2.ItemLabel, { children: label }) });
16715 }
16716 function ActionModal({
16717 action,
16718 items,
16719 closeModal
16720 }) {
16721 const label = typeof action.label === "string" ? action.label : action.label(items);
16722 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
16723 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16724 import_components4.Modal,
16725 {
16726 title: modalHeader || label,
16727 __experimentalHideHeader: !!action.hideModalHeader,
16728 onRequestClose: closeModal,
16729 focusOnMount: action.modalFocusOnMount ?? true,
16730 size: action.modalSize || "medium",
16731 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
16732 action.id
16733 )}`,
16734 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(action.RenderModal, { items, closeModal })
16735 }
16736 );
16737 }
16738 function ActionsMenuGroup({
16739 actions,
16740 item,
16741 registry,
16742 setActiveModalAction
16743 }) {
16744 const { primaryActions, regularActions } = (0, import_element67.useMemo)(() => {
16745 return actions.reduce(
16746 (acc, action) => {
16747 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
16748 return acc;
16749 },
16750 {
16751 primaryActions: [],
16752 regularActions: []
16753 }
16754 );
16755 }, [actions]);
16756 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16757 MenuItemTrigger,
16758 {
16759 action,
16760 onClick: () => {
16761 if ("RenderModal" in action) {
16762 setActiveModalAction(action);
16763 return;
16764 }
16765 action.callback([item], { registry });
16766 },
16767 items: [item]
16768 },
16769 action.id
16770 ));
16771 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Menu2.Group, { children: [
16772 renderActionGroup(primaryActions),
16773 renderActionGroup(regularActions)
16774 ] });
16775 }
16776 function ItemActions({
16777 item,
16778 actions,
16779 isCompact
16780 }) {
16781 const registry = (0, import_data2.useRegistry)();
16782 const { primaryActions, eligibleActions } = (0, import_element67.useMemo)(() => {
16783 const _eligibleActions = actions.filter(
16784 (action) => !action.isEligible || action.isEligible(item)
16785 );
16786 const _primaryActions = _eligibleActions.filter(
16787 (action) => action.isPrimary
16788 );
16789 return {
16790 primaryActions: _primaryActions,
16791 eligibleActions: _eligibleActions
16792 };
16793 }, [actions, item]);
16794 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
16795 if (isCompact) {
16796 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16797 CompactItemActions,
16798 {
16799 item,
16800 actions: eligibleActions,
16801 isSmall: true,
16802 registry
16803 }
16804 );
16805 }
16806 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
16807 Stack,
16808 {
16809 direction: "row",
16810 justify: "flex-end",
16811 className: "dataviews-item-actions",
16812 style: {
16813 flexShrink: 0,
16814 width: "auto"
16815 },
16816 children: [
16817 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16818 PrimaryActions,
16819 {
16820 item,
16821 actions: primaryActions,
16822 registry
16823 }
16824 ),
16825 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
16826 // there if there are any actions at all.
16827 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16828 CompactItemActions,
16829 {
16830 item,
16831 actions: eligibleActions,
16832 registry
16833 }
16834 )
16835 ]
16836 }
16837 );
16838 }
16839 function CompactItemActions({
16840 item,
16841 actions,
16842 isSmall,
16843 registry
16844 }) {
16845 const [activeModalAction, setActiveModalAction] = (0, import_element67.useState)(
16846 null
16847 );
16848 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
16849 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Menu2, { placement: "bottom-end", children: [
16850 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16851 Menu2.TriggerButton,
16852 {
16853 render: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16854 import_components4.Button,
16855 {
16856 size: isSmall ? "small" : "compact",
16857 icon: more_vertical_default,
16858 label: (0, import_i18n10.__)("Actions"),
16859 accessibleWhenDisabled: true,
16860 disabled: !actions.length,
16861 className: "dataviews-all-actions-button"
16862 }
16863 )
16864 }
16865 ),
16866 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Menu2.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16867 ActionsMenuGroup,
16868 {
16869 actions,
16870 item,
16871 registry,
16872 setActiveModalAction
16873 }
16874 ) })
16875 ] }),
16876 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16877 ActionModal,
16878 {
16879 action: activeModalAction,
16880 items: [item],
16881 closeModal: () => setActiveModalAction(null)
16882 }
16883 )
16884 ] });
16885 }
16886 function PrimaryActions({
16887 item,
16888 actions,
16889 registry,
16890 buttonVariant
16891 }) {
16892 const [activeModalAction, setActiveModalAction] = (0, import_element67.useState)(null);
16893 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
16894 if (isMobileViewport) {
16895 return null;
16896 }
16897 if (!Array.isArray(actions) || actions.length === 0) {
16898 return null;
16899 }
16900 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
16901 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16902 ButtonTrigger,
16903 {
16904 action,
16905 onClick: () => {
16906 if ("RenderModal" in action) {
16907 setActiveModalAction(action);
16908 return;
16909 }
16910 action.callback([item], { registry });
16911 },
16912 items: [item],
16913 variant: buttonVariant
16914 },
16915 action.id
16916 )),
16917 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16918 ActionModal,
16919 {
16920 action: activeModalAction,
16921 items: [item],
16922 closeModal: () => setActiveModalAction(null)
16923 }
16924 )
16925 ] });
16926 }
16927
16928 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
16929 var import_components5 = __toESM(require_components(), 1);
16930 var import_i18n12 = __toESM(require_i18n(), 1);
16931 var import_element68 = __toESM(require_element(), 1);
16932 var import_data3 = __toESM(require_data(), 1);
16933 var import_compose6 = __toESM(require_compose(), 1);
16934
16935 // packages/dataviews/build-module/utils/get-footer-message.mjs
16936 var import_i18n11 = __toESM(require_i18n(), 1);
16937 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
16938 if (selectionCount > 0) {
16939 return (0, import_i18n11.sprintf)(
16940 /* translators: %d: number of items. */
16941 (0, import_i18n11._n)("%d Item selected", "%d Items selected", selectionCount),
16942 selectionCount
16943 );
16944 }
16945 if (onlyTotalCount || totalItems <= itemsCount) {
16946 return (0, import_i18n11.sprintf)(
16947 /* translators: %d: number of items. */
16948 (0, import_i18n11._n)("%d Item", "%d Items", totalItems),
16949 totalItems
16950 );
16951 }
16952 return (0, import_i18n11.sprintf)(
16953 /* translators: %1$d: number of items. %2$d: total number of items. */
16954 (0, import_i18n11._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
16955 itemsCount,
16956 totalItems
16957 );
16958 }
16959
16960 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
16961 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
16962 function useHasAPossibleBulkAction(actions, item) {
16963 return (0, import_element68.useMemo)(() => {
16964 return actions.some((action) => {
16965 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
16966 });
16967 }, [actions, item]);
16968 }
16969 function useSomeItemHasAPossibleBulkAction(actions, data) {
16970 return (0, import_element68.useMemo)(() => {
16971 return data.some((item) => {
16972 return actions.some((action) => {
16973 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
16974 });
16975 });
16976 }, [actions, data]);
16977 }
16978 function BulkSelectionCheckbox({
16979 selection,
16980 onChangeSelection,
16981 data,
16982 actions,
16983 getItemId: getItemId2,
16984 disableSelectAll = false
16985 }) {
16986 const selectableItems = (0, import_element68.useMemo)(() => {
16987 return data.filter((item) => {
16988 return actions.some(
16989 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
16990 );
16991 });
16992 }, [data, actions]);
16993 const selectedItems = data.filter(
16994 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item)
16995 );
16996 const hasSelection = selection.length > 0;
16997 const areAllSelected = selectedItems.length === selectableItems.length;
16998 if (disableSelectAll) {
16999 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
17000 import_components5.CheckboxControl,
17001 {
17002 className: "dataviews-view-table-selection-checkbox",
17003 checked: hasSelection,
17004 disabled: !hasSelection,
17005 onChange: () => {
17006 onChangeSelection([]);
17007 },
17008 "aria-label": (0, import_i18n12.__)("Deselect all")
17009 }
17010 );
17011 }
17012 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
17013 import_components5.CheckboxControl,
17014 {
17015 className: "dataviews-view-table-selection-checkbox",
17016 checked: areAllSelected,
17017 indeterminate: !areAllSelected && !!selectedItems.length,
17018 onChange: () => {
17019 if (areAllSelected) {
17020 onChangeSelection([]);
17021 } else {
17022 onChangeSelection(
17023 selectableItems.map((item) => getItemId2(item))
17024 );
17025 }
17026 },
17027 "aria-label": areAllSelected ? (0, import_i18n12.__)("Deselect all") : (0, import_i18n12.__)("Select all")
17028 }
17029 );
17030 }
17031
17032 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
17033 var import_i18n13 = __toESM(require_i18n(), 1);
17034 var import_components6 = __toESM(require_components(), 1);
17035 var import_element69 = __toESM(require_element(), 1);
17036
17037 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
17038 function getHideableFields(view, fields2) {
17039 const togglableFields = [
17040 view?.titleField,
17041 view?.mediaField,
17042 view?.descriptionField
17043 ].filter(Boolean);
17044 return fields2.filter(
17045 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
17046 );
17047 }
17048
17049 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
17050 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
17051 var { Menu: Menu3 } = unlock3(import_components6.privateApis);
17052 function WithMenuSeparators({ children }) {
17053 return import_element69.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_element69.Fragment, { children: [
17054 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.Separator, {}),
17055 child
17056 ] }, i2));
17057 }
17058 var _HeaderMenu = (0, import_element69.forwardRef)(function HeaderMenu({
17059 fieldId,
17060 view,
17061 fields: fields2,
17062 onChangeView,
17063 onHide,
17064 setOpenedFilter,
17065 canMove = true,
17066 canInsertLeft = true,
17067 canInsertRight = true
17068 }, ref) {
17069 const visibleFieldIds = view.fields ?? [];
17070 const index2 = visibleFieldIds?.indexOf(fieldId);
17071 const isSorted = view.sort?.field === fieldId;
17072 let isHidable = false;
17073 let isSortable = false;
17074 let canAddFilter = false;
17075 let operators = [];
17076 const field = fields2.find((f2) => f2.id === fieldId);
17077 const { setIsShowingFilter } = (0, import_element69.useContext)(dataviews_context_default);
17078 if (!field) {
17079 return null;
17080 }
17081 isHidable = field.enableHiding !== false;
17082 isSortable = field.enableSorting !== false;
17083 const header = field.header;
17084 operators = !!field.filterBy && field.filterBy?.operators || [];
17085 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
17086 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
17087 return header;
17088 }
17089 const hiddenFields = getHideableFields(view, fields2).filter(
17090 (f2) => !visibleFieldIds.includes(f2.id)
17091 );
17092 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
17093 const isRtl = (0, import_i18n13.isRTL)();
17094 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Menu3, { children: [
17095 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
17096 Menu3.TriggerButton,
17097 {
17098 render: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17099 import_components6.Button,
17100 {
17101 size: "compact",
17102 className: "dataviews-view-table-header-button",
17103 ref,
17104 variant: "tertiary"
17105 }
17106 ),
17107 children: [
17108 header,
17109 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
17110 ]
17111 }
17112 ),
17113 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(WithMenuSeparators, { children: [
17114 isSortable && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.Group, { children: SORTING_DIRECTIONS.map(
17115 (direction) => {
17116 const isChecked = view.sort && isSorted && view.sort.direction === direction;
17117 const value = `${fieldId}-${direction}`;
17118 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17119 Menu3.RadioItem,
17120 {
17121 name: "view-table-sorting",
17122 value,
17123 checked: isChecked,
17124 onChange: () => {
17125 onChangeView({
17126 ...view,
17127 sort: {
17128 field: fieldId,
17129 direction
17130 },
17131 showLevels: false
17132 });
17133 },
17134 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: sortLabels[direction] })
17135 },
17136 value
17137 );
17138 }
17139 ) }),
17140 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17141 Menu3.Item,
17142 {
17143 prefix: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components6.Icon, { icon: funnel_default }),
17144 onClick: () => {
17145 setOpenedFilter(fieldId);
17146 setIsShowingFilter(true);
17147 onChangeView({
17148 ...view,
17149 page: 1,
17150 filters: [
17151 ...view.filters || [],
17152 {
17153 field: fieldId,
17154 value: void 0,
17155 operator: operators[0]
17156 }
17157 ]
17158 });
17159 },
17160 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: (0, import_i18n13.__)("Add filter") })
17161 }
17162 ) }),
17163 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Menu3.Group, { children: [
17164 canMove && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17165 Menu3.Item,
17166 {
17167 prefix: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components6.Icon, { icon: arrow_left_default }),
17168 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
17169 onClick: () => {
17170 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
17171 const newFields = [
17172 ...visibleFieldIds
17173 ];
17174 newFields.splice(index2, 1);
17175 newFields.splice(
17176 targetIndex,
17177 0,
17178 fieldId
17179 );
17180 onChangeView({
17181 ...view,
17182 fields: newFields
17183 });
17184 },
17185 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: (0, import_i18n13.__)("Move left") })
17186 }
17187 ),
17188 canMove && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17189 Menu3.Item,
17190 {
17191 prefix: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components6.Icon, { icon: arrow_right_default }),
17192 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
17193 onClick: () => {
17194 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
17195 const newFields = [
17196 ...visibleFieldIds
17197 ];
17198 newFields.splice(index2, 1);
17199 newFields.splice(
17200 targetIndex,
17201 0,
17202 fieldId
17203 );
17204 onChangeView({
17205 ...view,
17206 fields: newFields
17207 });
17208 },
17209 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: (0, import_i18n13.__)("Move right") })
17210 }
17211 ),
17212 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Menu3, { children: [
17213 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: (0, import_i18n13.__)("Insert left") }) }),
17214 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.Popover, { children: hiddenFields.map((hiddenField) => {
17215 const insertIndex = isRtl ? index2 + 1 : index2;
17216 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17217 Menu3.Item,
17218 {
17219 onClick: () => {
17220 onChangeView({
17221 ...view,
17222 fields: [
17223 ...visibleFieldIds.slice(
17224 0,
17225 insertIndex
17226 ),
17227 hiddenField.id,
17228 ...visibleFieldIds.slice(
17229 insertIndex
17230 )
17231 ]
17232 });
17233 },
17234 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: hiddenField.label })
17235 },
17236 hiddenField.id
17237 );
17238 }) })
17239 ] }),
17240 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Menu3, { children: [
17241 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: (0, import_i18n13.__)("Insert right") }) }),
17242 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.Popover, { children: hiddenFields.map((hiddenField) => {
17243 const insertIndex = isRtl ? index2 : index2 + 1;
17244 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17245 Menu3.Item,
17246 {
17247 onClick: () => {
17248 onChangeView({
17249 ...view,
17250 fields: [
17251 ...visibleFieldIds.slice(
17252 0,
17253 insertIndex
17254 ),
17255 hiddenField.id,
17256 ...visibleFieldIds.slice(
17257 insertIndex
17258 )
17259 ]
17260 });
17261 },
17262 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: hiddenField.label })
17263 },
17264 hiddenField.id
17265 );
17266 }) })
17267 ] }),
17268 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17269 Menu3.Item,
17270 {
17271 prefix: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components6.Icon, { icon: unseen_default }),
17272 onClick: () => {
17273 onHide(field);
17274 onChangeView({
17275 ...view,
17276 fields: visibleFieldIds.filter(
17277 (id) => id !== fieldId
17278 )
17279 });
17280 },
17281 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu3.ItemLabel, { children: (0, import_i18n13.__)("Hide column") })
17282 }
17283 )
17284 ] })
17285 ] }) })
17286 ] });
17287 });
17288 var ColumnHeaderMenu = _HeaderMenu;
17289 var column_header_menu_default = ColumnHeaderMenu;
17290
17291 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
17292 var import_element70 = __toESM(require_element(), 1);
17293 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
17294 function getClickableItemProps({
17295 item,
17296 isItemClickable: isItemClickable2,
17297 onClickItem,
17298 className
17299 }) {
17300 if (!isItemClickable2(item) || !onClickItem) {
17301 return { className };
17302 }
17303 return {
17304 className: className ? `${className} ${className}--clickable` : void 0,
17305 role: "button",
17306 tabIndex: 0,
17307 onClick: (event) => {
17308 event.stopPropagation();
17309 onClickItem(item);
17310 },
17311 onKeyDown: (event) => {
17312 if (event.key === "Enter" || event.key === "" || event.key === " ") {
17313 event.stopPropagation();
17314 onClickItem(item);
17315 }
17316 }
17317 };
17318 }
17319 function ItemClickWrapper({
17320 item,
17321 isItemClickable: isItemClickable2,
17322 onClickItem,
17323 renderItemLink,
17324 className,
17325 children,
17326 ...extraProps
17327 }) {
17328 if (!isItemClickable2(item)) {
17329 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className, ...extraProps, children });
17330 }
17331 if (renderItemLink) {
17332 const renderedElement = renderItemLink({
17333 item,
17334 className: `${className} ${className}--clickable`,
17335 ...extraProps,
17336 children
17337 });
17338 return (0, import_element70.cloneElement)(renderedElement, {
17339 onClick: (event) => {
17340 event.stopPropagation();
17341 if (renderedElement.props.onClick) {
17342 renderedElement.props.onClick(event);
17343 }
17344 },
17345 onKeyDown: (event) => {
17346 if (event.key === "Enter" || event.key === "" || event.key === " ") {
17347 event.stopPropagation();
17348 if (renderedElement.props.onKeyDown) {
17349 renderedElement.props.onKeyDown(event);
17350 }
17351 }
17352 }
17353 });
17354 }
17355 const clickProps = getClickableItemProps({
17356 item,
17357 isItemClickable: isItemClickable2,
17358 onClickItem,
17359 className
17360 });
17361 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { ...clickProps, ...extraProps, children });
17362 }
17363
17364 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
17365 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
17366 function ColumnPrimary({
17367 item,
17368 level,
17369 titleField,
17370 mediaField,
17371 descriptionField,
17372 onClickItem,
17373 renderItemLink,
17374 isItemClickable: isItemClickable2
17375 }) {
17376 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
17377 mediaField && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17378 ItemClickWrapper,
17379 {
17380 item,
17381 isItemClickable: isItemClickable2,
17382 onClickItem,
17383 renderItemLink,
17384 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
17385 "aria-label": isItemClickable2(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
17386 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17387 mediaField.render,
17388 {
17389 item,
17390 field: mediaField,
17391 config: { sizes: "32px" }
17392 }
17393 )
17394 }
17395 ),
17396 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
17397 Stack,
17398 {
17399 direction: "column",
17400 align: "flex-start",
17401 className: "dataviews-view-table__primary-column-content",
17402 children: [
17403 titleField && /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
17404 ItemClickWrapper,
17405 {
17406 item,
17407 isItemClickable: isItemClickable2,
17408 onClickItem,
17409 renderItemLink,
17410 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
17411 children: [
17412 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("span", { className: "dataviews-view-table__level", children: [
17413 Array(level).fill("\u2014").join(" "),
17414 "\xA0"
17415 ] }),
17416 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(titleField.render, { item, field: titleField })
17417 ]
17418 }
17419 ),
17420 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17421 descriptionField.render,
17422 {
17423 item,
17424 field: descriptionField
17425 }
17426 )
17427 ]
17428 }
17429 )
17430 ] });
17431 }
17432 var column_primary_default = ColumnPrimary;
17433
17434 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
17435 var import_element71 = __toESM(require_element(), 1);
17436 var import_i18n14 = __toESM(require_i18n(), 1);
17437 var isScrolledToEnd = (element) => {
17438 if ((0, import_i18n14.isRTL)()) {
17439 const scrollLeft = Math.abs(element.scrollLeft);
17440 return scrollLeft <= 1;
17441 }
17442 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
17443 };
17444 function useScrollState({
17445 scrollContainerRef,
17446 enabledHorizontal = false
17447 }) {
17448 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element71.useState)(false);
17449 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element71.useState)(false);
17450 const handleScroll = (0, import_element71.useCallback)(() => {
17451 const scrollContainer = scrollContainerRef.current;
17452 if (!scrollContainer) {
17453 return;
17454 }
17455 if (enabledHorizontal) {
17456 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
17457 }
17458 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
17459 }, [scrollContainerRef, enabledHorizontal]);
17460 (0, import_element71.useEffect)(() => {
17461 if (typeof window === "undefined" || !scrollContainerRef.current) {
17462 return () => {
17463 };
17464 }
17465 const scrollContainer = scrollContainerRef.current;
17466 handleScroll();
17467 scrollContainer.addEventListener("scroll", handleScroll);
17468 window.addEventListener("resize", handleScroll);
17469 return () => {
17470 scrollContainer.removeEventListener("scroll", handleScroll);
17471 window.removeEventListener("resize", handleScroll);
17472 };
17473 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
17474 return { isHorizontalScrollEnd, isVerticallyScrolled };
17475 }
17476
17477 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
17478 function getDataByGroup(data, groupByField) {
17479 return data.reduce((groups, item) => {
17480 const groupName = groupByField.getValue({ item });
17481 if (!groups.has(groupName)) {
17482 groups.set(groupName, []);
17483 }
17484 groups.get(groupName)?.push(item);
17485 return groups;
17486 }, /* @__PURE__ */ new Map());
17487 }
17488
17489 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
17490 var import_components7 = __toESM(require_components(), 1);
17491 var import_i18n15 = __toESM(require_i18n(), 1);
17492 var import_element72 = __toESM(require_element(), 1);
17493 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
17494 function FieldItem({
17495 field,
17496 isVisible: isVisible2,
17497 onToggleVisibility
17498 }) {
17499 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components7.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
17500 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components7.Icon, { icon: check_default }) }),
17501 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
17502 ] }) });
17503 }
17504 function isDefined(item) {
17505 return !!item;
17506 }
17507 function PropertiesSection({
17508 showLabel = true
17509 }) {
17510 const { view, fields: fields2, onChangeView } = (0, import_element72.useContext)(dataviews_context_default);
17511 const regularFields = getHideableFields(view, fields2);
17512 if (!regularFields?.length) {
17513 return null;
17514 }
17515 const titleField = fields2.find((f2) => f2.id === view.titleField);
17516 const previewField = fields2.find((f2) => f2.id === view.mediaField);
17517 const descriptionField = fields2.find(
17518 (f2) => f2.id === view.descriptionField
17519 );
17520 const lockedFields = [
17521 {
17522 field: titleField,
17523 isVisibleFlag: "showTitle"
17524 },
17525 {
17526 field: previewField,
17527 isVisibleFlag: "showMedia"
17528 },
17529 {
17530 field: descriptionField,
17531 isVisibleFlag: "showDescription"
17532 }
17533 ].filter(({ field }) => isDefined(field));
17534 const visibleFieldIds = view.fields ?? [];
17535 const visibleRegularFieldsCount = regularFields.filter(
17536 (f2) => visibleFieldIds.includes(f2.id)
17537 ).length;
17538 const visibleLockedFields = lockedFields.filter(
17539 ({ isVisibleFlag }) => (
17540 // @ts-expect-error
17541 view[isVisibleFlag] ?? true
17542 )
17543 );
17544 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
17545 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
17546 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
17547 showLabel && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n15.__)("Properties") }),
17548 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17549 Stack,
17550 {
17551 direction: "column",
17552 className: "dataviews-view-config__properties",
17553 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
17554 lockedFields.map(({ field, isVisibleFlag }) => {
17555 const isVisible2 = view[isVisibleFlag] ?? true;
17556 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
17557 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17558 FieldItem,
17559 {
17560 field: fieldToRender,
17561 isVisible: isVisible2,
17562 onToggleVisibility: () => {
17563 onChangeView({
17564 ...view,
17565 [isVisibleFlag]: !isVisible2
17566 });
17567 }
17568 },
17569 field.id
17570 );
17571 }),
17572 regularFields.map((field) => {
17573 const isVisible2 = visibleFieldIds.includes(field.id);
17574 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
17575 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17576 FieldItem,
17577 {
17578 field: fieldToRender,
17579 isVisible: isVisible2,
17580 onToggleVisibility: () => {
17581 onChangeView({
17582 ...view,
17583 fields: isVisible2 ? visibleFieldIds.filter(
17584 (fieldId) => fieldId !== field.id
17585 ) : [...visibleFieldIds, field.id]
17586 });
17587 }
17588 },
17589 field.id
17590 );
17591 })
17592 ] })
17593 }
17594 )
17595 ] });
17596 }
17597
17598 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
17599 var import_element73 = __toESM(require_element(), 1);
17600 function useDelayedLoading(isLoading, options = { delay: 400 }) {
17601 const [showLoader, setShowLoader] = (0, import_element73.useState)(false);
17602 (0, import_element73.useEffect)(() => {
17603 if (!isLoading) {
17604 return;
17605 }
17606 const timeout = setTimeout(() => {
17607 setShowLoader(true);
17608 }, options.delay);
17609 return () => {
17610 clearTimeout(timeout);
17611 setShowLoader(false);
17612 };
17613 }, [isLoading, options.delay]);
17614 return showLoader;
17615 }
17616
17617 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
17618 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
17619 function getEffectiveAlign(explicitAlign, fieldType) {
17620 if (explicitAlign) {
17621 return explicitAlign;
17622 }
17623 if (fieldType === "integer" || fieldType === "number") {
17624 return "end";
17625 }
17626 return void 0;
17627 }
17628 function TableColumnField({
17629 item,
17630 fields: fields2,
17631 column,
17632 align
17633 }) {
17634 const field = fields2.find((f2) => f2.id === column);
17635 if (!field) {
17636 return null;
17637 }
17638 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
17639 "dataviews-view-table__cell-align-end": align === "end",
17640 "dataviews-view-table__cell-align-center": align === "center"
17641 });
17642 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(field.render, { item, field }) });
17643 }
17644 function TableRow({
17645 hasBulkActions,
17646 item,
17647 level,
17648 actions,
17649 fields: fields2,
17650 id,
17651 view,
17652 titleField,
17653 mediaField,
17654 descriptionField,
17655 selection,
17656 getItemId: getItemId2,
17657 isItemClickable: isItemClickable2,
17658 onClickItem,
17659 renderItemLink,
17660 onChangeSelection,
17661 isActionsColumnSticky,
17662 posinset
17663 }) {
17664 const { paginationInfo } = (0, import_element74.useContext)(dataviews_context_default);
17665 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
17666 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
17667 const {
17668 showTitle = true,
17669 showMedia = true,
17670 showDescription = true,
17671 infiniteScrollEnabled
17672 } = view;
17673 const isTouchDeviceRef = (0, import_element74.useRef)(false);
17674 const columns = view.fields ?? [];
17675 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
17676 return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
17677 "tr",
17678 {
17679 className: clsx_default("dataviews-view-table__row", {
17680 "is-selected": hasPossibleBulkAction && isSelected2,
17681 "has-bulk-actions": hasPossibleBulkAction
17682 }),
17683 onTouchStart: () => {
17684 isTouchDeviceRef.current = true;
17685 },
17686 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
17687 "aria-posinset": posinset,
17688 role: infiniteScrollEnabled ? "article" : void 0,
17689 onMouseDown: (event) => {
17690 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
17691 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
17692 event?.preventDefault();
17693 }
17694 },
17695 onClick: (event) => {
17696 if (!hasPossibleBulkAction) {
17697 return;
17698 }
17699 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
17700 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
17701 onChangeSelection(
17702 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
17703 );
17704 }
17705 },
17706 children: [
17707 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17708 DataViewsSelectionCheckbox,
17709 {
17710 item,
17711 selection,
17712 onChangeSelection,
17713 getItemId: getItemId2,
17714 titleField,
17715 disabled: !hasPossibleBulkAction
17716 }
17717 ) }) }),
17718 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17719 column_primary_default,
17720 {
17721 item,
17722 level,
17723 titleField: showTitle ? titleField : void 0,
17724 mediaField: showMedia ? mediaField : void 0,
17725 descriptionField: showDescription ? descriptionField : void 0,
17726 isItemClickable: isItemClickable2,
17727 onClickItem,
17728 renderItemLink
17729 }
17730 ) }),
17731 columns.map((column) => {
17732 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
17733 const field = fields2.find((f2) => f2.id === column);
17734 const effectiveAlign = getEffectiveAlign(align, field?.type);
17735 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17736 "td",
17737 {
17738 style: {
17739 width,
17740 maxWidth,
17741 minWidth
17742 },
17743 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17744 TableColumnField,
17745 {
17746 fields: fields2,
17747 item,
17748 column,
17749 align: effectiveAlign
17750 }
17751 )
17752 },
17753 column
17754 );
17755 }),
17756 !!actions?.length && // Disable reason: we are not making the element interactive,
17757 // but preventing any click events from bubbling up to the
17758 // table row. This allows us to add a click handler to the row
17759 // itself (to toggle row selection) without erroneously
17760 // intercepting click events from ItemActions.
17761 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17762 "td",
17763 {
17764 className: clsx_default("dataviews-view-table__actions-column", {
17765 "dataviews-view-table__actions-column--sticky": true,
17766 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
17767 }),
17768 onClick: (e2) => e2.stopPropagation(),
17769 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ItemActions, { item, actions })
17770 }
17771 )
17772 ]
17773 }
17774 );
17775 }
17776 function ViewTable({
17777 actions,
17778 data,
17779 fields: fields2,
17780 getItemId: getItemId2,
17781 getItemLevel,
17782 isLoading = false,
17783 onChangeView,
17784 onChangeSelection,
17785 selection,
17786 setOpenedFilter,
17787 onClickItem,
17788 isItemClickable: isItemClickable2,
17789 renderItemLink,
17790 view,
17791 className,
17792 empty
17793 }) {
17794 const { containerRef } = (0, import_element74.useContext)(dataviews_context_default);
17795 const isDelayedLoading = useDelayedLoading(isLoading);
17796 const headerMenuRefs = (0, import_element74.useRef)(/* @__PURE__ */ new Map());
17797 const headerMenuToFocusRef = (0, import_element74.useRef)(void 0);
17798 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element74.useState)();
17799 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element74.useState)(null);
17800 (0, import_element74.useEffect)(() => {
17801 if (headerMenuToFocusRef.current) {
17802 headerMenuToFocusRef.current.focus();
17803 headerMenuToFocusRef.current = void 0;
17804 }
17805 });
17806 const tableNoticeId = (0, import_element74.useId)();
17807 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
17808 scrollContainerRef: containerRef,
17809 enabledHorizontal: !!actions?.length
17810 });
17811 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
17812 if (nextHeaderMenuToFocus) {
17813 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
17814 setNextHeaderMenuToFocus(void 0);
17815 return;
17816 }
17817 const onHide = (field) => {
17818 const hidden = headerMenuRefs.current.get(field.id);
17819 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
17820 setNextHeaderMenuToFocus(fallback?.node);
17821 };
17822 const handleHeaderContextMenu = (event) => {
17823 event.preventDefault();
17824 event.stopPropagation();
17825 const virtualAnchor = {
17826 getBoundingClientRect: () => ({
17827 x: event.clientX,
17828 y: event.clientY,
17829 top: event.clientY,
17830 left: event.clientX,
17831 right: event.clientX,
17832 bottom: event.clientY,
17833 width: 0,
17834 height: 0,
17835 toJSON: () => ({})
17836 })
17837 };
17838 window.requestAnimationFrame(() => {
17839 setContextMenuAnchor(virtualAnchor);
17840 });
17841 };
17842 const hasData = !!data?.length;
17843 const titleField = fields2.find((field) => field.id === view.titleField);
17844 const mediaField = fields2.find((field) => field.id === view.mediaField);
17845 const descriptionField = fields2.find(
17846 (field) => field.id === view.descriptionField
17847 );
17848 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
17849 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
17850 const { showTitle = true, showMedia = true, showDescription = true } = view;
17851 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
17852 const columns = view.fields ?? [];
17853 const headerMenuRef = (column, index2) => (node) => {
17854 if (node) {
17855 headerMenuRefs.current.set(column, {
17856 node,
17857 fallback: columns[index2 > 0 ? index2 - 1 : 1]
17858 });
17859 } else {
17860 headerMenuRefs.current.delete(column);
17861 }
17862 };
17863 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
17864 const isRtl = (0, import_i18n16.isRTL)();
17865 if (!hasData) {
17866 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17867 "div",
17868 {
17869 className: clsx_default("dataviews-no-results", {
17870 "is-refreshing": isDelayedLoading
17871 }),
17872 id: tableNoticeId,
17873 children: empty
17874 }
17875 );
17876 }
17877 return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_jsx_runtime94.Fragment, { children: [
17878 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
17879 "table",
17880 {
17881 className: clsx_default("dataviews-view-table", className, {
17882 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
17883 view.layout.density
17884 ),
17885 "has-bulk-actions": hasBulkActions,
17886 "is-refreshing": !isInfiniteScroll && isDelayedLoading
17887 }),
17888 "aria-busy": isLoading,
17889 "aria-describedby": tableNoticeId,
17890 role: isInfiniteScroll ? "feed" : void 0,
17891 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
17892 children: [
17893 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("colgroup", { children: [
17894 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
17895 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
17896 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17897 "col",
17898 {
17899 className: clsx_default(
17900 `dataviews-view-table__col-${column}`,
17901 {
17902 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
17903 }
17904 )
17905 },
17906 `col-${column}`
17907 )),
17908 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("col", { className: "dataviews-view-table__col-actions" })
17909 ] }),
17910 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17911 import_components8.Popover,
17912 {
17913 anchor: contextMenuAnchor,
17914 onClose: () => setContextMenuAnchor(null),
17915 placement: "bottom-start",
17916 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(PropertiesSection, { showLabel: false })
17917 }
17918 ),
17919 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17920 "thead",
17921 {
17922 className: clsx_default({
17923 "dataviews-view-table__thead--stuck": isVerticallyScrolled
17924 }),
17925 onContextMenu: handleHeaderContextMenu,
17926 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("tr", { className: "dataviews-view-table__row", children: [
17927 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17928 "th",
17929 {
17930 className: "dataviews-view-table__checkbox-column",
17931 scope: "col",
17932 onContextMenu: handleHeaderContextMenu,
17933 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17934 BulkSelectionCheckbox,
17935 {
17936 selection,
17937 onChangeSelection,
17938 data,
17939 actions,
17940 getItemId: getItemId2
17941 }
17942 )
17943 }
17944 ),
17945 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17946 column_header_menu_default,
17947 {
17948 ref: headerMenuRef(
17949 titleField.id,
17950 0
17951 ),
17952 fieldId: titleField.id,
17953 view,
17954 fields: fields2,
17955 onChangeView,
17956 onHide,
17957 setOpenedFilter,
17958 canMove: false,
17959 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
17960 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
17961 }
17962 ) }),
17963 columns.map((column, index2) => {
17964 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
17965 const field = fields2.find(
17966 (f2) => f2.id === column
17967 );
17968 const effectiveAlign = getEffectiveAlign(
17969 align,
17970 field?.type
17971 );
17972 const canInsertOrMove = view.layout?.enableMoving ?? true;
17973 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17974 "th",
17975 {
17976 style: {
17977 width,
17978 maxWidth,
17979 minWidth,
17980 textAlign: effectiveAlign
17981 },
17982 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
17983 scope: "col",
17984 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17985 column_header_menu_default,
17986 {
17987 ref: headerMenuRef(column, index2),
17988 fieldId: column,
17989 view,
17990 fields: fields2,
17991 onChangeView,
17992 onHide,
17993 setOpenedFilter,
17994 canMove: canInsertOrMove,
17995 canInsertLeft: canInsertOrMove,
17996 canInsertRight: canInsertOrMove
17997 }
17998 )
17999 },
18000 column
18001 );
18002 }),
18003 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
18004 "th",
18005 {
18006 className: clsx_default(
18007 "dataviews-view-table__actions-column",
18008 {
18009 "dataviews-view-table__actions-column--sticky": true,
18010 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
18011 }
18012 ),
18013 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n16.__)("Actions") })
18014 }
18015 )
18016 ] })
18017 }
18018 ),
18019 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
18020 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("tbody", { children: [
18021 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
18022 "td",
18023 {
18024 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
18025 className: "dataviews-view-table__group-header-cell",
18026 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n16.sprintf)(
18027 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
18028 (0, import_i18n16.__)("%1$s: %2$s"),
18029 groupField.label,
18030 groupName
18031 )
18032 }
18033 ) }),
18034 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
18035 TableRow,
18036 {
18037 item,
18038 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
18039 hasBulkActions,
18040 actions,
18041 fields: fields2,
18042 id: getItemId2(item) || index2.toString(),
18043 view,
18044 titleField,
18045 mediaField,
18046 descriptionField,
18047 selection,
18048 getItemId: getItemId2,
18049 onChangeSelection,
18050 onClickItem,
18051 renderItemLink,
18052 isItemClickable: isItemClickable2,
18053 isActionsColumnSticky: !isHorizontalScrollEnd
18054 },
18055 getItemId2(item)
18056 ))
18057 ] }, `group-${groupName}`)
18058 ) : /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
18059 TableRow,
18060 {
18061 item,
18062 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
18063 hasBulkActions,
18064 actions,
18065 fields: fields2,
18066 id: getItemId2(item) || index2.toString(),
18067 view,
18068 titleField,
18069 mediaField,
18070 descriptionField,
18071 selection,
18072 getItemId: getItemId2,
18073 onChangeSelection,
18074 onClickItem,
18075 renderItemLink,
18076 isItemClickable: isItemClickable2,
18077 isActionsColumnSticky: !isHorizontalScrollEnd,
18078 posinset: isInfiniteScroll ? index2 + 1 : void 0
18079 },
18080 getItemId2(item)
18081 )) })
18082 ]
18083 }
18084 ),
18085 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components8.Spinner, {}) }) })
18086 ] });
18087 }
18088 var table_default = ViewTable;
18089
18090 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
18091 var import_components11 = __toESM(require_components(), 1);
18092 var import_i18n19 = __toESM(require_i18n(), 1);
18093
18094 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
18095 var import_components10 = __toESM(require_components(), 1);
18096 var import_i18n18 = __toESM(require_i18n(), 1);
18097 var import_compose7 = __toESM(require_compose(), 1);
18098 var import_keycodes2 = __toESM(require_keycodes(), 1);
18099 var import_element78 = __toESM(require_element(), 1);
18100
18101 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
18102 var import_components9 = __toESM(require_components(), 1);
18103 var import_i18n17 = __toESM(require_i18n(), 1);
18104 var import_element75 = __toESM(require_element(), 1);
18105 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
18106 var imageSizes = [
18107 {
18108 value: 120,
18109 breakpoint: 1
18110 },
18111 {
18112 value: 170,
18113 breakpoint: 1
18114 },
18115 {
18116 value: 230,
18117 breakpoint: 1
18118 },
18119 {
18120 value: 290,
18121 breakpoint: 1112
18122 // at minimum image width, 4 images display at this container size
18123 },
18124 {
18125 value: 350,
18126 breakpoint: 1636
18127 // at minimum image width, 6 images display at this container size
18128 },
18129 {
18130 value: 430,
18131 breakpoint: 588
18132 // at minimum image width, 2 images display at this container size
18133 }
18134 ];
18135 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
18136 function useGridColumns() {
18137 const context = (0, import_element75.useContext)(dataviews_context_default);
18138 const view = context.view;
18139 return (0, import_element75.useMemo)(() => {
18140 const containerWidth = context.containerWidth;
18141 const gap = 32;
18142 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
18143 const columns = Math.floor(
18144 (containerWidth + gap) / (previewSize + gap)
18145 );
18146 return Math.max(1, columns);
18147 }, [context.containerWidth, view.layout?.previewSize]);
18148 }
18149
18150 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
18151 var import_element76 = __toESM(require_element(), 1);
18152 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
18153 var GridItems = (0, import_element76.forwardRef)(({ className, previewSize, ...props }, ref) => {
18154 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
18155 "div",
18156 {
18157 ref,
18158 className: clsx_default("dataviews-view-grid-items", className),
18159 style: {
18160 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
18161 },
18162 ...props
18163 }
18164 );
18165 });
18166
18167 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
18168 var import_element77 = __toESM(require_element(), 1);
18169 function useIntersectionObserver(elementRef, posinset) {
18170 const { intersectionObserver } = (0, import_element77.useContext)(dataviews_context_default);
18171 (0, import_element77.useEffect)(() => {
18172 const element = elementRef.current;
18173 if (!element || posinset === void 0 || !intersectionObserver) {
18174 return;
18175 }
18176 intersectionObserver.observe(element);
18177 return () => {
18178 intersectionObserver.unobserve(element);
18179 };
18180 }, [elementRef, intersectionObserver, posinset]);
18181 }
18182 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
18183 const hasData = !!data?.length;
18184 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
18185 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
18186 }
18187
18188 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
18189 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
18190 var { Badge: WCBadge } = unlock3(import_components10.privateApis);
18191 function chunk(array, size4) {
18192 const chunks = [];
18193 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
18194 chunks.push(array.slice(i2, i2 + size4));
18195 }
18196 return chunks;
18197 }
18198 var GridItem = (0, import_element78.forwardRef)(
18199 function GridItem2({
18200 view,
18201 selection,
18202 onChangeSelection,
18203 onClickItem,
18204 isItemClickable: isItemClickable2,
18205 renderItemLink,
18206 getItemId: getItemId2,
18207 item,
18208 actions,
18209 mediaField,
18210 titleField,
18211 descriptionField,
18212 regularFields,
18213 badgeFields,
18214 hasBulkActions,
18215 config,
18216 posinset,
18217 setsize,
18218 ...props
18219 }, forwardedRef) {
18220 const {
18221 showTitle = true,
18222 showMedia = true,
18223 showDescription = true
18224 } = view;
18225 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
18226 const id = getItemId2(item);
18227 const elementRef = (0, import_element78.useRef)(null);
18228 const setRefs = (0, import_element78.useCallback)(
18229 (node) => {
18230 elementRef.current = node;
18231 if (typeof forwardedRef === "function") {
18232 forwardedRef(node);
18233 } else if (forwardedRef) {
18234 forwardedRef.current = node;
18235 }
18236 },
18237 [forwardedRef]
18238 );
18239 useIntersectionObserver(elementRef, posinset);
18240 const instanceId = (0, import_compose7.useInstanceId)(GridItem2);
18241 const isSelected2 = selection.includes(id);
18242 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
18243 const rendersMediaField = showMedia && mediaField?.render;
18244 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18245 mediaField.render,
18246 {
18247 item,
18248 field: mediaField,
18249 config
18250 }
18251 ) : mediaPlaceholder;
18252 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(titleField.render, { item, field: titleField }) : null;
18253 let mediaA11yProps;
18254 let titleA11yProps;
18255 if (isItemClickable2(item) && onClickItem) {
18256 if (renderedTitleField) {
18257 mediaA11yProps = {
18258 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
18259 };
18260 titleA11yProps = {
18261 id: `dataviews-view-grid__title-field-${instanceId}`
18262 };
18263 } else {
18264 mediaA11yProps = {
18265 "aria-label": (0, import_i18n18.__)("Navigate to item")
18266 };
18267 }
18268 }
18269 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
18270 Stack,
18271 {
18272 direction: "column",
18273 ...props,
18274 ref: setRefs,
18275 "aria-setsize": setsize,
18276 "aria-posinset": posinset,
18277 className: clsx_default(
18278 props.className,
18279 "dataviews-view-grid__row__gridcell",
18280 "dataviews-view-grid__card",
18281 {
18282 "is-selected": hasBulkAction && isSelected2
18283 }
18284 ),
18285 onClickCapture: (event) => {
18286 props.onClickCapture?.(event);
18287 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
18288 event.stopPropagation();
18289 event.preventDefault();
18290 if (!hasBulkAction) {
18291 return;
18292 }
18293 onChangeSelection(
18294 isSelected2 ? selection.filter(
18295 (itemId) => id !== itemId
18296 ) : [...selection, id]
18297 );
18298 }
18299 },
18300 children: [
18301 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18302 ItemClickWrapper,
18303 {
18304 item,
18305 isItemClickable: isItemClickable2,
18306 onClickItem,
18307 renderItemLink,
18308 className: clsx_default("dataviews-view-grid__media", {
18309 "dataviews-view-grid__media--placeholder": !rendersMediaField
18310 }),
18311 ...mediaA11yProps,
18312 children: renderedMediaField
18313 }
18314 ),
18315 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18316 DataViewsSelectionCheckbox,
18317 {
18318 item,
18319 selection,
18320 onChangeSelection,
18321 getItemId: getItemId2,
18322 titleField,
18323 disabled: !hasBulkAction
18324 }
18325 ),
18326 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18327 ItemActions,
18328 {
18329 item,
18330 actions,
18331 isCompact: true
18332 }
18333 ) }),
18334 showTitle && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18335 ItemClickWrapper,
18336 {
18337 item,
18338 isItemClickable: isItemClickable2,
18339 onClickItem,
18340 renderItemLink,
18341 className: "dataviews-view-grid__title-field dataviews-title-field",
18342 ...titleA11yProps,
18343 title: titleField?.getValueFormatted({
18344 item,
18345 field: titleField
18346 }) || void 0,
18347 children: renderedTitleField
18348 }
18349 ) }),
18350 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", gap: "xs", children: [
18351 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18352 descriptionField.render,
18353 {
18354 item,
18355 field: descriptionField
18356 }
18357 ),
18358 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18359 Stack,
18360 {
18361 direction: "row",
18362 className: "dataviews-view-grid__badge-fields",
18363 gap: "sm",
18364 wrap: "wrap",
18365 align: "top",
18366 justify: "flex-start",
18367 children: badgeFields.map((field) => {
18368 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18369 WCBadge,
18370 {
18371 className: "dataviews-view-grid__field-value",
18372 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18373 field.render,
18374 {
18375 item,
18376 field
18377 }
18378 )
18379 },
18380 field.id
18381 );
18382 })
18383 }
18384 ),
18385 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18386 Stack,
18387 {
18388 direction: "column",
18389 className: "dataviews-view-grid__fields",
18390 gap: "xs",
18391 children: regularFields.map((field) => {
18392 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18393 import_components10.Flex,
18394 {
18395 className: "dataviews-view-grid__field",
18396 gap: 1,
18397 justify: "flex-start",
18398 expanded: true,
18399 style: { height: "auto" },
18400 direction: "row",
18401 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_jsx_runtime97.Fragment, { children: [
18402 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components10.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components10.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }),
18403 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18404 import_components10.FlexItem,
18405 {
18406 className: "dataviews-view-grid__field-value",
18407 style: { maxHeight: "none" },
18408 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18409 field.render,
18410 {
18411 item,
18412 field
18413 }
18414 )
18415 }
18416 )
18417 ] })
18418 },
18419 field.id
18420 );
18421 })
18422 }
18423 )
18424 ] })
18425 ]
18426 }
18427 );
18428 }
18429 );
18430 function CompositeGrid({
18431 data,
18432 isInfiniteScroll,
18433 className,
18434 inert,
18435 isLoading,
18436 view,
18437 fields: fields2,
18438 selection,
18439 onChangeSelection,
18440 onClickItem,
18441 isItemClickable: isItemClickable2,
18442 renderItemLink,
18443 getItemId: getItemId2,
18444 actions
18445 }) {
18446 const { paginationInfo, resizeObserverRef } = (0, import_element78.useContext)(dataviews_context_default);
18447 const gridColumns = useGridColumns();
18448 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
18449 const titleField = fields2.find(
18450 (field) => field.id === view?.titleField
18451 );
18452 const mediaField = fields2.find(
18453 (field) => field.id === view?.mediaField
18454 );
18455 const descriptionField = fields2.find(
18456 (field) => field.id === view?.descriptionField
18457 );
18458 const otherFields = view.fields ?? [];
18459 const { regularFields, badgeFields } = otherFields.reduce(
18460 (accumulator, fieldId) => {
18461 const field = fields2.find((f2) => f2.id === fieldId);
18462 if (!field) {
18463 return accumulator;
18464 }
18465 const key2 = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
18466 accumulator[key2].push(field);
18467 return accumulator;
18468 },
18469 { regularFields: [], badgeFields: [] }
18470 );
18471 const size4 = "900px";
18472 const totalRows = Math.ceil(data.length / gridColumns);
18473 const placeholdersNeeded = usePlaceholdersNeeded(
18474 data,
18475 isInfiniteScroll,
18476 gridColumns
18477 );
18478 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_jsx_runtime97.Fragment, {
18479 // Render infinite scroll layout (no rows, feed semantics)
18480 children: [
18481 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
18482 import_components10.Composite,
18483 {
18484 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18485 GridItems,
18486 {
18487 className: clsx_default(
18488 "dataviews-view-grid-infinite-scroll",
18489 className,
18490 {
18491 [`has-${view.layout?.density}-density`]: view.layout?.density && [
18492 "compact",
18493 "comfortable"
18494 ].includes(view.layout.density)
18495 }
18496 ),
18497 previewSize: view.layout?.previewSize,
18498 "aria-busy": isLoading,
18499 ref: resizeObserverRef
18500 }
18501 ),
18502 role: "feed",
18503 focusWrap: true,
18504 inert,
18505 children: [
18506 Array.from({ length: placeholdersNeeded }).map(
18507 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18508 import_components10.Composite.Item,
18509 {
18510 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18511 Stack,
18512 {
18513 ...props,
18514 direction: "column",
18515 role: "article",
18516 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
18517 }
18518 ),
18519 "aria-hidden": true,
18520 tabIndex: -1
18521 },
18522 `placeholder-${index2}`
18523 )
18524 ),
18525 data.map((item) => {
18526 const itemId = getItemId2(item);
18527 const stablePosition = item.position;
18528 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18529 import_components10.Composite.Item,
18530 {
18531 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18532 GridItem,
18533 {
18534 ...props,
18535 id: itemId,
18536 role: "article",
18537 view,
18538 selection,
18539 onChangeSelection,
18540 onClickItem,
18541 isItemClickable: isItemClickable2,
18542 renderItemLink,
18543 getItemId: getItemId2,
18544 item,
18545 actions,
18546 mediaField,
18547 titleField,
18548 descriptionField,
18549 regularFields,
18550 badgeFields,
18551 hasBulkActions,
18552 posinset: stablePosition,
18553 setsize: paginationInfo.totalItems,
18554 config: {
18555 sizes: size4
18556 }
18557 }
18558 )
18559 },
18560 itemId
18561 );
18562 })
18563 ]
18564 }
18565 ),
18566 // Render standard grid layout (with rows, grid semantics)
18567 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18568 import_components10.Composite,
18569 {
18570 role: "grid",
18571 className: clsx_default("dataviews-view-grid", className, {
18572 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
18573 view.layout.density
18574 )
18575 }),
18576 focusWrap: true,
18577 "aria-busy": isLoading,
18578 "aria-rowcount": totalRows,
18579 ref: resizeObserverRef,
18580 inert,
18581 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18582 import_components10.Composite.Row,
18583 {
18584 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18585 "div",
18586 {
18587 role: "row",
18588 "aria-rowindex": i2 + 1,
18589 "aria-label": (0, import_i18n18.sprintf)(
18590 /* translators: %d: The row number in the grid */
18591 (0, import_i18n18.__)("Row %d"),
18592 i2 + 1
18593 ),
18594 className: "dataviews-view-grid__row",
18595 style: {
18596 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
18597 }
18598 }
18599 ),
18600 children: row.map((item) => {
18601 const itemId = getItemId2(item);
18602 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18603 import_components10.Composite.Item,
18604 {
18605 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18606 GridItem,
18607 {
18608 ...props,
18609 id: itemId,
18610 role: "gridcell",
18611 view,
18612 selection,
18613 onChangeSelection,
18614 onClickItem,
18615 isItemClickable: isItemClickable2,
18616 renderItemLink,
18617 getItemId: getItemId2,
18618 item,
18619 actions,
18620 mediaField,
18621 titleField,
18622 descriptionField,
18623 regularFields,
18624 badgeFields,
18625 hasBulkActions,
18626 config: {
18627 sizes: size4
18628 }
18629 }
18630 )
18631 },
18632 itemId
18633 );
18634 })
18635 },
18636 i2
18637 ))
18638 }
18639 )
18640 ]
18641 });
18642 }
18643
18644 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
18645 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
18646 function ViewGrid({
18647 actions,
18648 data,
18649 fields: fields2,
18650 getItemId: getItemId2,
18651 isLoading,
18652 onChangeSelection,
18653 onClickItem,
18654 isItemClickable: isItemClickable2,
18655 renderItemLink,
18656 selection,
18657 view,
18658 className,
18659 empty
18660 }) {
18661 const isDelayedLoading = useDelayedLoading(!!isLoading);
18662 const hasData = !!data?.length;
18663 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
18664 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
18665 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
18666 if (!hasData) {
18667 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18668 "div",
18669 {
18670 className: clsx_default("dataviews-no-results", {
18671 "is-refreshing": isDelayedLoading
18672 }),
18673 children: empty
18674 }
18675 );
18676 }
18677 const gridProps = {
18678 className: clsx_default(className, {
18679 "is-refreshing": !isInfiniteScroll && isDelayedLoading
18680 }),
18681 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
18682 isLoading,
18683 view,
18684 fields: fields2,
18685 selection,
18686 onChangeSelection,
18687 onClickItem,
18688 isItemClickable: isItemClickable2,
18689 renderItemLink,
18690 getItemId: getItemId2,
18691 actions
18692 };
18693 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_jsx_runtime98.Fragment, {
18694 // Render multiple groups.
18695 children: [
18696 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
18697 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
18698 Stack,
18699 {
18700 direction: "column",
18701 gap: "sm",
18702 children: [
18703 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
18704 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
18705 (0, import_i18n19.__)("%1$s: %2$s"),
18706 groupField.label,
18707 groupName
18708 ) }),
18709 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18710 CompositeGrid,
18711 {
18712 ...gridProps,
18713 data: groupItems,
18714 isInfiniteScroll: false
18715 }
18716 )
18717 ]
18718 },
18719 groupName
18720 )
18721 ) }),
18722 // Render a single grid with all data.
18723 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18724 CompositeGrid,
18725 {
18726 ...gridProps,
18727 data,
18728 isInfiniteScroll: !!isInfiniteScroll
18729 }
18730 ),
18731 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components11.Spinner, {}) })
18732 ]
18733 });
18734 }
18735 var grid_default = ViewGrid;
18736
18737 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
18738 var import_compose8 = __toESM(require_compose(), 1);
18739 var import_components12 = __toESM(require_components(), 1);
18740 var import_element79 = __toESM(require_element(), 1);
18741 var import_i18n20 = __toESM(require_i18n(), 1);
18742 var import_data4 = __toESM(require_data(), 1);
18743 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
18744 var { Menu: Menu4 } = unlock3(import_components12.privateApis);
18745 function generateItemWrapperCompositeId(idPrefix) {
18746 return `${idPrefix}-item-wrapper`;
18747 }
18748 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
18749 return `${idPrefix}-primary-action-${primaryActionId}`;
18750 }
18751 function generateDropdownTriggerCompositeId(idPrefix) {
18752 return `${idPrefix}-dropdown`;
18753 }
18754 function PrimaryActionGridCell({
18755 idPrefix,
18756 primaryAction,
18757 item
18758 }) {
18759 const registry = (0, import_data4.useRegistry)();
18760 const [isModalOpen, setIsModalOpen] = (0, import_element79.useState)(false);
18761 const compositeItemId = generatePrimaryActionCompositeId(
18762 idPrefix,
18763 primaryAction.id
18764 );
18765 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
18766 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18767 import_components12.Composite.Item,
18768 {
18769 id: compositeItemId,
18770 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18771 import_components12.Button,
18772 {
18773 disabled: !!primaryAction.disabled,
18774 accessibleWhenDisabled: true,
18775 text: label,
18776 size: "small",
18777 onClick: () => setIsModalOpen(true)
18778 }
18779 ),
18780 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18781 ActionModal,
18782 {
18783 action: primaryAction,
18784 items: [item],
18785 closeModal: () => setIsModalOpen(false)
18786 }
18787 )
18788 }
18789 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18790 import_components12.Composite.Item,
18791 {
18792 id: compositeItemId,
18793 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18794 import_components12.Button,
18795 {
18796 disabled: !!primaryAction.disabled,
18797 accessibleWhenDisabled: true,
18798 size: "small",
18799 onClick: () => {
18800 primaryAction.callback([item], { registry });
18801 },
18802 children: label
18803 }
18804 )
18805 }
18806 ) }, primaryAction.id);
18807 }
18808 function ListItem({
18809 view,
18810 actions,
18811 idPrefix,
18812 isSelected: isSelected2,
18813 item,
18814 titleField,
18815 mediaField,
18816 descriptionField,
18817 onSelect,
18818 otherFields,
18819 onDropdownTriggerKeyDown,
18820 posinset
18821 }) {
18822 const {
18823 showTitle = true,
18824 showMedia = true,
18825 showDescription = true,
18826 infiniteScrollEnabled
18827 } = view;
18828 const itemRef = (0, import_element79.useRef)(null);
18829 const labelId = `${idPrefix}-label`;
18830 const descriptionId = `${idPrefix}-description`;
18831 const registry = (0, import_data4.useRegistry)();
18832 const [isHovered, setIsHovered] = (0, import_element79.useState)(false);
18833 const [activeModalAction, setActiveModalAction] = (0, import_element79.useState)(
18834 null
18835 );
18836 const handleHover = ({ type }) => {
18837 const isHover = type === "mouseenter";
18838 setIsHovered(isHover);
18839 };
18840 const { paginationInfo } = (0, import_element79.useContext)(dataviews_context_default);
18841 (0, import_element79.useEffect)(() => {
18842 if (isSelected2) {
18843 itemRef.current?.scrollIntoView({
18844 behavior: "auto",
18845 block: "nearest",
18846 inline: "nearest"
18847 });
18848 }
18849 }, [isSelected2]);
18850 const { primaryAction, eligibleActions } = (0, import_element79.useMemo)(() => {
18851 const _eligibleActions = actions.filter(
18852 (action) => !action.isEligible || action.isEligible(item)
18853 );
18854 const _primaryActions = _eligibleActions.filter(
18855 (action) => action.isPrimary
18856 );
18857 return {
18858 primaryAction: _primaryActions[0],
18859 eligibleActions: _eligibleActions
18860 };
18861 }, [actions, item]);
18862 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
18863 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18864 mediaField.render,
18865 {
18866 item,
18867 field: mediaField,
18868 config: { sizes: "52px" }
18869 }
18870 ) }) : null;
18871 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(titleField.render, { item, field: titleField }) : null;
18872 const renderDescription = showDescription && descriptionField?.render;
18873 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
18874 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
18875 Stack,
18876 {
18877 direction: "row",
18878 gap: "md",
18879 className: "dataviews-view-list__item-actions",
18880 children: [
18881 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18882 PrimaryActionGridCell,
18883 {
18884 idPrefix,
18885 primaryAction,
18886 item
18887 }
18888 ),
18889 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { role: "gridcell", children: [
18890 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(Menu4, { placement: "bottom-end", children: [
18891 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18892 Menu4.TriggerButton,
18893 {
18894 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18895 import_components12.Composite.Item,
18896 {
18897 id: generateDropdownTriggerCompositeId(
18898 idPrefix
18899 ),
18900 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18901 import_components12.Button,
18902 {
18903 size: "small",
18904 icon: more_vertical_default,
18905 label: (0, import_i18n20.__)("Actions"),
18906 accessibleWhenDisabled: true,
18907 disabled: !actions.length,
18908 onKeyDown: onDropdownTriggerKeyDown
18909 }
18910 )
18911 }
18912 )
18913 }
18914 ),
18915 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Menu4.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18916 ActionsMenuGroup,
18917 {
18918 actions: eligibleActions,
18919 item,
18920 registry,
18921 setActiveModalAction
18922 }
18923 ) })
18924 ] }),
18925 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18926 ActionModal,
18927 {
18928 action: activeModalAction,
18929 items: [item],
18930 closeModal: () => setActiveModalAction(null)
18931 }
18932 )
18933 ] })
18934 ]
18935 }
18936 );
18937 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18938 import_components12.Composite.Row,
18939 {
18940 ref: itemRef,
18941 render: (
18942 /* aria-posinset breaks Composite.Row if passed to it directly. */
18943 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18944 "div",
18945 {
18946 "aria-posinset": posinset,
18947 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
18948 }
18949 )
18950 ),
18951 role: infiniteScrollEnabled ? "article" : "row",
18952 className: clsx_default({
18953 "is-selected": isSelected2,
18954 "is-hovered": isHovered
18955 }),
18956 onMouseEnter: handleHover,
18957 onMouseLeave: handleHover,
18958 children: /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
18959 Stack,
18960 {
18961 direction: "row",
18962 className: "dataviews-view-list__item-wrapper",
18963 children: [
18964 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18965 import_components12.Composite.Item,
18966 {
18967 id: generateItemWrapperCompositeId(idPrefix),
18968 "aria-pressed": isSelected2,
18969 "aria-labelledby": labelId,
18970 "aria-describedby": descriptionId,
18971 className: "dataviews-view-list__item",
18972 onClick: () => onSelect(item)
18973 }
18974 ) }),
18975 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
18976 Stack,
18977 {
18978 direction: "row",
18979 gap: "md",
18980 justify: "start",
18981 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
18982 style: { flex: 1, minWidth: 0 },
18983 children: [
18984 renderedMediaField,
18985 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
18986 Stack,
18987 {
18988 direction: "column",
18989 gap: "xs",
18990 className: "dataviews-view-list__field-wrapper",
18991 children: [
18992 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(Stack, { direction: "row", align: "center", children: [
18993 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
18994 "div",
18995 {
18996 className: "dataviews-title-field dataviews-view-list__title-field",
18997 id: labelId,
18998 children: renderedTitleField
18999 }
19000 ),
19001 usedActions
19002 ] }),
19003 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19004 descriptionField.render,
19005 {
19006 item,
19007 field: descriptionField
19008 }
19009 ) }),
19010 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19011 "div",
19012 {
19013 className: "dataviews-view-list__fields",
19014 id: descriptionId,
19015 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
19016 "div",
19017 {
19018 className: "dataviews-view-list__field",
19019 children: [
19020 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19021 VisuallyHidden,
19022 {
19023 className: "dataviews-view-list__field-label",
19024 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", {}),
19025 children: field.label
19026 }
19027 ),
19028 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19029 field.render,
19030 {
19031 item,
19032 field
19033 }
19034 ) })
19035 ]
19036 },
19037 field.id
19038 ))
19039 }
19040 )
19041 ]
19042 }
19043 )
19044 ]
19045 }
19046 )
19047 ]
19048 }
19049 )
19050 }
19051 );
19052 }
19053 function isDefined2(item) {
19054 return !!item;
19055 }
19056 function ViewList(props) {
19057 const {
19058 actions,
19059 data,
19060 fields: fields2,
19061 getItemId: getItemId2,
19062 isLoading,
19063 onChangeSelection,
19064 selection,
19065 view,
19066 className,
19067 empty
19068 } = props;
19069 const baseId = (0, import_compose8.useInstanceId)(ViewList, "view-list");
19070 const isDelayedLoading = useDelayedLoading(!!isLoading);
19071 const selectedItem = data?.findLast(
19072 (item) => selection.includes(getItemId2(item))
19073 );
19074 const titleField = fields2.find((field) => field.id === view.titleField);
19075 const mediaField = fields2.find((field) => field.id === view.mediaField);
19076 const descriptionField = fields2.find(
19077 (field) => field.id === view.descriptionField
19078 );
19079 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined2);
19080 const onSelect = (item) => onChangeSelection([getItemId2(item)]);
19081 const generateCompositeItemIdPrefix = (0, import_element79.useCallback)(
19082 (item) => `${baseId}-${getItemId2(item)}`,
19083 [baseId, getItemId2]
19084 );
19085 const isActiveCompositeItem = (0, import_element79.useCallback)(
19086 (item, idToCheck) => {
19087 return idToCheck.startsWith(
19088 generateCompositeItemIdPrefix(item)
19089 );
19090 },
19091 [generateCompositeItemIdPrefix]
19092 );
19093 const [activeCompositeId, setActiveCompositeId] = (0, import_element79.useState)(void 0);
19094 const compositeRef = (0, import_element79.useRef)(null);
19095 (0, import_element79.useEffect)(() => {
19096 if (selectedItem) {
19097 setActiveCompositeId(
19098 generateItemWrapperCompositeId(
19099 generateCompositeItemIdPrefix(selectedItem)
19100 )
19101 );
19102 }
19103 }, [selectedItem, generateCompositeItemIdPrefix]);
19104 const activeItemIndex = data.findIndex(
19105 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
19106 );
19107 const previousActiveItemIndex = (0, import_compose8.usePrevious)(activeItemIndex);
19108 const isActiveIdInList = activeItemIndex !== -1;
19109 const selectCompositeItem = (0, import_element79.useCallback)(
19110 (targetIndex, generateCompositeId) => {
19111 const clampedIndex = Math.min(
19112 data.length - 1,
19113 Math.max(0, targetIndex)
19114 );
19115 if (!data[clampedIndex]) {
19116 return;
19117 }
19118 const itemIdPrefix = generateCompositeItemIdPrefix(
19119 data[clampedIndex]
19120 );
19121 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
19122 setActiveCompositeId(targetCompositeItemId);
19123 if (compositeRef.current?.contains(
19124 compositeRef.current.ownerDocument.activeElement
19125 )) {
19126 document.getElementById(targetCompositeItemId)?.focus();
19127 }
19128 },
19129 [data, generateCompositeItemIdPrefix]
19130 );
19131 (0, import_element79.useEffect)(() => {
19132 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
19133 if (!isActiveIdInList && wasActiveIdInList) {
19134 selectCompositeItem(
19135 previousActiveItemIndex,
19136 generateItemWrapperCompositeId
19137 );
19138 }
19139 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
19140 const onDropdownTriggerKeyDown = (0, import_element79.useCallback)(
19141 (event) => {
19142 if (event.key === "ArrowDown") {
19143 event.preventDefault();
19144 selectCompositeItem(
19145 activeItemIndex + 1,
19146 generateDropdownTriggerCompositeId
19147 );
19148 }
19149 if (event.key === "ArrowUp") {
19150 event.preventDefault();
19151 selectCompositeItem(
19152 activeItemIndex - 1,
19153 generateDropdownTriggerCompositeId
19154 );
19155 }
19156 },
19157 [selectCompositeItem, activeItemIndex]
19158 );
19159 const hasData = !!data?.length;
19160 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
19161 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
19162 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
19163 if (!hasData) {
19164 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19165 "div",
19166 {
19167 className: clsx_default("dataviews-no-results", {
19168 "is-refreshing": isDelayedLoading
19169 }),
19170 children: empty
19171 }
19172 );
19173 }
19174 if (hasData && groupField && dataByGroup) {
19175 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19176 import_components12.Composite,
19177 {
19178 ref: compositeRef,
19179 id: `${baseId}`,
19180 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", {}),
19181 className: "dataviews-view-list__group",
19182 role: "grid",
19183 activeId: activeCompositeId,
19184 setActiveId: setActiveCompositeId,
19185 children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19186 Stack,
19187 {
19188 direction: "column",
19189 gap: "lg",
19190 className: clsx_default("dataviews-view-list", className),
19191 children: Array.from(dataByGroup.entries()).map(
19192 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
19193 Stack,
19194 {
19195 direction: "column",
19196 gap: "sm",
19197 children: [
19198 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n20.sprintf)(
19199 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
19200 (0, import_i18n20.__)("%1$s: %2$s"),
19201 groupField.label,
19202 groupName
19203 ) }),
19204 groupItems.map((item) => {
19205 const id = generateCompositeItemIdPrefix(item);
19206 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19207 ListItem,
19208 {
19209 view,
19210 idPrefix: id,
19211 actions,
19212 item,
19213 isSelected: item === selectedItem,
19214 onSelect,
19215 mediaField,
19216 titleField,
19217 descriptionField,
19218 otherFields,
19219 onDropdownTriggerKeyDown
19220 },
19221 id
19222 );
19223 })
19224 ]
19225 },
19226 groupName
19227 )
19228 )
19229 }
19230 )
19231 }
19232 );
19233 }
19234 return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(import_jsx_runtime99.Fragment, { children: [
19235 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19236 import_components12.Composite,
19237 {
19238 ref: compositeRef,
19239 id: baseId,
19240 render: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", {}),
19241 className: clsx_default("dataviews-view-list", className, {
19242 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
19243 view.layout.density
19244 ),
19245 "is-refreshing": !isInfiniteScroll && isDelayedLoading
19246 }),
19247 role: view.infiniteScrollEnabled ? "feed" : "grid",
19248 activeId: activeCompositeId,
19249 setActiveId: setActiveCompositeId,
19250 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
19251 children: data.map((item, index2) => {
19252 const id = generateCompositeItemIdPrefix(item);
19253 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
19254 ListItem,
19255 {
19256 view,
19257 idPrefix: id,
19258 actions,
19259 item,
19260 isSelected: item === selectedItem,
19261 onSelect,
19262 mediaField,
19263 titleField,
19264 descriptionField,
19265 otherFields,
19266 onDropdownTriggerKeyDown,
19267 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
19268 },
19269 id
19270 );
19271 })
19272 }
19273 ),
19274 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components12.Spinner, {}) })
19275 ] });
19276 }
19277
19278 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
19279 var import_components13 = __toESM(require_components(), 1);
19280
19281 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
19282 var import_i18n21 = __toESM(require_i18n(), 1);
19283 var import_element80 = __toESM(require_element(), 1);
19284 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
19285 function ActivityGroup({
19286 groupName,
19287 groupData,
19288 groupField,
19289 showLabel = true,
19290 children
19291 }) {
19292 const groupHeader = showLabel ? (0, import_element80.createInterpolateElement)(
19293 // translators: %s: The label of the field e.g. "Status".
19294 (0, import_i18n21.sprintf)((0, import_i18n21.__)("%s: <groupName />"), groupField.label).trim(),
19295 {
19296 groupName: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
19297 groupField.render,
19298 {
19299 item: groupData[0],
19300 field: groupField
19301 }
19302 )
19303 }
19304 ) : /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(groupField.render, { item: groupData[0], field: groupField });
19305 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
19306 Stack,
19307 {
19308 direction: "column",
19309 className: "dataviews-view-activity__group",
19310 children: [
19311 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
19312 children
19313 ]
19314 },
19315 groupName
19316 );
19317 }
19318
19319 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
19320 var import_element81 = __toESM(require_element(), 1);
19321 var import_data5 = __toESM(require_data(), 1);
19322 var import_compose9 = __toESM(require_compose(), 1);
19323 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
19324 function ActivityItem(props) {
19325 const {
19326 view,
19327 actions,
19328 item,
19329 titleField,
19330 mediaField,
19331 descriptionField,
19332 otherFields,
19333 posinset,
19334 onClickItem,
19335 renderItemLink,
19336 isItemClickable: isItemClickable2
19337 } = props;
19338 const {
19339 showTitle = true,
19340 showMedia = true,
19341 showDescription = true,
19342 infiniteScrollEnabled
19343 } = view;
19344 const itemRef = (0, import_element81.useRef)(null);
19345 const registry = (0, import_data5.useRegistry)();
19346 const { paginationInfo } = (0, import_element81.useContext)(dataviews_context_default);
19347 const { primaryActions, eligibleActions } = (0, import_element81.useMemo)(() => {
19348 const _eligibleActions = actions.filter(
19349 (action) => !action.isEligible || action.isEligible(item)
19350 );
19351 const _primaryActions = _eligibleActions.filter(
19352 (action) => action.isPrimary
19353 );
19354 return {
19355 primaryActions: _primaryActions,
19356 eligibleActions: _eligibleActions
19357 };
19358 }, [actions, item]);
19359 const isMobileViewport = (0, import_compose9.useViewportMatch)("medium", "<");
19360 const density = view.layout?.density ?? "balanced";
19361 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19362 mediaField.render,
19363 {
19364 item,
19365 field: mediaField,
19366 config: {
19367 sizes: density === "comfortable" ? "32px" : "24px"
19368 }
19369 }
19370 ) : null;
19371 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19372 "span",
19373 {
19374 className: "dataviews-view-activity__item-bullet",
19375 "aria-hidden": "true"
19376 }
19377 ) });
19378 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(titleField.render, { item, field: titleField }) : null;
19379 const verticalGap = (0, import_element81.useMemo)(() => {
19380 switch (density) {
19381 case "comfortable":
19382 return "md";
19383 default:
19384 return "sm";
19385 }
19386 }, [density]);
19387 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19388 "div",
19389 {
19390 ref: itemRef,
19391 role: infiniteScrollEnabled ? "article" : void 0,
19392 "aria-posinset": posinset,
19393 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
19394 className: clsx_default(
19395 "dataviews-view-activity__item",
19396 density === "compact" && "is-compact",
19397 density === "balanced" && "is-balanced",
19398 density === "comfortable" && "is-comfortable"
19399 ),
19400 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
19401 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19402 Stack,
19403 {
19404 direction: "column",
19405 gap: "xs",
19406 align: "center",
19407 className: "dataviews-view-activity__item-type",
19408 children: renderedMediaField
19409 }
19410 ),
19411 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
19412 Stack,
19413 {
19414 direction: "column",
19415 gap: verticalGap,
19416 align: "flex-start",
19417 className: "dataviews-view-activity__item-content",
19418 children: [
19419 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19420 ItemClickWrapper,
19421 {
19422 item,
19423 isItemClickable: isItemClickable2,
19424 onClickItem,
19425 renderItemLink,
19426 className: "dataviews-view-activity__item-title",
19427 children: renderedTitleField
19428 }
19429 ),
19430 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19431 descriptionField.render,
19432 {
19433 item,
19434 field: descriptionField
19435 }
19436 ) }),
19437 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
19438 "div",
19439 {
19440 className: "dataviews-view-activity__item-field",
19441 children: [
19442 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19443 VisuallyHidden,
19444 {
19445 className: "dataviews-view-activity__item-field-label",
19446 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", {}),
19447 children: field.label
19448 }
19449 ),
19450 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19451 field.render,
19452 {
19453 item,
19454 field
19455 }
19456 ) })
19457 ]
19458 },
19459 field.id
19460 )) }),
19461 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19462 PrimaryActions,
19463 {
19464 item,
19465 actions: primaryActions,
19466 registry,
19467 buttonVariant: "secondary"
19468 }
19469 )
19470 ]
19471 }
19472 ),
19473 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
19474 // there if there are any actions at all.
19475 isMobileViewport && // At the same time, only show the menu if there are actions to show.
19476 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19477 ItemActions,
19478 {
19479 item,
19480 actions: eligibleActions,
19481 isCompact: true
19482 }
19483 ) })
19484 ] })
19485 }
19486 );
19487 }
19488 var activity_item_default = ActivityItem;
19489
19490 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
19491 var import_react19 = __toESM(require_react(), 1);
19492 function isDefined3(item) {
19493 return !!item;
19494 }
19495 function ActivityItems(props) {
19496 const { data, fields: fields2, getItemId: getItemId2, view } = props;
19497 const titleField = fields2.find((field) => field.id === view.titleField);
19498 const mediaField = fields2.find((field) => field.id === view.mediaField);
19499 const descriptionField = fields2.find(
19500 (field) => field.id === view.descriptionField
19501 );
19502 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined3);
19503 return data.map((item, index2) => {
19504 return /* @__PURE__ */ (0, import_react19.createElement)(
19505 activity_item_default,
19506 {
19507 ...props,
19508 key: getItemId2(item),
19509 item,
19510 mediaField,
19511 titleField,
19512 descriptionField,
19513 otherFields,
19514 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
19515 }
19516 );
19517 });
19518 }
19519
19520 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
19521 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
19522 function ViewActivity(props) {
19523 const { empty, data, fields: fields2, isLoading, view, className } = props;
19524 const isDelayedLoading = useDelayedLoading(!!isLoading);
19525 const hasData = !!data?.length;
19526 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
19527 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
19528 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
19529 if (!hasData) {
19530 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19531 "div",
19532 {
19533 className: clsx_default("dataviews-no-results", {
19534 "is-refreshing": isDelayedLoading
19535 }),
19536 children: empty
19537 }
19538 );
19539 }
19540 const isInert2 = !isInfiniteScroll && !!isLoading;
19541 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
19542 "is-refreshing": !isInfiniteScroll && isDelayedLoading
19543 });
19544 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
19545 if (hasData && groupField && dataByGroup) {
19546 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19547 Stack,
19548 {
19549 direction: "column",
19550 gap: "sm",
19551 className: wrapperClassName,
19552 inert: isInert2 ? "true" : void 0,
19553 children: groupedEntries.map(
19554 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19555 ActivityGroup,
19556 {
19557 groupName,
19558 groupData,
19559 groupField,
19560 showLabel: view.groupBy?.showLabel !== false,
19561 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19562 ActivityItems,
19563 {
19564 ...props,
19565 data: groupData
19566 }
19567 )
19568 },
19569 groupName
19570 )
19571 )
19572 }
19573 );
19574 }
19575 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_jsx_runtime102.Fragment, { children: [
19576 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19577 "div",
19578 {
19579 className: wrapperClassName,
19580 role: view.infiniteScrollEnabled ? "feed" : void 0,
19581 inert: isInert2 ? "true" : void 0,
19582 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(ActivityItems, { ...props })
19583 }
19584 ),
19585 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components13.Spinner, {}) })
19586 ] });
19587 }
19588
19589 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
19590 var import_components16 = __toESM(require_components(), 1);
19591 var import_i18n24 = __toESM(require_i18n(), 1);
19592 var import_compose10 = __toESM(require_compose(), 1);
19593 var import_element84 = __toESM(require_element(), 1);
19594
19595 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
19596 var import_components15 = __toESM(require_components(), 1);
19597 var import_data6 = __toESM(require_data(), 1);
19598 var import_element83 = __toESM(require_element(), 1);
19599 var import_i18n23 = __toESM(require_i18n(), 1);
19600
19601 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
19602 var import_components14 = __toESM(require_components(), 1);
19603 var import_element82 = __toESM(require_element(), 1);
19604 var import_i18n22 = __toESM(require_i18n(), 1);
19605 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
19606 function DataViewsPagination() {
19607 const {
19608 view,
19609 onChangeView,
19610 paginationInfo: { totalItems = 0, totalPages }
19611 } = (0, import_element82.useContext)(dataviews_context_default);
19612 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
19613 return null;
19614 }
19615 const currentPage = view.page ?? 1;
19616 const pageSelectOptions = Array.from(Array(totalPages)).map(
19617 (_, i2) => {
19618 const page = i2 + 1;
19619 return {
19620 value: page.toString(),
19621 label: page.toString(),
19622 "aria-label": currentPage === page ? (0, import_i18n22.sprintf)(
19623 // translators: 1: current page number. 2: total number of pages.
19624 (0, import_i18n22.__)("Page %1$d of %2$d"),
19625 currentPage,
19626 totalPages
19627 ) : page.toString()
19628 };
19629 }
19630 );
19631 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19632 Stack,
19633 {
19634 direction: "row",
19635 className: "dataviews-pagination",
19636 justify: "end",
19637 align: "center",
19638 gap: "xl",
19639 children: [
19640 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19641 Stack,
19642 {
19643 direction: "row",
19644 justify: "flex-start",
19645 align: "center",
19646 gap: "xs",
19647 className: "dataviews-pagination__page-select",
19648 children: (0, import_element82.createInterpolateElement)(
19649 (0, import_i18n22.sprintf)(
19650 // translators: 1: Current page number, 2: Total number of pages.
19651 (0, import_i18n22._x)(
19652 "<div>Page</div>%1$s<div>of %2$d</div>",
19653 "paging"
19654 ),
19655 "<CurrentPage />",
19656 totalPages
19657 ),
19658 {
19659 div: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { "aria-hidden": true }),
19660 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
19661 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19662 import_components14.SelectControl,
19663 {
19664 "aria-label": (0, import_i18n22.__)("Current page"),
19665 value: currentPage.toString(),
19666 options: pageSelectOptions,
19667 onChange: (newValue) => {
19668 onChangeView({
19669 ...view,
19670 page: +newValue
19671 });
19672 },
19673 size: "small",
19674 variant: "minimal"
19675 }
19676 )
19677 }
19678 )
19679 }
19680 ),
19681 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
19682 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19683 import_components14.Button,
19684 {
19685 onClick: () => onChangeView({
19686 ...view,
19687 page: currentPage - 1
19688 }),
19689 disabled: currentPage === 1,
19690 accessibleWhenDisabled: true,
19691 label: (0, import_i18n22.__)("Previous page"),
19692 icon: (0, import_i18n22.isRTL)() ? next_default : previous_default,
19693 showTooltip: true,
19694 size: "compact",
19695 tooltipPosition: "top"
19696 }
19697 ),
19698 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19699 import_components14.Button,
19700 {
19701 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
19702 disabled: currentPage >= totalPages,
19703 accessibleWhenDisabled: true,
19704 label: (0, import_i18n22.__)("Next page"),
19705 icon: (0, import_i18n22.isRTL)() ? previous_default : next_default,
19706 showTooltip: true,
19707 size: "compact",
19708 tooltipPosition: "top"
19709 }
19710 )
19711 ] })
19712 ]
19713 }
19714 );
19715 }
19716 var dataviews_pagination_default = (0, import_element82.memo)(DataViewsPagination);
19717
19718 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
19719 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
19720 var EMPTY_ARRAY2 = [];
19721 function useIsMultiselectPicker(actions) {
19722 return (0, import_element83.useMemo)(() => {
19723 return actions?.every((action) => action.supportsBulk);
19724 }, [actions]);
19725 }
19726 function BulkSelectionCheckbox2({
19727 selection,
19728 selectedItems,
19729 onChangeSelection,
19730 data,
19731 getItemId: getItemId2,
19732 disableSelectAll = false
19733 }) {
19734 const hasSelection = selection.length > 0;
19735 const areAllSelected = selectedItems.length === data.length;
19736 if (disableSelectAll) {
19737 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
19738 import_components15.CheckboxControl,
19739 {
19740 className: "dataviews-view-table-selection-checkbox",
19741 checked: hasSelection,
19742 disabled: !hasSelection,
19743 onChange: () => {
19744 onChangeSelection([]);
19745 },
19746 "aria-label": (0, import_i18n23.__)("Deselect all")
19747 }
19748 );
19749 }
19750 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
19751 import_components15.CheckboxControl,
19752 {
19753 className: "dataviews-view-table-selection-checkbox",
19754 checked: areAllSelected,
19755 indeterminate: !areAllSelected && !!selectedItems.length,
19756 onChange: () => {
19757 if (areAllSelected) {
19758 onChangeSelection(
19759 selection.filter(
19760 (id) => !data.some(
19761 (item) => id === getItemId2(item)
19762 )
19763 )
19764 );
19765 } else {
19766 const selectionSet = /* @__PURE__ */ new Set([
19767 ...selection,
19768 ...data.map((item) => getItemId2(item))
19769 ]);
19770 onChangeSelection(Array.from(selectionSet));
19771 }
19772 },
19773 "aria-label": areAllSelected ? (0, import_i18n23.__)("Deselect all") : (0, import_i18n23.__)("Select all")
19774 }
19775 );
19776 }
19777 function ActionButtons({
19778 actions,
19779 items,
19780 selection
19781 }) {
19782 const registry = (0, import_data6.useRegistry)();
19783 const [actionInProgress, setActionInProgress] = (0, import_element83.useState)(
19784 null
19785 );
19786 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Stack, { direction: "row", gap: "xs", children: actions.map((action) => {
19787 if (!("callback" in action)) {
19788 return null;
19789 }
19790 const { id, label, icon, isPrimary, callback } = action;
19791 const _label = typeof label === "string" ? label : label(items);
19792 const variant = isPrimary ? "primary" : "tertiary";
19793 const isInProgress = id === actionInProgress;
19794 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
19795 import_components15.Button,
19796 {
19797 accessibleWhenDisabled: true,
19798 icon,
19799 disabled: isInProgress || !selection?.length,
19800 isBusy: isInProgress,
19801 onClick: async () => {
19802 setActionInProgress(id);
19803 await callback(items, {
19804 registry
19805 });
19806 setActionInProgress(null);
19807 },
19808 size: "compact",
19809 variant,
19810 children: _label
19811 },
19812 id
19813 );
19814 }) });
19815 }
19816 function DataViewsPickerFooter() {
19817 const {
19818 data,
19819 selection,
19820 onChangeSelection,
19821 getItemId: getItemId2,
19822 actions = EMPTY_ARRAY2,
19823 paginationInfo,
19824 view
19825 } = (0, import_element83.useContext)(dataviews_context_default);
19826 const isMultiselect = useIsMultiselectPicker(actions);
19827 const message2 = getFooterMessage(
19828 selection.length,
19829 data.length,
19830 paginationInfo.totalItems,
19831 !!view.infiniteScrollEnabled
19832 );
19833 const selectedItems = (0, import_element83.useMemo)(
19834 () => data.filter((item) => selection.includes(getItemId2(item))),
19835 [selection, getItemId2, data]
19836 );
19837 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
19838 Stack,
19839 {
19840 direction: "row",
19841 justify: "space-between",
19842 align: "center",
19843 className: "dataviews-footer",
19844 gap: "sm",
19845 children: [
19846 /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
19847 Stack,
19848 {
19849 direction: "row",
19850 className: "dataviews-picker-footer__bulk-selection",
19851 gap: "md",
19852 align: "center",
19853 children: [
19854 isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
19855 BulkSelectionCheckbox2,
19856 {
19857 selection,
19858 selectedItems,
19859 onChangeSelection,
19860 data,
19861 getItemId: getItemId2,
19862 disableSelectAll: !!view.infiniteScrollEnabled
19863 }
19864 ),
19865 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 })
19866 ]
19867 }
19868 ),
19869 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(dataviews_pagination_default, {}),
19870 Boolean(actions?.length) && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "dataviews-picker-footer__actions", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
19871 ActionButtons,
19872 {
19873 actions,
19874 items: selectedItems,
19875 selection
19876 }
19877 ) })
19878 ]
19879 }
19880 );
19881 }
19882
19883 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
19884 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
19885 var { Badge: WCBadge2 } = unlock3(import_components16.privateApis);
19886 function GridItem3({
19887 view,
19888 multiselect,
19889 selection,
19890 onChangeSelection,
19891 getItemId: getItemId2,
19892 item,
19893 mediaField,
19894 titleField,
19895 descriptionField,
19896 regularFields,
19897 badgeFields,
19898 config,
19899 posinset,
19900 setsize
19901 }) {
19902 const { showTitle = true, showMedia = true, showDescription = true } = view;
19903 const id = getItemId2(item);
19904 const elementRef = (0, import_element84.useRef)(null);
19905 const isSelected2 = selection.includes(id);
19906 useIntersectionObserver(elementRef, posinset);
19907 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19908 mediaField.render,
19909 {
19910 item,
19911 field: mediaField,
19912 config
19913 }
19914 ) : null;
19915 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(titleField.render, { item, field: titleField }) : null;
19916 return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
19917 import_components16.Composite.Item,
19918 {
19919 ref: elementRef,
19920 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n24.__)("(no title)") : void 0,
19921 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(Stack, { direction: "column", children, ...props }),
19922 role: "option",
19923 "aria-posinset": posinset,
19924 "aria-setsize": setsize,
19925 className: clsx_default("dataviews-view-picker-grid__card", {
19926 "is-selected": isSelected2
19927 }),
19928 "aria-selected": isSelected2,
19929 onClick: () => {
19930 if (isSelected2) {
19931 onChangeSelection(
19932 selection.filter((itemId) => id !== itemId)
19933 );
19934 } else {
19935 const newSelection = multiselect ? [...selection, id] : [id];
19936 onChangeSelection(newSelection);
19937 }
19938 },
19939 children: [
19940 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
19941 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19942 DataViewsSelectionCheckbox,
19943 {
19944 item,
19945 selection,
19946 onChangeSelection,
19947 getItemId: getItemId2,
19948 titleField,
19949 disabled: false,
19950 "aria-hidden": true,
19951 tabIndex: -1
19952 }
19953 ),
19954 showTitle && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19955 Stack,
19956 {
19957 direction: "row",
19958 justify: "space-between",
19959 className: "dataviews-view-picker-grid__title-actions",
19960 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
19961 }
19962 ),
19963 /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(Stack, { direction: "column", gap: "xs", children: [
19964 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19965 descriptionField.render,
19966 {
19967 item,
19968 field: descriptionField
19969 }
19970 ),
19971 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19972 Stack,
19973 {
19974 direction: "row",
19975 className: "dataviews-view-picker-grid__badge-fields",
19976 gap: "sm",
19977 wrap: "wrap",
19978 align: "top",
19979 justify: "flex-start",
19980 children: badgeFields.map((field) => {
19981 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19982 WCBadge2,
19983 {
19984 className: "dataviews-view-picker-grid__field-value",
19985 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19986 field.render,
19987 {
19988 item,
19989 field
19990 }
19991 )
19992 },
19993 field.id
19994 );
19995 })
19996 }
19997 ),
19998 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19999 Stack,
20000 {
20001 direction: "column",
20002 className: "dataviews-view-picker-grid__fields",
20003 gap: "xs",
20004 children: regularFields.map((field) => {
20005 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20006 import_components16.Flex,
20007 {
20008 className: "dataviews-view-picker-grid__field",
20009 gap: 1,
20010 justify: "flex-start",
20011 expanded: true,
20012 style: { height: "auto" },
20013 direction: "row",
20014 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(import_jsx_runtime105.Fragment, { children: [
20015 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components16.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
20016 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20017 import_components16.FlexItem,
20018 {
20019 className: "dataviews-view-picker-grid__field-value",
20020 style: { maxHeight: "none" },
20021 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20022 field.render,
20023 {
20024 item,
20025 field
20026 }
20027 )
20028 }
20029 )
20030 ] })
20031 },
20032 field.id
20033 );
20034 })
20035 }
20036 )
20037 ] })
20038 ]
20039 },
20040 id
20041 );
20042 }
20043 function GridGroup({
20044 groupName,
20045 groupField,
20046 showLabel = true,
20047 children
20048 }) {
20049 const headerId = (0, import_compose10.useInstanceId)(
20050 GridGroup,
20051 "dataviews-view-picker-grid-group__header"
20052 );
20053 return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
20054 Stack,
20055 {
20056 direction: "column",
20057 gap: "sm",
20058 role: "group",
20059 "aria-labelledby": headerId,
20060 children: [
20061 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20062 "h3",
20063 {
20064 className: "dataviews-view-picker-grid-group__header",
20065 id: headerId,
20066 children: showLabel ? (0, import_i18n24.sprintf)(
20067 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
20068 (0, import_i18n24.__)("%1$s: %2$s"),
20069 groupField.label,
20070 groupName
20071 ) : groupName
20072 }
20073 ),
20074 children
20075 ]
20076 },
20077 groupName
20078 );
20079 }
20080 function ViewPickerGrid({
20081 actions,
20082 data,
20083 fields: fields2,
20084 getItemId: getItemId2,
20085 isLoading,
20086 onChangeSelection,
20087 selection,
20088 view,
20089 className,
20090 empty
20091 }) {
20092 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element84.useContext)(dataviews_context_default);
20093 const titleField = fields2.find(
20094 (field) => field.id === view?.titleField
20095 );
20096 const mediaField = fields2.find(
20097 (field) => field.id === view?.mediaField
20098 );
20099 const descriptionField = fields2.find(
20100 (field) => field.id === view?.descriptionField
20101 );
20102 const otherFields = view.fields ?? [];
20103 const { regularFields, badgeFields } = otherFields.reduce(
20104 (accumulator, fieldId) => {
20105 const field = fields2.find((f2) => f2.id === fieldId);
20106 if (!field) {
20107 return accumulator;
20108 }
20109 const key2 = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
20110 accumulator[key2].push(field);
20111 return accumulator;
20112 },
20113 { regularFields: [], badgeFields: [] }
20114 );
20115 const hasData = !!data?.length;
20116 const usedPreviewSize = view.layout?.previewSize;
20117 const isMultiselect = useIsMultiselectPicker(actions);
20118 const size4 = "900px";
20119 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
20120 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
20121 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
20122 const currentPage = view?.page ?? 1;
20123 const perPage = view?.perPage ?? 0;
20124 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
20125 const gridColumns = useGridColumns();
20126 const placeholdersNeeded = usePlaceholdersNeeded(
20127 data,
20128 isInfiniteScroll,
20129 gridColumns
20130 );
20131 return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(import_jsx_runtime105.Fragment, {
20132 // Render multiple groups.
20133 children: [
20134 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20135 import_components16.Composite,
20136 {
20137 virtualFocus: true,
20138 orientation: "horizontal",
20139 role: "listbox",
20140 "aria-multiselectable": isMultiselect,
20141 className: clsx_default(
20142 "dataviews-view-picker-grid",
20143 className,
20144 {
20145 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
20146 view.layout.density
20147 )
20148 }
20149 ),
20150 "aria-label": itemListLabel,
20151 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20152 Stack,
20153 {
20154 direction: "column",
20155 gap: "lg",
20156 children,
20157 ...props
20158 }
20159 ),
20160 children: Array.from(dataByGroup.entries()).map(
20161 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20162 GridGroup,
20163 {
20164 groupName,
20165 groupField,
20166 showLabel: view.groupBy?.showLabel !== false,
20167 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20168 GridItems,
20169 {
20170 previewSize: usedPreviewSize,
20171 style: {
20172 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
20173 },
20174 "aria-busy": isLoading,
20175 ref: resizeObserverRef,
20176 children: groupItems.map((item) => {
20177 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
20178 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20179 GridItem3,
20180 {
20181 view,
20182 multiselect: isMultiselect,
20183 selection,
20184 onChangeSelection,
20185 getItemId: getItemId2,
20186 item,
20187 mediaField,
20188 titleField,
20189 descriptionField,
20190 regularFields,
20191 badgeFields,
20192 config: {
20193 sizes: size4
20194 },
20195 posinset: posInSet,
20196 setsize: setSize
20197 },
20198 getItemId2(item)
20199 );
20200 })
20201 }
20202 )
20203 },
20204 groupName
20205 )
20206 )
20207 }
20208 ),
20209 // Render a single grid with all data.
20210 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
20211 import_components16.Composite,
20212 {
20213 render: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20214 GridItems,
20215 {
20216 className: clsx_default(
20217 "dataviews-view-picker-grid",
20218 className,
20219 {
20220 [`has-${view.layout?.density}-density`]: view.layout?.density && [
20221 "compact",
20222 "comfortable"
20223 ].includes(view.layout.density)
20224 }
20225 ),
20226 previewSize: usedPreviewSize,
20227 "aria-busy": isLoading,
20228 ref: resizeObserverRef
20229 }
20230 ),
20231 virtualFocus: true,
20232 orientation: "horizontal",
20233 role: "listbox",
20234 "aria-multiselectable": isMultiselect,
20235 "aria-label": itemListLabel,
20236 children: [
20237 Array.from({ length: placeholdersNeeded }).map(
20238 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20239 import_components16.Composite.Item,
20240 {
20241 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20242 Stack,
20243 {
20244 direction: "column",
20245 children,
20246 ...props
20247 }
20248 ),
20249 role: "option",
20250 "aria-hidden": true,
20251 tabIndex: -1,
20252 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
20253 },
20254 `placeholder-${index2}`
20255 )
20256 ),
20257 data.map((item) => {
20258 const posinset = item.position;
20259 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20260 GridItem3,
20261 {
20262 view,
20263 multiselect: isMultiselect,
20264 selection,
20265 onChangeSelection,
20266 getItemId: getItemId2,
20267 item,
20268 mediaField,
20269 titleField,
20270 descriptionField,
20271 regularFields,
20272 badgeFields,
20273 config: {
20274 sizes: size4
20275 },
20276 posinset,
20277 setsize: setSize
20278 },
20279 getItemId2(item)
20280 );
20281 })
20282 ]
20283 }
20284 ),
20285 // Render empty state.
20286 !hasData && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
20287 "div",
20288 {
20289 className: clsx_default({
20290 "dataviews-loading": isLoading,
20291 "dataviews-no-results": !isLoading
20292 }),
20293 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components16.Spinner, {}) }) : empty
20294 }
20295 ),
20296 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components16.Spinner, {}) })
20297 ]
20298 });
20299 }
20300 var picker_grid_default = ViewPickerGrid;
20301
20302 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
20303 var import_i18n25 = __toESM(require_i18n(), 1);
20304 var import_components17 = __toESM(require_components(), 1);
20305 var import_element85 = __toESM(require_element(), 1);
20306 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
20307 function TableColumnField2({
20308 item,
20309 fields: fields2,
20310 column,
20311 align
20312 }) {
20313 const field = fields2.find((f2) => f2.id === column);
20314 if (!field) {
20315 return null;
20316 }
20317 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
20318 "dataviews-view-table__cell-align-end": align === "end",
20319 "dataviews-view-table__cell-align-center": align === "center"
20320 });
20321 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(field.render, { item, field }) });
20322 }
20323 function TableRow2({
20324 item,
20325 fields: fields2,
20326 id,
20327 view,
20328 titleField,
20329 mediaField,
20330 descriptionField,
20331 selection,
20332 getItemId: getItemId2,
20333 onChangeSelection,
20334 multiselect,
20335 posinset
20336 }) {
20337 const { paginationInfo } = (0, import_element85.useContext)(dataviews_context_default);
20338 const isSelected2 = selection.includes(id);
20339 const [isHovered, setIsHovered] = (0, import_element85.useState)(false);
20340 const elementRef = (0, import_element85.useRef)(null);
20341 useIntersectionObserver(elementRef, posinset);
20342 const {
20343 showTitle = true,
20344 showMedia = true,
20345 showDescription = true,
20346 infiniteScrollEnabled
20347 } = view;
20348 const handleMouseEnter = () => {
20349 setIsHovered(true);
20350 };
20351 const handleMouseLeave = () => {
20352 setIsHovered(false);
20353 };
20354 const columns = view.fields ?? [];
20355 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
20356 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
20357 import_components17.Composite.Item,
20358 {
20359 ref: elementRef,
20360 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20361 "tr",
20362 {
20363 className: clsx_default("dataviews-view-table__row", {
20364 "is-selected": isSelected2,
20365 "is-hovered": isHovered
20366 }),
20367 onMouseEnter: handleMouseEnter,
20368 onMouseLeave: handleMouseLeave,
20369 children,
20370 ...props
20371 }
20372 ),
20373 "aria-selected": isSelected2,
20374 "aria-setsize": paginationInfo.totalItems || void 0,
20375 "aria-posinset": posinset,
20376 role: infiniteScrollEnabled ? "article" : "option",
20377 onClick: () => {
20378 if (isSelected2) {
20379 onChangeSelection(
20380 selection.filter((itemId) => id !== itemId)
20381 );
20382 } else {
20383 const newSelection = multiselect ? [...selection, id] : [id];
20384 onChangeSelection(newSelection);
20385 }
20386 },
20387 children: [
20388 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20389 "td",
20390 {
20391 className: "dataviews-view-table__checkbox-column",
20392 role: "presentation",
20393 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20394 DataViewsSelectionCheckbox,
20395 {
20396 item,
20397 selection,
20398 onChangeSelection,
20399 getItemId: getItemId2,
20400 titleField,
20401 disabled: false,
20402 "aria-hidden": true,
20403 tabIndex: -1
20404 }
20405 ) })
20406 }
20407 ),
20408 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20409 "td",
20410 {
20411 role: "presentation",
20412 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20413 column_primary_default,
20414 {
20415 item,
20416 titleField: showTitle ? titleField : void 0,
20417 mediaField: showMedia ? mediaField : void 0,
20418 descriptionField: showDescription ? descriptionField : void 0,
20419 isItemClickable: () => false
20420 }
20421 )
20422 }
20423 ),
20424 columns.map((column) => {
20425 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
20426 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20427 "td",
20428 {
20429 style: {
20430 width,
20431 maxWidth,
20432 minWidth
20433 },
20434 role: "presentation",
20435 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20436 TableColumnField2,
20437 {
20438 fields: fields2,
20439 item,
20440 column,
20441 align
20442 }
20443 )
20444 },
20445 column
20446 );
20447 })
20448 ]
20449 },
20450 id
20451 );
20452 }
20453 function ViewPickerTable({
20454 actions,
20455 data,
20456 fields: fields2,
20457 getItemId: getItemId2,
20458 isLoading = false,
20459 onChangeView,
20460 onChangeSelection,
20461 selection,
20462 setOpenedFilter,
20463 view,
20464 className,
20465 empty
20466 }) {
20467 const headerMenuRefs = (0, import_element85.useRef)(/* @__PURE__ */ new Map());
20468 const headerMenuToFocusRef = (0, import_element85.useRef)(void 0);
20469 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element85.useState)();
20470 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
20471 (0, import_element85.useEffect)(() => {
20472 if (headerMenuToFocusRef.current) {
20473 headerMenuToFocusRef.current.focus();
20474 headerMenuToFocusRef.current = void 0;
20475 }
20476 });
20477 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
20478 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
20479 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
20480 const tableNoticeId = (0, import_element85.useId)();
20481 if (nextHeaderMenuToFocus) {
20482 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
20483 setNextHeaderMenuToFocus(void 0);
20484 return;
20485 }
20486 const onHide = (field) => {
20487 const hidden = headerMenuRefs.current.get(field.id);
20488 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
20489 setNextHeaderMenuToFocus(fallback?.node);
20490 };
20491 const hasData = !!data?.length;
20492 const titleField = fields2.find((field) => field.id === view.titleField);
20493 const mediaField = fields2.find((field) => field.id === view.mediaField);
20494 const descriptionField = fields2.find(
20495 (field) => field.id === view.descriptionField
20496 );
20497 const { showTitle = true, showMedia = true, showDescription = true } = view;
20498 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
20499 const columns = view.fields ?? [];
20500 const headerMenuRef = (column, index2) => (node) => {
20501 if (node) {
20502 headerMenuRefs.current.set(column, {
20503 node,
20504 fallback: columns[index2 > 0 ? index2 - 1 : 1]
20505 });
20506 } else {
20507 headerMenuRefs.current.delete(column);
20508 }
20509 };
20510 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(import_jsx_runtime106.Fragment, { children: [
20511 /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
20512 "table",
20513 {
20514 className: clsx_default(
20515 "dataviews-view-table",
20516 "dataviews-view-picker-table",
20517 className,
20518 {
20519 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
20520 view.layout.density
20521 )
20522 }
20523 ),
20524 "aria-busy": isLoading,
20525 "aria-describedby": tableNoticeId,
20526 role: isInfiniteScroll ? "feed" : "listbox",
20527 children: [
20528 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
20529 "tr",
20530 {
20531 className: "dataviews-view-table__row",
20532 role: "presentation",
20533 children: [
20534 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20535 BulkSelectionCheckbox,
20536 {
20537 selection,
20538 onChangeSelection,
20539 data,
20540 actions,
20541 getItemId: getItemId2,
20542 disableSelectAll: isInfiniteScroll
20543 }
20544 ) }),
20545 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20546 column_header_menu_default,
20547 {
20548 ref: headerMenuRef(
20549 titleField.id,
20550 0
20551 ),
20552 fieldId: titleField.id,
20553 view,
20554 fields: fields2,
20555 onChangeView,
20556 onHide,
20557 setOpenedFilter,
20558 canMove: false
20559 }
20560 ) }),
20561 columns.map((column, index2) => {
20562 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
20563 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20564 "th",
20565 {
20566 style: {
20567 width,
20568 maxWidth,
20569 minWidth,
20570 textAlign: align
20571 },
20572 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
20573 scope: "col",
20574 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20575 column_header_menu_default,
20576 {
20577 ref: headerMenuRef(column, index2),
20578 fieldId: column,
20579 view,
20580 fields: fields2,
20581 onChangeView,
20582 onHide,
20583 setOpenedFilter,
20584 canMove: view.layout?.enableMoving ?? true
20585 }
20586 )
20587 },
20588 column
20589 );
20590 })
20591 ]
20592 }
20593 ) }),
20594 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
20595 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
20596 import_components17.Composite,
20597 {
20598 virtualFocus: true,
20599 orientation: "vertical",
20600 render: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("tbody", { role: "group" }),
20601 children: [
20602 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20603 "tr",
20604 {
20605 className: "dataviews-view-table__group-header-row",
20606 role: "presentation",
20607 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20608 "td",
20609 {
20610 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
20611 className: "dataviews-view-table__group-header-cell",
20612 role: "presentation",
20613 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n25.sprintf)(
20614 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
20615 (0, import_i18n25.__)("%1$s: %2$s"),
20616 groupField.label,
20617 groupName
20618 )
20619 }
20620 )
20621 }
20622 ),
20623 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20624 TableRow2,
20625 {
20626 item,
20627 fields: fields2,
20628 id: getItemId2(item) || index2.toString(),
20629 view,
20630 titleField,
20631 mediaField,
20632 descriptionField,
20633 selection,
20634 getItemId: getItemId2,
20635 onChangeSelection,
20636 multiselect: isMultiselect
20637 },
20638 getItemId2(item)
20639 ))
20640 ]
20641 },
20642 `group-${groupName}`
20643 )
20644 ) : /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20645 import_components17.Composite,
20646 {
20647 render: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("tbody", { role: "presentation" }),
20648 virtualFocus: true,
20649 orientation: "vertical",
20650 children: hasData && data.map((item, index2) => {
20651 const itemId = getItemId2(item);
20652 const posinset = item.position;
20653 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20654 TableRow2,
20655 {
20656 item,
20657 fields: fields2,
20658 id: itemId || index2.toString(),
20659 view,
20660 titleField,
20661 mediaField,
20662 descriptionField,
20663 selection,
20664 getItemId: getItemId2,
20665 onChangeSelection,
20666 multiselect: isMultiselect,
20667 posinset
20668 },
20669 itemId
20670 );
20671 })
20672 }
20673 )
20674 ]
20675 }
20676 ),
20677 /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
20678 "div",
20679 {
20680 className: clsx_default({
20681 "dataviews-loading": isLoading,
20682 "dataviews-no-results": !hasData && !isLoading
20683 }),
20684 id: tableNoticeId,
20685 children: [
20686 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components17.Spinner, {}) }) : empty),
20687 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components17.Spinner, {}) })
20688 ]
20689 }
20690 )
20691 ] });
20692 }
20693 var picker_table_default = ViewPickerTable;
20694
20695 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
20696 var import_components18 = __toESM(require_components(), 1);
20697 var import_i18n26 = __toESM(require_i18n(), 1);
20698 var import_element86 = __toESM(require_element(), 1);
20699 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
20700 function DensityPicker() {
20701 const context = (0, import_element86.useContext)(dataviews_context_default);
20702 const view = context.view;
20703 return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
20704 import_components18.__experimentalToggleGroupControl,
20705 {
20706 size: "__unstable-large",
20707 label: (0, import_i18n26.__)("Density"),
20708 value: view.layout?.density || "balanced",
20709 onChange: (value) => {
20710 context.onChangeView({
20711 ...view,
20712 layout: {
20713 ...view.layout,
20714 density: value
20715 }
20716 });
20717 },
20718 isBlock: true,
20719 children: [
20720 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20721 import_components18.__experimentalToggleGroupControlOption,
20722 {
20723 value: "comfortable",
20724 label: (0, import_i18n26._x)(
20725 "Comfortable",
20726 "Density option for DataView layout"
20727 )
20728 },
20729 "comfortable"
20730 ),
20731 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20732 import_components18.__experimentalToggleGroupControlOption,
20733 {
20734 value: "balanced",
20735 label: (0, import_i18n26._x)("Balanced", "Density option for DataView layout")
20736 },
20737 "balanced"
20738 ),
20739 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20740 import_components18.__experimentalToggleGroupControlOption,
20741 {
20742 value: "compact",
20743 label: (0, import_i18n26._x)("Compact", "Density option for DataView layout")
20744 },
20745 "compact"
20746 )
20747 ]
20748 }
20749 );
20750 }
20751
20752 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
20753 var import_components19 = __toESM(require_components(), 1);
20754 var import_i18n27 = __toESM(require_i18n(), 1);
20755 var import_element87 = __toESM(require_element(), 1);
20756 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
20757 var imageSizes2 = [
20758 {
20759 value: 120,
20760 breakpoint: 1
20761 },
20762 {
20763 value: 170,
20764 breakpoint: 1
20765 },
20766 {
20767 value: 230,
20768 breakpoint: 1
20769 },
20770 {
20771 value: 290,
20772 breakpoint: 1112
20773 // at minimum image width, 4 images display at this container size
20774 },
20775 {
20776 value: 350,
20777 breakpoint: 1636
20778 // at minimum image width, 6 images display at this container size
20779 },
20780 {
20781 value: 430,
20782 breakpoint: 588
20783 // at minimum image width, 2 images display at this container size
20784 }
20785 ];
20786 function PreviewSizePicker() {
20787 const context = (0, import_element87.useContext)(dataviews_context_default);
20788 const view = context.view;
20789 const breakValues = imageSizes2.filter((size4) => {
20790 return context.containerWidth >= size4.breakpoint;
20791 });
20792 const layoutPreviewSize = view.layout?.previewSize ?? 230;
20793 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
20794 const marks = breakValues.map((size4, index2) => {
20795 return {
20796 value: index2
20797 };
20798 });
20799 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
20800 import_components19.RangeControl,
20801 {
20802 __next40pxDefaultSize: true,
20803 showTooltip: false,
20804 label: (0, import_i18n27.__)("Preview size"),
20805 value: previewSizeToUse,
20806 min: 0,
20807 max: breakValues.length - 1,
20808 withInputField: false,
20809 onChange: (value = 0) => {
20810 context.onChangeView({
20811 ...view,
20812 layout: {
20813 ...view.layout,
20814 previewSize: breakValues[value].value
20815 }
20816 });
20817 },
20818 step: 1,
20819 marks
20820 }
20821 );
20822 }
20823
20824 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
20825 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
20826 function GridConfigOptions() {
20827 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
20828 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(DensityPicker, {}),
20829 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PreviewSizePicker, {})
20830 ] });
20831 }
20832
20833 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
20834 var VIEW_LAYOUTS = [
20835 {
20836 type: LAYOUT_TABLE,
20837 label: (0, import_i18n28.__)("Table"),
20838 component: table_default,
20839 icon: block_table_default,
20840 viewConfigOptions: DensityPicker
20841 },
20842 {
20843 type: LAYOUT_GRID,
20844 label: (0, import_i18n28.__)("Grid"),
20845 component: grid_default,
20846 icon: category_default,
20847 viewConfigOptions: GridConfigOptions
20848 },
20849 {
20850 type: LAYOUT_LIST,
20851 label: (0, import_i18n28.__)("List"),
20852 component: ViewList,
20853 icon: (0, import_i18n28.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
20854 viewConfigOptions: DensityPicker
20855 },
20856 {
20857 type: LAYOUT_ACTIVITY,
20858 label: (0, import_i18n28.__)("Activity"),
20859 component: ViewActivity,
20860 icon: scheduled_default,
20861 viewConfigOptions: DensityPicker
20862 },
20863 {
20864 type: LAYOUT_PICKER_GRID,
20865 label: (0, import_i18n28.__)("Grid"),
20866 component: picker_grid_default,
20867 icon: category_default,
20868 viewConfigOptions: GridConfigOptions,
20869 isPicker: true
20870 },
20871 {
20872 type: LAYOUT_PICKER_TABLE,
20873 label: (0, import_i18n28.__)("Table"),
20874 component: picker_table_default,
20875 icon: block_table_default,
20876 viewConfigOptions: DensityPicker,
20877 isPicker: true
20878 }
20879 ];
20880
20881 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
20882 var import_element95 = __toESM(require_element(), 1);
20883
20884 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
20885 var import_components22 = __toESM(require_components(), 1);
20886 var import_i18n31 = __toESM(require_i18n(), 1);
20887 var import_element92 = __toESM(require_element(), 1);
20888
20889 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
20890 function noop5(..._) {
20891 }
20892 function applyState(argument, currentValue) {
20893 if (isUpdater(argument)) {
20894 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
20895 return argument(value);
20896 }
20897 return argument;
20898 }
20899 function isUpdater(argument) {
20900 return typeof argument === "function";
20901 }
20902 function isLazyValue(value) {
20903 return typeof value === "function";
20904 }
20905 function hasOwnProperty(object, prop) {
20906 if (typeof Object.hasOwn === "function") {
20907 return Object.hasOwn(object, prop);
20908 }
20909 return Object.prototype.hasOwnProperty.call(object, prop);
20910 }
20911 function chain(...fns) {
20912 return (...args) => {
20913 for (const fn of fns) {
20914 if (typeof fn === "function") {
20915 fn(...args);
20916 }
20917 }
20918 };
20919 }
20920 function normalizeString(str) {
20921 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
20922 }
20923 function omit(object, keys) {
20924 const result = { ...object };
20925 for (const key2 of keys) {
20926 if (hasOwnProperty(result, key2)) {
20927 delete result[key2];
20928 }
20929 }
20930 return result;
20931 }
20932 function pick(object, paths) {
20933 const result = {};
20934 for (const key2 of paths) {
20935 if (hasOwnProperty(object, key2)) {
20936 result[key2] = object[key2];
20937 }
20938 }
20939 return result;
20940 }
20941 function identity(value) {
20942 return value;
20943 }
20944 function invariant(condition, message2) {
20945 if (condition) return;
20946 if (typeof message2 !== "string") throw new Error("Invariant failed");
20947 throw new Error(message2);
20948 }
20949 function getKeys(obj) {
20950 return Object.keys(obj);
20951 }
20952 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
20953 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
20954 if (result == null) return false;
20955 return !result;
20956 }
20957 function disabledFromProps(props) {
20958 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
20959 }
20960 function removeUndefinedValues(obj) {
20961 const result = {};
20962 for (const key2 in obj) {
20963 if (obj[key2] !== void 0) {
20964 result[key2] = obj[key2];
20965 }
20966 }
20967 return result;
20968 }
20969 function defaultValue(...values) {
20970 for (const value of values) {
20971 if (value !== void 0) return value;
20972 }
20973 return void 0;
20974 }
20975
20976 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
20977 var import_react20 = __toESM(require_react(), 1);
20978 function setRef(ref, value) {
20979 if (typeof ref === "function") {
20980 ref(value);
20981 } else if (ref) {
20982 ref.current = value;
20983 }
20984 }
20985 function isValidElementWithRef(element) {
20986 if (!element) return false;
20987 if (!(0, import_react20.isValidElement)(element)) return false;
20988 if ("ref" in element.props) return true;
20989 if ("ref" in element) return true;
20990 return false;
20991 }
20992 function getRefProperty(element) {
20993 if (!isValidElementWithRef(element)) return null;
20994 const props = { ...element.props };
20995 return props.ref || element.ref;
20996 }
20997 function mergeProps3(base, overrides) {
20998 const props = { ...base };
20999 for (const key2 in overrides) {
21000 if (!hasOwnProperty(overrides, key2)) continue;
21001 if (key2 === "className") {
21002 const prop = "className";
21003 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
21004 continue;
21005 }
21006 if (key2 === "style") {
21007 const prop = "style";
21008 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
21009 continue;
21010 }
21011 const overrideValue = overrides[key2];
21012 if (typeof overrideValue === "function" && key2.startsWith("on")) {
21013 const baseValue = base[key2];
21014 if (typeof baseValue === "function") {
21015 props[key2] = (...args) => {
21016 overrideValue(...args);
21017 baseValue(...args);
21018 };
21019 continue;
21020 }
21021 }
21022 props[key2] = overrideValue;
21023 }
21024 return props;
21025 }
21026
21027 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
21028 var canUseDOM = checkIsBrowser();
21029 function checkIsBrowser() {
21030 var _a;
21031 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
21032 }
21033 function getDocument(node) {
21034 if (!node) return document;
21035 if ("self" in node) return node.document;
21036 return node.ownerDocument || document;
21037 }
21038 function getActiveElement(node, activeDescendant = false) {
21039 var _a;
21040 const { activeElement: activeElement2 } = getDocument(node);
21041 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
21042 return null;
21043 }
21044 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
21045 return getActiveElement(
21046 activeElement2.contentDocument.body,
21047 activeDescendant
21048 );
21049 }
21050 if (activeDescendant) {
21051 const id = activeElement2.getAttribute("aria-activedescendant");
21052 if (id) {
21053 const element = getDocument(activeElement2).getElementById(id);
21054 if (element) {
21055 return element;
21056 }
21057 }
21058 }
21059 return activeElement2;
21060 }
21061 function contains2(parent, child) {
21062 return parent === child || parent.contains(child);
21063 }
21064 function isFrame(element) {
21065 return element.tagName === "IFRAME";
21066 }
21067 function isButton(element) {
21068 const tagName = element.tagName.toLowerCase();
21069 if (tagName === "button") return true;
21070 if (tagName === "input" && element.type) {
21071 return buttonInputTypes.indexOf(element.type) !== -1;
21072 }
21073 return false;
21074 }
21075 var buttonInputTypes = [
21076 "button",
21077 "color",
21078 "file",
21079 "image",
21080 "reset",
21081 "submit"
21082 ];
21083 function isVisible(element) {
21084 if (typeof element.checkVisibility === "function") {
21085 return element.checkVisibility();
21086 }
21087 const htmlElement = element;
21088 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
21089 }
21090 function isTextField(element) {
21091 try {
21092 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
21093 const isTextArea = element.tagName === "TEXTAREA";
21094 return isTextInput || isTextArea || false;
21095 } catch (_error) {
21096 return false;
21097 }
21098 }
21099 function isTextbox(element) {
21100 return element.isContentEditable || isTextField(element);
21101 }
21102 function getTextboxValue(element) {
21103 if (isTextField(element)) {
21104 return element.value;
21105 }
21106 if (element.isContentEditable) {
21107 const range = getDocument(element).createRange();
21108 range.selectNodeContents(element);
21109 return range.toString();
21110 }
21111 return "";
21112 }
21113 function getTextboxSelection(element) {
21114 let start = 0;
21115 let end = 0;
21116 if (isTextField(element)) {
21117 start = element.selectionStart || 0;
21118 end = element.selectionEnd || 0;
21119 } else if (element.isContentEditable) {
21120 const selection = getDocument(element).getSelection();
21121 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
21122 const range = selection.getRangeAt(0);
21123 const nextRange = range.cloneRange();
21124 nextRange.selectNodeContents(element);
21125 nextRange.setEnd(range.startContainer, range.startOffset);
21126 start = nextRange.toString().length;
21127 nextRange.setEnd(range.endContainer, range.endOffset);
21128 end = nextRange.toString().length;
21129 }
21130 }
21131 return { start, end };
21132 }
21133 function getPopupRole(element, fallback) {
21134 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
21135 const role = element == null ? void 0 : element.getAttribute("role");
21136 if (role && allowedPopupRoles.indexOf(role) !== -1) {
21137 return role;
21138 }
21139 return fallback;
21140 }
21141 function getScrollingElement(element) {
21142 if (!element) return null;
21143 const isScrollableOverflow = (overflow) => {
21144 if (overflow === "auto") return true;
21145 if (overflow === "scroll") return true;
21146 return false;
21147 };
21148 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
21149 const { overflowY } = getComputedStyle(element);
21150 if (isScrollableOverflow(overflowY)) return element;
21151 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
21152 const { overflowX } = getComputedStyle(element);
21153 if (isScrollableOverflow(overflowX)) return element;
21154 }
21155 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
21156 }
21157 function setSelectionRange(element, ...args) {
21158 if (/text|search|password|tel|url/i.test(element.type)) {
21159 element.setSelectionRange(...args);
21160 }
21161 }
21162 function sortBasedOnDOMPosition(items, getElement) {
21163 const pairs = items.map((item, index2) => [index2, item]);
21164 let isOrderDifferent = false;
21165 pairs.sort(([indexA, a2], [indexB, b2]) => {
21166 const elementA = getElement(a2);
21167 const elementB = getElement(b2);
21168 if (elementA === elementB) return 0;
21169 if (!elementA || !elementB) return 0;
21170 if (isElementPreceding(elementA, elementB)) {
21171 if (indexA > indexB) {
21172 isOrderDifferent = true;
21173 }
21174 return -1;
21175 }
21176 if (indexA < indexB) {
21177 isOrderDifferent = true;
21178 }
21179 return 1;
21180 });
21181 if (isOrderDifferent) {
21182 return pairs.map(([_, item]) => item);
21183 }
21184 return items;
21185 }
21186 function isElementPreceding(a2, b2) {
21187 return Boolean(
21188 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
21189 );
21190 }
21191
21192 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
21193 function isTouchDevice() {
21194 return canUseDOM && !!navigator.maxTouchPoints;
21195 }
21196 function isApple() {
21197 if (!canUseDOM) return false;
21198 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
21199 }
21200 function isSafari2() {
21201 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
21202 }
21203 function isFirefox2() {
21204 return canUseDOM && /firefox\//i.test(navigator.userAgent);
21205 }
21206
21207 // node_modules/@ariakit/core/esm/utils/events.js
21208 function isPortalEvent(event) {
21209 return Boolean(
21210 event.currentTarget && !contains2(event.currentTarget, event.target)
21211 );
21212 }
21213 function isSelfTarget(event) {
21214 return event.target === event.currentTarget;
21215 }
21216 function isOpeningInNewTab(event) {
21217 const element = event.currentTarget;
21218 if (!element) return false;
21219 const isAppleDevice = isApple();
21220 if (isAppleDevice && !event.metaKey) return false;
21221 if (!isAppleDevice && !event.ctrlKey) return false;
21222 const tagName = element.tagName.toLowerCase();
21223 if (tagName === "a") return true;
21224 if (tagName === "button" && element.type === "submit") return true;
21225 if (tagName === "input" && element.type === "submit") return true;
21226 return false;
21227 }
21228 function isDownloading(event) {
21229 const element = event.currentTarget;
21230 if (!element) return false;
21231 const tagName = element.tagName.toLowerCase();
21232 if (!event.altKey) return false;
21233 if (tagName === "a") return true;
21234 if (tagName === "button" && element.type === "submit") return true;
21235 if (tagName === "input" && element.type === "submit") return true;
21236 return false;
21237 }
21238 function fireBlurEvent(element, eventInit) {
21239 const event = new FocusEvent("blur", eventInit);
21240 const defaultAllowed = element.dispatchEvent(event);
21241 const bubbleInit = { ...eventInit, bubbles: true };
21242 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
21243 return defaultAllowed;
21244 }
21245 function fireKeyboardEvent(element, type, eventInit) {
21246 const event = new KeyboardEvent(type, eventInit);
21247 return element.dispatchEvent(event);
21248 }
21249 function fireClickEvent(element, eventInit) {
21250 const event = new MouseEvent("click", eventInit);
21251 return element.dispatchEvent(event);
21252 }
21253 function isFocusEventOutside(event, container) {
21254 const containerElement = container || event.currentTarget;
21255 const relatedTarget = event.relatedTarget;
21256 return !relatedTarget || !contains2(containerElement, relatedTarget);
21257 }
21258 function queueBeforeEvent(element, type, callback, timeout) {
21259 const createTimer = (callback2) => {
21260 if (timeout) {
21261 const timerId2 = setTimeout(callback2, timeout);
21262 return () => clearTimeout(timerId2);
21263 }
21264 const timerId = requestAnimationFrame(callback2);
21265 return () => cancelAnimationFrame(timerId);
21266 };
21267 const cancelTimer = createTimer(() => {
21268 element.removeEventListener(type, callSync, true);
21269 callback();
21270 });
21271 const callSync = () => {
21272 cancelTimer();
21273 callback();
21274 };
21275 element.addEventListener(type, callSync, { once: true, capture: true });
21276 return cancelTimer;
21277 }
21278 function addGlobalEventListener(type, listener, options, scope = window) {
21279 const children = [];
21280 try {
21281 scope.document.addEventListener(type, listener, options);
21282 for (const frame of Array.from(scope.frames)) {
21283 children.push(addGlobalEventListener(type, listener, options, frame));
21284 }
21285 } catch (e2) {
21286 }
21287 const removeEventListener = () => {
21288 try {
21289 scope.document.removeEventListener(type, listener, options);
21290 } catch (e2) {
21291 }
21292 for (const remove of children) {
21293 remove();
21294 }
21295 };
21296 return removeEventListener;
21297 }
21298
21299 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
21300 var React73 = __toESM(require_react(), 1);
21301 var import_react21 = __toESM(require_react(), 1);
21302 var _React = { ...React73 };
21303 var useReactId = _React.useId;
21304 var useReactDeferredValue = _React.useDeferredValue;
21305 var useReactInsertionEffect = _React.useInsertionEffect;
21306 var useSafeLayoutEffect = canUseDOM ? import_react21.useLayoutEffect : import_react21.useEffect;
21307 function useInitialValue(value) {
21308 const [initialValue] = (0, import_react21.useState)(value);
21309 return initialValue;
21310 }
21311 function useLiveRef(value) {
21312 const ref = (0, import_react21.useRef)(value);
21313 useSafeLayoutEffect(() => {
21314 ref.current = value;
21315 });
21316 return ref;
21317 }
21318 function useEvent(callback) {
21319 const ref = (0, import_react21.useRef)(() => {
21320 throw new Error("Cannot call an event handler while rendering.");
21321 });
21322 if (useReactInsertionEffect) {
21323 useReactInsertionEffect(() => {
21324 ref.current = callback;
21325 });
21326 } else {
21327 ref.current = callback;
21328 }
21329 return (0, import_react21.useCallback)((...args) => {
21330 var _a;
21331 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
21332 }, []);
21333 }
21334 function useTransactionState(callback) {
21335 const [state, setState] = (0, import_react21.useState)(null);
21336 useSafeLayoutEffect(() => {
21337 if (state == null) return;
21338 if (!callback) return;
21339 let prevState = null;
21340 callback((prev) => {
21341 prevState = prev;
21342 return state;
21343 });
21344 return () => {
21345 callback(prevState);
21346 };
21347 }, [state, callback]);
21348 return [state, setState];
21349 }
21350 function useMergeRefs5(...refs) {
21351 return (0, import_react21.useMemo)(() => {
21352 if (!refs.some(Boolean)) return;
21353 return (value) => {
21354 for (const ref of refs) {
21355 setRef(ref, value);
21356 }
21357 };
21358 }, refs);
21359 }
21360 function useId4(defaultId) {
21361 if (useReactId) {
21362 const reactId = useReactId();
21363 if (defaultId) return defaultId;
21364 return reactId;
21365 }
21366 const [id, setId] = (0, import_react21.useState)(defaultId);
21367 useSafeLayoutEffect(() => {
21368 if (defaultId || id) return;
21369 const random = Math.random().toString(36).slice(2, 8);
21370 setId(`id-${random}`);
21371 }, [defaultId, id]);
21372 return defaultId || id;
21373 }
21374 function useTagName(refOrElement, type) {
21375 const stringOrUndefined = (type2) => {
21376 if (typeof type2 !== "string") return;
21377 return type2;
21378 };
21379 const [tagName, setTagName] = (0, import_react21.useState)(() => stringOrUndefined(type));
21380 useSafeLayoutEffect(() => {
21381 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
21382 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
21383 }, [refOrElement, type]);
21384 return tagName;
21385 }
21386 function useAttribute(refOrElement, attributeName, defaultValue3) {
21387 const initialValue = useInitialValue(defaultValue3);
21388 const [attribute, setAttribute] = (0, import_react21.useState)(initialValue);
21389 (0, import_react21.useEffect)(() => {
21390 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
21391 if (!element) return;
21392 const callback = () => {
21393 const value = element.getAttribute(attributeName);
21394 setAttribute(value == null ? initialValue : value);
21395 };
21396 const observer = new MutationObserver(callback);
21397 observer.observe(element, { attributeFilter: [attributeName] });
21398 callback();
21399 return () => observer.disconnect();
21400 }, [refOrElement, attributeName, initialValue]);
21401 return attribute;
21402 }
21403 function useUpdateEffect(effect, deps) {
21404 const mounted = (0, import_react21.useRef)(false);
21405 (0, import_react21.useEffect)(() => {
21406 if (mounted.current) {
21407 return effect();
21408 }
21409 mounted.current = true;
21410 }, deps);
21411 (0, import_react21.useEffect)(
21412 () => () => {
21413 mounted.current = false;
21414 },
21415 []
21416 );
21417 }
21418 function useUpdateLayoutEffect(effect, deps) {
21419 const mounted = (0, import_react21.useRef)(false);
21420 useSafeLayoutEffect(() => {
21421 if (mounted.current) {
21422 return effect();
21423 }
21424 mounted.current = true;
21425 }, deps);
21426 useSafeLayoutEffect(
21427 () => () => {
21428 mounted.current = false;
21429 },
21430 []
21431 );
21432 }
21433 function useForceUpdate() {
21434 return (0, import_react21.useReducer)(() => [], []);
21435 }
21436 function useBooleanEvent(booleanOrCallback) {
21437 return useEvent(
21438 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
21439 );
21440 }
21441 function useWrapElement(props, callback, deps = []) {
21442 const wrapElement = (0, import_react21.useCallback)(
21443 (element) => {
21444 if (props.wrapElement) {
21445 element = props.wrapElement(element);
21446 }
21447 return callback(element);
21448 },
21449 [...deps, props.wrapElement]
21450 );
21451 return { ...props, wrapElement };
21452 }
21453 function useMetadataProps(props, key2, value) {
21454 const parent = props.onLoadedMetadataCapture;
21455 const onLoadedMetadataCapture = (0, import_react21.useMemo)(() => {
21456 return Object.assign(() => {
21457 }, { ...parent, [key2]: value });
21458 }, [parent, key2, value]);
21459 return [parent == null ? void 0 : parent[key2], { onLoadedMetadataCapture }];
21460 }
21461 var hasInstalledGlobalEventListeners = false;
21462 function useIsMouseMoving() {
21463 (0, import_react21.useEffect)(() => {
21464 if (hasInstalledGlobalEventListeners) return;
21465 addGlobalEventListener("mousemove", setMouseMoving, true);
21466 addGlobalEventListener("mousedown", resetMouseMoving, true);
21467 addGlobalEventListener("mouseup", resetMouseMoving, true);
21468 addGlobalEventListener("keydown", resetMouseMoving, true);
21469 addGlobalEventListener("scroll", resetMouseMoving, true);
21470 hasInstalledGlobalEventListeners = true;
21471 }, []);
21472 const isMouseMoving = useEvent(() => mouseMoving);
21473 return isMouseMoving;
21474 }
21475 var mouseMoving = false;
21476 var previousScreenX = 0;
21477 var previousScreenY = 0;
21478 function hasMouseMovement(event) {
21479 const movementX = event.movementX || event.screenX - previousScreenX;
21480 const movementY = event.movementY || event.screenY - previousScreenY;
21481 previousScreenX = event.screenX;
21482 previousScreenY = event.screenY;
21483 return movementX || movementY || false;
21484 }
21485 function setMouseMoving(event) {
21486 if (!hasMouseMovement(event)) return;
21487 mouseMoving = true;
21488 }
21489 function resetMouseMoving() {
21490 mouseMoving = false;
21491 }
21492
21493 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
21494 var React74 = __toESM(require_react(), 1);
21495 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
21496 function forwardRef210(render4) {
21497 const Role = React74.forwardRef(
21498 // @ts-ignore Incompatible with React 19 types. Ignore for now.
21499 (props, ref) => render4({ ...props, ref })
21500 );
21501 Role.displayName = render4.displayName || render4.name;
21502 return Role;
21503 }
21504 function memo22(Component2, propsAreEqual) {
21505 return React74.memo(Component2, propsAreEqual);
21506 }
21507 function createElement3(Type, props) {
21508 const { wrapElement, render: render4, ...rest } = props;
21509 const mergedRef = useMergeRefs5(props.ref, getRefProperty(render4));
21510 let element;
21511 if (React74.isValidElement(render4)) {
21512 const renderProps = {
21513 // @ts-ignore Incompatible with React 19 types. Ignore for now.
21514 ...render4.props,
21515 ref: mergedRef
21516 };
21517 element = React74.cloneElement(render4, mergeProps3(rest, renderProps));
21518 } else if (render4) {
21519 element = render4(rest);
21520 } else {
21521 element = /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Type, { ...rest });
21522 }
21523 if (wrapElement) {
21524 return wrapElement(element);
21525 }
21526 return element;
21527 }
21528 function createHook(useProps) {
21529 const useRole2 = (props = {}) => {
21530 return useProps(props);
21531 };
21532 useRole2.displayName = useProps.name;
21533 return useRole2;
21534 }
21535 function createStoreContext(providers = [], scopedProviders = []) {
21536 const context = React74.createContext(void 0);
21537 const scopedContext = React74.createContext(void 0);
21538 const useContext210 = () => React74.useContext(context);
21539 const useScopedContext = (onlyScoped = false) => {
21540 const scoped = React74.useContext(scopedContext);
21541 const store = useContext210();
21542 if (onlyScoped) return scoped;
21543 return scoped || store;
21544 };
21545 const useProviderContext = () => {
21546 const scoped = React74.useContext(scopedContext);
21547 const store = useContext210();
21548 if (scoped && scoped === store) return;
21549 return store;
21550 };
21551 const ContextProvider = (props) => {
21552 return providers.reduceRight(
21553 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Provider2, { ...props, children }),
21554 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(context.Provider, { ...props })
21555 );
21556 };
21557 const ScopedContextProvider = (props) => {
21558 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
21559 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Provider2, { ...props, children }),
21560 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(scopedContext.Provider, { ...props })
21561 ) });
21562 };
21563 return {
21564 context,
21565 scopedContext,
21566 useContext: useContext210,
21567 useScopedContext,
21568 useProviderContext,
21569 ContextProvider,
21570 ScopedContextProvider
21571 };
21572 }
21573
21574 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
21575 var ctx = createStoreContext();
21576 var useCollectionContext = ctx.useContext;
21577 var useCollectionScopedContext = ctx.useScopedContext;
21578 var useCollectionProviderContext = ctx.useProviderContext;
21579 var CollectionContextProvider = ctx.ContextProvider;
21580 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
21581
21582 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
21583 var import_react22 = __toESM(require_react(), 1);
21584 var ctx2 = createStoreContext(
21585 [CollectionContextProvider],
21586 [CollectionScopedContextProvider]
21587 );
21588 var useCompositeContext = ctx2.useContext;
21589 var useCompositeScopedContext = ctx2.useScopedContext;
21590 var useCompositeProviderContext = ctx2.useProviderContext;
21591 var CompositeContextProvider = ctx2.ContextProvider;
21592 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
21593 var CompositeItemContext = (0, import_react22.createContext)(
21594 void 0
21595 );
21596 var CompositeRowContext = (0, import_react22.createContext)(
21597 void 0
21598 );
21599
21600 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
21601 function findFirstEnabledItem(items, excludeId) {
21602 return items.find((item) => {
21603 if (excludeId) {
21604 return !item.disabled && item.id !== excludeId;
21605 }
21606 return !item.disabled;
21607 });
21608 }
21609 function getEnabledItem(store, id) {
21610 if (!id) return null;
21611 return store.item(id) || null;
21612 }
21613 function groupItemsByRows(items) {
21614 const rows = [];
21615 for (const item of items) {
21616 const row = rows.find((currentRow) => {
21617 var _a;
21618 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
21619 });
21620 if (row) {
21621 row.push(item);
21622 } else {
21623 rows.push([item]);
21624 }
21625 }
21626 return rows;
21627 }
21628 function selectTextField(element, collapseToEnd = false) {
21629 if (isTextField(element)) {
21630 element.setSelectionRange(
21631 collapseToEnd ? element.value.length : 0,
21632 element.value.length
21633 );
21634 } else if (element.isContentEditable) {
21635 const selection = getDocument(element).getSelection();
21636 selection == null ? void 0 : selection.selectAllChildren(element);
21637 if (collapseToEnd) {
21638 selection == null ? void 0 : selection.collapseToEnd();
21639 }
21640 }
21641 }
21642 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
21643 function focusSilently(element) {
21644 element[FOCUS_SILENTLY] = true;
21645 element.focus({ preventScroll: true });
21646 }
21647 function silentlyFocused(element) {
21648 const isSilentlyFocused = element[FOCUS_SILENTLY];
21649 delete element[FOCUS_SILENTLY];
21650 return isSilentlyFocused;
21651 }
21652 function isItem(store, element, exclude) {
21653 if (!element) return false;
21654 if (element === exclude) return false;
21655 const item = store.item(element.id);
21656 if (!item) return false;
21657 if (exclude && item.element === exclude) return false;
21658 return true;
21659 }
21660
21661 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
21662 var import_react23 = __toESM(require_react(), 1);
21663 var TagName = "div";
21664 var useCollectionItem = createHook(
21665 function useCollectionItem2({
21666 store,
21667 shouldRegisterItem = true,
21668 getItem = identity,
21669 // @ts-expect-error This prop may come from a collection renderer.
21670 element,
21671 ...props
21672 }) {
21673 const context = useCollectionContext();
21674 store = store || context;
21675 const id = useId4(props.id);
21676 const ref = (0, import_react23.useRef)(element);
21677 (0, import_react23.useEffect)(() => {
21678 const element2 = ref.current;
21679 if (!id) return;
21680 if (!element2) return;
21681 if (!shouldRegisterItem) return;
21682 const item = getItem({ id, element: element2 });
21683 return store == null ? void 0 : store.renderItem(item);
21684 }, [id, shouldRegisterItem, getItem, store]);
21685 props = {
21686 ...props,
21687 ref: useMergeRefs5(ref, props.ref)
21688 };
21689 return removeUndefinedValues(props);
21690 }
21691 );
21692 var CollectionItem = forwardRef210(function CollectionItem2(props) {
21693 const htmlProps = useCollectionItem(props);
21694 return createElement3(TagName, htmlProps);
21695 });
21696
21697 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
21698 var import_react24 = __toESM(require_react(), 1);
21699 var FocusableContext = (0, import_react24.createContext)(true);
21700
21701 // node_modules/@ariakit/core/esm/utils/focus.js
21702 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'])";
21703 function isFocusable(element) {
21704 if (!element.matches(selector)) return false;
21705 if (!isVisible(element)) return false;
21706 if (element.closest("[inert]")) return false;
21707 return true;
21708 }
21709 function getClosestFocusable(element) {
21710 while (element && !isFocusable(element)) {
21711 element = element.closest(selector);
21712 }
21713 return element || null;
21714 }
21715 function hasFocus(element) {
21716 const activeElement2 = getActiveElement(element);
21717 if (!activeElement2) return false;
21718 if (activeElement2 === element) return true;
21719 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
21720 if (!activeDescendant) return false;
21721 return activeDescendant === element.id;
21722 }
21723 function hasFocusWithin(element) {
21724 const activeElement2 = getActiveElement(element);
21725 if (!activeElement2) return false;
21726 if (contains2(element, activeElement2)) return true;
21727 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
21728 if (!activeDescendant) return false;
21729 if (!("id" in element)) return false;
21730 if (activeDescendant === element.id) return true;
21731 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
21732 }
21733 function focusIfNeeded(element) {
21734 if (!hasFocusWithin(element) && isFocusable(element)) {
21735 element.focus();
21736 }
21737 }
21738 function focusIntoView(element, options) {
21739 if (!("scrollIntoView" in element)) {
21740 element.focus();
21741 } else {
21742 element.focus({ preventScroll: true });
21743 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
21744 }
21745 }
21746
21747 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
21748 var import_react25 = __toESM(require_react(), 1);
21749 var TagName2 = "div";
21750 var isSafariBrowser = isSafari2();
21751 var alwaysFocusVisibleInputTypes = [
21752 "text",
21753 "search",
21754 "url",
21755 "tel",
21756 "email",
21757 "password",
21758 "number",
21759 "date",
21760 "month",
21761 "week",
21762 "time",
21763 "datetime",
21764 "datetime-local"
21765 ];
21766 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
21767 function markSafariFocusAncestor(element, value) {
21768 if (!element) return;
21769 element[safariFocusAncestorSymbol] = value;
21770 }
21771 function isAlwaysFocusVisible(element) {
21772 const { tagName, readOnly, type } = element;
21773 if (tagName === "TEXTAREA" && !readOnly) return true;
21774 if (tagName === "SELECT" && !readOnly) return true;
21775 if (tagName === "INPUT" && !readOnly) {
21776 return alwaysFocusVisibleInputTypes.includes(type);
21777 }
21778 if (element.isContentEditable) return true;
21779 const role = element.getAttribute("role");
21780 if (role === "combobox" && element.dataset.name) {
21781 return true;
21782 }
21783 return false;
21784 }
21785 function getLabels(element) {
21786 if ("labels" in element) {
21787 return element.labels;
21788 }
21789 return null;
21790 }
21791 function isNativeCheckboxOrRadio(element) {
21792 const tagName = element.tagName.toLowerCase();
21793 if (tagName === "input" && element.type) {
21794 return element.type === "radio" || element.type === "checkbox";
21795 }
21796 return false;
21797 }
21798 function isNativeTabbable(tagName) {
21799 if (!tagName) return true;
21800 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
21801 }
21802 function supportsDisabledAttribute(tagName) {
21803 if (!tagName) return true;
21804 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
21805 }
21806 function getTabIndex4(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
21807 if (!focusable2) {
21808 return tabIndexProp;
21809 }
21810 if (trulyDisabled) {
21811 if (nativeTabbable && !supportsDisabled) {
21812 return -1;
21813 }
21814 return;
21815 }
21816 if (nativeTabbable) {
21817 return tabIndexProp;
21818 }
21819 return tabIndexProp || 0;
21820 }
21821 function useDisableEvent(onEvent, disabled2) {
21822 return useEvent((event) => {
21823 onEvent == null ? void 0 : onEvent(event);
21824 if (event.defaultPrevented) return;
21825 if (disabled2) {
21826 event.stopPropagation();
21827 event.preventDefault();
21828 }
21829 });
21830 }
21831 var hasInstalledGlobalEventListeners2 = false;
21832 var isKeyboardModality = true;
21833 function onGlobalMouseDown(event) {
21834 const target = event.target;
21835 if (target && "hasAttribute" in target) {
21836 if (!target.hasAttribute("data-focus-visible")) {
21837 isKeyboardModality = false;
21838 }
21839 }
21840 }
21841 function onGlobalKeyDown(event) {
21842 if (event.metaKey) return;
21843 if (event.ctrlKey) return;
21844 if (event.altKey) return;
21845 isKeyboardModality = true;
21846 }
21847 var useFocusable = createHook(
21848 function useFocusable2({
21849 focusable: focusable2 = true,
21850 accessibleWhenDisabled,
21851 autoFocus,
21852 onFocusVisible,
21853 ...props
21854 }) {
21855 const ref = (0, import_react25.useRef)(null);
21856 (0, import_react25.useEffect)(() => {
21857 if (!focusable2) return;
21858 if (hasInstalledGlobalEventListeners2) return;
21859 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
21860 addGlobalEventListener("keydown", onGlobalKeyDown, true);
21861 hasInstalledGlobalEventListeners2 = true;
21862 }, [focusable2]);
21863 if (isSafariBrowser) {
21864 (0, import_react25.useEffect)(() => {
21865 if (!focusable2) return;
21866 const element = ref.current;
21867 if (!element) return;
21868 if (!isNativeCheckboxOrRadio(element)) return;
21869 const labels = getLabels(element);
21870 if (!labels) return;
21871 const onMouseUp = () => queueMicrotask(() => element.focus());
21872 for (const label of labels) {
21873 label.addEventListener("mouseup", onMouseUp);
21874 }
21875 return () => {
21876 for (const label of labels) {
21877 label.removeEventListener("mouseup", onMouseUp);
21878 }
21879 };
21880 }, [focusable2]);
21881 }
21882 const disabled2 = focusable2 && disabledFromProps(props);
21883 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
21884 const [focusVisible, setFocusVisible] = (0, import_react25.useState)(false);
21885 (0, import_react25.useEffect)(() => {
21886 if (!focusable2) return;
21887 if (trulyDisabled && focusVisible) {
21888 setFocusVisible(false);
21889 }
21890 }, [focusable2, trulyDisabled, focusVisible]);
21891 (0, import_react25.useEffect)(() => {
21892 if (!focusable2) return;
21893 if (!focusVisible) return;
21894 const element = ref.current;
21895 if (!element) return;
21896 if (typeof IntersectionObserver === "undefined") return;
21897 const observer = new IntersectionObserver(() => {
21898 if (!isFocusable(element)) {
21899 setFocusVisible(false);
21900 }
21901 });
21902 observer.observe(element);
21903 return () => observer.disconnect();
21904 }, [focusable2, focusVisible]);
21905 const onKeyPressCapture = useDisableEvent(
21906 props.onKeyPressCapture,
21907 disabled2
21908 );
21909 const onMouseDownCapture = useDisableEvent(
21910 props.onMouseDownCapture,
21911 disabled2
21912 );
21913 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
21914 const onMouseDownProp = props.onMouseDown;
21915 const onMouseDown = useEvent((event) => {
21916 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
21917 if (event.defaultPrevented) return;
21918 if (!focusable2) return;
21919 const element = event.currentTarget;
21920 if (!isSafariBrowser) return;
21921 if (isPortalEvent(event)) return;
21922 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
21923 let receivedFocus = false;
21924 const onFocus = () => {
21925 receivedFocus = true;
21926 };
21927 const options = { capture: true, once: true };
21928 element.addEventListener("focusin", onFocus, options);
21929 const focusableContainer = getClosestFocusable(element.parentElement);
21930 markSafariFocusAncestor(focusableContainer, true);
21931 queueBeforeEvent(element, "mouseup", () => {
21932 element.removeEventListener("focusin", onFocus, true);
21933 markSafariFocusAncestor(focusableContainer, false);
21934 if (receivedFocus) return;
21935 focusIfNeeded(element);
21936 });
21937 });
21938 const handleFocusVisible = (event, currentTarget) => {
21939 if (currentTarget) {
21940 event.currentTarget = currentTarget;
21941 }
21942 if (!focusable2) return;
21943 const element = event.currentTarget;
21944 if (!element) return;
21945 if (!hasFocus(element)) return;
21946 onFocusVisible == null ? void 0 : onFocusVisible(event);
21947 if (event.defaultPrevented) return;
21948 element.dataset.focusVisible = "true";
21949 setFocusVisible(true);
21950 };
21951 const onKeyDownCaptureProp = props.onKeyDownCapture;
21952 const onKeyDownCapture = useEvent((event) => {
21953 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
21954 if (event.defaultPrevented) return;
21955 if (!focusable2) return;
21956 if (focusVisible) return;
21957 if (event.metaKey) return;
21958 if (event.altKey) return;
21959 if (event.ctrlKey) return;
21960 if (!isSelfTarget(event)) return;
21961 const element = event.currentTarget;
21962 const applyFocusVisible = () => handleFocusVisible(event, element);
21963 queueBeforeEvent(element, "focusout", applyFocusVisible);
21964 });
21965 const onFocusCaptureProp = props.onFocusCapture;
21966 const onFocusCapture = useEvent((event) => {
21967 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
21968 if (event.defaultPrevented) return;
21969 if (!focusable2) return;
21970 if (!isSelfTarget(event)) {
21971 setFocusVisible(false);
21972 return;
21973 }
21974 const element = event.currentTarget;
21975 const applyFocusVisible = () => handleFocusVisible(event, element);
21976 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
21977 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
21978 } else {
21979 setFocusVisible(false);
21980 }
21981 });
21982 const onBlurProp = props.onBlur;
21983 const onBlur = useEvent((event) => {
21984 onBlurProp == null ? void 0 : onBlurProp(event);
21985 if (!focusable2) return;
21986 if (!isFocusEventOutside(event)) return;
21987 event.currentTarget.removeAttribute("data-focus-visible");
21988 setFocusVisible(false);
21989 });
21990 const autoFocusOnShow = (0, import_react25.useContext)(FocusableContext);
21991 const autoFocusRef = useEvent((element) => {
21992 if (!focusable2) return;
21993 if (!autoFocus) return;
21994 if (!element) return;
21995 if (!autoFocusOnShow) return;
21996 queueMicrotask(() => {
21997 if (hasFocus(element)) return;
21998 if (!isFocusable(element)) return;
21999 element.focus();
22000 });
22001 });
22002 const tagName = useTagName(ref);
22003 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
22004 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
22005 const styleProp = props.style;
22006 const style = (0, import_react25.useMemo)(() => {
22007 if (trulyDisabled) {
22008 return { pointerEvents: "none", ...styleProp };
22009 }
22010 return styleProp;
22011 }, [trulyDisabled, styleProp]);
22012 props = {
22013 "data-focus-visible": focusable2 && focusVisible || void 0,
22014 "data-autofocus": autoFocus || void 0,
22015 "aria-disabled": disabled2 || void 0,
22016 ...props,
22017 ref: useMergeRefs5(ref, autoFocusRef, props.ref),
22018 style,
22019 tabIndex: getTabIndex4(
22020 focusable2,
22021 trulyDisabled,
22022 nativeTabbable,
22023 supportsDisabled,
22024 props.tabIndex
22025 ),
22026 disabled: supportsDisabled && trulyDisabled ? true : void 0,
22027 // TODO: Test Focusable contentEditable.
22028 contentEditable: disabled2 ? void 0 : props.contentEditable,
22029 onKeyPressCapture,
22030 onClickCapture,
22031 onMouseDownCapture,
22032 onMouseDown,
22033 onKeyDownCapture,
22034 onFocusCapture,
22035 onBlur
22036 };
22037 return removeUndefinedValues(props);
22038 }
22039 );
22040 var Focusable = forwardRef210(function Focusable2(props) {
22041 const htmlProps = useFocusable(props);
22042 return createElement3(TagName2, htmlProps);
22043 });
22044
22045 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
22046 var import_react26 = __toESM(require_react(), 1);
22047 var TagName3 = "button";
22048 function isNativeClick(event) {
22049 if (!event.isTrusted) return false;
22050 const element = event.currentTarget;
22051 if (event.key === "Enter") {
22052 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
22053 }
22054 if (event.key === " ") {
22055 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
22056 }
22057 return false;
22058 }
22059 var symbol = /* @__PURE__ */ Symbol("command");
22060 var useCommand = createHook(
22061 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
22062 const ref = (0, import_react26.useRef)(null);
22063 const [isNativeButton, setIsNativeButton] = (0, import_react26.useState)(false);
22064 (0, import_react26.useEffect)(() => {
22065 if (!ref.current) return;
22066 setIsNativeButton(isButton(ref.current));
22067 }, []);
22068 const [active, setActive] = (0, import_react26.useState)(false);
22069 const activeRef = (0, import_react26.useRef)(false);
22070 const disabled2 = disabledFromProps(props);
22071 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
22072 const onKeyDownProp = props.onKeyDown;
22073 const onKeyDown = useEvent((event) => {
22074 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
22075 const element = event.currentTarget;
22076 if (event.defaultPrevented) return;
22077 if (isDuplicate) return;
22078 if (disabled2) return;
22079 if (!isSelfTarget(event)) return;
22080 if (isTextField(element)) return;
22081 if (element.isContentEditable) return;
22082 const isEnter = clickOnEnter && event.key === "Enter";
22083 const isSpace = clickOnSpace && event.key === " ";
22084 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
22085 const shouldPreventSpace = event.key === " " && !clickOnSpace;
22086 if (shouldPreventEnter || shouldPreventSpace) {
22087 event.preventDefault();
22088 return;
22089 }
22090 if (isEnter || isSpace) {
22091 const nativeClick = isNativeClick(event);
22092 if (isEnter) {
22093 if (!nativeClick) {
22094 event.preventDefault();
22095 const { view, ...eventInit } = event;
22096 const click = () => fireClickEvent(element, eventInit);
22097 if (isFirefox2()) {
22098 queueBeforeEvent(element, "keyup", click);
22099 } else {
22100 queueMicrotask(click);
22101 }
22102 }
22103 } else if (isSpace) {
22104 activeRef.current = true;
22105 if (!nativeClick) {
22106 event.preventDefault();
22107 setActive(true);
22108 }
22109 }
22110 }
22111 });
22112 const onKeyUpProp = props.onKeyUp;
22113 const onKeyUp = useEvent((event) => {
22114 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
22115 if (event.defaultPrevented) return;
22116 if (isDuplicate) return;
22117 if (disabled2) return;
22118 if (event.metaKey) return;
22119 const isSpace = clickOnSpace && event.key === " ";
22120 if (activeRef.current && isSpace) {
22121 activeRef.current = false;
22122 if (!isNativeClick(event)) {
22123 event.preventDefault();
22124 setActive(false);
22125 const element = event.currentTarget;
22126 const { view, ...eventInit } = event;
22127 queueMicrotask(() => fireClickEvent(element, eventInit));
22128 }
22129 }
22130 });
22131 props = {
22132 "data-active": active || void 0,
22133 type: isNativeButton ? "button" : void 0,
22134 ...metadataProps,
22135 ...props,
22136 ref: useMergeRefs5(ref, props.ref),
22137 onKeyDown,
22138 onKeyUp
22139 };
22140 props = useFocusable(props);
22141 return props;
22142 }
22143 );
22144 var Command = forwardRef210(function Command2(props) {
22145 const htmlProps = useCommand(props);
22146 return createElement3(TagName3, htmlProps);
22147 });
22148
22149 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
22150 function getInternal(store, key2) {
22151 const internals = store.__unstableInternals;
22152 invariant(internals, "Invalid store");
22153 return internals[key2];
22154 }
22155 function createStore(initialState, ...stores) {
22156 let state = initialState;
22157 let prevStateBatch = state;
22158 let lastUpdate = /* @__PURE__ */ Symbol();
22159 let destroy = noop5;
22160 const instances = /* @__PURE__ */ new Set();
22161 const updatedKeys = /* @__PURE__ */ new Set();
22162 const setups = /* @__PURE__ */ new Set();
22163 const listeners = /* @__PURE__ */ new Set();
22164 const batchListeners = /* @__PURE__ */ new Set();
22165 const disposables = /* @__PURE__ */ new WeakMap();
22166 const listenerKeys = /* @__PURE__ */ new WeakMap();
22167 const storeSetup = (callback) => {
22168 setups.add(callback);
22169 return () => setups.delete(callback);
22170 };
22171 const storeInit = () => {
22172 const initialized = instances.size;
22173 const instance = /* @__PURE__ */ Symbol();
22174 instances.add(instance);
22175 const maybeDestroy = () => {
22176 instances.delete(instance);
22177 if (instances.size) return;
22178 destroy();
22179 };
22180 if (initialized) return maybeDestroy;
22181 const desyncs = getKeys(state).map(
22182 (key2) => chain(
22183 ...stores.map((store) => {
22184 var _a;
22185 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
22186 if (!storeState) return;
22187 if (!hasOwnProperty(storeState, key2)) return;
22188 return sync(store, [key2], (state2) => {
22189 setState(
22190 key2,
22191 state2[key2],
22192 // @ts-expect-error - Not public API. This is just to prevent
22193 // infinite loops.
22194 true
22195 );
22196 });
22197 })
22198 )
22199 );
22200 const teardowns = [];
22201 for (const setup2 of setups) {
22202 teardowns.push(setup2());
22203 }
22204 const cleanups = stores.map(init);
22205 destroy = chain(...desyncs, ...teardowns, ...cleanups);
22206 return maybeDestroy;
22207 };
22208 const sub = (keys, listener, set3 = listeners) => {
22209 set3.add(listener);
22210 listenerKeys.set(listener, keys);
22211 return () => {
22212 var _a;
22213 (_a = disposables.get(listener)) == null ? void 0 : _a();
22214 disposables.delete(listener);
22215 listenerKeys.delete(listener);
22216 set3.delete(listener);
22217 };
22218 };
22219 const storeSubscribe = (keys, listener) => sub(keys, listener);
22220 const storeSync = (keys, listener) => {
22221 disposables.set(listener, listener(state, state));
22222 return sub(keys, listener);
22223 };
22224 const storeBatch = (keys, listener) => {
22225 disposables.set(listener, listener(state, prevStateBatch));
22226 return sub(keys, listener, batchListeners);
22227 };
22228 const storePick = (keys) => createStore(pick(state, keys), finalStore);
22229 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
22230 const getState = () => state;
22231 const setState = (key2, value, fromStores = false) => {
22232 var _a;
22233 if (!hasOwnProperty(state, key2)) return;
22234 const nextValue = applyState(value, state[key2]);
22235 if (nextValue === state[key2]) return;
22236 if (!fromStores) {
22237 for (const store of stores) {
22238 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key2, nextValue);
22239 }
22240 }
22241 const prevState = state;
22242 state = { ...state, [key2]: nextValue };
22243 const thisUpdate = /* @__PURE__ */ Symbol();
22244 lastUpdate = thisUpdate;
22245 updatedKeys.add(key2);
22246 const run = (listener, prev, uKeys) => {
22247 var _a2;
22248 const keys = listenerKeys.get(listener);
22249 const updated = (k) => uKeys ? uKeys.has(k) : k === key2;
22250 if (!keys || keys.some(updated)) {
22251 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
22252 disposables.set(listener, listener(state, prev));
22253 }
22254 };
22255 for (const listener of listeners) {
22256 run(listener, prevState);
22257 }
22258 queueMicrotask(() => {
22259 if (lastUpdate !== thisUpdate) return;
22260 const snapshot = state;
22261 for (const listener of batchListeners) {
22262 run(listener, prevStateBatch, updatedKeys);
22263 }
22264 prevStateBatch = snapshot;
22265 updatedKeys.clear();
22266 });
22267 };
22268 const finalStore = {
22269 getState,
22270 setState,
22271 __unstableInternals: {
22272 setup: storeSetup,
22273 init: storeInit,
22274 subscribe: storeSubscribe,
22275 sync: storeSync,
22276 batch: storeBatch,
22277 pick: storePick,
22278 omit: storeOmit
22279 }
22280 };
22281 return finalStore;
22282 }
22283 function setup(store, ...args) {
22284 if (!store) return;
22285 return getInternal(store, "setup")(...args);
22286 }
22287 function init(store, ...args) {
22288 if (!store) return;
22289 return getInternal(store, "init")(...args);
22290 }
22291 function subscribe(store, ...args) {
22292 if (!store) return;
22293 return getInternal(store, "subscribe")(...args);
22294 }
22295 function sync(store, ...args) {
22296 if (!store) return;
22297 return getInternal(store, "sync")(...args);
22298 }
22299 function batch(store, ...args) {
22300 if (!store) return;
22301 return getInternal(store, "batch")(...args);
22302 }
22303 function omit2(store, ...args) {
22304 if (!store) return;
22305 return getInternal(store, "omit")(...args);
22306 }
22307 function pick2(store, ...args) {
22308 if (!store) return;
22309 return getInternal(store, "pick")(...args);
22310 }
22311 function mergeStore(...stores) {
22312 var _a;
22313 const initialState = {};
22314 for (const store2 of stores) {
22315 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
22316 if (nextState) {
22317 Object.assign(initialState, nextState);
22318 }
22319 }
22320 const store = createStore(initialState, ...stores);
22321 return Object.assign({}, ...stores, store);
22322 }
22323 function throwOnConflictingProps(props, store) {
22324 if (false) return;
22325 if (!store) return;
22326 const defaultKeys = Object.entries(props).filter(([key2, value]) => key2.startsWith("default") && value !== void 0).map(([key2]) => {
22327 var _a;
22328 const stateKey = key2.replace("default", "");
22329 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
22330 });
22331 if (!defaultKeys.length) return;
22332 const storeState = store.getState();
22333 const conflictingProps = defaultKeys.filter(
22334 (key2) => hasOwnProperty(storeState, key2)
22335 );
22336 if (!conflictingProps.length) return;
22337 throw new Error(
22338 `Passing a store prop in conjunction with a default state is not supported.
22339
22340 const store = useSelectStore();
22341 <SelectProvider store={store} defaultValue="Apple" />
22342 ^ ^
22343
22344 Instead, pass the default state to the topmost store:
22345
22346 const store = useSelectStore({ defaultValue: "Apple" });
22347 <SelectProvider store={store} />
22348
22349 See https://github.com/ariakit/ariakit/pull/2745 for more details.
22350
22351 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
22352 `
22353 );
22354 }
22355
22356 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
22357 var React75 = __toESM(require_react(), 1);
22358 var import_shim2 = __toESM(require_shim(), 1);
22359 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
22360 var noopSubscribe = () => () => {
22361 };
22362 function useStoreState(store, keyOrSelector = identity) {
22363 const storeSubscribe = React75.useCallback(
22364 (callback) => {
22365 if (!store) return noopSubscribe();
22366 return subscribe(store, null, callback);
22367 },
22368 [store]
22369 );
22370 const getSnapshot = () => {
22371 const key2 = typeof keyOrSelector === "string" ? keyOrSelector : null;
22372 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
22373 const state = store == null ? void 0 : store.getState();
22374 if (selector2) return selector2(state);
22375 if (!state) return;
22376 if (!key2) return;
22377 if (!hasOwnProperty(state, key2)) return;
22378 return state[key2];
22379 };
22380 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
22381 }
22382 function useStoreStateObject(store, object) {
22383 const objRef = React75.useRef(
22384 {}
22385 );
22386 const storeSubscribe = React75.useCallback(
22387 (callback) => {
22388 if (!store) return noopSubscribe();
22389 return subscribe(store, null, callback);
22390 },
22391 [store]
22392 );
22393 const getSnapshot = () => {
22394 const state = store == null ? void 0 : store.getState();
22395 let updated = false;
22396 const obj = objRef.current;
22397 for (const prop in object) {
22398 const keyOrSelector = object[prop];
22399 if (typeof keyOrSelector === "function") {
22400 const value = keyOrSelector(state);
22401 if (value !== obj[prop]) {
22402 obj[prop] = value;
22403 updated = true;
22404 }
22405 }
22406 if (typeof keyOrSelector === "string") {
22407 if (!state) continue;
22408 if (!hasOwnProperty(state, keyOrSelector)) continue;
22409 const value = state[keyOrSelector];
22410 if (value !== obj[prop]) {
22411 obj[prop] = value;
22412 updated = true;
22413 }
22414 }
22415 }
22416 if (updated) {
22417 objRef.current = { ...obj };
22418 }
22419 return objRef.current;
22420 };
22421 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
22422 }
22423 function useStoreProps(store, props, key2, setKey) {
22424 const value = hasOwnProperty(props, key2) ? props[key2] : void 0;
22425 const setValue = setKey ? props[setKey] : void 0;
22426 const propsRef = useLiveRef({ value, setValue });
22427 useSafeLayoutEffect(() => {
22428 return sync(store, [key2], (state, prev) => {
22429 const { value: value2, setValue: setValue2 } = propsRef.current;
22430 if (!setValue2) return;
22431 if (state[key2] === prev[key2]) return;
22432 if (state[key2] === value2) return;
22433 setValue2(state[key2]);
22434 });
22435 }, [store, key2]);
22436 useSafeLayoutEffect(() => {
22437 if (value === void 0) return;
22438 store.setState(key2, value);
22439 return batch(store, [key2], () => {
22440 if (value === void 0) return;
22441 store.setState(key2, value);
22442 });
22443 });
22444 }
22445 function useStore2(createStore2, props) {
22446 const [store, setStore] = React75.useState(() => createStore2(props));
22447 useSafeLayoutEffect(() => init(store), [store]);
22448 const useState210 = React75.useCallback(
22449 (keyOrSelector) => useStoreState(store, keyOrSelector),
22450 [store]
22451 );
22452 const memoizedStore = React75.useMemo(
22453 () => ({ ...store, useState: useState210 }),
22454 [store, useState210]
22455 );
22456 const updateStore = useEvent(() => {
22457 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
22458 });
22459 return [memoizedStore, updateStore];
22460 }
22461
22462 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
22463 var import_react27 = __toESM(require_react(), 1);
22464 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
22465 var TagName4 = "button";
22466 function isEditableElement(element) {
22467 if (isTextbox(element)) return true;
22468 return element.tagName === "INPUT" && !isButton(element);
22469 }
22470 function getNextPageOffset(scrollingElement, pageUp = false) {
22471 const height = scrollingElement.clientHeight;
22472 const { top } = scrollingElement.getBoundingClientRect();
22473 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
22474 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
22475 if (scrollingElement.tagName === "HTML") {
22476 return pageOffset + scrollingElement.scrollTop;
22477 }
22478 return pageOffset;
22479 }
22480 function getItemOffset(itemElement, pageUp = false) {
22481 const { top } = itemElement.getBoundingClientRect();
22482 if (pageUp) {
22483 return top + itemElement.clientHeight;
22484 }
22485 return top;
22486 }
22487 function findNextPageItemId(element, store, next, pageUp = false) {
22488 var _a;
22489 if (!store) return;
22490 if (!next) return;
22491 const { renderedItems } = store.getState();
22492 const scrollingElement = getScrollingElement(element);
22493 if (!scrollingElement) return;
22494 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
22495 let id;
22496 let prevDifference;
22497 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
22498 const previousId = id;
22499 id = next(i2);
22500 if (!id) break;
22501 if (id === previousId) continue;
22502 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
22503 if (!itemElement) continue;
22504 const itemOffset = getItemOffset(itemElement, pageUp);
22505 const difference = itemOffset - nextPageOffset;
22506 const absDifference = Math.abs(difference);
22507 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
22508 if (prevDifference !== void 0 && prevDifference < absDifference) {
22509 id = previousId;
22510 }
22511 break;
22512 }
22513 prevDifference = absDifference;
22514 }
22515 return id;
22516 }
22517 function targetIsAnotherItem(event, store) {
22518 if (isSelfTarget(event)) return false;
22519 return isItem(store, event.target);
22520 }
22521 var useCompositeItem = createHook(
22522 function useCompositeItem2({
22523 store,
22524 rowId: rowIdProp,
22525 preventScrollOnKeyDown = false,
22526 moveOnKeyPress = true,
22527 tabbable: tabbable4 = false,
22528 getItem: getItemProp,
22529 "aria-setsize": ariaSetSizeProp,
22530 "aria-posinset": ariaPosInSetProp,
22531 ...props
22532 }) {
22533 const context = useCompositeContext();
22534 store = store || context;
22535 const id = useId4(props.id);
22536 const ref = (0, import_react27.useRef)(null);
22537 const row = (0, import_react27.useContext)(CompositeRowContext);
22538 const disabled2 = disabledFromProps(props);
22539 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
22540 const {
22541 rowId,
22542 baseElement,
22543 isActiveItem,
22544 ariaSetSize,
22545 ariaPosInSet,
22546 isTabbable: isTabbable2
22547 } = useStoreStateObject(store, {
22548 rowId(state) {
22549 if (rowIdProp) return rowIdProp;
22550 if (!state) return;
22551 if (!(row == null ? void 0 : row.baseElement)) return;
22552 if (row.baseElement !== state.baseElement) return;
22553 return row.id;
22554 },
22555 baseElement(state) {
22556 return (state == null ? void 0 : state.baseElement) || void 0;
22557 },
22558 isActiveItem(state) {
22559 return !!state && state.activeId === id;
22560 },
22561 ariaSetSize(state) {
22562 if (ariaSetSizeProp != null) return ariaSetSizeProp;
22563 if (!state) return;
22564 if (!(row == null ? void 0 : row.ariaSetSize)) return;
22565 if (row.baseElement !== state.baseElement) return;
22566 return row.ariaSetSize;
22567 },
22568 ariaPosInSet(state) {
22569 if (ariaPosInSetProp != null) return ariaPosInSetProp;
22570 if (!state) return;
22571 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
22572 if (row.baseElement !== state.baseElement) return;
22573 const itemsInRow = state.renderedItems.filter(
22574 (item) => item.rowId === rowId
22575 );
22576 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
22577 },
22578 isTabbable(state) {
22579 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
22580 if (state.virtualFocus) return false;
22581 if (tabbable4) return true;
22582 if (state.activeId === null) return false;
22583 const item = store == null ? void 0 : store.item(state.activeId);
22584 if (item == null ? void 0 : item.disabled) return true;
22585 if (!(item == null ? void 0 : item.element)) return true;
22586 return state.activeId === id;
22587 }
22588 });
22589 const getItem = (0, import_react27.useCallback)(
22590 (item) => {
22591 var _a;
22592 const nextItem = {
22593 ...item,
22594 id: id || item.id,
22595 rowId,
22596 disabled: !!trulyDisabled,
22597 children: (_a = item.element) == null ? void 0 : _a.textContent
22598 };
22599 if (getItemProp) {
22600 return getItemProp(nextItem);
22601 }
22602 return nextItem;
22603 },
22604 [id, rowId, trulyDisabled, getItemProp]
22605 );
22606 const onFocusProp = props.onFocus;
22607 const hasFocusedComposite = (0, import_react27.useRef)(false);
22608 const onFocus = useEvent((event) => {
22609 onFocusProp == null ? void 0 : onFocusProp(event);
22610 if (event.defaultPrevented) return;
22611 if (isPortalEvent(event)) return;
22612 if (!id) return;
22613 if (!store) return;
22614 if (targetIsAnotherItem(event, store)) return;
22615 const { virtualFocus, baseElement: baseElement2 } = store.getState();
22616 store.setActiveId(id);
22617 if (isTextbox(event.currentTarget)) {
22618 selectTextField(event.currentTarget);
22619 }
22620 if (!virtualFocus) return;
22621 if (!isSelfTarget(event)) return;
22622 if (isEditableElement(event.currentTarget)) return;
22623 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
22624 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
22625 event.currentTarget.scrollIntoView({
22626 block: "nearest",
22627 inline: "nearest"
22628 });
22629 }
22630 hasFocusedComposite.current = true;
22631 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
22632 if (fromComposite) {
22633 focusSilently(baseElement2);
22634 } else {
22635 baseElement2.focus();
22636 }
22637 });
22638 const onBlurCaptureProp = props.onBlurCapture;
22639 const onBlurCapture = useEvent((event) => {
22640 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
22641 if (event.defaultPrevented) return;
22642 const state = store == null ? void 0 : store.getState();
22643 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
22644 hasFocusedComposite.current = false;
22645 event.preventDefault();
22646 event.stopPropagation();
22647 }
22648 });
22649 const onKeyDownProp = props.onKeyDown;
22650 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
22651 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
22652 const onKeyDown = useEvent((event) => {
22653 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
22654 if (event.defaultPrevented) return;
22655 if (!isSelfTarget(event)) return;
22656 if (!store) return;
22657 const { currentTarget } = event;
22658 const state = store.getState();
22659 const item = store.item(id);
22660 const isGrid2 = !!(item == null ? void 0 : item.rowId);
22661 const isVertical = state.orientation !== "horizontal";
22662 const isHorizontal = state.orientation !== "vertical";
22663 const canHomeEnd = () => {
22664 if (isGrid2) return true;
22665 if (isHorizontal) return true;
22666 if (!state.baseElement) return true;
22667 if (!isTextField(state.baseElement)) return true;
22668 return false;
22669 };
22670 const keyMap = {
22671 ArrowUp: (isGrid2 || isVertical) && store.up,
22672 ArrowRight: (isGrid2 || isHorizontal) && store.next,
22673 ArrowDown: (isGrid2 || isVertical) && store.down,
22674 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
22675 Home: () => {
22676 if (!canHomeEnd()) return;
22677 if (!isGrid2 || event.ctrlKey) {
22678 return store == null ? void 0 : store.first();
22679 }
22680 return store == null ? void 0 : store.previous(-1);
22681 },
22682 End: () => {
22683 if (!canHomeEnd()) return;
22684 if (!isGrid2 || event.ctrlKey) {
22685 return store == null ? void 0 : store.last();
22686 }
22687 return store == null ? void 0 : store.next(-1);
22688 },
22689 PageUp: () => {
22690 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
22691 },
22692 PageDown: () => {
22693 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
22694 }
22695 };
22696 const action = keyMap[event.key];
22697 if (action) {
22698 if (isTextbox(currentTarget)) {
22699 const selection = getTextboxSelection(currentTarget);
22700 const isLeft = isHorizontal && event.key === "ArrowLeft";
22701 const isRight = isHorizontal && event.key === "ArrowRight";
22702 const isUp = isVertical && event.key === "ArrowUp";
22703 const isDown = isVertical && event.key === "ArrowDown";
22704 if (isRight || isDown) {
22705 const { length: valueLength } = getTextboxValue(currentTarget);
22706 if (selection.end !== valueLength) return;
22707 } else if ((isLeft || isUp) && selection.start !== 0) return;
22708 }
22709 const nextId = action();
22710 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
22711 if (!moveOnKeyPressProp(event)) return;
22712 event.preventDefault();
22713 store.move(nextId);
22714 }
22715 }
22716 });
22717 const providerValue = (0, import_react27.useMemo)(
22718 () => ({ id, baseElement }),
22719 [id, baseElement]
22720 );
22721 props = useWrapElement(
22722 props,
22723 (element) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
22724 [providerValue]
22725 );
22726 props = {
22727 id,
22728 "data-active-item": isActiveItem || void 0,
22729 ...props,
22730 ref: useMergeRefs5(ref, props.ref),
22731 tabIndex: isTabbable2 ? props.tabIndex : -1,
22732 onFocus,
22733 onBlurCapture,
22734 onKeyDown
22735 };
22736 props = useCommand(props);
22737 props = useCollectionItem({
22738 store,
22739 ...props,
22740 getItem,
22741 shouldRegisterItem: id ? props.shouldRegisterItem : false
22742 });
22743 return removeUndefinedValues({
22744 ...props,
22745 "aria-setsize": ariaSetSize,
22746 "aria-posinset": ariaPosInSet
22747 });
22748 }
22749 );
22750 var CompositeItem = memo22(
22751 forwardRef210(function CompositeItem2(props) {
22752 const htmlProps = useCompositeItem(props);
22753 return createElement3(TagName4, htmlProps);
22754 })
22755 );
22756
22757 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
22758 function toArray(arg) {
22759 if (Array.isArray(arg)) {
22760 return arg;
22761 }
22762 return typeof arg !== "undefined" ? [arg] : [];
22763 }
22764 function flatten2DArray(array) {
22765 const flattened = [];
22766 for (const row of array) {
22767 flattened.push(...row);
22768 }
22769 return flattened;
22770 }
22771 function reverseArray(array) {
22772 return array.slice().reverse();
22773 }
22774
22775 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
22776 var import_react28 = __toESM(require_react(), 1);
22777 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
22778 var TagName5 = "div";
22779 function isGrid(items) {
22780 return items.some((item) => !!item.rowId);
22781 }
22782 function isPrintableKey(event) {
22783 const target = event.target;
22784 if (target && !isTextField(target)) return false;
22785 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
22786 }
22787 function isModifierKey(event) {
22788 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
22789 }
22790 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
22791 return useEvent((event) => {
22792 var _a;
22793 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
22794 if (event.defaultPrevented) return;
22795 if (event.isPropagationStopped()) return;
22796 if (!isSelfTarget(event)) return;
22797 if (isModifierKey(event)) return;
22798 if (isPrintableKey(event)) return;
22799 const state = store.getState();
22800 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
22801 if (!activeElement2) return;
22802 const { view, ...eventInit } = event;
22803 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
22804 if (activeElement2 !== previousElement) {
22805 activeElement2.focus();
22806 }
22807 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
22808 event.preventDefault();
22809 }
22810 if (event.currentTarget.contains(activeElement2)) {
22811 event.stopPropagation();
22812 }
22813 });
22814 }
22815 function findFirstEnabledItemInTheLastRow(items) {
22816 return findFirstEnabledItem(
22817 flatten2DArray(reverseArray(groupItemsByRows(items)))
22818 );
22819 }
22820 function useScheduleFocus(store) {
22821 const [scheduled, setScheduled] = (0, import_react28.useState)(false);
22822 const schedule = (0, import_react28.useCallback)(() => setScheduled(true), []);
22823 const activeItem = store.useState(
22824 (state) => getEnabledItem(store, state.activeId)
22825 );
22826 (0, import_react28.useEffect)(() => {
22827 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
22828 if (!scheduled) return;
22829 if (!activeElement2) return;
22830 setScheduled(false);
22831 activeElement2.focus({ preventScroll: true });
22832 }, [activeItem, scheduled]);
22833 return schedule;
22834 }
22835 var useComposite = createHook(
22836 function useComposite2({
22837 store,
22838 composite = true,
22839 focusOnMove = composite,
22840 moveOnKeyPress = true,
22841 ...props
22842 }) {
22843 const context = useCompositeProviderContext();
22844 store = store || context;
22845 invariant(
22846 store,
22847 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
22848 );
22849 const ref = (0, import_react28.useRef)(null);
22850 const previousElementRef = (0, import_react28.useRef)(null);
22851 const scheduleFocus = useScheduleFocus(store);
22852 const moves = store.useState("moves");
22853 const [, setBaseElement] = useTransactionState(
22854 composite ? store.setBaseElement : null
22855 );
22856 (0, import_react28.useEffect)(() => {
22857 var _a;
22858 if (!store) return;
22859 if (!moves) return;
22860 if (!composite) return;
22861 if (!focusOnMove) return;
22862 const { activeId: activeId2 } = store.getState();
22863 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
22864 if (!itemElement) return;
22865 focusIntoView(itemElement);
22866 }, [store, moves, composite, focusOnMove]);
22867 useSafeLayoutEffect(() => {
22868 if (!store) return;
22869 if (!moves) return;
22870 if (!composite) return;
22871 const { baseElement, activeId: activeId2 } = store.getState();
22872 const isSelfAcive = activeId2 === null;
22873 if (!isSelfAcive) return;
22874 if (!baseElement) return;
22875 const previousElement = previousElementRef.current;
22876 previousElementRef.current = null;
22877 if (previousElement) {
22878 fireBlurEvent(previousElement, { relatedTarget: baseElement });
22879 }
22880 if (!hasFocus(baseElement)) {
22881 baseElement.focus();
22882 }
22883 }, [store, moves, composite]);
22884 const activeId = store.useState("activeId");
22885 const virtualFocus = store.useState("virtualFocus");
22886 useSafeLayoutEffect(() => {
22887 var _a;
22888 if (!store) return;
22889 if (!composite) return;
22890 if (!virtualFocus) return;
22891 const previousElement = previousElementRef.current;
22892 previousElementRef.current = null;
22893 if (!previousElement) return;
22894 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
22895 const relatedTarget = activeElement2 || getActiveElement(previousElement);
22896 if (relatedTarget === previousElement) return;
22897 fireBlurEvent(previousElement, { relatedTarget });
22898 }, [store, activeId, virtualFocus, composite]);
22899 const onKeyDownCapture = useKeyboardEventProxy(
22900 store,
22901 props.onKeyDownCapture,
22902 previousElementRef
22903 );
22904 const onKeyUpCapture = useKeyboardEventProxy(
22905 store,
22906 props.onKeyUpCapture,
22907 previousElementRef
22908 );
22909 const onFocusCaptureProp = props.onFocusCapture;
22910 const onFocusCapture = useEvent((event) => {
22911 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
22912 if (event.defaultPrevented) return;
22913 if (!store) return;
22914 const { virtualFocus: virtualFocus2 } = store.getState();
22915 if (!virtualFocus2) return;
22916 const previousActiveElement = event.relatedTarget;
22917 const isSilentlyFocused = silentlyFocused(event.currentTarget);
22918 if (isSelfTarget(event) && isSilentlyFocused) {
22919 event.stopPropagation();
22920 previousElementRef.current = previousActiveElement;
22921 }
22922 });
22923 const onFocusProp = props.onFocus;
22924 const onFocus = useEvent((event) => {
22925 onFocusProp == null ? void 0 : onFocusProp(event);
22926 if (event.defaultPrevented) return;
22927 if (!composite) return;
22928 if (!store) return;
22929 const { relatedTarget } = event;
22930 const { virtualFocus: virtualFocus2 } = store.getState();
22931 if (virtualFocus2) {
22932 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
22933 queueMicrotask(scheduleFocus);
22934 }
22935 } else if (isSelfTarget(event)) {
22936 store.setActiveId(null);
22937 }
22938 });
22939 const onBlurCaptureProp = props.onBlurCapture;
22940 const onBlurCapture = useEvent((event) => {
22941 var _a;
22942 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
22943 if (event.defaultPrevented) return;
22944 if (!store) return;
22945 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
22946 if (!virtualFocus2) return;
22947 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
22948 const nextActiveElement = event.relatedTarget;
22949 const nextActiveElementIsItem = isItem(store, nextActiveElement);
22950 const previousElement = previousElementRef.current;
22951 previousElementRef.current = null;
22952 if (isSelfTarget(event) && nextActiveElementIsItem) {
22953 if (nextActiveElement === activeElement2) {
22954 if (previousElement && previousElement !== nextActiveElement) {
22955 fireBlurEvent(previousElement, event);
22956 }
22957 } else if (activeElement2) {
22958 fireBlurEvent(activeElement2, event);
22959 } else if (previousElement) {
22960 fireBlurEvent(previousElement, event);
22961 }
22962 event.stopPropagation();
22963 } else {
22964 const targetIsItem = isItem(store, event.target);
22965 if (!targetIsItem && activeElement2) {
22966 fireBlurEvent(activeElement2, event);
22967 }
22968 }
22969 });
22970 const onKeyDownProp = props.onKeyDown;
22971 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
22972 const onKeyDown = useEvent((event) => {
22973 var _a;
22974 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
22975 if (event.nativeEvent.isComposing) return;
22976 if (event.defaultPrevented) return;
22977 if (!store) return;
22978 if (!isSelfTarget(event)) return;
22979 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
22980 const activeItem = getEnabledItem(store, activeId2);
22981 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
22982 const isVertical = orientation !== "horizontal";
22983 const isHorizontal = orientation !== "vertical";
22984 const grid = isGrid(renderedItems);
22985 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
22986 if (isHorizontalKey && isTextField(event.currentTarget)) return;
22987 const up = () => {
22988 if (grid) {
22989 const item = findFirstEnabledItemInTheLastRow(renderedItems);
22990 return item == null ? void 0 : item.id;
22991 }
22992 return store == null ? void 0 : store.last();
22993 };
22994 const keyMap = {
22995 ArrowUp: (grid || isVertical) && up,
22996 ArrowRight: (grid || isHorizontal) && store.first,
22997 ArrowDown: (grid || isVertical) && store.first,
22998 ArrowLeft: (grid || isHorizontal) && store.last,
22999 Home: store.first,
23000 End: store.last,
23001 PageUp: store.first,
23002 PageDown: store.last
23003 };
23004 const action = keyMap[event.key];
23005 if (action) {
23006 const id = action();
23007 if (id !== void 0) {
23008 if (!moveOnKeyPressProp(event)) return;
23009 event.preventDefault();
23010 store.move(id);
23011 }
23012 }
23013 });
23014 props = useWrapElement(
23015 props,
23016 (element) => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(CompositeContextProvider, { value: store, children: element }),
23017 [store]
23018 );
23019 const activeDescendant = store.useState((state) => {
23020 var _a;
23021 if (!store) return;
23022 if (!composite) return;
23023 if (!state.virtualFocus) return;
23024 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
23025 });
23026 props = {
23027 "aria-activedescendant": activeDescendant,
23028 ...props,
23029 ref: useMergeRefs5(ref, setBaseElement, props.ref),
23030 onKeyDownCapture,
23031 onKeyUpCapture,
23032 onFocusCapture,
23033 onFocus,
23034 onBlurCapture,
23035 onKeyDown
23036 };
23037 const focusable2 = store.useState(
23038 (state) => composite && (state.virtualFocus || state.activeId === null)
23039 );
23040 props = useFocusable({ focusable: focusable2, ...props });
23041 return props;
23042 }
23043 );
23044 var Composite5 = forwardRef210(function Composite22(props) {
23045 const htmlProps = useComposite(props);
23046 return createElement3(TagName5, htmlProps);
23047 });
23048
23049 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
23050 var ctx3 = createStoreContext();
23051 var useDisclosureContext = ctx3.useContext;
23052 var useDisclosureScopedContext = ctx3.useScopedContext;
23053 var useDisclosureProviderContext = ctx3.useProviderContext;
23054 var DisclosureContextProvider = ctx3.ContextProvider;
23055 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
23056
23057 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
23058 var import_react29 = __toESM(require_react(), 1);
23059 var ctx4 = createStoreContext(
23060 [DisclosureContextProvider],
23061 [DisclosureScopedContextProvider]
23062 );
23063 var useDialogContext = ctx4.useContext;
23064 var useDialogScopedContext = ctx4.useScopedContext;
23065 var useDialogProviderContext = ctx4.useProviderContext;
23066 var DialogContextProvider = ctx4.ContextProvider;
23067 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
23068 var DialogHeadingContext = (0, import_react29.createContext)(void 0);
23069 var DialogDescriptionContext = (0, import_react29.createContext)(void 0);
23070
23071 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
23072 var import_react30 = __toESM(require_react(), 1);
23073 var import_react_dom4 = __toESM(require_react_dom(), 1);
23074 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
23075 var TagName6 = "div";
23076 function afterTimeout(timeoutMs, cb) {
23077 const timeoutId = setTimeout(cb, timeoutMs);
23078 return () => clearTimeout(timeoutId);
23079 }
23080 function afterPaint2(cb) {
23081 let raf = requestAnimationFrame(() => {
23082 raf = requestAnimationFrame(cb);
23083 });
23084 return () => cancelAnimationFrame(raf);
23085 }
23086 function parseCSSTime(...times) {
23087 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
23088 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
23089 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
23090 if (currentTime > longestTime) return currentTime;
23091 return longestTime;
23092 }, 0);
23093 }
23094 function isHidden3(mounted, hidden, alwaysVisible) {
23095 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
23096 }
23097 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
23098 const context = useDisclosureProviderContext();
23099 store = store || context;
23100 invariant(
23101 store,
23102 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
23103 );
23104 const ref = (0, import_react30.useRef)(null);
23105 const id = useId4(props.id);
23106 const [transition, setTransition] = (0, import_react30.useState)(null);
23107 const open = store.useState("open");
23108 const mounted = store.useState("mounted");
23109 const animated = store.useState("animated");
23110 const contentElement = store.useState("contentElement");
23111 const otherElement = useStoreState(store.disclosure, "contentElement");
23112 useSafeLayoutEffect(() => {
23113 if (!ref.current) return;
23114 store == null ? void 0 : store.setContentElement(ref.current);
23115 }, [store]);
23116 useSafeLayoutEffect(() => {
23117 let previousAnimated;
23118 store == null ? void 0 : store.setState("animated", (animated2) => {
23119 previousAnimated = animated2;
23120 return true;
23121 });
23122 return () => {
23123 if (previousAnimated === void 0) return;
23124 store == null ? void 0 : store.setState("animated", previousAnimated);
23125 };
23126 }, [store]);
23127 useSafeLayoutEffect(() => {
23128 if (!animated) return;
23129 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
23130 setTransition(null);
23131 return;
23132 }
23133 return afterPaint2(() => {
23134 setTransition(open ? "enter" : mounted ? "leave" : null);
23135 });
23136 }, [animated, contentElement, open, mounted]);
23137 useSafeLayoutEffect(() => {
23138 if (!store) return;
23139 if (!animated) return;
23140 if (!transition) return;
23141 if (!contentElement) return;
23142 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
23143 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
23144 if (transition === "leave" && open) return;
23145 if (transition === "enter" && !open) return;
23146 if (typeof animated === "number") {
23147 const timeout2 = animated;
23148 return afterTimeout(timeout2, stopAnimationSync);
23149 }
23150 const {
23151 transitionDuration,
23152 animationDuration,
23153 transitionDelay,
23154 animationDelay
23155 } = getComputedStyle(contentElement);
23156 const {
23157 transitionDuration: transitionDuration2 = "0",
23158 animationDuration: animationDuration2 = "0",
23159 transitionDelay: transitionDelay2 = "0",
23160 animationDelay: animationDelay2 = "0"
23161 } = otherElement ? getComputedStyle(otherElement) : {};
23162 const delay = parseCSSTime(
23163 transitionDelay,
23164 animationDelay,
23165 transitionDelay2,
23166 animationDelay2
23167 );
23168 const duration = parseCSSTime(
23169 transitionDuration,
23170 animationDuration,
23171 transitionDuration2,
23172 animationDuration2
23173 );
23174 const timeout = delay + duration;
23175 if (!timeout) {
23176 if (transition === "enter") {
23177 store.setState("animated", false);
23178 }
23179 stopAnimation();
23180 return;
23181 }
23182 const frameRate = 1e3 / 60;
23183 const maxTimeout = Math.max(timeout - frameRate, 0);
23184 return afterTimeout(maxTimeout, stopAnimationSync);
23185 }, [store, animated, contentElement, otherElement, open, transition]);
23186 props = useWrapElement(
23187 props,
23188 (element) => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DialogScopedContextProvider, { value: store, children: element }),
23189 [store]
23190 );
23191 const hidden = isHidden3(mounted, props.hidden, alwaysVisible);
23192 const styleProp = props.style;
23193 const style = (0, import_react30.useMemo)(() => {
23194 if (hidden) {
23195 return { ...styleProp, display: "none" };
23196 }
23197 return styleProp;
23198 }, [hidden, styleProp]);
23199 props = {
23200 id,
23201 "data-open": open || void 0,
23202 "data-enter": transition === "enter" || void 0,
23203 "data-leave": transition === "leave" || void 0,
23204 hidden,
23205 ...props,
23206 ref: useMergeRefs5(id ? store.setContentElement : null, ref, props.ref),
23207 style
23208 };
23209 return removeUndefinedValues(props);
23210 });
23211 var DisclosureContentImpl = forwardRef210(function DisclosureContentImpl2(props) {
23212 const htmlProps = useDisclosureContent(props);
23213 return createElement3(TagName6, htmlProps);
23214 });
23215 var DisclosureContent = forwardRef210(function DisclosureContent2({
23216 unmountOnHide,
23217 ...props
23218 }) {
23219 const context = useDisclosureProviderContext();
23220 const store = props.store || context;
23221 const mounted = useStoreState(
23222 store,
23223 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
23224 );
23225 if (mounted === false) return null;
23226 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DisclosureContentImpl, { ...props });
23227 });
23228
23229 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
23230 function createDisclosureStore(props = {}) {
23231 const store = mergeStore(
23232 props.store,
23233 omit2(props.disclosure, ["contentElement", "disclosureElement"])
23234 );
23235 throwOnConflictingProps(props, store);
23236 const syncState = store == null ? void 0 : store.getState();
23237 const open = defaultValue(
23238 props.open,
23239 syncState == null ? void 0 : syncState.open,
23240 props.defaultOpen,
23241 false
23242 );
23243 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
23244 const initialState = {
23245 open,
23246 animated,
23247 animating: !!animated && open,
23248 mounted: open,
23249 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
23250 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
23251 };
23252 const disclosure = createStore(initialState, store);
23253 setup(
23254 disclosure,
23255 () => sync(disclosure, ["animated", "animating"], (state) => {
23256 if (state.animated) return;
23257 disclosure.setState("animating", false);
23258 })
23259 );
23260 setup(
23261 disclosure,
23262 () => subscribe(disclosure, ["open"], () => {
23263 if (!disclosure.getState().animated) return;
23264 disclosure.setState("animating", true);
23265 })
23266 );
23267 setup(
23268 disclosure,
23269 () => sync(disclosure, ["open", "animating"], (state) => {
23270 disclosure.setState("mounted", state.open || state.animating);
23271 })
23272 );
23273 return {
23274 ...disclosure,
23275 disclosure: props.disclosure,
23276 setOpen: (value) => disclosure.setState("open", value),
23277 show: () => disclosure.setState("open", true),
23278 hide: () => disclosure.setState("open", false),
23279 toggle: () => disclosure.setState("open", (open2) => !open2),
23280 stopAnimation: () => disclosure.setState("animating", false),
23281 setContentElement: (value) => disclosure.setState("contentElement", value),
23282 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
23283 };
23284 }
23285
23286 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
23287 function useDisclosureStoreProps(store, update2, props) {
23288 useUpdateEffect(update2, [props.store, props.disclosure]);
23289 useStoreProps(store, props, "open", "setOpen");
23290 useStoreProps(store, props, "mounted", "setMounted");
23291 useStoreProps(store, props, "animated");
23292 return Object.assign(store, { disclosure: props.disclosure });
23293 }
23294
23295 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
23296 var ctx5 = createStoreContext(
23297 [DialogContextProvider],
23298 [DialogScopedContextProvider]
23299 );
23300 var usePopoverContext = ctx5.useContext;
23301 var usePopoverScopedContext = ctx5.useScopedContext;
23302 var usePopoverProviderContext = ctx5.useProviderContext;
23303 var PopoverContextProvider = ctx5.ContextProvider;
23304 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
23305
23306 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
23307 function getCommonParent(items) {
23308 var _a;
23309 const firstItem = items.find((item) => !!item.element);
23310 const lastItem = [...items].reverse().find((item) => !!item.element);
23311 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
23312 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
23313 const parent = parentElement;
23314 if (lastItem && parent.contains(lastItem.element)) {
23315 return parentElement;
23316 }
23317 parentElement = parentElement.parentElement;
23318 }
23319 return getDocument(parentElement).body;
23320 }
23321 function getPrivateStore(store) {
23322 return store == null ? void 0 : store.__unstablePrivateStore;
23323 }
23324 function createCollectionStore(props = {}) {
23325 var _a;
23326 throwOnConflictingProps(props, props.store);
23327 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
23328 const items = defaultValue(
23329 props.items,
23330 syncState == null ? void 0 : syncState.items,
23331 props.defaultItems,
23332 []
23333 );
23334 const itemsMap = new Map(items.map((item) => [item.id, item]));
23335 const initialState = {
23336 items,
23337 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
23338 };
23339 const syncPrivateStore = getPrivateStore(props.store);
23340 const privateStore = createStore(
23341 { items, renderedItems: initialState.renderedItems },
23342 syncPrivateStore
23343 );
23344 const collection = createStore(initialState, props.store);
23345 const sortItems = (renderedItems) => {
23346 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
23347 privateStore.setState("renderedItems", sortedItems);
23348 collection.setState("renderedItems", sortedItems);
23349 };
23350 setup(collection, () => init(privateStore));
23351 setup(privateStore, () => {
23352 return batch(privateStore, ["items"], (state) => {
23353 collection.setState("items", state.items);
23354 });
23355 });
23356 setup(privateStore, () => {
23357 return batch(privateStore, ["renderedItems"], (state) => {
23358 let firstRun = true;
23359 let raf = requestAnimationFrame(() => {
23360 const { renderedItems } = collection.getState();
23361 if (state.renderedItems === renderedItems) return;
23362 sortItems(state.renderedItems);
23363 });
23364 if (typeof IntersectionObserver !== "function") {
23365 return () => cancelAnimationFrame(raf);
23366 }
23367 const ioCallback = () => {
23368 if (firstRun) {
23369 firstRun = false;
23370 return;
23371 }
23372 cancelAnimationFrame(raf);
23373 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
23374 };
23375 const root = getCommonParent(state.renderedItems);
23376 const observer = new IntersectionObserver(ioCallback, { root });
23377 for (const item of state.renderedItems) {
23378 if (!item.element) continue;
23379 observer.observe(item.element);
23380 }
23381 return () => {
23382 cancelAnimationFrame(raf);
23383 observer.disconnect();
23384 };
23385 });
23386 });
23387 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
23388 let prevItem;
23389 setItems((items2) => {
23390 const index2 = items2.findIndex(({ id }) => id === item.id);
23391 const nextItems = items2.slice();
23392 if (index2 !== -1) {
23393 prevItem = items2[index2];
23394 const nextItem = { ...prevItem, ...item };
23395 nextItems[index2] = nextItem;
23396 itemsMap.set(item.id, nextItem);
23397 } else {
23398 nextItems.push(item);
23399 itemsMap.set(item.id, item);
23400 }
23401 return nextItems;
23402 });
23403 const unmergeItem = () => {
23404 setItems((items2) => {
23405 if (!prevItem) {
23406 if (canDeleteFromMap) {
23407 itemsMap.delete(item.id);
23408 }
23409 return items2.filter(({ id }) => id !== item.id);
23410 }
23411 const index2 = items2.findIndex(({ id }) => id === item.id);
23412 if (index2 === -1) return items2;
23413 const nextItems = items2.slice();
23414 nextItems[index2] = prevItem;
23415 itemsMap.set(item.id, prevItem);
23416 return nextItems;
23417 });
23418 };
23419 return unmergeItem;
23420 };
23421 const registerItem = (item) => mergeItem(
23422 item,
23423 (getItems) => privateStore.setState("items", getItems),
23424 true
23425 );
23426 return {
23427 ...collection,
23428 registerItem,
23429 renderItem: (item) => chain(
23430 registerItem(item),
23431 mergeItem(
23432 item,
23433 (getItems) => privateStore.setState("renderedItems", getItems)
23434 )
23435 ),
23436 item: (id) => {
23437 if (!id) return null;
23438 let item = itemsMap.get(id);
23439 if (!item) {
23440 const { items: items2 } = privateStore.getState();
23441 item = items2.find((item2) => item2.id === id);
23442 if (item) {
23443 itemsMap.set(id, item);
23444 }
23445 }
23446 return item || null;
23447 },
23448 // @ts-expect-error Internal
23449 __unstablePrivateStore: privateStore
23450 };
23451 }
23452
23453 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
23454 function useCollectionStoreProps(store, update2, props) {
23455 useUpdateEffect(update2, [props.store]);
23456 useStoreProps(store, props, "items", "setItems");
23457 return store;
23458 }
23459
23460 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
23461 var NULL_ITEM = { id: null };
23462 function findFirstEnabledItem2(items, excludeId) {
23463 return items.find((item) => {
23464 if (excludeId) {
23465 return !item.disabled && item.id !== excludeId;
23466 }
23467 return !item.disabled;
23468 });
23469 }
23470 function getEnabledItems(items, excludeId) {
23471 return items.filter((item) => {
23472 if (excludeId) {
23473 return !item.disabled && item.id !== excludeId;
23474 }
23475 return !item.disabled;
23476 });
23477 }
23478 function getItemsInRow(items, rowId) {
23479 return items.filter((item) => item.rowId === rowId);
23480 }
23481 function flipItems(items, activeId, shouldInsertNullItem = false) {
23482 const index2 = items.findIndex((item) => item.id === activeId);
23483 return [
23484 ...items.slice(index2 + 1),
23485 ...shouldInsertNullItem ? [NULL_ITEM] : [],
23486 ...items.slice(0, index2)
23487 ];
23488 }
23489 function groupItemsByRows2(items) {
23490 const rows = [];
23491 for (const item of items) {
23492 const row = rows.find((currentRow) => {
23493 var _a;
23494 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
23495 });
23496 if (row) {
23497 row.push(item);
23498 } else {
23499 rows.push([item]);
23500 }
23501 }
23502 return rows;
23503 }
23504 function getMaxRowLength(array) {
23505 let maxLength = 0;
23506 for (const { length } of array) {
23507 if (length > maxLength) {
23508 maxLength = length;
23509 }
23510 }
23511 return maxLength;
23512 }
23513 function createEmptyItem(rowId) {
23514 return {
23515 id: "__EMPTY_ITEM__",
23516 disabled: true,
23517 rowId
23518 };
23519 }
23520 function normalizeRows(rows, activeId, focusShift) {
23521 const maxLength = getMaxRowLength(rows);
23522 for (const row of rows) {
23523 for (let i2 = 0; i2 < maxLength; i2 += 1) {
23524 const item = row[i2];
23525 if (!item || focusShift && item.disabled) {
23526 const isFirst = i2 === 0;
23527 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
23528 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
23529 }
23530 }
23531 }
23532 return rows;
23533 }
23534 function verticalizeItems(items) {
23535 const rows = groupItemsByRows2(items);
23536 const maxLength = getMaxRowLength(rows);
23537 const verticalized = [];
23538 for (let i2 = 0; i2 < maxLength; i2 += 1) {
23539 for (const row of rows) {
23540 const item = row[i2];
23541 if (item) {
23542 verticalized.push({
23543 ...item,
23544 // If there's no rowId, it means that it's not a grid composite, but
23545 // a single row instead. So, instead of verticalizing it, that is,
23546 // assigning a different rowId based on the column index, we keep it
23547 // undefined so they will be part of the same row. This is useful
23548 // when using up/down on one-dimensional composites.
23549 rowId: item.rowId ? `${i2}` : void 0
23550 });
23551 }
23552 }
23553 }
23554 return verticalized;
23555 }
23556 function createCompositeStore(props = {}) {
23557 var _a;
23558 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
23559 const collection = createCollectionStore(props);
23560 const activeId = defaultValue(
23561 props.activeId,
23562 syncState == null ? void 0 : syncState.activeId,
23563 props.defaultActiveId
23564 );
23565 const initialState = {
23566 ...collection.getState(),
23567 id: defaultValue(
23568 props.id,
23569 syncState == null ? void 0 : syncState.id,
23570 `id-${Math.random().toString(36).slice(2, 8)}`
23571 ),
23572 activeId,
23573 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
23574 includesBaseElement: defaultValue(
23575 props.includesBaseElement,
23576 syncState == null ? void 0 : syncState.includesBaseElement,
23577 activeId === null
23578 ),
23579 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
23580 orientation: defaultValue(
23581 props.orientation,
23582 syncState == null ? void 0 : syncState.orientation,
23583 "both"
23584 ),
23585 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
23586 virtualFocus: defaultValue(
23587 props.virtualFocus,
23588 syncState == null ? void 0 : syncState.virtualFocus,
23589 false
23590 ),
23591 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
23592 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
23593 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
23594 };
23595 const composite = createStore(initialState, collection, props.store);
23596 setup(
23597 composite,
23598 () => sync(composite, ["renderedItems", "activeId"], (state) => {
23599 composite.setState("activeId", (activeId2) => {
23600 var _a2;
23601 if (activeId2 !== void 0) return activeId2;
23602 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
23603 });
23604 })
23605 );
23606 const getNextId = (direction = "next", options = {}) => {
23607 var _a2, _b;
23608 const defaultState = composite.getState();
23609 const {
23610 skip = 0,
23611 activeId: activeId2 = defaultState.activeId,
23612 focusShift = defaultState.focusShift,
23613 focusLoop = defaultState.focusLoop,
23614 focusWrap = defaultState.focusWrap,
23615 includesBaseElement = defaultState.includesBaseElement,
23616 renderedItems = defaultState.renderedItems,
23617 rtl = defaultState.rtl
23618 } = options;
23619 const isVerticalDirection = direction === "up" || direction === "down";
23620 const isNextDirection = direction === "next" || direction === "down";
23621 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
23622 const canShift = focusShift && !skip;
23623 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
23624 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
23625 );
23626 items = canReverse ? reverseArray(items) : items;
23627 items = isVerticalDirection ? verticalizeItems(items) : items;
23628 if (activeId2 == null) {
23629 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
23630 }
23631 const activeItem = items.find((item) => item.id === activeId2);
23632 if (!activeItem) {
23633 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
23634 }
23635 const isGrid2 = items.some((item) => item.rowId);
23636 const activeIndex = items.indexOf(activeItem);
23637 const nextItems = items.slice(activeIndex + 1);
23638 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
23639 if (skip) {
23640 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
23641 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
23642 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
23643 return nextItem2 == null ? void 0 : nextItem2.id;
23644 }
23645 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
23646 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
23647 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
23648 if (canLoop) {
23649 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
23650 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
23651 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
23652 return nextItem2 == null ? void 0 : nextItem2.id;
23653 }
23654 if (canWrap) {
23655 const nextItem2 = findFirstEnabledItem2(
23656 // We can use nextItems, which contains all the next items, including
23657 // items from other rows, to wrap between rows. However, if there is a
23658 // null item (the composite container), we'll only use the next items in
23659 // the row. So moving next from the last item will focus on the
23660 // composite container. On grid composites, horizontal navigation never
23661 // focuses on the composite container, only vertical.
23662 hasNullItem ? nextItemsInRow : nextItems,
23663 activeId2
23664 );
23665 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
23666 return nextId;
23667 }
23668 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
23669 if (!nextItem && hasNullItem) {
23670 return null;
23671 }
23672 return nextItem == null ? void 0 : nextItem.id;
23673 };
23674 return {
23675 ...collection,
23676 ...composite,
23677 setBaseElement: (element) => composite.setState("baseElement", element),
23678 setActiveId: (id) => composite.setState("activeId", id),
23679 move: (id) => {
23680 if (id === void 0) return;
23681 composite.setState("activeId", id);
23682 composite.setState("moves", (moves) => moves + 1);
23683 },
23684 first: () => {
23685 var _a2;
23686 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
23687 },
23688 last: () => {
23689 var _a2;
23690 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
23691 },
23692 next: (options) => {
23693 if (options !== void 0 && typeof options === "number") {
23694 options = { skip: options };
23695 }
23696 return getNextId("next", options);
23697 },
23698 previous: (options) => {
23699 if (options !== void 0 && typeof options === "number") {
23700 options = { skip: options };
23701 }
23702 return getNextId("previous", options);
23703 },
23704 down: (options) => {
23705 if (options !== void 0 && typeof options === "number") {
23706 options = { skip: options };
23707 }
23708 return getNextId("down", options);
23709 },
23710 up: (options) => {
23711 if (options !== void 0 && typeof options === "number") {
23712 options = { skip: options };
23713 }
23714 return getNextId("up", options);
23715 }
23716 };
23717 }
23718
23719 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
23720 function useCompositeStoreOptions(props) {
23721 const id = useId4(props.id);
23722 return { id, ...props };
23723 }
23724 function useCompositeStoreProps(store, update2, props) {
23725 store = useCollectionStoreProps(store, update2, props);
23726 useStoreProps(store, props, "activeId", "setActiveId");
23727 useStoreProps(store, props, "includesBaseElement");
23728 useStoreProps(store, props, "virtualFocus");
23729 useStoreProps(store, props, "orientation");
23730 useStoreProps(store, props, "rtl");
23731 useStoreProps(store, props, "focusLoop");
23732 useStoreProps(store, props, "focusWrap");
23733 useStoreProps(store, props, "focusShift");
23734 return store;
23735 }
23736
23737 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
23738 var import_react31 = __toESM(require_react(), 1);
23739 var ComboboxListRoleContext = (0, import_react31.createContext)(
23740 void 0
23741 );
23742 var ctx6 = createStoreContext(
23743 [PopoverContextProvider, CompositeContextProvider],
23744 [PopoverScopedContextProvider, CompositeScopedContextProvider]
23745 );
23746 var useComboboxContext = ctx6.useContext;
23747 var useComboboxScopedContext = ctx6.useScopedContext;
23748 var useComboboxProviderContext = ctx6.useProviderContext;
23749 var ComboboxContextProvider = ctx6.ContextProvider;
23750 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
23751 var ComboboxItemValueContext = (0, import_react31.createContext)(
23752 void 0
23753 );
23754 var ComboboxItemCheckedContext = (0, import_react31.createContext)(false);
23755
23756 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
23757 function createDialogStore(props = {}) {
23758 return createDisclosureStore(props);
23759 }
23760
23761 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
23762 function useDialogStoreProps(store, update2, props) {
23763 return useDisclosureStoreProps(store, update2, props);
23764 }
23765
23766 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
23767 function createPopoverStore({
23768 popover: otherPopover,
23769 ...props
23770 } = {}) {
23771 const store = mergeStore(
23772 props.store,
23773 omit2(otherPopover, [
23774 "arrowElement",
23775 "anchorElement",
23776 "contentElement",
23777 "popoverElement",
23778 "disclosureElement"
23779 ])
23780 );
23781 throwOnConflictingProps(props, store);
23782 const syncState = store == null ? void 0 : store.getState();
23783 const dialog = createDialogStore({ ...props, store });
23784 const placement = defaultValue(
23785 props.placement,
23786 syncState == null ? void 0 : syncState.placement,
23787 "bottom"
23788 );
23789 const initialState = {
23790 ...dialog.getState(),
23791 placement,
23792 currentPlacement: placement,
23793 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
23794 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
23795 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
23796 rendered: /* @__PURE__ */ Symbol("rendered")
23797 };
23798 const popover = createStore(initialState, dialog, store);
23799 return {
23800 ...dialog,
23801 ...popover,
23802 setAnchorElement: (element) => popover.setState("anchorElement", element),
23803 setPopoverElement: (element) => popover.setState("popoverElement", element),
23804 setArrowElement: (element) => popover.setState("arrowElement", element),
23805 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
23806 };
23807 }
23808
23809 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
23810 function usePopoverStoreProps(store, update2, props) {
23811 useUpdateEffect(update2, [props.popover]);
23812 useStoreProps(store, props, "placement");
23813 return useDialogStoreProps(store, update2, props);
23814 }
23815
23816 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
23817 var TagName7 = "div";
23818 var usePopoverAnchor = createHook(
23819 function usePopoverAnchor2({ store, ...props }) {
23820 const context = usePopoverProviderContext();
23821 store = store || context;
23822 props = {
23823 ...props,
23824 ref: useMergeRefs5(store == null ? void 0 : store.setAnchorElement, props.ref)
23825 };
23826 return props;
23827 }
23828 );
23829 var PopoverAnchor = forwardRef210(function PopoverAnchor2(props) {
23830 const htmlProps = usePopoverAnchor(props);
23831 return createElement3(TagName7, htmlProps);
23832 });
23833
23834 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
23835 var import_react32 = __toESM(require_react(), 1);
23836 var TagName8 = "div";
23837 function getMouseDestination(event) {
23838 const relatedTarget = event.relatedTarget;
23839 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
23840 return relatedTarget;
23841 }
23842 return null;
23843 }
23844 function hoveringInside(event) {
23845 const nextElement = getMouseDestination(event);
23846 if (!nextElement) return false;
23847 return contains2(event.currentTarget, nextElement);
23848 }
23849 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
23850 function movingToAnotherItem(event) {
23851 let dest = getMouseDestination(event);
23852 if (!dest) return false;
23853 do {
23854 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
23855 dest = dest.parentElement;
23856 } while (dest);
23857 return false;
23858 }
23859 var useCompositeHover = createHook(
23860 function useCompositeHover2({
23861 store,
23862 focusOnHover = true,
23863 blurOnHoverEnd = !!focusOnHover,
23864 ...props
23865 }) {
23866 const context = useCompositeContext();
23867 store = store || context;
23868 invariant(
23869 store,
23870 "CompositeHover must be wrapped in a Composite component."
23871 );
23872 const isMouseMoving = useIsMouseMoving();
23873 const onMouseMoveProp = props.onMouseMove;
23874 const focusOnHoverProp = useBooleanEvent(focusOnHover);
23875 const onMouseMove = useEvent((event) => {
23876 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
23877 if (event.defaultPrevented) return;
23878 if (!isMouseMoving()) return;
23879 if (!focusOnHoverProp(event)) return;
23880 if (!hasFocusWithin(event.currentTarget)) {
23881 const baseElement = store == null ? void 0 : store.getState().baseElement;
23882 if (baseElement && !hasFocus(baseElement)) {
23883 baseElement.focus();
23884 }
23885 }
23886 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
23887 });
23888 const onMouseLeaveProp = props.onMouseLeave;
23889 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
23890 const onMouseLeave = useEvent((event) => {
23891 var _a;
23892 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
23893 if (event.defaultPrevented) return;
23894 if (!isMouseMoving()) return;
23895 if (hoveringInside(event)) return;
23896 if (movingToAnotherItem(event)) return;
23897 if (!focusOnHoverProp(event)) return;
23898 if (!blurOnHoverEndProp(event)) return;
23899 store == null ? void 0 : store.setActiveId(null);
23900 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
23901 });
23902 const ref = (0, import_react32.useCallback)((element) => {
23903 if (!element) return;
23904 element[symbol2] = true;
23905 }, []);
23906 props = {
23907 ...props,
23908 ref: useMergeRefs5(ref, props.ref),
23909 onMouseMove,
23910 onMouseLeave
23911 };
23912 return removeUndefinedValues(props);
23913 }
23914 );
23915 var CompositeHover = memo22(
23916 forwardRef210(function CompositeHover2(props) {
23917 const htmlProps = useCompositeHover(props);
23918 return createElement3(TagName8, htmlProps);
23919 })
23920 );
23921
23922 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
23923 var import_react33 = __toESM(require_react(), 1);
23924 var TagName9 = "input";
23925 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
23926 if (!autoSelect) return false;
23927 const firstItem = items.find((item) => !item.disabled && item.value);
23928 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
23929 }
23930 function hasCompletionString(value, activeValue) {
23931 if (!activeValue) return false;
23932 if (value == null) return false;
23933 value = normalizeString(value);
23934 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
23935 }
23936 function isInputEvent(event) {
23937 return event.type === "input";
23938 }
23939 function isAriaAutoCompleteValue(value) {
23940 return value === "inline" || value === "list" || value === "both" || value === "none";
23941 }
23942 function getDefaultAutoSelectId(items) {
23943 const item = items.find((item2) => {
23944 var _a;
23945 if (item2.disabled) return false;
23946 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
23947 });
23948 return item == null ? void 0 : item.id;
23949 }
23950 var useCombobox = createHook(
23951 function useCombobox2({
23952 store,
23953 focusable: focusable2 = true,
23954 autoSelect: autoSelectProp = false,
23955 getAutoSelectId,
23956 setValueOnChange,
23957 showMinLength = 0,
23958 showOnChange,
23959 showOnMouseDown,
23960 showOnClick = showOnMouseDown,
23961 showOnKeyDown,
23962 showOnKeyPress = showOnKeyDown,
23963 blurActiveItemOnClick,
23964 setValueOnClick = true,
23965 moveOnKeyPress = true,
23966 autoComplete = "list",
23967 ...props
23968 }) {
23969 const context = useComboboxProviderContext();
23970 store = store || context;
23971 invariant(
23972 store,
23973 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
23974 );
23975 const ref = (0, import_react33.useRef)(null);
23976 const [valueUpdated, forceValueUpdate] = useForceUpdate();
23977 const canAutoSelectRef = (0, import_react33.useRef)(false);
23978 const composingRef = (0, import_react33.useRef)(false);
23979 const autoSelect = store.useState(
23980 (state) => state.virtualFocus && autoSelectProp
23981 );
23982 const inline4 = autoComplete === "inline" || autoComplete === "both";
23983 const [canInline, setCanInline] = (0, import_react33.useState)(inline4);
23984 useUpdateLayoutEffect(() => {
23985 if (!inline4) return;
23986 setCanInline(true);
23987 }, [inline4]);
23988 const storeValue = store.useState("value");
23989 const prevSelectedValueRef = (0, import_react33.useRef)(void 0);
23990 (0, import_react33.useEffect)(() => {
23991 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
23992 prevSelectedValueRef.current = prev.selectedValue;
23993 });
23994 }, []);
23995 const inlineActiveValue = store.useState((state) => {
23996 var _a;
23997 if (!inline4) return;
23998 if (!canInline) return;
23999 if (state.activeValue && Array.isArray(state.selectedValue)) {
24000 if (state.selectedValue.includes(state.activeValue)) return;
24001 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
24002 }
24003 return state.activeValue;
24004 });
24005 const items = store.useState("renderedItems");
24006 const open = store.useState("open");
24007 const contentElement = store.useState("contentElement");
24008 const value = (0, import_react33.useMemo)(() => {
24009 if (!inline4) return storeValue;
24010 if (!canInline) return storeValue;
24011 const firstItemAutoSelected = isFirstItemAutoSelected(
24012 items,
24013 inlineActiveValue,
24014 autoSelect
24015 );
24016 if (firstItemAutoSelected) {
24017 if (hasCompletionString(storeValue, inlineActiveValue)) {
24018 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
24019 return storeValue + slice;
24020 }
24021 return storeValue;
24022 }
24023 return inlineActiveValue || storeValue;
24024 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
24025 (0, import_react33.useEffect)(() => {
24026 const element = ref.current;
24027 if (!element) return;
24028 const onCompositeItemMove = () => setCanInline(true);
24029 element.addEventListener("combobox-item-move", onCompositeItemMove);
24030 return () => {
24031 element.removeEventListener("combobox-item-move", onCompositeItemMove);
24032 };
24033 }, []);
24034 (0, import_react33.useEffect)(() => {
24035 if (!inline4) return;
24036 if (!canInline) return;
24037 if (!inlineActiveValue) return;
24038 const firstItemAutoSelected = isFirstItemAutoSelected(
24039 items,
24040 inlineActiveValue,
24041 autoSelect
24042 );
24043 if (!firstItemAutoSelected) return;
24044 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
24045 let cleanup = noop5;
24046 queueMicrotask(() => {
24047 const element = ref.current;
24048 if (!element) return;
24049 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
24050 const nextStart = storeValue.length;
24051 const nextEnd = inlineActiveValue.length;
24052 setSelectionRange(element, nextStart, nextEnd);
24053 cleanup = () => {
24054 if (!hasFocus(element)) return;
24055 const { start, end } = getTextboxSelection(element);
24056 if (start !== nextStart) return;
24057 if (end !== nextEnd) return;
24058 setSelectionRange(element, prevStart, prevEnd);
24059 };
24060 });
24061 return () => cleanup();
24062 }, [
24063 valueUpdated,
24064 inline4,
24065 canInline,
24066 inlineActiveValue,
24067 items,
24068 autoSelect,
24069 storeValue
24070 ]);
24071 const scrollingElementRef = (0, import_react33.useRef)(null);
24072 const getAutoSelectIdProp = useEvent(getAutoSelectId);
24073 const autoSelectIdRef = (0, import_react33.useRef)(null);
24074 (0, import_react33.useEffect)(() => {
24075 if (!open) return;
24076 if (!contentElement) return;
24077 const scrollingElement = getScrollingElement(contentElement);
24078 if (!scrollingElement) return;
24079 scrollingElementRef.current = scrollingElement;
24080 const onUserScroll = () => {
24081 canAutoSelectRef.current = false;
24082 };
24083 const onScroll = () => {
24084 if (!store) return;
24085 if (!canAutoSelectRef.current) return;
24086 const { activeId } = store.getState();
24087 if (activeId === null) return;
24088 if (activeId === autoSelectIdRef.current) return;
24089 canAutoSelectRef.current = false;
24090 };
24091 const options = { passive: true, capture: true };
24092 scrollingElement.addEventListener("wheel", onUserScroll, options);
24093 scrollingElement.addEventListener("touchmove", onUserScroll, options);
24094 scrollingElement.addEventListener("scroll", onScroll, options);
24095 return () => {
24096 scrollingElement.removeEventListener("wheel", onUserScroll, true);
24097 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
24098 scrollingElement.removeEventListener("scroll", onScroll, true);
24099 };
24100 }, [open, contentElement, store]);
24101 useSafeLayoutEffect(() => {
24102 if (!storeValue) return;
24103 if (composingRef.current) return;
24104 canAutoSelectRef.current = true;
24105 }, [storeValue]);
24106 useSafeLayoutEffect(() => {
24107 if (autoSelect !== "always" && open) return;
24108 canAutoSelectRef.current = open;
24109 }, [autoSelect, open]);
24110 const resetValueOnSelect = store.useState("resetValueOnSelect");
24111 useUpdateEffect(() => {
24112 var _a, _b;
24113 const canAutoSelect = canAutoSelectRef.current;
24114 if (!store) return;
24115 if (!open) return;
24116 if (!canAutoSelect && !resetValueOnSelect) return;
24117 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
24118 if (baseElement && !hasFocus(baseElement)) return;
24119 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
24120 const observer = new MutationObserver(forceValueUpdate);
24121 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
24122 return () => observer.disconnect();
24123 }
24124 if (autoSelect && canAutoSelect) {
24125 const userAutoSelectId = getAutoSelectIdProp(items);
24126 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
24127 autoSelectIdRef.current = autoSelectId;
24128 store.move(autoSelectId != null ? autoSelectId : null);
24129 } else {
24130 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
24131 if (element && "scrollIntoView" in element) {
24132 element.scrollIntoView({ block: "nearest", inline: "nearest" });
24133 }
24134 }
24135 return;
24136 }, [
24137 store,
24138 open,
24139 valueUpdated,
24140 storeValue,
24141 autoSelect,
24142 resetValueOnSelect,
24143 getAutoSelectIdProp,
24144 items
24145 ]);
24146 (0, import_react33.useEffect)(() => {
24147 if (!inline4) return;
24148 const combobox = ref.current;
24149 if (!combobox) return;
24150 const elements = [combobox, contentElement].filter(
24151 (value2) => !!value2
24152 );
24153 const onBlur2 = (event) => {
24154 if (elements.every((el) => isFocusEventOutside(event, el))) {
24155 store == null ? void 0 : store.setValue(value);
24156 }
24157 };
24158 for (const element of elements) {
24159 element.addEventListener("focusout", onBlur2);
24160 }
24161 return () => {
24162 for (const element of elements) {
24163 element.removeEventListener("focusout", onBlur2);
24164 }
24165 };
24166 }, [inline4, contentElement, store, value]);
24167 const canShow = (event) => {
24168 const currentTarget = event.currentTarget;
24169 return currentTarget.value.length >= showMinLength;
24170 };
24171 const onChangeProp = props.onChange;
24172 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
24173 const setValueOnChangeProp = useBooleanEvent(
24174 // If the combobox is combined with tags, the value will be set by the tag
24175 // input component.
24176 setValueOnChange != null ? setValueOnChange : !store.tag
24177 );
24178 const onChange = useEvent((event) => {
24179 onChangeProp == null ? void 0 : onChangeProp(event);
24180 if (event.defaultPrevented) return;
24181 if (!store) return;
24182 const currentTarget = event.currentTarget;
24183 const { value: value2, selectionStart, selectionEnd } = currentTarget;
24184 const nativeEvent = event.nativeEvent;
24185 canAutoSelectRef.current = true;
24186 if (isInputEvent(nativeEvent)) {
24187 if (nativeEvent.isComposing) {
24188 canAutoSelectRef.current = false;
24189 composingRef.current = true;
24190 }
24191 if (inline4) {
24192 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
24193 const caretAtEnd = selectionStart === value2.length;
24194 setCanInline(textInserted && caretAtEnd);
24195 }
24196 }
24197 if (setValueOnChangeProp(event)) {
24198 const isSameValue = value2 === store.getState().value;
24199 store.setValue(value2);
24200 queueMicrotask(() => {
24201 setSelectionRange(currentTarget, selectionStart, selectionEnd);
24202 });
24203 if (inline4 && autoSelect && isSameValue) {
24204 forceValueUpdate();
24205 }
24206 }
24207 if (showOnChangeProp(event)) {
24208 store.show();
24209 }
24210 if (!autoSelect || !canAutoSelectRef.current) {
24211 store.setActiveId(null);
24212 }
24213 });
24214 const onCompositionEndProp = props.onCompositionEnd;
24215 const onCompositionEnd = useEvent((event) => {
24216 canAutoSelectRef.current = true;
24217 composingRef.current = false;
24218 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
24219 if (event.defaultPrevented) return;
24220 if (!autoSelect) return;
24221 forceValueUpdate();
24222 });
24223 const onMouseDownProp = props.onMouseDown;
24224 const blurActiveItemOnClickProp = useBooleanEvent(
24225 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
24226 );
24227 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
24228 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
24229 const onMouseDown = useEvent((event) => {
24230 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
24231 if (event.defaultPrevented) return;
24232 if (event.button) return;
24233 if (event.ctrlKey) return;
24234 if (!store) return;
24235 if (blurActiveItemOnClickProp(event)) {
24236 store.setActiveId(null);
24237 }
24238 if (setValueOnClickProp(event)) {
24239 store.setValue(value);
24240 }
24241 if (showOnClickProp(event)) {
24242 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
24243 }
24244 });
24245 const onKeyDownProp = props.onKeyDown;
24246 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
24247 const onKeyDown = useEvent((event) => {
24248 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
24249 if (!event.repeat) {
24250 canAutoSelectRef.current = false;
24251 }
24252 if (event.defaultPrevented) return;
24253 if (event.ctrlKey) return;
24254 if (event.altKey) return;
24255 if (event.shiftKey) return;
24256 if (event.metaKey) return;
24257 if (!store) return;
24258 const { open: open2 } = store.getState();
24259 if (open2) return;
24260 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
24261 if (showOnKeyPressProp(event)) {
24262 event.preventDefault();
24263 store.show();
24264 }
24265 }
24266 });
24267 const onBlurProp = props.onBlur;
24268 const onBlur = useEvent((event) => {
24269 canAutoSelectRef.current = false;
24270 onBlurProp == null ? void 0 : onBlurProp(event);
24271 if (event.defaultPrevented) return;
24272 });
24273 const id = useId4(props.id);
24274 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
24275 const isActiveItem = store.useState((state) => state.activeId === null);
24276 props = {
24277 id,
24278 role: "combobox",
24279 "aria-autocomplete": ariaAutoComplete,
24280 "aria-haspopup": getPopupRole(contentElement, "listbox"),
24281 "aria-expanded": open,
24282 "aria-controls": contentElement == null ? void 0 : contentElement.id,
24283 "data-active-item": isActiveItem || void 0,
24284 value,
24285 ...props,
24286 ref: useMergeRefs5(ref, props.ref),
24287 onChange,
24288 onCompositionEnd,
24289 onMouseDown,
24290 onKeyDown,
24291 onBlur
24292 };
24293 props = useComposite({
24294 store,
24295 focusable: focusable2,
24296 ...props,
24297 // Enable inline autocomplete when the user moves from the combobox input
24298 // to an item.
24299 moveOnKeyPress: (event) => {
24300 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
24301 if (inline4) setCanInline(true);
24302 return true;
24303 }
24304 });
24305 props = usePopoverAnchor({ store, ...props });
24306 return { autoComplete: "off", ...props };
24307 }
24308 );
24309 var Combobox = forwardRef210(function Combobox2(props) {
24310 const htmlProps = useCombobox(props);
24311 return createElement3(TagName9, htmlProps);
24312 });
24313
24314 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
24315 var import_react34 = __toESM(require_react(), 1);
24316 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24317 var TagName10 = "div";
24318 function isSelected(storeValue, itemValue) {
24319 if (itemValue == null) return;
24320 if (storeValue == null) return false;
24321 if (Array.isArray(storeValue)) {
24322 return storeValue.includes(itemValue);
24323 }
24324 return storeValue === itemValue;
24325 }
24326 function getItemRole(popupRole) {
24327 var _a;
24328 const itemRoleByPopupRole = {
24329 menu: "menuitem",
24330 listbox: "option",
24331 tree: "treeitem"
24332 };
24333 const key2 = popupRole;
24334 return (_a = itemRoleByPopupRole[key2]) != null ? _a : "option";
24335 }
24336 var useComboboxItem = createHook(
24337 function useComboboxItem2({
24338 store,
24339 value,
24340 hideOnClick,
24341 setValueOnClick,
24342 selectValueOnClick = true,
24343 resetValueOnSelect,
24344 focusOnHover = false,
24345 moveOnKeyPress = true,
24346 getItem: getItemProp,
24347 ...props
24348 }) {
24349 var _a;
24350 const context = useComboboxScopedContext();
24351 store = store || context;
24352 invariant(
24353 store,
24354 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
24355 );
24356 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
24357 resetValueOnSelectState: "resetValueOnSelect",
24358 multiSelectable(state) {
24359 return Array.isArray(state.selectedValue);
24360 },
24361 selected(state) {
24362 return isSelected(state.selectedValue, value);
24363 }
24364 });
24365 const getItem = (0, import_react34.useCallback)(
24366 (item) => {
24367 const nextItem = { ...item, value };
24368 if (getItemProp) {
24369 return getItemProp(nextItem);
24370 }
24371 return nextItem;
24372 },
24373 [value, getItemProp]
24374 );
24375 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
24376 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
24377 const onClickProp = props.onClick;
24378 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
24379 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
24380 const resetValueOnSelectProp = useBooleanEvent(
24381 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
24382 );
24383 const hideOnClickProp = useBooleanEvent(hideOnClick);
24384 const onClick = useEvent((event) => {
24385 onClickProp == null ? void 0 : onClickProp(event);
24386 if (event.defaultPrevented) return;
24387 if (isDownloading(event)) return;
24388 if (isOpeningInNewTab(event)) return;
24389 if (value != null) {
24390 if (selectValueOnClickProp(event)) {
24391 if (resetValueOnSelectProp(event)) {
24392 store == null ? void 0 : store.resetValue();
24393 }
24394 store == null ? void 0 : store.setSelectedValue((prevValue) => {
24395 if (!Array.isArray(prevValue)) return value;
24396 if (prevValue.includes(value)) {
24397 return prevValue.filter((v2) => v2 !== value);
24398 }
24399 return [...prevValue, value];
24400 });
24401 }
24402 if (setValueOnClickProp(event)) {
24403 store == null ? void 0 : store.setValue(value);
24404 }
24405 }
24406 if (hideOnClickProp(event)) {
24407 store == null ? void 0 : store.hide();
24408 }
24409 });
24410 const onKeyDownProp = props.onKeyDown;
24411 const onKeyDown = useEvent((event) => {
24412 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
24413 if (event.defaultPrevented) return;
24414 const baseElement = store == null ? void 0 : store.getState().baseElement;
24415 if (!baseElement) return;
24416 if (hasFocus(baseElement)) return;
24417 const printable = event.key.length === 1;
24418 if (printable || event.key === "Backspace" || event.key === "Delete") {
24419 queueMicrotask(() => baseElement.focus());
24420 if (isTextField(baseElement)) {
24421 store == null ? void 0 : store.setValue(baseElement.value);
24422 }
24423 }
24424 });
24425 if (multiSelectable && selected != null) {
24426 props = {
24427 "aria-selected": selected,
24428 ...props
24429 };
24430 }
24431 props = useWrapElement(
24432 props,
24433 (element) => /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
24434 [value, selected]
24435 );
24436 const popupRole = (0, import_react34.useContext)(ComboboxListRoleContext);
24437 props = {
24438 role: getItemRole(popupRole),
24439 children: value,
24440 ...props,
24441 onClick,
24442 onKeyDown
24443 };
24444 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
24445 props = useCompositeItem({
24446 store,
24447 ...props,
24448 getItem,
24449 // Dispatch a custom event on the combobox input when moving to an item
24450 // with the keyboard so the Combobox component can enable inline
24451 // autocompletion.
24452 moveOnKeyPress: (event) => {
24453 if (!moveOnKeyPressProp(event)) return false;
24454 const moveEvent = new Event("combobox-item-move");
24455 const baseElement = store == null ? void 0 : store.getState().baseElement;
24456 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
24457 return true;
24458 }
24459 });
24460 props = useCompositeHover({ store, focusOnHover, ...props });
24461 return props;
24462 }
24463 );
24464 var ComboboxItem = memo22(
24465 forwardRef210(function ComboboxItem2(props) {
24466 const htmlProps = useComboboxItem(props);
24467 return createElement3(TagName10, htmlProps);
24468 })
24469 );
24470
24471 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
24472 var import_react35 = __toESM(require_react(), 1);
24473 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
24474 var TagName11 = "span";
24475 function normalizeValue(value) {
24476 return normalizeString(value).toLowerCase();
24477 }
24478 function getOffsets(string, values) {
24479 const offsets = [];
24480 for (const value of values) {
24481 let pos = 0;
24482 const length = value.length;
24483 while (string.indexOf(value, pos) !== -1) {
24484 const index2 = string.indexOf(value, pos);
24485 if (index2 !== -1) {
24486 offsets.push([index2, length]);
24487 }
24488 pos = index2 + 1;
24489 }
24490 }
24491 return offsets;
24492 }
24493 function filterOverlappingOffsets(offsets) {
24494 return offsets.filter(([offset4, length], i2, arr) => {
24495 return !arr.some(
24496 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
24497 );
24498 });
24499 }
24500 function sortOffsets(offsets) {
24501 return offsets.sort(([a2], [b2]) => a2 - b2);
24502 }
24503 function splitValue(itemValue, userValue) {
24504 if (!itemValue) return itemValue;
24505 if (!userValue) return itemValue;
24506 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
24507 const parts = [];
24508 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
24509 "span",
24510 {
24511 "data-autocomplete-value": autocomplete ? "" : void 0,
24512 "data-user-value": autocomplete ? void 0 : "",
24513 children: value
24514 },
24515 parts.length
24516 );
24517 const offsets = sortOffsets(
24518 filterOverlappingOffsets(
24519 // Convert userValues into a set to avoid duplicates
24520 getOffsets(normalizeValue(itemValue), new Set(userValues))
24521 )
24522 );
24523 if (!offsets.length) {
24524 parts.push(span(itemValue, true));
24525 return parts;
24526 }
24527 const [firstOffset] = offsets[0];
24528 const values = [
24529 itemValue.slice(0, firstOffset),
24530 ...offsets.flatMap(([offset4, length], i2) => {
24531 var _a;
24532 const value = itemValue.slice(offset4, offset4 + length);
24533 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
24534 const nextValue = itemValue.slice(offset4 + length, nextOffset);
24535 return [value, nextValue];
24536 })
24537 ];
24538 values.forEach((value, i2) => {
24539 if (!value) return;
24540 parts.push(span(value, i2 % 2 === 0));
24541 });
24542 return parts;
24543 }
24544 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
24545 const context = useComboboxScopedContext();
24546 store = store || context;
24547 const itemContext = (0, import_react35.useContext)(ComboboxItemValueContext);
24548 const itemValue = value != null ? value : itemContext;
24549 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
24550 const children = (0, import_react35.useMemo)(() => {
24551 if (!itemValue) return;
24552 if (!inputValue) return itemValue;
24553 return splitValue(itemValue, inputValue);
24554 }, [itemValue, inputValue]);
24555 props = {
24556 children,
24557 ...props
24558 };
24559 return removeUndefinedValues(props);
24560 });
24561 var ComboboxItemValue = forwardRef210(function ComboboxItemValue2(props) {
24562 const htmlProps = useComboboxItemValue(props);
24563 return createElement3(TagName11, htmlProps);
24564 });
24565
24566 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
24567 var TagName12 = "label";
24568 var useComboboxLabel = createHook(
24569 function useComboboxLabel2({ store, ...props }) {
24570 const context = useComboboxProviderContext();
24571 store = store || context;
24572 invariant(
24573 store,
24574 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
24575 );
24576 const comboboxId = store.useState((state) => {
24577 var _a;
24578 return (_a = state.baseElement) == null ? void 0 : _a.id;
24579 });
24580 props = {
24581 htmlFor: comboboxId,
24582 ...props
24583 };
24584 return removeUndefinedValues(props);
24585 }
24586 );
24587 var ComboboxLabel = memo22(
24588 forwardRef210(function ComboboxLabel2(props) {
24589 const htmlProps = useComboboxLabel(props);
24590 return createElement3(TagName12, htmlProps);
24591 })
24592 );
24593
24594 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
24595 var import_react36 = __toESM(require_react(), 1);
24596 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
24597 var TagName13 = "div";
24598 var useComboboxList = createHook(
24599 function useComboboxList2({ store, alwaysVisible, ...props }) {
24600 const scopedContext = useComboboxScopedContext(true);
24601 const context = useComboboxContext();
24602 store = store || context;
24603 const scopedContextSameStore = !!store && store === scopedContext;
24604 invariant(
24605 store,
24606 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
24607 );
24608 const ref = (0, import_react36.useRef)(null);
24609 const id = useId4(props.id);
24610 const mounted = store.useState("mounted");
24611 const hidden = isHidden3(mounted, props.hidden, alwaysVisible);
24612 const style = hidden ? { ...props.style, display: "none" } : props.style;
24613 const multiSelectable = store.useState(
24614 (state) => Array.isArray(state.selectedValue)
24615 );
24616 const role = useAttribute(ref, "role", props.role);
24617 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
24618 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
24619 const [hasListboxInside, setHasListboxInside] = (0, import_react36.useState)(false);
24620 const contentElement = store.useState("contentElement");
24621 useSafeLayoutEffect(() => {
24622 if (!mounted) return;
24623 const element = ref.current;
24624 if (!element) return;
24625 if (contentElement !== element) return;
24626 const callback = () => {
24627 setHasListboxInside(!!element.querySelector("[role='listbox']"));
24628 };
24629 const observer = new MutationObserver(callback);
24630 observer.observe(element, {
24631 subtree: true,
24632 childList: true,
24633 attributeFilter: ["role"]
24634 });
24635 callback();
24636 return () => observer.disconnect();
24637 }, [mounted, contentElement]);
24638 if (!hasListboxInside) {
24639 props = {
24640 role: "listbox",
24641 "aria-multiselectable": ariaMultiSelectable,
24642 ...props
24643 };
24644 }
24645 props = useWrapElement(
24646 props,
24647 (element) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
24648 [store, role]
24649 );
24650 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
24651 props = {
24652 id,
24653 hidden,
24654 ...props,
24655 ref: useMergeRefs5(setContentElement, ref, props.ref),
24656 style
24657 };
24658 return removeUndefinedValues(props);
24659 }
24660 );
24661 var ComboboxList = forwardRef210(function ComboboxList2(props) {
24662 const htmlProps = useComboboxList(props);
24663 return createElement3(TagName13, htmlProps);
24664 });
24665
24666 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
24667 var import_react37 = __toESM(require_react(), 1);
24668 var TagValueContext = (0, import_react37.createContext)(null);
24669 var TagRemoveIdContext = (0, import_react37.createContext)(
24670 null
24671 );
24672 var ctx7 = createStoreContext(
24673 [CompositeContextProvider],
24674 [CompositeScopedContextProvider]
24675 );
24676 var useTagContext = ctx7.useContext;
24677 var useTagScopedContext = ctx7.useScopedContext;
24678 var useTagProviderContext = ctx7.useProviderContext;
24679 var TagContextProvider = ctx7.ContextProvider;
24680 var TagScopedContextProvider = ctx7.ScopedContextProvider;
24681
24682 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
24683 var isTouchSafari = isSafari2() && isTouchDevice();
24684 function createComboboxStore({
24685 tag,
24686 ...props
24687 } = {}) {
24688 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
24689 throwOnConflictingProps(props, store);
24690 const tagState = tag == null ? void 0 : tag.getState();
24691 const syncState = store == null ? void 0 : store.getState();
24692 const activeId = defaultValue(
24693 props.activeId,
24694 syncState == null ? void 0 : syncState.activeId,
24695 props.defaultActiveId,
24696 null
24697 );
24698 const composite = createCompositeStore({
24699 ...props,
24700 activeId,
24701 includesBaseElement: defaultValue(
24702 props.includesBaseElement,
24703 syncState == null ? void 0 : syncState.includesBaseElement,
24704 true
24705 ),
24706 orientation: defaultValue(
24707 props.orientation,
24708 syncState == null ? void 0 : syncState.orientation,
24709 "vertical"
24710 ),
24711 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
24712 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
24713 virtualFocus: defaultValue(
24714 props.virtualFocus,
24715 syncState == null ? void 0 : syncState.virtualFocus,
24716 true
24717 )
24718 });
24719 const popover = createPopoverStore({
24720 ...props,
24721 placement: defaultValue(
24722 props.placement,
24723 syncState == null ? void 0 : syncState.placement,
24724 "bottom-start"
24725 )
24726 });
24727 const value = defaultValue(
24728 props.value,
24729 syncState == null ? void 0 : syncState.value,
24730 props.defaultValue,
24731 ""
24732 );
24733 const selectedValue = defaultValue(
24734 props.selectedValue,
24735 syncState == null ? void 0 : syncState.selectedValue,
24736 tagState == null ? void 0 : tagState.values,
24737 props.defaultSelectedValue,
24738 ""
24739 );
24740 const multiSelectable = Array.isArray(selectedValue);
24741 const initialState = {
24742 ...composite.getState(),
24743 ...popover.getState(),
24744 value,
24745 selectedValue,
24746 resetValueOnSelect: defaultValue(
24747 props.resetValueOnSelect,
24748 syncState == null ? void 0 : syncState.resetValueOnSelect,
24749 multiSelectable
24750 ),
24751 resetValueOnHide: defaultValue(
24752 props.resetValueOnHide,
24753 syncState == null ? void 0 : syncState.resetValueOnHide,
24754 multiSelectable && !tag
24755 ),
24756 activeValue: syncState == null ? void 0 : syncState.activeValue
24757 };
24758 const combobox = createStore(initialState, composite, popover, store);
24759 if (isTouchSafari) {
24760 setup(
24761 combobox,
24762 () => sync(combobox, ["virtualFocus"], () => {
24763 combobox.setState("virtualFocus", false);
24764 })
24765 );
24766 }
24767 setup(combobox, () => {
24768 if (!tag) return;
24769 return chain(
24770 sync(combobox, ["selectedValue"], (state) => {
24771 if (!Array.isArray(state.selectedValue)) return;
24772 tag.setValues(state.selectedValue);
24773 }),
24774 sync(tag, ["values"], (state) => {
24775 combobox.setState("selectedValue", state.values);
24776 })
24777 );
24778 });
24779 setup(
24780 combobox,
24781 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
24782 if (!state.resetValueOnHide) return;
24783 if (state.mounted) return;
24784 combobox.setState("value", value);
24785 })
24786 );
24787 setup(
24788 combobox,
24789 () => sync(combobox, ["open"], (state) => {
24790 if (state.open) return;
24791 combobox.setState("activeId", activeId);
24792 combobox.setState("moves", 0);
24793 })
24794 );
24795 setup(
24796 combobox,
24797 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
24798 if (state.moves === prevState.moves) {
24799 combobox.setState("activeValue", void 0);
24800 }
24801 })
24802 );
24803 setup(
24804 combobox,
24805 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
24806 if (state.moves === prev.moves) return;
24807 const { activeId: activeId2 } = combobox.getState();
24808 const activeItem = composite.item(activeId2);
24809 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
24810 })
24811 );
24812 return {
24813 ...popover,
24814 ...composite,
24815 ...combobox,
24816 tag,
24817 setValue: (value2) => combobox.setState("value", value2),
24818 resetValue: () => combobox.setState("value", initialState.value),
24819 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
24820 };
24821 }
24822
24823 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
24824 function useComboboxStoreOptions(props) {
24825 const tag = useTagContext();
24826 props = {
24827 ...props,
24828 tag: props.tag !== void 0 ? props.tag : tag
24829 };
24830 return useCompositeStoreOptions(props);
24831 }
24832 function useComboboxStoreProps(store, update2, props) {
24833 useUpdateEffect(update2, [props.tag]);
24834 useStoreProps(store, props, "value", "setValue");
24835 useStoreProps(store, props, "selectedValue", "setSelectedValue");
24836 useStoreProps(store, props, "resetValueOnHide");
24837 useStoreProps(store, props, "resetValueOnSelect");
24838 return Object.assign(
24839 useCompositeStoreProps(
24840 usePopoverStoreProps(store, update2, props),
24841 update2,
24842 props
24843 ),
24844 { tag: props.tag }
24845 );
24846 }
24847 function useComboboxStore(props = {}) {
24848 props = useComboboxStoreOptions(props);
24849 const [store, update2] = useStore2(createComboboxStore, props);
24850 return useComboboxStoreProps(store, update2, props);
24851 }
24852
24853 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
24854 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
24855 function ComboboxProvider(props = {}) {
24856 const store = useComboboxStore(props);
24857 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(ComboboxContextProvider, { value: store, children: props.children });
24858 }
24859
24860 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
24861 var import_remove_accents = __toESM(require_remove_accents(), 1);
24862 var import_compose11 = __toESM(require_compose(), 1);
24863 var import_i18n29 = __toESM(require_i18n(), 1);
24864 var import_element89 = __toESM(require_element(), 1);
24865 var import_components20 = __toESM(require_components(), 1);
24866
24867 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
24868 var EMPTY_ARRAY3 = [];
24869 var getCurrentValue = (filterDefinition, currentFilter) => {
24870 if (filterDefinition.singleSelection) {
24871 return currentFilter?.value;
24872 }
24873 if (Array.isArray(currentFilter?.value)) {
24874 return currentFilter.value;
24875 }
24876 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
24877 return [currentFilter.value];
24878 }
24879 return EMPTY_ARRAY3;
24880 };
24881
24882 // packages/dataviews/build-module/hooks/use-elements.mjs
24883 var import_element88 = __toESM(require_element(), 1);
24884 var EMPTY_ARRAY4 = [];
24885 function useElements({
24886 elements,
24887 getElements
24888 }) {
24889 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
24890 const [records, setRecords] = (0, import_element88.useState)(staticElements);
24891 const [isLoading, setIsLoading] = (0, import_element88.useState)(false);
24892 (0, import_element88.useEffect)(() => {
24893 if (!getElements) {
24894 setRecords(staticElements);
24895 return;
24896 }
24897 let cancelled = false;
24898 setIsLoading(true);
24899 getElements().then((fetchedElements) => {
24900 if (!cancelled) {
24901 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
24902 setRecords(dynamicElements);
24903 }
24904 }).catch(() => {
24905 if (!cancelled) {
24906 setRecords(staticElements);
24907 }
24908 }).finally(() => {
24909 if (!cancelled) {
24910 setIsLoading(false);
24911 }
24912 });
24913 return () => {
24914 cancelled = true;
24915 };
24916 }, [getElements, staticElements]);
24917 return {
24918 elements: records,
24919 isLoading
24920 };
24921 }
24922
24923 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
24924 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
24925 function normalizeSearchInput(input = "") {
24926 return (0, import_remove_accents.default)(input.trim().toLowerCase());
24927 }
24928 var getNewValue = (filterDefinition, currentFilter, value) => {
24929 if (filterDefinition.singleSelection) {
24930 return value;
24931 }
24932 if (Array.isArray(currentFilter?.value)) {
24933 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
24934 }
24935 return [value];
24936 };
24937 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
24938 return `${prefix}-${filterElementValue}`;
24939 }
24940 var MultiSelectionOption = ({ selected }) => {
24941 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
24942 "span",
24943 {
24944 className: clsx_default(
24945 "dataviews-filters__search-widget-listitem-multi-selection",
24946 { "is-selected": selected }
24947 ),
24948 children: selected && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components20.Icon, { icon: check_default })
24949 }
24950 );
24951 };
24952 var SingleSelectionOption = ({ selected }) => {
24953 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
24954 "span",
24955 {
24956 className: clsx_default(
24957 "dataviews-filters__search-widget-listitem-single-selection",
24958 { "is-selected": selected }
24959 )
24960 }
24961 );
24962 };
24963 function ListBox({ view, filter, onChangeView }) {
24964 const baseId = (0, import_compose11.useInstanceId)(ListBox, "dataviews-filter-list-box");
24965 const [activeCompositeId, setActiveCompositeId] = (0, import_element89.useState)(
24966 // When there are one or less operators, the first item is set as active
24967 // (by setting the initial `activeId` to `undefined`).
24968 // With 2 or more operators, the focus is moved on the operators control
24969 // (by setting the initial `activeId` to `null`), meaning that there won't
24970 // be an active item initially. Focus is then managed via the
24971 // `onFocusVisible` callback.
24972 filter.operators?.length === 1 ? void 0 : null
24973 );
24974 const currentFilter = view.filters?.find(
24975 (f2) => f2.field === filter.field
24976 );
24977 const currentValue = getCurrentValue(filter, currentFilter);
24978 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
24979 import_components20.Composite,
24980 {
24981 virtualFocus: true,
24982 focusLoop: true,
24983 activeId: activeCompositeId,
24984 setActiveId: setActiveCompositeId,
24985 role: "listbox",
24986 className: "dataviews-filters__search-widget-listbox",
24987 "aria-label": (0, import_i18n29.sprintf)(
24988 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
24989 (0, import_i18n29.__)("List of: %1$s"),
24990 filter.name
24991 ),
24992 onFocusVisible: () => {
24993 if (!activeCompositeId && filter.elements.length) {
24994 setActiveCompositeId(
24995 generateFilterElementCompositeItemId(
24996 baseId,
24997 filter.elements[0].value
24998 )
24999 );
25000 }
25001 },
25002 render: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components20.Composite.Typeahead, {}),
25003 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
25004 import_components20.Composite.Hover,
25005 {
25006 render: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25007 import_components20.Composite.Item,
25008 {
25009 id: generateFilterElementCompositeItemId(
25010 baseId,
25011 element.value
25012 ),
25013 render: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25014 "div",
25015 {
25016 "aria-label": element.label,
25017 role: "option",
25018 className: "dataviews-filters__search-widget-listitem"
25019 }
25020 ),
25021 onClick: () => {
25022 const newFilters = currentFilter ? [
25023 ...(view.filters ?? []).map(
25024 (_filter) => {
25025 if (_filter.field === filter.field) {
25026 return {
25027 ..._filter,
25028 operator: currentFilter.operator || filter.operators[0],
25029 value: getNewValue(
25030 filter,
25031 currentFilter,
25032 element.value
25033 )
25034 };
25035 }
25036 return _filter;
25037 }
25038 )
25039 ] : [
25040 ...view.filters ?? [],
25041 {
25042 field: filter.field,
25043 operator: filter.operators[0],
25044 value: getNewValue(
25045 filter,
25046 currentFilter,
25047 element.value
25048 )
25049 }
25050 ];
25051 onChangeView({
25052 ...view,
25053 page: 1,
25054 filters: newFilters
25055 });
25056 }
25057 }
25058 ),
25059 children: [
25060 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25061 SingleSelectionOption,
25062 {
25063 selected: currentValue === element.value
25064 }
25065 ),
25066 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25067 MultiSelectionOption,
25068 {
25069 selected: currentValue.includes(element.value)
25070 }
25071 ),
25072 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25073 "span",
25074 {
25075 className: "dataviews-filters__search-widget-listitem-value",
25076 title: element.label,
25077 children: element.label
25078 }
25079 )
25080 ]
25081 },
25082 element.value
25083 ))
25084 }
25085 );
25086 }
25087 function ComboboxList22({ view, filter, onChangeView }) {
25088 const [searchValue, setSearchValue] = (0, import_element89.useState)("");
25089 const deferredSearchValue = (0, import_element89.useDeferredValue)(searchValue);
25090 const currentFilter = view.filters?.find(
25091 (_filter) => _filter.field === filter.field
25092 );
25093 const currentValue = getCurrentValue(filter, currentFilter);
25094 const matches2 = (0, import_element89.useMemo)(() => {
25095 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
25096 return filter.elements.filter(
25097 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
25098 );
25099 }, [filter.elements, deferredSearchValue]);
25100 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
25101 ComboboxProvider,
25102 {
25103 selectedValue: currentValue,
25104 setSelectedValue: (value) => {
25105 const newFilters = currentFilter ? [
25106 ...(view.filters ?? []).map((_filter) => {
25107 if (_filter.field === filter.field) {
25108 return {
25109 ..._filter,
25110 operator: currentFilter.operator || filter.operators[0],
25111 value
25112 };
25113 }
25114 return _filter;
25115 })
25116 ] : [
25117 ...view.filters ?? [],
25118 {
25119 field: filter.field,
25120 operator: filter.operators[0],
25121 value
25122 }
25123 ];
25124 onChangeView({
25125 ...view,
25126 page: 1,
25127 filters: newFilters
25128 });
25129 },
25130 setValue: setSearchValue,
25131 children: [
25132 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
25133 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(ComboboxLabel, {}), children: (0, import_i18n29.__)("Search items") }),
25134 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25135 Combobox,
25136 {
25137 autoSelect: "always",
25138 placeholder: (0, import_i18n29.__)("Search"),
25139 className: "dataviews-filters__search-widget-filter-combobox__input"
25140 }
25141 ),
25142 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components20.Icon, { icon: search_default }) })
25143 ] }),
25144 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
25145 ComboboxList,
25146 {
25147 className: "dataviews-filters__search-widget-filter-combobox-list",
25148 alwaysVisible: true,
25149 children: [
25150 matches2.map((element) => {
25151 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
25152 ComboboxItem,
25153 {
25154 resetValueOnSelect: false,
25155 value: element.value,
25156 className: "dataviews-filters__search-widget-listitem",
25157 hideOnClick: false,
25158 setValueOnClick: false,
25159 focusOnHover: true,
25160 children: [
25161 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25162 SingleSelectionOption,
25163 {
25164 selected: currentValue === element.value
25165 }
25166 ),
25167 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25168 MultiSelectionOption,
25169 {
25170 selected: currentValue.includes(
25171 element.value
25172 )
25173 }
25174 ),
25175 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
25176 "span",
25177 {
25178 className: "dataviews-filters__search-widget-listitem-value",
25179 title: element.label,
25180 children: [
25181 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
25182 ComboboxItemValue,
25183 {
25184 className: "dataviews-filters__search-widget-filter-combobox-item-value",
25185 value: element.label
25186 }
25187 ),
25188 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
25189 ]
25190 }
25191 )
25192 ]
25193 },
25194 element.value
25195 );
25196 }),
25197 !matches2.length && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("p", { children: (0, import_i18n29.__)("No results found") })
25198 ]
25199 }
25200 )
25201 ]
25202 }
25203 );
25204 }
25205 function SearchWidget(props) {
25206 const { elements, isLoading } = useElements({
25207 elements: props.filter.elements,
25208 getElements: props.filter.getElements
25209 });
25210 if (isLoading) {
25211 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components20.Spinner, {}) });
25212 }
25213 if (elements.length === 0) {
25214 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n29.__)("No elements found") });
25215 }
25216 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
25217 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
25218 }
25219
25220 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
25221 var import_es62 = __toESM(require_es6(), 1);
25222 var import_compose12 = __toESM(require_compose(), 1);
25223 var import_element90 = __toESM(require_element(), 1);
25224 var import_components21 = __toESM(require_components(), 1);
25225 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
25226 function InputWidget({
25227 filter,
25228 view,
25229 onChangeView,
25230 fields: fields2
25231 }) {
25232 const currentFilter = view.filters?.find(
25233 (f2) => f2.field === filter.field
25234 );
25235 const currentValue = getCurrentValue(filter, currentFilter);
25236 const field = (0, import_element90.useMemo)(() => {
25237 const currentField = fields2.find((f2) => f2.id === filter.field);
25238 if (currentField) {
25239 return {
25240 ...currentField,
25241 // Deactivate validation for filters.
25242 isValid: {},
25243 // Filter controls are always enabled.
25244 isDisabled: () => false,
25245 // Filter controls are always visible.
25246 isVisible: () => true,
25247 // Configure getValue/setValue as if Item was a plain object.
25248 getValue: ({ item }) => item[currentField.id],
25249 setValue: ({ value }) => ({
25250 [currentField.id]: value
25251 })
25252 };
25253 }
25254 return currentField;
25255 }, [fields2, filter.field]);
25256 const data = (0, import_element90.useMemo)(() => {
25257 return (view.filters ?? []).reduce(
25258 (acc, activeFilter) => {
25259 acc[activeFilter.field] = activeFilter.value;
25260 return acc;
25261 },
25262 {}
25263 );
25264 }, [view.filters]);
25265 const handleChange = (0, import_compose12.useEvent)((updatedData) => {
25266 if (!field || !currentFilter) {
25267 return;
25268 }
25269 const nextValue = field.getValue({ item: updatedData });
25270 if ((0, import_es62.default)(nextValue, currentValue)) {
25271 return;
25272 }
25273 onChangeView({
25274 ...view,
25275 filters: (view.filters ?? []).map(
25276 (_filter) => _filter.field === filter.field ? {
25277 ..._filter,
25278 operator: currentFilter.operator || filter.operators[0],
25279 // Consider empty strings as undefined:
25280 //
25281 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
25282 // - empty string as value means "search empty string": returns only the records that have an empty string as value
25283 //
25284 // In practice, this means the filter will not be able to find an empty string as the value.
25285 value: nextValue === "" ? void 0 : nextValue
25286 } : _filter
25287 )
25288 });
25289 });
25290 if (!field || !field.Edit || !currentFilter) {
25291 return null;
25292 }
25293 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
25294 import_components21.Flex,
25295 {
25296 className: "dataviews-filters__user-input-widget",
25297 gap: 2.5,
25298 direction: "column",
25299 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
25300 field.Edit,
25301 {
25302 hideLabelFromVision: true,
25303 data,
25304 field,
25305 operator: currentFilter.operator,
25306 onChange: handleChange
25307 }
25308 )
25309 }
25310 );
25311 }
25312
25313 // node_modules/date-fns/constants.js
25314 var daysInYear = 365.2425;
25315 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
25316 var minTime = -maxTime;
25317 var millisecondsInWeek = 6048e5;
25318 var millisecondsInDay = 864e5;
25319 var secondsInHour = 3600;
25320 var secondsInDay = secondsInHour * 24;
25321 var secondsInWeek = secondsInDay * 7;
25322 var secondsInYear = secondsInDay * daysInYear;
25323 var secondsInMonth = secondsInYear / 12;
25324 var secondsInQuarter = secondsInMonth * 3;
25325 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
25326
25327 // node_modules/date-fns/constructFrom.js
25328 function constructFrom(date, value) {
25329 if (typeof date === "function") return date(value);
25330 if (date && typeof date === "object" && constructFromSymbol in date)
25331 return date[constructFromSymbol](value);
25332 if (date instanceof Date) return new date.constructor(value);
25333 return new Date(value);
25334 }
25335
25336 // node_modules/date-fns/toDate.js
25337 function toDate(argument, context) {
25338 return constructFrom(context || argument, argument);
25339 }
25340
25341 // node_modules/date-fns/addDays.js
25342 function addDays(date, amount, options) {
25343 const _date = toDate(date, options?.in);
25344 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
25345 if (!amount) return _date;
25346 _date.setDate(_date.getDate() + amount);
25347 return _date;
25348 }
25349
25350 // node_modules/date-fns/addMonths.js
25351 function addMonths(date, amount, options) {
25352 const _date = toDate(date, options?.in);
25353 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
25354 if (!amount) {
25355 return _date;
25356 }
25357 const dayOfMonth = _date.getDate();
25358 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
25359 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
25360 const daysInMonth = endOfDesiredMonth.getDate();
25361 if (dayOfMonth >= daysInMonth) {
25362 return endOfDesiredMonth;
25363 } else {
25364 _date.setFullYear(
25365 endOfDesiredMonth.getFullYear(),
25366 endOfDesiredMonth.getMonth(),
25367 dayOfMonth
25368 );
25369 return _date;
25370 }
25371 }
25372
25373 // node_modules/date-fns/_lib/defaultOptions.js
25374 var defaultOptions = {};
25375 function getDefaultOptions() {
25376 return defaultOptions;
25377 }
25378
25379 // node_modules/date-fns/startOfWeek.js
25380 function startOfWeek(date, options) {
25381 const defaultOptions3 = getDefaultOptions();
25382 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions3.weekStartsOn ?? defaultOptions3.locale?.options?.weekStartsOn ?? 0;
25383 const _date = toDate(date, options?.in);
25384 const day = _date.getDay();
25385 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
25386 _date.setDate(_date.getDate() - diff);
25387 _date.setHours(0, 0, 0, 0);
25388 return _date;
25389 }
25390
25391 // node_modules/date-fns/startOfISOWeek.js
25392 function startOfISOWeek(date, options) {
25393 return startOfWeek(date, { ...options, weekStartsOn: 1 });
25394 }
25395
25396 // node_modules/date-fns/getISOWeekYear.js
25397 function getISOWeekYear(date, options) {
25398 const _date = toDate(date, options?.in);
25399 const year = _date.getFullYear();
25400 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
25401 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
25402 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
25403 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
25404 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
25405 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
25406 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
25407 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
25408 if (_date.getTime() >= startOfNextYear.getTime()) {
25409 return year + 1;
25410 } else if (_date.getTime() >= startOfThisYear.getTime()) {
25411 return year;
25412 } else {
25413 return year - 1;
25414 }
25415 }
25416
25417 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
25418 function getTimezoneOffsetInMilliseconds(date) {
25419 const _date = toDate(date);
25420 const utcDate = new Date(
25421 Date.UTC(
25422 _date.getFullYear(),
25423 _date.getMonth(),
25424 _date.getDate(),
25425 _date.getHours(),
25426 _date.getMinutes(),
25427 _date.getSeconds(),
25428 _date.getMilliseconds()
25429 )
25430 );
25431 utcDate.setUTCFullYear(_date.getFullYear());
25432 return +date - +utcDate;
25433 }
25434
25435 // node_modules/date-fns/_lib/normalizeDates.js
25436 function normalizeDates(context, ...dates) {
25437 const normalize = constructFrom.bind(
25438 null,
25439 context || dates.find((date) => typeof date === "object")
25440 );
25441 return dates.map(normalize);
25442 }
25443
25444 // node_modules/date-fns/startOfDay.js
25445 function startOfDay(date, options) {
25446 const _date = toDate(date, options?.in);
25447 _date.setHours(0, 0, 0, 0);
25448 return _date;
25449 }
25450
25451 // node_modules/date-fns/differenceInCalendarDays.js
25452 function differenceInCalendarDays(laterDate, earlierDate, options) {
25453 const [laterDate_, earlierDate_] = normalizeDates(
25454 options?.in,
25455 laterDate,
25456 earlierDate
25457 );
25458 const laterStartOfDay = startOfDay(laterDate_);
25459 const earlierStartOfDay = startOfDay(earlierDate_);
25460 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
25461 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
25462 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
25463 }
25464
25465 // node_modules/date-fns/startOfISOWeekYear.js
25466 function startOfISOWeekYear(date, options) {
25467 const year = getISOWeekYear(date, options);
25468 const fourthOfJanuary = constructFrom(options?.in || date, 0);
25469 fourthOfJanuary.setFullYear(year, 0, 4);
25470 fourthOfJanuary.setHours(0, 0, 0, 0);
25471 return startOfISOWeek(fourthOfJanuary);
25472 }
25473
25474 // node_modules/date-fns/addWeeks.js
25475 function addWeeks(date, amount, options) {
25476 return addDays(date, amount * 7, options);
25477 }
25478
25479 // node_modules/date-fns/addYears.js
25480 function addYears(date, amount, options) {
25481 return addMonths(date, amount * 12, options);
25482 }
25483
25484 // node_modules/date-fns/isDate.js
25485 function isDate(value) {
25486 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
25487 }
25488
25489 // node_modules/date-fns/isValid.js
25490 function isValid(date) {
25491 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
25492 }
25493
25494 // node_modules/date-fns/startOfMonth.js
25495 function startOfMonth(date, options) {
25496 const _date = toDate(date, options?.in);
25497 _date.setDate(1);
25498 _date.setHours(0, 0, 0, 0);
25499 return _date;
25500 }
25501
25502 // node_modules/date-fns/startOfYear.js
25503 function startOfYear(date, options) {
25504 const date_ = toDate(date, options?.in);
25505 date_.setFullYear(date_.getFullYear(), 0, 1);
25506 date_.setHours(0, 0, 0, 0);
25507 return date_;
25508 }
25509
25510 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
25511 var formatDistanceLocale = {
25512 lessThanXSeconds: {
25513 one: "less than a second",
25514 other: "less than {{count}} seconds"
25515 },
25516 xSeconds: {
25517 one: "1 second",
25518 other: "{{count}} seconds"
25519 },
25520 halfAMinute: "half a minute",
25521 lessThanXMinutes: {
25522 one: "less than a minute",
25523 other: "less than {{count}} minutes"
25524 },
25525 xMinutes: {
25526 one: "1 minute",
25527 other: "{{count}} minutes"
25528 },
25529 aboutXHours: {
25530 one: "about 1 hour",
25531 other: "about {{count}} hours"
25532 },
25533 xHours: {
25534 one: "1 hour",
25535 other: "{{count}} hours"
25536 },
25537 xDays: {
25538 one: "1 day",
25539 other: "{{count}} days"
25540 },
25541 aboutXWeeks: {
25542 one: "about 1 week",
25543 other: "about {{count}} weeks"
25544 },
25545 xWeeks: {
25546 one: "1 week",
25547 other: "{{count}} weeks"
25548 },
25549 aboutXMonths: {
25550 one: "about 1 month",
25551 other: "about {{count}} months"
25552 },
25553 xMonths: {
25554 one: "1 month",
25555 other: "{{count}} months"
25556 },
25557 aboutXYears: {
25558 one: "about 1 year",
25559 other: "about {{count}} years"
25560 },
25561 xYears: {
25562 one: "1 year",
25563 other: "{{count}} years"
25564 },
25565 overXYears: {
25566 one: "over 1 year",
25567 other: "over {{count}} years"
25568 },
25569 almostXYears: {
25570 one: "almost 1 year",
25571 other: "almost {{count}} years"
25572 }
25573 };
25574 var formatDistance = (token, count, options) => {
25575 let result;
25576 const tokenValue = formatDistanceLocale[token];
25577 if (typeof tokenValue === "string") {
25578 result = tokenValue;
25579 } else if (count === 1) {
25580 result = tokenValue.one;
25581 } else {
25582 result = tokenValue.other.replace("{{count}}", count.toString());
25583 }
25584 if (options?.addSuffix) {
25585 if (options.comparison && options.comparison > 0) {
25586 return "in " + result;
25587 } else {
25588 return result + " ago";
25589 }
25590 }
25591 return result;
25592 };
25593
25594 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
25595 function buildFormatLongFn(args) {
25596 return (options = {}) => {
25597 const width = options.width ? String(options.width) : args.defaultWidth;
25598 const format6 = args.formats[width] || args.formats[args.defaultWidth];
25599 return format6;
25600 };
25601 }
25602
25603 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
25604 var dateFormats = {
25605 full: "EEEE, MMMM do, y",
25606 long: "MMMM do, y",
25607 medium: "MMM d, y",
25608 short: "MM/dd/yyyy"
25609 };
25610 var timeFormats = {
25611 full: "h:mm:ss a zzzz",
25612 long: "h:mm:ss a z",
25613 medium: "h:mm:ss a",
25614 short: "h:mm a"
25615 };
25616 var dateTimeFormats = {
25617 full: "{{date}} 'at' {{time}}",
25618 long: "{{date}} 'at' {{time}}",
25619 medium: "{{date}}, {{time}}",
25620 short: "{{date}}, {{time}}"
25621 };
25622 var formatLong = {
25623 date: buildFormatLongFn({
25624 formats: dateFormats,
25625 defaultWidth: "full"
25626 }),
25627 time: buildFormatLongFn({
25628 formats: timeFormats,
25629 defaultWidth: "full"
25630 }),
25631 dateTime: buildFormatLongFn({
25632 formats: dateTimeFormats,
25633 defaultWidth: "full"
25634 })
25635 };
25636
25637 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
25638 var formatRelativeLocale = {
25639 lastWeek: "'last' eeee 'at' p",
25640 yesterday: "'yesterday at' p",
25641 today: "'today at' p",
25642 tomorrow: "'tomorrow at' p",
25643 nextWeek: "eeee 'at' p",
25644 other: "P"
25645 };
25646 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
25647
25648 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
25649 function buildLocalizeFn(args) {
25650 return (value, options) => {
25651 const context = options?.context ? String(options.context) : "standalone";
25652 let valuesArray;
25653 if (context === "formatting" && args.formattingValues) {
25654 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
25655 const width = options?.width ? String(options.width) : defaultWidth;
25656 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
25657 } else {
25658 const defaultWidth = args.defaultWidth;
25659 const width = options?.width ? String(options.width) : args.defaultWidth;
25660 valuesArray = args.values[width] || args.values[defaultWidth];
25661 }
25662 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
25663 return valuesArray[index2];
25664 };
25665 }
25666
25667 // node_modules/date-fns/locale/en-US/_lib/localize.js
25668 var eraValues = {
25669 narrow: ["B", "A"],
25670 abbreviated: ["BC", "AD"],
25671 wide: ["Before Christ", "Anno Domini"]
25672 };
25673 var quarterValues = {
25674 narrow: ["1", "2", "3", "4"],
25675 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
25676 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
25677 };
25678 var monthValues = {
25679 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
25680 abbreviated: [
25681 "Jan",
25682 "Feb",
25683 "Mar",
25684 "Apr",
25685 "May",
25686 "Jun",
25687 "Jul",
25688 "Aug",
25689 "Sep",
25690 "Oct",
25691 "Nov",
25692 "Dec"
25693 ],
25694 wide: [
25695 "January",
25696 "February",
25697 "March",
25698 "April",
25699 "May",
25700 "June",
25701 "July",
25702 "August",
25703 "September",
25704 "October",
25705 "November",
25706 "December"
25707 ]
25708 };
25709 var dayValues = {
25710 narrow: ["S", "M", "T", "W", "T", "F", "S"],
25711 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
25712 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
25713 wide: [
25714 "Sunday",
25715 "Monday",
25716 "Tuesday",
25717 "Wednesday",
25718 "Thursday",
25719 "Friday",
25720 "Saturday"
25721 ]
25722 };
25723 var dayPeriodValues = {
25724 narrow: {
25725 am: "a",
25726 pm: "p",
25727 midnight: "mi",
25728 noon: "n",
25729 morning: "morning",
25730 afternoon: "afternoon",
25731 evening: "evening",
25732 night: "night"
25733 },
25734 abbreviated: {
25735 am: "AM",
25736 pm: "PM",
25737 midnight: "midnight",
25738 noon: "noon",
25739 morning: "morning",
25740 afternoon: "afternoon",
25741 evening: "evening",
25742 night: "night"
25743 },
25744 wide: {
25745 am: "a.m.",
25746 pm: "p.m.",
25747 midnight: "midnight",
25748 noon: "noon",
25749 morning: "morning",
25750 afternoon: "afternoon",
25751 evening: "evening",
25752 night: "night"
25753 }
25754 };
25755 var formattingDayPeriodValues = {
25756 narrow: {
25757 am: "a",
25758 pm: "p",
25759 midnight: "mi",
25760 noon: "n",
25761 morning: "in the morning",
25762 afternoon: "in the afternoon",
25763 evening: "in the evening",
25764 night: "at night"
25765 },
25766 abbreviated: {
25767 am: "AM",
25768 pm: "PM",
25769 midnight: "midnight",
25770 noon: "noon",
25771 morning: "in the morning",
25772 afternoon: "in the afternoon",
25773 evening: "in the evening",
25774 night: "at night"
25775 },
25776 wide: {
25777 am: "a.m.",
25778 pm: "p.m.",
25779 midnight: "midnight",
25780 noon: "noon",
25781 morning: "in the morning",
25782 afternoon: "in the afternoon",
25783 evening: "in the evening",
25784 night: "at night"
25785 }
25786 };
25787 var ordinalNumber = (dirtyNumber, _options) => {
25788 const number = Number(dirtyNumber);
25789 const rem100 = number % 100;
25790 if (rem100 > 20 || rem100 < 10) {
25791 switch (rem100 % 10) {
25792 case 1:
25793 return number + "st";
25794 case 2:
25795 return number + "nd";
25796 case 3:
25797 return number + "rd";
25798 }
25799 }
25800 return number + "th";
25801 };
25802 var localize = {
25803 ordinalNumber,
25804 era: buildLocalizeFn({
25805 values: eraValues,
25806 defaultWidth: "wide"
25807 }),
25808 quarter: buildLocalizeFn({
25809 values: quarterValues,
25810 defaultWidth: "wide",
25811 argumentCallback: (quarter) => quarter - 1
25812 }),
25813 month: buildLocalizeFn({
25814 values: monthValues,
25815 defaultWidth: "wide"
25816 }),
25817 day: buildLocalizeFn({
25818 values: dayValues,
25819 defaultWidth: "wide"
25820 }),
25821 dayPeriod: buildLocalizeFn({
25822 values: dayPeriodValues,
25823 defaultWidth: "wide",
25824 formattingValues: formattingDayPeriodValues,
25825 defaultFormattingWidth: "wide"
25826 })
25827 };
25828
25829 // node_modules/date-fns/locale/_lib/buildMatchFn.js
25830 function buildMatchFn(args) {
25831 return (string, options = {}) => {
25832 const width = options.width;
25833 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
25834 const matchResult = string.match(matchPattern);
25835 if (!matchResult) {
25836 return null;
25837 }
25838 const matchedString = matchResult[0];
25839 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
25840 const key2 = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
25841 // [TODO] -- I challenge you to fix the type
25842 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
25843 );
25844 let value;
25845 value = args.valueCallback ? args.valueCallback(key2) : key2;
25846 value = options.valueCallback ? (
25847 // [TODO] -- I challenge you to fix the type
25848 options.valueCallback(value)
25849 ) : value;
25850 const rest = string.slice(matchedString.length);
25851 return { value, rest };
25852 };
25853 }
25854 function findKey(object, predicate) {
25855 for (const key2 in object) {
25856 if (Object.prototype.hasOwnProperty.call(object, key2) && predicate(object[key2])) {
25857 return key2;
25858 }
25859 }
25860 return void 0;
25861 }
25862 function findIndex(array, predicate) {
25863 for (let key2 = 0; key2 < array.length; key2++) {
25864 if (predicate(array[key2])) {
25865 return key2;
25866 }
25867 }
25868 return void 0;
25869 }
25870
25871 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
25872 function buildMatchPatternFn(args) {
25873 return (string, options = {}) => {
25874 const matchResult = string.match(args.matchPattern);
25875 if (!matchResult) return null;
25876 const matchedString = matchResult[0];
25877 const parseResult = string.match(args.parsePattern);
25878 if (!parseResult) return null;
25879 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
25880 value = options.valueCallback ? options.valueCallback(value) : value;
25881 const rest = string.slice(matchedString.length);
25882 return { value, rest };
25883 };
25884 }
25885
25886 // node_modules/date-fns/locale/en-US/_lib/match.js
25887 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
25888 var parseOrdinalNumberPattern = /\d+/i;
25889 var matchEraPatterns = {
25890 narrow: /^(b|a)/i,
25891 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
25892 wide: /^(before christ|before common era|anno domini|common era)/i
25893 };
25894 var parseEraPatterns = {
25895 any: [/^b/i, /^(a|c)/i]
25896 };
25897 var matchQuarterPatterns = {
25898 narrow: /^[1234]/i,
25899 abbreviated: /^q[1234]/i,
25900 wide: /^[1234](th|st|nd|rd)? quarter/i
25901 };
25902 var parseQuarterPatterns = {
25903 any: [/1/i, /2/i, /3/i, /4/i]
25904 };
25905 var matchMonthPatterns = {
25906 narrow: /^[jfmasond]/i,
25907 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
25908 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
25909 };
25910 var parseMonthPatterns = {
25911 narrow: [
25912 /^j/i,
25913 /^f/i,
25914 /^m/i,
25915 /^a/i,
25916 /^m/i,
25917 /^j/i,
25918 /^j/i,
25919 /^a/i,
25920 /^s/i,
25921 /^o/i,
25922 /^n/i,
25923 /^d/i
25924 ],
25925 any: [
25926 /^ja/i,
25927 /^f/i,
25928 /^mar/i,
25929 /^ap/i,
25930 /^may/i,
25931 /^jun/i,
25932 /^jul/i,
25933 /^au/i,
25934 /^s/i,
25935 /^o/i,
25936 /^n/i,
25937 /^d/i
25938 ]
25939 };
25940 var matchDayPatterns = {
25941 narrow: /^[smtwf]/i,
25942 short: /^(su|mo|tu|we|th|fr|sa)/i,
25943 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
25944 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
25945 };
25946 var parseDayPatterns = {
25947 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
25948 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
25949 };
25950 var matchDayPeriodPatterns = {
25951 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
25952 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
25953 };
25954 var parseDayPeriodPatterns = {
25955 any: {
25956 am: /^a/i,
25957 pm: /^p/i,
25958 midnight: /^mi/i,
25959 noon: /^no/i,
25960 morning: /morning/i,
25961 afternoon: /afternoon/i,
25962 evening: /evening/i,
25963 night: /night/i
25964 }
25965 };
25966 var match = {
25967 ordinalNumber: buildMatchPatternFn({
25968 matchPattern: matchOrdinalNumberPattern,
25969 parsePattern: parseOrdinalNumberPattern,
25970 valueCallback: (value) => parseInt(value, 10)
25971 }),
25972 era: buildMatchFn({
25973 matchPatterns: matchEraPatterns,
25974 defaultMatchWidth: "wide",
25975 parsePatterns: parseEraPatterns,
25976 defaultParseWidth: "any"
25977 }),
25978 quarter: buildMatchFn({
25979 matchPatterns: matchQuarterPatterns,
25980 defaultMatchWidth: "wide",
25981 parsePatterns: parseQuarterPatterns,
25982 defaultParseWidth: "any",
25983 valueCallback: (index2) => index2 + 1
25984 }),
25985 month: buildMatchFn({
25986 matchPatterns: matchMonthPatterns,
25987 defaultMatchWidth: "wide",
25988 parsePatterns: parseMonthPatterns,
25989 defaultParseWidth: "any"
25990 }),
25991 day: buildMatchFn({
25992 matchPatterns: matchDayPatterns,
25993 defaultMatchWidth: "wide",
25994 parsePatterns: parseDayPatterns,
25995 defaultParseWidth: "any"
25996 }),
25997 dayPeriod: buildMatchFn({
25998 matchPatterns: matchDayPeriodPatterns,
25999 defaultMatchWidth: "any",
26000 parsePatterns: parseDayPeriodPatterns,
26001 defaultParseWidth: "any"
26002 })
26003 };
26004
26005 // node_modules/date-fns/locale/en-US.js
26006 var enUS = {
26007 code: "en-US",
26008 formatDistance,
26009 formatLong,
26010 formatRelative,
26011 localize,
26012 match,
26013 options: {
26014 weekStartsOn: 0,
26015 firstWeekContainsDate: 1
26016 }
26017 };
26018
26019 // node_modules/date-fns/getDayOfYear.js
26020 function getDayOfYear(date, options) {
26021 const _date = toDate(date, options?.in);
26022 const diff = differenceInCalendarDays(_date, startOfYear(_date));
26023 const dayOfYear = diff + 1;
26024 return dayOfYear;
26025 }
26026
26027 // node_modules/date-fns/getISOWeek.js
26028 function getISOWeek(date, options) {
26029 const _date = toDate(date, options?.in);
26030 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
26031 return Math.round(diff / millisecondsInWeek) + 1;
26032 }
26033
26034 // node_modules/date-fns/getWeekYear.js
26035 function getWeekYear(date, options) {
26036 const _date = toDate(date, options?.in);
26037 const year = _date.getFullYear();
26038 const defaultOptions3 = getDefaultOptions();
26039 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions3.firstWeekContainsDate ?? defaultOptions3.locale?.options?.firstWeekContainsDate ?? 1;
26040 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
26041 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
26042 firstWeekOfNextYear.setHours(0, 0, 0, 0);
26043 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
26044 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
26045 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
26046 firstWeekOfThisYear.setHours(0, 0, 0, 0);
26047 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
26048 if (+_date >= +startOfNextYear) {
26049 return year + 1;
26050 } else if (+_date >= +startOfThisYear) {
26051 return year;
26052 } else {
26053 return year - 1;
26054 }
26055 }
26056
26057 // node_modules/date-fns/startOfWeekYear.js
26058 function startOfWeekYear(date, options) {
26059 const defaultOptions3 = getDefaultOptions();
26060 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions3.firstWeekContainsDate ?? defaultOptions3.locale?.options?.firstWeekContainsDate ?? 1;
26061 const year = getWeekYear(date, options);
26062 const firstWeek = constructFrom(options?.in || date, 0);
26063 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
26064 firstWeek.setHours(0, 0, 0, 0);
26065 const _date = startOfWeek(firstWeek, options);
26066 return _date;
26067 }
26068
26069 // node_modules/date-fns/getWeek.js
26070 function getWeek(date, options) {
26071 const _date = toDate(date, options?.in);
26072 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
26073 return Math.round(diff / millisecondsInWeek) + 1;
26074 }
26075
26076 // node_modules/date-fns/_lib/addLeadingZeros.js
26077 function addLeadingZeros(number, targetLength) {
26078 const sign = number < 0 ? "-" : "";
26079 const output = Math.abs(number).toString().padStart(targetLength, "0");
26080 return sign + output;
26081 }
26082
26083 // node_modules/date-fns/_lib/format/lightFormatters.js
26084 var lightFormatters = {
26085 // Year
26086 y(date, token) {
26087 const signedYear = date.getFullYear();
26088 const year = signedYear > 0 ? signedYear : 1 - signedYear;
26089 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
26090 },
26091 // Month
26092 M(date, token) {
26093 const month = date.getMonth();
26094 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
26095 },
26096 // Day of the month
26097 d(date, token) {
26098 return addLeadingZeros(date.getDate(), token.length);
26099 },
26100 // AM or PM
26101 a(date, token) {
26102 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
26103 switch (token) {
26104 case "a":
26105 case "aa":
26106 return dayPeriodEnumValue.toUpperCase();
26107 case "aaa":
26108 return dayPeriodEnumValue;
26109 case "aaaaa":
26110 return dayPeriodEnumValue[0];
26111 case "aaaa":
26112 default:
26113 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
26114 }
26115 },
26116 // Hour [1-12]
26117 h(date, token) {
26118 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
26119 },
26120 // Hour [0-23]
26121 H(date, token) {
26122 return addLeadingZeros(date.getHours(), token.length);
26123 },
26124 // Minute
26125 m(date, token) {
26126 return addLeadingZeros(date.getMinutes(), token.length);
26127 },
26128 // Second
26129 s(date, token) {
26130 return addLeadingZeros(date.getSeconds(), token.length);
26131 },
26132 // Fraction of second
26133 S(date, token) {
26134 const numberOfDigits = token.length;
26135 const milliseconds = date.getMilliseconds();
26136 const fractionalSeconds = Math.trunc(
26137 milliseconds * Math.pow(10, numberOfDigits - 3)
26138 );
26139 return addLeadingZeros(fractionalSeconds, token.length);
26140 }
26141 };
26142
26143 // node_modules/date-fns/_lib/format/formatters.js
26144 var dayPeriodEnum = {
26145 am: "am",
26146 pm: "pm",
26147 midnight: "midnight",
26148 noon: "noon",
26149 morning: "morning",
26150 afternoon: "afternoon",
26151 evening: "evening",
26152 night: "night"
26153 };
26154 var formatters = {
26155 // Era
26156 G: function(date, token, localize2) {
26157 const era = date.getFullYear() > 0 ? 1 : 0;
26158 switch (token) {
26159 // AD, BC
26160 case "G":
26161 case "GG":
26162 case "GGG":
26163 return localize2.era(era, { width: "abbreviated" });
26164 // A, B
26165 case "GGGGG":
26166 return localize2.era(era, { width: "narrow" });
26167 // Anno Domini, Before Christ
26168 case "GGGG":
26169 default:
26170 return localize2.era(era, { width: "wide" });
26171 }
26172 },
26173 // Year
26174 y: function(date, token, localize2) {
26175 if (token === "yo") {
26176 const signedYear = date.getFullYear();
26177 const year = signedYear > 0 ? signedYear : 1 - signedYear;
26178 return localize2.ordinalNumber(year, { unit: "year" });
26179 }
26180 return lightFormatters.y(date, token);
26181 },
26182 // Local week-numbering year
26183 Y: function(date, token, localize2, options) {
26184 const signedWeekYear = getWeekYear(date, options);
26185 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
26186 if (token === "YY") {
26187 const twoDigitYear = weekYear % 100;
26188 return addLeadingZeros(twoDigitYear, 2);
26189 }
26190 if (token === "Yo") {
26191 return localize2.ordinalNumber(weekYear, { unit: "year" });
26192 }
26193 return addLeadingZeros(weekYear, token.length);
26194 },
26195 // ISO week-numbering year
26196 R: function(date, token) {
26197 const isoWeekYear = getISOWeekYear(date);
26198 return addLeadingZeros(isoWeekYear, token.length);
26199 },
26200 // Extended year. This is a single number designating the year of this calendar system.
26201 // The main difference between `y` and `u` localizers are B.C. years:
26202 // | Year | `y` | `u` |
26203 // |------|-----|-----|
26204 // | AC 1 | 1 | 1 |
26205 // | BC 1 | 1 | 0 |
26206 // | BC 2 | 2 | -1 |
26207 // Also `yy` always returns the last two digits of a year,
26208 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
26209 u: function(date, token) {
26210 const year = date.getFullYear();
26211 return addLeadingZeros(year, token.length);
26212 },
26213 // Quarter
26214 Q: function(date, token, localize2) {
26215 const quarter = Math.ceil((date.getMonth() + 1) / 3);
26216 switch (token) {
26217 // 1, 2, 3, 4
26218 case "Q":
26219 return String(quarter);
26220 // 01, 02, 03, 04
26221 case "QQ":
26222 return addLeadingZeros(quarter, 2);
26223 // 1st, 2nd, 3rd, 4th
26224 case "Qo":
26225 return localize2.ordinalNumber(quarter, { unit: "quarter" });
26226 // Q1, Q2, Q3, Q4
26227 case "QQQ":
26228 return localize2.quarter(quarter, {
26229 width: "abbreviated",
26230 context: "formatting"
26231 });
26232 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
26233 case "QQQQQ":
26234 return localize2.quarter(quarter, {
26235 width: "narrow",
26236 context: "formatting"
26237 });
26238 // 1st quarter, 2nd quarter, ...
26239 case "QQQQ":
26240 default:
26241 return localize2.quarter(quarter, {
26242 width: "wide",
26243 context: "formatting"
26244 });
26245 }
26246 },
26247 // Stand-alone quarter
26248 q: function(date, token, localize2) {
26249 const quarter = Math.ceil((date.getMonth() + 1) / 3);
26250 switch (token) {
26251 // 1, 2, 3, 4
26252 case "q":
26253 return String(quarter);
26254 // 01, 02, 03, 04
26255 case "qq":
26256 return addLeadingZeros(quarter, 2);
26257 // 1st, 2nd, 3rd, 4th
26258 case "qo":
26259 return localize2.ordinalNumber(quarter, { unit: "quarter" });
26260 // Q1, Q2, Q3, Q4
26261 case "qqq":
26262 return localize2.quarter(quarter, {
26263 width: "abbreviated",
26264 context: "standalone"
26265 });
26266 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
26267 case "qqqqq":
26268 return localize2.quarter(quarter, {
26269 width: "narrow",
26270 context: "standalone"
26271 });
26272 // 1st quarter, 2nd quarter, ...
26273 case "qqqq":
26274 default:
26275 return localize2.quarter(quarter, {
26276 width: "wide",
26277 context: "standalone"
26278 });
26279 }
26280 },
26281 // Month
26282 M: function(date, token, localize2) {
26283 const month = date.getMonth();
26284 switch (token) {
26285 case "M":
26286 case "MM":
26287 return lightFormatters.M(date, token);
26288 // 1st, 2nd, ..., 12th
26289 case "Mo":
26290 return localize2.ordinalNumber(month + 1, { unit: "month" });
26291 // Jan, Feb, ..., Dec
26292 case "MMM":
26293 return localize2.month(month, {
26294 width: "abbreviated",
26295 context: "formatting"
26296 });
26297 // J, F, ..., D
26298 case "MMMMM":
26299 return localize2.month(month, {
26300 width: "narrow",
26301 context: "formatting"
26302 });
26303 // January, February, ..., December
26304 case "MMMM":
26305 default:
26306 return localize2.month(month, { width: "wide", context: "formatting" });
26307 }
26308 },
26309 // Stand-alone month
26310 L: function(date, token, localize2) {
26311 const month = date.getMonth();
26312 switch (token) {
26313 // 1, 2, ..., 12
26314 case "L":
26315 return String(month + 1);
26316 // 01, 02, ..., 12
26317 case "LL":
26318 return addLeadingZeros(month + 1, 2);
26319 // 1st, 2nd, ..., 12th
26320 case "Lo":
26321 return localize2.ordinalNumber(month + 1, { unit: "month" });
26322 // Jan, Feb, ..., Dec
26323 case "LLL":
26324 return localize2.month(month, {
26325 width: "abbreviated",
26326 context: "standalone"
26327 });
26328 // J, F, ..., D
26329 case "LLLLL":
26330 return localize2.month(month, {
26331 width: "narrow",
26332 context: "standalone"
26333 });
26334 // January, February, ..., December
26335 case "LLLL":
26336 default:
26337 return localize2.month(month, { width: "wide", context: "standalone" });
26338 }
26339 },
26340 // Local week of year
26341 w: function(date, token, localize2, options) {
26342 const week = getWeek(date, options);
26343 if (token === "wo") {
26344 return localize2.ordinalNumber(week, { unit: "week" });
26345 }
26346 return addLeadingZeros(week, token.length);
26347 },
26348 // ISO week of year
26349 I: function(date, token, localize2) {
26350 const isoWeek = getISOWeek(date);
26351 if (token === "Io") {
26352 return localize2.ordinalNumber(isoWeek, { unit: "week" });
26353 }
26354 return addLeadingZeros(isoWeek, token.length);
26355 },
26356 // Day of the month
26357 d: function(date, token, localize2) {
26358 if (token === "do") {
26359 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
26360 }
26361 return lightFormatters.d(date, token);
26362 },
26363 // Day of year
26364 D: function(date, token, localize2) {
26365 const dayOfYear = getDayOfYear(date);
26366 if (token === "Do") {
26367 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
26368 }
26369 return addLeadingZeros(dayOfYear, token.length);
26370 },
26371 // Day of week
26372 E: function(date, token, localize2) {
26373 const dayOfWeek = date.getDay();
26374 switch (token) {
26375 // Tue
26376 case "E":
26377 case "EE":
26378 case "EEE":
26379 return localize2.day(dayOfWeek, {
26380 width: "abbreviated",
26381 context: "formatting"
26382 });
26383 // T
26384 case "EEEEE":
26385 return localize2.day(dayOfWeek, {
26386 width: "narrow",
26387 context: "formatting"
26388 });
26389 // Tu
26390 case "EEEEEE":
26391 return localize2.day(dayOfWeek, {
26392 width: "short",
26393 context: "formatting"
26394 });
26395 // Tuesday
26396 case "EEEE":
26397 default:
26398 return localize2.day(dayOfWeek, {
26399 width: "wide",
26400 context: "formatting"
26401 });
26402 }
26403 },
26404 // Local day of week
26405 e: function(date, token, localize2, options) {
26406 const dayOfWeek = date.getDay();
26407 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
26408 switch (token) {
26409 // Numerical value (Nth day of week with current locale or weekStartsOn)
26410 case "e":
26411 return String(localDayOfWeek);
26412 // Padded numerical value
26413 case "ee":
26414 return addLeadingZeros(localDayOfWeek, 2);
26415 // 1st, 2nd, ..., 7th
26416 case "eo":
26417 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
26418 case "eee":
26419 return localize2.day(dayOfWeek, {
26420 width: "abbreviated",
26421 context: "formatting"
26422 });
26423 // T
26424 case "eeeee":
26425 return localize2.day(dayOfWeek, {
26426 width: "narrow",
26427 context: "formatting"
26428 });
26429 // Tu
26430 case "eeeeee":
26431 return localize2.day(dayOfWeek, {
26432 width: "short",
26433 context: "formatting"
26434 });
26435 // Tuesday
26436 case "eeee":
26437 default:
26438 return localize2.day(dayOfWeek, {
26439 width: "wide",
26440 context: "formatting"
26441 });
26442 }
26443 },
26444 // Stand-alone local day of week
26445 c: function(date, token, localize2, options) {
26446 const dayOfWeek = date.getDay();
26447 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
26448 switch (token) {
26449 // Numerical value (same as in `e`)
26450 case "c":
26451 return String(localDayOfWeek);
26452 // Padded numerical value
26453 case "cc":
26454 return addLeadingZeros(localDayOfWeek, token.length);
26455 // 1st, 2nd, ..., 7th
26456 case "co":
26457 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
26458 case "ccc":
26459 return localize2.day(dayOfWeek, {
26460 width: "abbreviated",
26461 context: "standalone"
26462 });
26463 // T
26464 case "ccccc":
26465 return localize2.day(dayOfWeek, {
26466 width: "narrow",
26467 context: "standalone"
26468 });
26469 // Tu
26470 case "cccccc":
26471 return localize2.day(dayOfWeek, {
26472 width: "short",
26473 context: "standalone"
26474 });
26475 // Tuesday
26476 case "cccc":
26477 default:
26478 return localize2.day(dayOfWeek, {
26479 width: "wide",
26480 context: "standalone"
26481 });
26482 }
26483 },
26484 // ISO day of week
26485 i: function(date, token, localize2) {
26486 const dayOfWeek = date.getDay();
26487 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
26488 switch (token) {
26489 // 2
26490 case "i":
26491 return String(isoDayOfWeek);
26492 // 02
26493 case "ii":
26494 return addLeadingZeros(isoDayOfWeek, token.length);
26495 // 2nd
26496 case "io":
26497 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
26498 // Tue
26499 case "iii":
26500 return localize2.day(dayOfWeek, {
26501 width: "abbreviated",
26502 context: "formatting"
26503 });
26504 // T
26505 case "iiiii":
26506 return localize2.day(dayOfWeek, {
26507 width: "narrow",
26508 context: "formatting"
26509 });
26510 // Tu
26511 case "iiiiii":
26512 return localize2.day(dayOfWeek, {
26513 width: "short",
26514 context: "formatting"
26515 });
26516 // Tuesday
26517 case "iiii":
26518 default:
26519 return localize2.day(dayOfWeek, {
26520 width: "wide",
26521 context: "formatting"
26522 });
26523 }
26524 },
26525 // AM or PM
26526 a: function(date, token, localize2) {
26527 const hours = date.getHours();
26528 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
26529 switch (token) {
26530 case "a":
26531 case "aa":
26532 return localize2.dayPeriod(dayPeriodEnumValue, {
26533 width: "abbreviated",
26534 context: "formatting"
26535 });
26536 case "aaa":
26537 return localize2.dayPeriod(dayPeriodEnumValue, {
26538 width: "abbreviated",
26539 context: "formatting"
26540 }).toLowerCase();
26541 case "aaaaa":
26542 return localize2.dayPeriod(dayPeriodEnumValue, {
26543 width: "narrow",
26544 context: "formatting"
26545 });
26546 case "aaaa":
26547 default:
26548 return localize2.dayPeriod(dayPeriodEnumValue, {
26549 width: "wide",
26550 context: "formatting"
26551 });
26552 }
26553 },
26554 // AM, PM, midnight, noon
26555 b: function(date, token, localize2) {
26556 const hours = date.getHours();
26557 let dayPeriodEnumValue;
26558 if (hours === 12) {
26559 dayPeriodEnumValue = dayPeriodEnum.noon;
26560 } else if (hours === 0) {
26561 dayPeriodEnumValue = dayPeriodEnum.midnight;
26562 } else {
26563 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
26564 }
26565 switch (token) {
26566 case "b":
26567 case "bb":
26568 return localize2.dayPeriod(dayPeriodEnumValue, {
26569 width: "abbreviated",
26570 context: "formatting"
26571 });
26572 case "bbb":
26573 return localize2.dayPeriod(dayPeriodEnumValue, {
26574 width: "abbreviated",
26575 context: "formatting"
26576 }).toLowerCase();
26577 case "bbbbb":
26578 return localize2.dayPeriod(dayPeriodEnumValue, {
26579 width: "narrow",
26580 context: "formatting"
26581 });
26582 case "bbbb":
26583 default:
26584 return localize2.dayPeriod(dayPeriodEnumValue, {
26585 width: "wide",
26586 context: "formatting"
26587 });
26588 }
26589 },
26590 // in the morning, in the afternoon, in the evening, at night
26591 B: function(date, token, localize2) {
26592 const hours = date.getHours();
26593 let dayPeriodEnumValue;
26594 if (hours >= 17) {
26595 dayPeriodEnumValue = dayPeriodEnum.evening;
26596 } else if (hours >= 12) {
26597 dayPeriodEnumValue = dayPeriodEnum.afternoon;
26598 } else if (hours >= 4) {
26599 dayPeriodEnumValue = dayPeriodEnum.morning;
26600 } else {
26601 dayPeriodEnumValue = dayPeriodEnum.night;
26602 }
26603 switch (token) {
26604 case "B":
26605 case "BB":
26606 case "BBB":
26607 return localize2.dayPeriod(dayPeriodEnumValue, {
26608 width: "abbreviated",
26609 context: "formatting"
26610 });
26611 case "BBBBB":
26612 return localize2.dayPeriod(dayPeriodEnumValue, {
26613 width: "narrow",
26614 context: "formatting"
26615 });
26616 case "BBBB":
26617 default:
26618 return localize2.dayPeriod(dayPeriodEnumValue, {
26619 width: "wide",
26620 context: "formatting"
26621 });
26622 }
26623 },
26624 // Hour [1-12]
26625 h: function(date, token, localize2) {
26626 if (token === "ho") {
26627 let hours = date.getHours() % 12;
26628 if (hours === 0) hours = 12;
26629 return localize2.ordinalNumber(hours, { unit: "hour" });
26630 }
26631 return lightFormatters.h(date, token);
26632 },
26633 // Hour [0-23]
26634 H: function(date, token, localize2) {
26635 if (token === "Ho") {
26636 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
26637 }
26638 return lightFormatters.H(date, token);
26639 },
26640 // Hour [0-11]
26641 K: function(date, token, localize2) {
26642 const hours = date.getHours() % 12;
26643 if (token === "Ko") {
26644 return localize2.ordinalNumber(hours, { unit: "hour" });
26645 }
26646 return addLeadingZeros(hours, token.length);
26647 },
26648 // Hour [1-24]
26649 k: function(date, token, localize2) {
26650 let hours = date.getHours();
26651 if (hours === 0) hours = 24;
26652 if (token === "ko") {
26653 return localize2.ordinalNumber(hours, { unit: "hour" });
26654 }
26655 return addLeadingZeros(hours, token.length);
26656 },
26657 // Minute
26658 m: function(date, token, localize2) {
26659 if (token === "mo") {
26660 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
26661 }
26662 return lightFormatters.m(date, token);
26663 },
26664 // Second
26665 s: function(date, token, localize2) {
26666 if (token === "so") {
26667 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
26668 }
26669 return lightFormatters.s(date, token);
26670 },
26671 // Fraction of second
26672 S: function(date, token) {
26673 return lightFormatters.S(date, token);
26674 },
26675 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
26676 X: function(date, token, _localize) {
26677 const timezoneOffset = date.getTimezoneOffset();
26678 if (timezoneOffset === 0) {
26679 return "Z";
26680 }
26681 switch (token) {
26682 // Hours and optional minutes
26683 case "X":
26684 return formatTimezoneWithOptionalMinutes(timezoneOffset);
26685 // Hours, minutes and optional seconds without `:` delimiter
26686 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26687 // so this token always has the same output as `XX`
26688 case "XXXX":
26689 case "XX":
26690 return formatTimezone(timezoneOffset);
26691 // Hours, minutes and optional seconds with `:` delimiter
26692 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26693 // so this token always has the same output as `XXX`
26694 case "XXXXX":
26695 case "XXX":
26696 // Hours and minutes with `:` delimiter
26697 default:
26698 return formatTimezone(timezoneOffset, ":");
26699 }
26700 },
26701 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
26702 x: function(date, token, _localize) {
26703 const timezoneOffset = date.getTimezoneOffset();
26704 switch (token) {
26705 // Hours and optional minutes
26706 case "x":
26707 return formatTimezoneWithOptionalMinutes(timezoneOffset);
26708 // Hours, minutes and optional seconds without `:` delimiter
26709 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26710 // so this token always has the same output as `xx`
26711 case "xxxx":
26712 case "xx":
26713 return formatTimezone(timezoneOffset);
26714 // Hours, minutes and optional seconds with `:` delimiter
26715 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26716 // so this token always has the same output as `xxx`
26717 case "xxxxx":
26718 case "xxx":
26719 // Hours and minutes with `:` delimiter
26720 default:
26721 return formatTimezone(timezoneOffset, ":");
26722 }
26723 },
26724 // Timezone (GMT)
26725 O: function(date, token, _localize) {
26726 const timezoneOffset = date.getTimezoneOffset();
26727 switch (token) {
26728 // Short
26729 case "O":
26730 case "OO":
26731 case "OOO":
26732 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
26733 // Long
26734 case "OOOO":
26735 default:
26736 return "GMT" + formatTimezone(timezoneOffset, ":");
26737 }
26738 },
26739 // Timezone (specific non-location)
26740 z: function(date, token, _localize) {
26741 const timezoneOffset = date.getTimezoneOffset();
26742 switch (token) {
26743 // Short
26744 case "z":
26745 case "zz":
26746 case "zzz":
26747 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
26748 // Long
26749 case "zzzz":
26750 default:
26751 return "GMT" + formatTimezone(timezoneOffset, ":");
26752 }
26753 },
26754 // Seconds timestamp
26755 t: function(date, token, _localize) {
26756 const timestamp = Math.trunc(+date / 1e3);
26757 return addLeadingZeros(timestamp, token.length);
26758 },
26759 // Milliseconds timestamp
26760 T: function(date, token, _localize) {
26761 return addLeadingZeros(+date, token.length);
26762 }
26763 };
26764 function formatTimezoneShort(offset4, delimiter = "") {
26765 const sign = offset4 > 0 ? "-" : "+";
26766 const absOffset = Math.abs(offset4);
26767 const hours = Math.trunc(absOffset / 60);
26768 const minutes = absOffset % 60;
26769 if (minutes === 0) {
26770 return sign + String(hours);
26771 }
26772 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
26773 }
26774 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
26775 if (offset4 % 60 === 0) {
26776 const sign = offset4 > 0 ? "-" : "+";
26777 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
26778 }
26779 return formatTimezone(offset4, delimiter);
26780 }
26781 function formatTimezone(offset4, delimiter = "") {
26782 const sign = offset4 > 0 ? "-" : "+";
26783 const absOffset = Math.abs(offset4);
26784 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
26785 const minutes = addLeadingZeros(absOffset % 60, 2);
26786 return sign + hours + delimiter + minutes;
26787 }
26788
26789 // node_modules/date-fns/_lib/format/longFormatters.js
26790 var dateLongFormatter = (pattern, formatLong2) => {
26791 switch (pattern) {
26792 case "P":
26793 return formatLong2.date({ width: "short" });
26794 case "PP":
26795 return formatLong2.date({ width: "medium" });
26796 case "PPP":
26797 return formatLong2.date({ width: "long" });
26798 case "PPPP":
26799 default:
26800 return formatLong2.date({ width: "full" });
26801 }
26802 };
26803 var timeLongFormatter = (pattern, formatLong2) => {
26804 switch (pattern) {
26805 case "p":
26806 return formatLong2.time({ width: "short" });
26807 case "pp":
26808 return formatLong2.time({ width: "medium" });
26809 case "ppp":
26810 return formatLong2.time({ width: "long" });
26811 case "pppp":
26812 default:
26813 return formatLong2.time({ width: "full" });
26814 }
26815 };
26816 var dateTimeLongFormatter = (pattern, formatLong2) => {
26817 const matchResult = pattern.match(/(P+)(p+)?/) || [];
26818 const datePattern = matchResult[1];
26819 const timePattern = matchResult[2];
26820 if (!timePattern) {
26821 return dateLongFormatter(pattern, formatLong2);
26822 }
26823 let dateTimeFormat;
26824 switch (datePattern) {
26825 case "P":
26826 dateTimeFormat = formatLong2.dateTime({ width: "short" });
26827 break;
26828 case "PP":
26829 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
26830 break;
26831 case "PPP":
26832 dateTimeFormat = formatLong2.dateTime({ width: "long" });
26833 break;
26834 case "PPPP":
26835 default:
26836 dateTimeFormat = formatLong2.dateTime({ width: "full" });
26837 break;
26838 }
26839 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
26840 };
26841 var longFormatters = {
26842 p: timeLongFormatter,
26843 P: dateTimeLongFormatter
26844 };
26845
26846 // node_modules/date-fns/_lib/protectedTokens.js
26847 var dayOfYearTokenRE = /^D+$/;
26848 var weekYearTokenRE = /^Y+$/;
26849 var throwTokens = ["D", "DD", "YY", "YYYY"];
26850 function isProtectedDayOfYearToken(token) {
26851 return dayOfYearTokenRE.test(token);
26852 }
26853 function isProtectedWeekYearToken(token) {
26854 return weekYearTokenRE.test(token);
26855 }
26856 function warnOrThrowProtectedError(token, format6, input) {
26857 const _message = message(token, format6, input);
26858 console.warn(_message);
26859 if (throwTokens.includes(token)) throw new RangeError(_message);
26860 }
26861 function message(token, format6, input) {
26862 const subject = token[0] === "Y" ? "years" : "days of the month";
26863 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`;
26864 }
26865
26866 // node_modules/date-fns/format.js
26867 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
26868 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
26869 var escapedStringRegExp = /^'([^]*?)'?$/;
26870 var doubleQuoteRegExp = /''/g;
26871 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
26872 function format(date, formatStr, options) {
26873 const defaultOptions3 = getDefaultOptions();
26874 const locale = options?.locale ?? defaultOptions3.locale ?? enUS;
26875 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions3.firstWeekContainsDate ?? defaultOptions3.locale?.options?.firstWeekContainsDate ?? 1;
26876 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions3.weekStartsOn ?? defaultOptions3.locale?.options?.weekStartsOn ?? 0;
26877 const originalDate = toDate(date, options?.in);
26878 if (!isValid(originalDate)) {
26879 throw new RangeError("Invalid time value");
26880 }
26881 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
26882 const firstCharacter = substring[0];
26883 if (firstCharacter === "p" || firstCharacter === "P") {
26884 const longFormatter = longFormatters[firstCharacter];
26885 return longFormatter(substring, locale.formatLong);
26886 }
26887 return substring;
26888 }).join("").match(formattingTokensRegExp).map((substring) => {
26889 if (substring === "''") {
26890 return { isToken: false, value: "'" };
26891 }
26892 const firstCharacter = substring[0];
26893 if (firstCharacter === "'") {
26894 return { isToken: false, value: cleanEscapedString(substring) };
26895 }
26896 if (formatters[firstCharacter]) {
26897 return { isToken: true, value: substring };
26898 }
26899 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
26900 throw new RangeError(
26901 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
26902 );
26903 }
26904 return { isToken: false, value: substring };
26905 });
26906 if (locale.localize.preprocessor) {
26907 parts = locale.localize.preprocessor(originalDate, parts);
26908 }
26909 const formatterOptions = {
26910 firstWeekContainsDate,
26911 weekStartsOn,
26912 locale
26913 };
26914 return parts.map((part) => {
26915 if (!part.isToken) return part.value;
26916 const token = part.value;
26917 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
26918 warnOrThrowProtectedError(token, formatStr, String(date));
26919 }
26920 const formatter = formatters[token[0]];
26921 return formatter(originalDate, token, locale.localize, formatterOptions);
26922 }).join("");
26923 }
26924 function cleanEscapedString(input) {
26925 const matched = input.match(escapedStringRegExp);
26926 if (!matched) {
26927 return input;
26928 }
26929 return matched[1].replace(doubleQuoteRegExp, "'");
26930 }
26931
26932 // node_modules/date-fns/subDays.js
26933 function subDays(date, amount, options) {
26934 return addDays(date, -amount, options);
26935 }
26936
26937 // node_modules/date-fns/subMonths.js
26938 function subMonths(date, amount, options) {
26939 return addMonths(date, -amount, options);
26940 }
26941
26942 // node_modules/date-fns/subWeeks.js
26943 function subWeeks(date, amount, options) {
26944 return addWeeks(date, -amount, options);
26945 }
26946
26947 // node_modules/date-fns/subYears.js
26948 function subYears(date, amount, options) {
26949 return addYears(date, -amount, options);
26950 }
26951
26952 // packages/dataviews/build-module/utils/operators.mjs
26953 var import_i18n30 = __toESM(require_i18n(), 1);
26954 var import_element91 = __toESM(require_element(), 1);
26955 var import_date = __toESM(require_date(), 1);
26956 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26957 var filterTextWrappers = {
26958 Name: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
26959 Value: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
26960 };
26961 function getRelativeDate(value, unit) {
26962 switch (unit) {
26963 case "days":
26964 return subDays(/* @__PURE__ */ new Date(), value);
26965 case "weeks":
26966 return subWeeks(/* @__PURE__ */ new Date(), value);
26967 case "months":
26968 return subMonths(/* @__PURE__ */ new Date(), value);
26969 case "years":
26970 return subYears(/* @__PURE__ */ new Date(), value);
26971 default:
26972 return /* @__PURE__ */ new Date();
26973 }
26974 }
26975 var isNoneOperatorDefinition = {
26976 /* translators: DataViews operator name */
26977 label: (0, import_i18n30.__)("Is none of"),
26978 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
26979 (0, import_i18n30.sprintf)(
26980 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
26981 (0, import_i18n30.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
26982 filter.name,
26983 activeElements.map((element) => element.label).join(", ")
26984 ),
26985 filterTextWrappers
26986 ),
26987 filter: ((item, field, filterValue) => {
26988 if (!filterValue?.length) {
26989 return true;
26990 }
26991 const fieldValue = field.getValue({ item });
26992 if (Array.isArray(fieldValue)) {
26993 return !filterValue.some(
26994 (fv) => fieldValue.includes(fv)
26995 );
26996 } else if (typeof fieldValue === "string") {
26997 return !filterValue.includes(fieldValue);
26998 }
26999 return false;
27000 }),
27001 selection: "multi"
27002 };
27003 var OPERATORS = [
27004 {
27005 name: OPERATOR_IS_ANY,
27006 /* translators: DataViews operator name */
27007 label: (0, import_i18n30.__)("Includes"),
27008 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27009 (0, import_i18n30.sprintf)(
27010 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
27011 (0, import_i18n30.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
27012 filter.name,
27013 activeElements.map((element) => element.label).join(", ")
27014 ),
27015 filterTextWrappers
27016 ),
27017 filter(item, field, filterValue) {
27018 if (!filterValue?.length) {
27019 return true;
27020 }
27021 const fieldValue = field.getValue({ item });
27022 if (Array.isArray(fieldValue)) {
27023 return filterValue.some(
27024 (fv) => fieldValue.includes(fv)
27025 );
27026 } else if (typeof fieldValue === "string") {
27027 return filterValue.includes(fieldValue);
27028 }
27029 return false;
27030 },
27031 selection: "multi"
27032 },
27033 {
27034 name: OPERATOR_IS_NONE,
27035 ...isNoneOperatorDefinition
27036 },
27037 {
27038 name: OPERATOR_IS_ALL,
27039 /* translators: DataViews operator name */
27040 label: (0, import_i18n30.__)("Includes all"),
27041 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27042 (0, import_i18n30.sprintf)(
27043 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
27044 (0, import_i18n30.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
27045 filter.name,
27046 activeElements.map((element) => element.label).join(", ")
27047 ),
27048 filterTextWrappers
27049 ),
27050 filter(item, field, filterValue) {
27051 if (!filterValue?.length) {
27052 return true;
27053 }
27054 return filterValue.every((value) => {
27055 return field.getValue({ item })?.includes(value);
27056 });
27057 },
27058 selection: "multi"
27059 },
27060 {
27061 name: OPERATOR_IS_NOT_ALL,
27062 ...isNoneOperatorDefinition
27063 },
27064 {
27065 name: OPERATOR_BETWEEN,
27066 /* translators: DataViews operator name */
27067 label: (0, import_i18n30.__)("Between (inc)"),
27068 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27069 (0, import_i18n30.sprintf)(
27070 /* 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". */
27071 (0, import_i18n30.__)(
27072 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
27073 ),
27074 filter.name,
27075 activeElements[0].label[0],
27076 activeElements[0].label[1]
27077 ),
27078 filterTextWrappers
27079 ),
27080 filter(item, field, filterValue) {
27081 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
27082 return true;
27083 }
27084 const fieldValue = field.getValue({ item });
27085 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
27086 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
27087 }
27088 return false;
27089 },
27090 selection: "custom"
27091 },
27092 {
27093 name: OPERATOR_IN_THE_PAST,
27094 /* translators: DataViews operator name */
27095 label: (0, import_i18n30.__)("In the past"),
27096 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27097 (0, import_i18n30.sprintf)(
27098 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
27099 (0, import_i18n30.__)(
27100 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
27101 ),
27102 filter.name,
27103 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
27104 ),
27105 filterTextWrappers
27106 ),
27107 filter(item, field, filterValue) {
27108 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
27109 return true;
27110 }
27111 const targetDate = getRelativeDate(
27112 filterValue.value,
27113 filterValue.unit
27114 );
27115 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
27116 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
27117 },
27118 selection: "custom"
27119 },
27120 {
27121 name: OPERATOR_OVER,
27122 /* translators: DataViews operator name */
27123 label: (0, import_i18n30.__)("Over"),
27124 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27125 (0, import_i18n30.sprintf)(
27126 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
27127 (0, import_i18n30.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
27128 filter.name,
27129 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
27130 ),
27131 filterTextWrappers
27132 ),
27133 filter(item, field, filterValue) {
27134 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
27135 return true;
27136 }
27137 const targetDate = getRelativeDate(
27138 filterValue.value,
27139 filterValue.unit
27140 );
27141 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
27142 return fieldValue < targetDate;
27143 },
27144 selection: "custom"
27145 },
27146 {
27147 name: OPERATOR_IS,
27148 /* translators: DataViews operator name */
27149 label: (0, import_i18n30.__)("Is"),
27150 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27151 (0, import_i18n30.sprintf)(
27152 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
27153 (0, import_i18n30.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
27154 filter.name,
27155 activeElements[0].label
27156 ),
27157 filterTextWrappers
27158 ),
27159 filter(item, field, filterValue) {
27160 return filterValue === field.getValue({ item }) || filterValue === void 0;
27161 },
27162 selection: "single"
27163 },
27164 {
27165 name: OPERATOR_IS_NOT,
27166 /* translators: DataViews operator name */
27167 label: (0, import_i18n30.__)("Is not"),
27168 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27169 (0, import_i18n30.sprintf)(
27170 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
27171 (0, import_i18n30.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
27172 filter.name,
27173 activeElements[0].label
27174 ),
27175 filterTextWrappers
27176 ),
27177 filter(item, field, filterValue) {
27178 return filterValue !== field.getValue({ item });
27179 },
27180 selection: "single"
27181 },
27182 {
27183 name: OPERATOR_LESS_THAN,
27184 /* translators: DataViews operator name */
27185 label: (0, import_i18n30.__)("Less than"),
27186 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27187 (0, import_i18n30.sprintf)(
27188 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
27189 (0, import_i18n30.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
27190 filter.name,
27191 activeElements[0].label
27192 ),
27193 filterTextWrappers
27194 ),
27195 filter(item, field, filterValue) {
27196 if (filterValue === void 0) {
27197 return true;
27198 }
27199 const fieldValue = field.getValue({ item });
27200 return fieldValue < filterValue;
27201 },
27202 selection: "single"
27203 },
27204 {
27205 name: OPERATOR_GREATER_THAN,
27206 /* translators: DataViews operator name */
27207 label: (0, import_i18n30.__)("Greater than"),
27208 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27209 (0, import_i18n30.sprintf)(
27210 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
27211 (0, import_i18n30.__)(
27212 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
27213 ),
27214 filter.name,
27215 activeElements[0].label
27216 ),
27217 filterTextWrappers
27218 ),
27219 filter(item, field, filterValue) {
27220 if (filterValue === void 0) {
27221 return true;
27222 }
27223 const fieldValue = field.getValue({ item });
27224 return fieldValue > filterValue;
27225 },
27226 selection: "single"
27227 },
27228 {
27229 name: OPERATOR_LESS_THAN_OR_EQUAL,
27230 /* translators: DataViews operator name */
27231 label: (0, import_i18n30.__)("Less than or equal"),
27232 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27233 (0, import_i18n30.sprintf)(
27234 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
27235 (0, import_i18n30.__)(
27236 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
27237 ),
27238 filter.name,
27239 activeElements[0].label
27240 ),
27241 filterTextWrappers
27242 ),
27243 filter(item, field, filterValue) {
27244 if (filterValue === void 0) {
27245 return true;
27246 }
27247 const fieldValue = field.getValue({ item });
27248 return fieldValue <= filterValue;
27249 },
27250 selection: "single"
27251 },
27252 {
27253 name: OPERATOR_GREATER_THAN_OR_EQUAL,
27254 /* translators: DataViews operator name */
27255 label: (0, import_i18n30.__)("Greater than or equal"),
27256 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27257 (0, import_i18n30.sprintf)(
27258 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
27259 (0, import_i18n30.__)(
27260 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
27261 ),
27262 filter.name,
27263 activeElements[0].label
27264 ),
27265 filterTextWrappers
27266 ),
27267 filter(item, field, filterValue) {
27268 if (filterValue === void 0) {
27269 return true;
27270 }
27271 const fieldValue = field.getValue({ item });
27272 return fieldValue >= filterValue;
27273 },
27274 selection: "single"
27275 },
27276 {
27277 name: OPERATOR_BEFORE,
27278 /* translators: DataViews operator name */
27279 label: (0, import_i18n30.__)("Before"),
27280 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27281 (0, import_i18n30.sprintf)(
27282 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
27283 (0, import_i18n30.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
27284 filter.name,
27285 activeElements[0].label
27286 ),
27287 filterTextWrappers
27288 ),
27289 filter(item, field, filterValue) {
27290 if (filterValue === void 0) {
27291 return true;
27292 }
27293 const filterDate = (0, import_date.getDate)(filterValue);
27294 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27295 return fieldDate < filterDate;
27296 },
27297 selection: "single"
27298 },
27299 {
27300 name: OPERATOR_AFTER,
27301 /* translators: DataViews operator name */
27302 label: (0, import_i18n30.__)("After"),
27303 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27304 (0, import_i18n30.sprintf)(
27305 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
27306 (0, import_i18n30.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
27307 filter.name,
27308 activeElements[0].label
27309 ),
27310 filterTextWrappers
27311 ),
27312 filter(item, field, filterValue) {
27313 if (filterValue === void 0) {
27314 return true;
27315 }
27316 const filterDate = (0, import_date.getDate)(filterValue);
27317 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27318 return fieldDate > filterDate;
27319 },
27320 selection: "single"
27321 },
27322 {
27323 name: OPERATOR_BEFORE_INC,
27324 /* translators: DataViews operator name */
27325 label: (0, import_i18n30.__)("Before (inc)"),
27326 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27327 (0, import_i18n30.sprintf)(
27328 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
27329 (0, import_i18n30.__)(
27330 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
27331 ),
27332 filter.name,
27333 activeElements[0].label
27334 ),
27335 filterTextWrappers
27336 ),
27337 filter(item, field, filterValue) {
27338 if (filterValue === void 0) {
27339 return true;
27340 }
27341 const filterDate = (0, import_date.getDate)(filterValue);
27342 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27343 return fieldDate <= filterDate;
27344 },
27345 selection: "single"
27346 },
27347 {
27348 name: OPERATOR_AFTER_INC,
27349 /* translators: DataViews operator name */
27350 label: (0, import_i18n30.__)("After (inc)"),
27351 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27352 (0, import_i18n30.sprintf)(
27353 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
27354 (0, import_i18n30.__)(
27355 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
27356 ),
27357 filter.name,
27358 activeElements[0].label
27359 ),
27360 filterTextWrappers
27361 ),
27362 filter(item, field, filterValue) {
27363 if (filterValue === void 0) {
27364 return true;
27365 }
27366 const filterDate = (0, import_date.getDate)(filterValue);
27367 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27368 return fieldDate >= filterDate;
27369 },
27370 selection: "single"
27371 },
27372 {
27373 name: OPERATOR_CONTAINS,
27374 /* translators: DataViews operator name */
27375 label: (0, import_i18n30.__)("Contains"),
27376 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27377 (0, import_i18n30.sprintf)(
27378 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
27379 (0, import_i18n30.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
27380 filter.name,
27381 activeElements[0].label
27382 ),
27383 filterTextWrappers
27384 ),
27385 filter(item, field, filterValue) {
27386 if (filterValue === void 0) {
27387 return true;
27388 }
27389 const fieldValue = field.getValue({ item });
27390 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
27391 },
27392 selection: "single"
27393 },
27394 {
27395 name: OPERATOR_NOT_CONTAINS,
27396 /* translators: DataViews operator name */
27397 label: (0, import_i18n30.__)("Doesn't contain"),
27398 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27399 (0, import_i18n30.sprintf)(
27400 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
27401 (0, import_i18n30.__)(
27402 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
27403 ),
27404 filter.name,
27405 activeElements[0].label
27406 ),
27407 filterTextWrappers
27408 ),
27409 filter(item, field, filterValue) {
27410 if (filterValue === void 0) {
27411 return true;
27412 }
27413 const fieldValue = field.getValue({ item });
27414 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
27415 },
27416 selection: "single"
27417 },
27418 {
27419 name: OPERATOR_STARTS_WITH,
27420 /* translators: DataViews operator name */
27421 label: (0, import_i18n30.__)("Starts with"),
27422 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27423 (0, import_i18n30.sprintf)(
27424 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
27425 (0, import_i18n30.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
27426 filter.name,
27427 activeElements[0].label
27428 ),
27429 filterTextWrappers
27430 ),
27431 filter(item, field, filterValue) {
27432 if (filterValue === void 0) {
27433 return true;
27434 }
27435 const fieldValue = field.getValue({ item });
27436 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
27437 },
27438 selection: "single"
27439 },
27440 {
27441 name: OPERATOR_ON,
27442 /* translators: DataViews operator name */
27443 label: (0, import_i18n30.__)("On"),
27444 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27445 (0, import_i18n30.sprintf)(
27446 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
27447 (0, import_i18n30.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
27448 filter.name,
27449 activeElements[0].label
27450 ),
27451 filterTextWrappers
27452 ),
27453 filter(item, field, filterValue) {
27454 if (filterValue === void 0) {
27455 return true;
27456 }
27457 const filterDate = (0, import_date.getDate)(filterValue);
27458 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27459 return filterDate.getTime() === fieldDate.getTime();
27460 },
27461 selection: "single"
27462 },
27463 {
27464 name: OPERATOR_NOT_ON,
27465 /* translators: DataViews operator name */
27466 label: (0, import_i18n30.__)("Not on"),
27467 filterText: (filter, activeElements) => (0, import_element91.createInterpolateElement)(
27468 (0, import_i18n30.sprintf)(
27469 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
27470 (0, import_i18n30.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
27471 filter.name,
27472 activeElements[0].label
27473 ),
27474 filterTextWrappers
27475 ),
27476 filter(item, field, filterValue) {
27477 if (filterValue === void 0) {
27478 return true;
27479 }
27480 const filterDate = (0, import_date.getDate)(filterValue);
27481 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27482 return filterDate.getTime() !== fieldDate.getTime();
27483 },
27484 selection: "single"
27485 }
27486 ];
27487 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
27488 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
27489 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
27490 (op) => op.name === name
27491 );
27492 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
27493
27494 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
27495 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
27496 var ENTER = "Enter";
27497 var SPACE = " ";
27498 var FilterText = ({
27499 activeElements,
27500 filterInView,
27501 filter
27502 }) => {
27503 if (activeElements === void 0 || activeElements.length === 0) {
27504 return filter.name;
27505 }
27506 const operator = getOperatorByName(filterInView?.operator);
27507 if (operator !== void 0) {
27508 return operator.filterText(filter, activeElements);
27509 }
27510 return (0, import_i18n31.sprintf)(
27511 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
27512 (0, import_i18n31.__)("Unknown status for %1$s"),
27513 filter.name
27514 );
27515 };
27516 function OperatorSelector({
27517 filter,
27518 view,
27519 onChangeView
27520 }) {
27521 const operatorOptions = filter.operators?.map((operator) => ({
27522 value: operator,
27523 label: getOperatorByName(operator)?.label || operator
27524 }));
27525 const currentFilter = view.filters?.find(
27526 (_filter) => _filter.field === filter.field
27527 );
27528 const value = currentFilter?.operator || filter.operators[0];
27529 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
27530 Stack,
27531 {
27532 direction: "row",
27533 gap: "sm",
27534 justify: "flex-start",
27535 className: "dataviews-filters__summary-operators-container",
27536 align: "center",
27537 children: [
27538 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(import_components22.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
27539 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27540 import_components22.SelectControl,
27541 {
27542 className: "dataviews-filters__summary-operators-filter-select",
27543 label: (0, import_i18n31.__)("Conditions"),
27544 value,
27545 options: operatorOptions,
27546 onChange: (newValue) => {
27547 const newOperator = newValue;
27548 const currentOperator = currentFilter?.operator;
27549 const newFilters = currentFilter ? [
27550 ...(view.filters ?? []).map(
27551 (_filter) => {
27552 if (_filter.field === filter.field) {
27553 const currentOpSelectionModel = getOperatorByName(
27554 currentOperator
27555 )?.selection;
27556 const newOpSelectionModel = getOperatorByName(
27557 newOperator
27558 )?.selection;
27559 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
27560 currentOpSelectionModel,
27561 newOpSelectionModel
27562 ].includes("custom");
27563 return {
27564 ..._filter,
27565 value: shouldResetValue ? void 0 : _filter.value,
27566 operator: newOperator
27567 };
27568 }
27569 return _filter;
27570 }
27571 )
27572 ] : [
27573 ...view.filters ?? [],
27574 {
27575 field: filter.field,
27576 operator: newOperator,
27577 value: void 0
27578 }
27579 ];
27580 onChangeView({
27581 ...view,
27582 page: 1,
27583 filters: newFilters
27584 });
27585 },
27586 size: "small",
27587 variant: "minimal",
27588 hideLabelFromVision: true
27589 }
27590 )
27591 ]
27592 }
27593 );
27594 }
27595 function Filter({
27596 addFilterRef,
27597 openedFilter,
27598 fields: fields2,
27599 ...commonProps
27600 }) {
27601 const toggleRef = (0, import_element92.useRef)(null);
27602 const { filter, view, onChangeView } = commonProps;
27603 const filterInView = view.filters?.find(
27604 (f2) => f2.field === filter.field
27605 );
27606 let activeElements = [];
27607 const field = (0, import_element92.useMemo)(() => {
27608 const currentField = fields2.find((f2) => f2.id === filter.field);
27609 if (currentField) {
27610 return {
27611 ...currentField,
27612 // Configure getValue as if Item was a plain object.
27613 // See related input-widget.tsx
27614 getValue: ({ item }) => item[currentField.id]
27615 };
27616 }
27617 return currentField;
27618 }, [fields2, filter.field]);
27619 const { elements } = useElements({
27620 elements: filter.elements,
27621 getElements: filter.getElements
27622 });
27623 if (elements.length > 0) {
27624 activeElements = elements.filter((element) => {
27625 if (filter.singleSelection) {
27626 return element.value === filterInView?.value;
27627 }
27628 return filterInView?.value?.includes(element.value);
27629 });
27630 } else if (Array.isArray(filterInView?.value)) {
27631 const label = filterInView.value.map((v2) => {
27632 const formattedValue = field?.getValueFormatted({
27633 item: { [field.id]: v2 },
27634 field
27635 });
27636 return formattedValue || String(v2);
27637 });
27638 activeElements = [
27639 {
27640 value: filterInView.value,
27641 // @ts-ignore
27642 label
27643 }
27644 ];
27645 } else if (typeof filterInView?.value === "object") {
27646 activeElements = [
27647 { value: filterInView.value, label: filterInView.value }
27648 ];
27649 } else if (filterInView?.value !== void 0) {
27650 const label = field !== void 0 ? field.getValueFormatted({
27651 item: { [field.id]: filterInView.value },
27652 field
27653 }) : String(filterInView.value);
27654 activeElements = [
27655 {
27656 value: filterInView.value,
27657 label
27658 }
27659 ];
27660 }
27661 const isPrimary = filter.isPrimary;
27662 const isLocked = filterInView?.isLocked;
27663 const hasValues = !isLocked && filterInView?.value !== void 0;
27664 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
27665 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27666 import_components22.Dropdown,
27667 {
27668 defaultOpen: openedFilter === filter.field,
27669 contentClassName: "dataviews-filters__summary-popover",
27670 popoverProps: { placement: "bottom-start", role: "dialog" },
27671 onClose: () => {
27672 toggleRef.current?.focus();
27673 },
27674 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
27675 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27676 import_components22.Tooltip,
27677 {
27678 text: (0, import_i18n31.sprintf)(
27679 /* translators: 1: Filter name. */
27680 (0, import_i18n31.__)("Filter by: %1$s"),
27681 filter.name.toLowerCase()
27682 ),
27683 placement: "top",
27684 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27685 "div",
27686 {
27687 className: clsx_default(
27688 "dataviews-filters__summary-chip",
27689 {
27690 "has-reset": canResetOrRemove,
27691 "has-values": hasValues,
27692 "is-not-clickable": isLocked
27693 }
27694 ),
27695 role: "button",
27696 tabIndex: isLocked ? -1 : 0,
27697 onClick: () => {
27698 if (!isLocked) {
27699 onToggle();
27700 }
27701 },
27702 onKeyDown: (event) => {
27703 if (!isLocked && [ENTER, SPACE].includes(event.key)) {
27704 onToggle();
27705 event.preventDefault();
27706 }
27707 },
27708 "aria-disabled": isLocked,
27709 "aria-pressed": isOpen,
27710 "aria-expanded": isOpen,
27711 ref: toggleRef,
27712 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27713 FilterText,
27714 {
27715 activeElements,
27716 filterInView,
27717 filter
27718 }
27719 )
27720 }
27721 )
27722 }
27723 ),
27724 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27725 import_components22.Tooltip,
27726 {
27727 text: isPrimary ? (0, import_i18n31.__)("Reset") : (0, import_i18n31.__)("Remove"),
27728 placement: "top",
27729 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27730 "button",
27731 {
27732 className: clsx_default(
27733 "dataviews-filters__summary-chip-remove",
27734 { "has-values": hasValues }
27735 ),
27736 onClick: () => {
27737 onChangeView({
27738 ...view,
27739 page: 1,
27740 filters: view.filters?.filter(
27741 (_filter) => _filter.field !== filter.field
27742 )
27743 });
27744 if (!isPrimary) {
27745 addFilterRef.current?.focus();
27746 } else {
27747 toggleRef.current?.focus();
27748 }
27749 },
27750 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(import_components22.Icon, { icon: close_small_default })
27751 }
27752 )
27753 }
27754 )
27755 ] }),
27756 renderContent: () => {
27757 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
27758 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(OperatorSelector, { ...commonProps }),
27759 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27760 SearchWidget,
27761 {
27762 ...commonProps,
27763 filter: {
27764 ...commonProps.filter,
27765 elements
27766 }
27767 }
27768 ) : /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(InputWidget, { ...commonProps, fields: fields2 })
27769 ] });
27770 }
27771 }
27772 );
27773 }
27774
27775 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
27776 var import_components23 = __toESM(require_components(), 1);
27777 var import_i18n32 = __toESM(require_i18n(), 1);
27778 var import_element93 = __toESM(require_element(), 1);
27779 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
27780 var { Menu: Menu5 } = unlock3(import_components23.privateApis);
27781 function AddFilterMenu({
27782 filters,
27783 view,
27784 onChangeView,
27785 setOpenedFilter,
27786 triggerProps
27787 }) {
27788 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
27789 return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(Menu5, { children: [
27790 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Menu5.TriggerButton, { ...triggerProps }),
27791 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Menu5.Popover, { children: inactiveFilters.map((filter) => {
27792 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
27793 Menu5.Item,
27794 {
27795 onClick: () => {
27796 setOpenedFilter(filter.field);
27797 onChangeView({
27798 ...view,
27799 page: 1,
27800 filters: [
27801 ...view.filters || [],
27802 {
27803 field: filter.field,
27804 value: void 0,
27805 operator: filter.operators[0]
27806 }
27807 ]
27808 });
27809 },
27810 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Menu5.ItemLabel, { children: filter.name })
27811 },
27812 filter.field
27813 );
27814 }) })
27815 ] });
27816 }
27817 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
27818 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
27819 return null;
27820 }
27821 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
27822 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
27823 AddFilterMenu,
27824 {
27825 triggerProps: {
27826 render: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
27827 import_components23.Button,
27828 {
27829 accessibleWhenDisabled: true,
27830 size: "compact",
27831 className: "dataviews-filters-button",
27832 variant: "tertiary",
27833 disabled: !inactiveFilters.length,
27834 ref
27835 }
27836 ),
27837 children: (0, import_i18n32.__)("Add filter")
27838 },
27839 ...{ filters, view, onChangeView, setOpenedFilter }
27840 }
27841 );
27842 }
27843 var add_filter_default = (0, import_element93.forwardRef)(AddFilter);
27844
27845 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
27846 var import_components24 = __toESM(require_components(), 1);
27847 var import_i18n33 = __toESM(require_i18n(), 1);
27848 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
27849 function ResetFilter({
27850 filters,
27851 view,
27852 onChangeView
27853 }) {
27854 const isPrimary = (field) => filters.some(
27855 (_filter) => _filter.field === field && _filter.isPrimary
27856 );
27857 const isDisabled = !view.search && !view.filters?.some(
27858 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
27859 );
27860 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27861 import_components24.Button,
27862 {
27863 disabled: isDisabled,
27864 accessibleWhenDisabled: true,
27865 size: "compact",
27866 variant: "tertiary",
27867 className: "dataviews-filters__reset-button",
27868 onClick: () => {
27869 onChangeView({
27870 ...view,
27871 page: 1,
27872 search: "",
27873 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
27874 });
27875 },
27876 children: (0, import_i18n33.__)("Reset")
27877 }
27878 );
27879 }
27880
27881 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
27882 var import_element94 = __toESM(require_element(), 1);
27883 function useFilters(fields2, view) {
27884 return (0, import_element94.useMemo)(() => {
27885 const filters = [];
27886 fields2.forEach((field) => {
27887 if (field.filterBy === false || !field.hasElements && !field.Edit) {
27888 return;
27889 }
27890 const operators = field.filterBy.operators;
27891 const isPrimary = !!field.filterBy?.isPrimary;
27892 const isLocked = view.filters?.some(
27893 (f2) => f2.field === field.id && !!f2.isLocked
27894 ) ?? false;
27895 filters.push({
27896 field: field.id,
27897 name: field.label,
27898 elements: field.elements,
27899 getElements: field.getElements,
27900 hasElements: field.hasElements,
27901 singleSelection: operators.some(
27902 (op) => isSingleSelectionOperator(op)
27903 ),
27904 operators,
27905 isVisible: isLocked || isPrimary || !!view.filters?.some(
27906 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
27907 ),
27908 isPrimary,
27909 isLocked
27910 });
27911 });
27912 filters.sort((a2, b2) => {
27913 if (a2.isLocked && !b2.isLocked) {
27914 return -1;
27915 }
27916 if (!a2.isLocked && b2.isLocked) {
27917 return 1;
27918 }
27919 if (a2.isPrimary && !b2.isPrimary) {
27920 return -1;
27921 }
27922 if (!a2.isPrimary && b2.isPrimary) {
27923 return 1;
27924 }
27925 return a2.name.localeCompare(b2.name);
27926 });
27927 return filters;
27928 }, [fields2, view]);
27929 }
27930 var use_filters_default = useFilters;
27931
27932 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
27933 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
27934 function Filters({ className }) {
27935 const { fields: fields2, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element95.useContext)(dataviews_context_default);
27936 const addFilterRef = (0, import_element95.useRef)(null);
27937 const filters = use_filters_default(fields2, view);
27938 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27939 add_filter_default,
27940 {
27941 filters,
27942 view,
27943 onChangeView,
27944 ref: addFilterRef,
27945 setOpenedFilter
27946 },
27947 "add-filter"
27948 );
27949 const visibleFilters = filters.filter((filter) => filter.isVisible);
27950 if (visibleFilters.length === 0) {
27951 return null;
27952 }
27953 const filterComponents = [
27954 ...visibleFilters.map((filter) => {
27955 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27956 Filter,
27957 {
27958 filter,
27959 view,
27960 fields: fields2,
27961 onChangeView,
27962 addFilterRef,
27963 openedFilter
27964 },
27965 filter.field
27966 );
27967 }),
27968 addFilter
27969 ];
27970 filterComponents.push(
27971 /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27972 ResetFilter,
27973 {
27974 filters,
27975 view,
27976 onChangeView
27977 },
27978 "reset-filters"
27979 )
27980 );
27981 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27982 Stack,
27983 {
27984 direction: "row",
27985 justify: "flex-start",
27986 gap: "sm",
27987 style: { width: "fit-content" },
27988 wrap: "wrap",
27989 className,
27990 children: filterComponents
27991 }
27992 );
27993 }
27994 var filters_default = (0, import_element95.memo)(Filters);
27995
27996 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
27997 var import_element96 = __toESM(require_element(), 1);
27998 var import_components25 = __toESM(require_components(), 1);
27999 var import_i18n34 = __toESM(require_i18n(), 1);
28000 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
28001 function FiltersToggle() {
28002 const {
28003 filters,
28004 view,
28005 onChangeView,
28006 setOpenedFilter,
28007 isShowingFilter,
28008 setIsShowingFilter
28009 } = (0, import_element96.useContext)(dataviews_context_default);
28010 const buttonRef = (0, import_element96.useRef)(null);
28011 const onChangeViewWithFilterVisibility = (0, import_element96.useCallback)(
28012 (_view) => {
28013 onChangeView(_view);
28014 setIsShowingFilter(true);
28015 },
28016 [onChangeView, setIsShowingFilter]
28017 );
28018 if (filters.length === 0) {
28019 return null;
28020 }
28021 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
28022 const addFilterButtonProps = {
28023 label: (0, import_i18n34.__)("Add filter"),
28024 "aria-expanded": false,
28025 isPressed: false
28026 };
28027 const toggleFiltersButtonProps = {
28028 label: (0, import_i18n34._x)("Filter", "verb"),
28029 "aria-expanded": isShowingFilter,
28030 isPressed: isShowingFilter,
28031 onClick: () => {
28032 if (!isShowingFilter) {
28033 setOpenedFilter(null);
28034 }
28035 setIsShowingFilter(!isShowingFilter);
28036 }
28037 };
28038 const hasPrimaryOrLockedFilters = filters.some(
28039 (filter) => filter.isPrimary || filter.isLocked
28040 );
28041 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
28042 import_components25.Button,
28043 {
28044 ref: buttonRef,
28045 className: "dataviews-filters__visibility-toggle",
28046 size: "compact",
28047 icon: funnel_default,
28048 disabled: hasPrimaryOrLockedFilters,
28049 accessibleWhenDisabled: true,
28050 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
28051 }
28052 );
28053 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
28054 AddFilterMenu,
28055 {
28056 filters,
28057 view,
28058 onChangeView: onChangeViewWithFilterVisibility,
28059 setOpenedFilter,
28060 triggerProps: { render: buttonComponent }
28061 }
28062 ) : /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
28063 FilterVisibilityToggle,
28064 {
28065 buttonRef,
28066 filtersCount: view.filters?.length,
28067 children: buttonComponent
28068 }
28069 ) });
28070 }
28071 function FilterVisibilityToggle({
28072 buttonRef,
28073 filtersCount,
28074 children
28075 }) {
28076 (0, import_element96.useEffect)(
28077 () => () => {
28078 buttonRef.current?.focus();
28079 },
28080 [buttonRef]
28081 );
28082 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(import_jsx_runtime125.Fragment, { children: [
28083 children,
28084 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
28085 ] });
28086 }
28087 var toggle_default = FiltersToggle;
28088
28089 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
28090 var import_element97 = __toESM(require_element(), 1);
28091 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
28092 function FiltersToggled(props) {
28093 const { isShowingFilter } = (0, import_element97.useContext)(dataviews_context_default);
28094 if (!isShowingFilter) {
28095 return null;
28096 }
28097 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(filters_default, { ...props });
28098 }
28099 var filters_toggled_default = FiltersToggled;
28100
28101 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
28102 var import_element98 = __toESM(require_element(), 1);
28103 var import_components26 = __toESM(require_components(), 1);
28104 var import_i18n35 = __toESM(require_i18n(), 1);
28105 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
28106 function DataViewsLayout({ className }) {
28107 const {
28108 actions = [],
28109 data,
28110 fields: fields2,
28111 getItemId: getItemId2,
28112 getItemLevel,
28113 hasInitiallyLoaded,
28114 isLoading,
28115 view,
28116 onChangeView,
28117 selection,
28118 onChangeSelection,
28119 setOpenedFilter,
28120 onClickItem,
28121 isItemClickable: isItemClickable2,
28122 renderItemLink,
28123 defaultLayouts,
28124 containerRef,
28125 empty = /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("p", { children: (0, import_i18n35.__)("No results") })
28126 } = (0, import_element98.useContext)(dataviews_context_default);
28127 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
28128 delay: 200
28129 });
28130 if (!hasInitiallyLoaded) {
28131 if (!isDelayedInitialLoading) {
28132 return null;
28133 }
28134 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_components26.Spinner, {}) }) });
28135 }
28136 const ViewComponent = VIEW_LAYOUTS.find(
28137 (v2) => v2.type === view.type && defaultLayouts[v2.type]
28138 )?.component;
28139 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
28140 ViewComponent,
28141 {
28142 className,
28143 actions,
28144 data,
28145 fields: fields2,
28146 getItemId: getItemId2,
28147 getItemLevel,
28148 isLoading,
28149 onChangeView,
28150 onChangeSelection,
28151 selection,
28152 setOpenedFilter,
28153 onClickItem,
28154 renderItemLink,
28155 isItemClickable: isItemClickable2,
28156 view,
28157 empty
28158 }
28159 ) });
28160 }
28161
28162 // packages/dataviews/build-module/components/dataviews-search/index.mjs
28163 var import_i18n36 = __toESM(require_i18n(), 1);
28164 var import_element99 = __toESM(require_element(), 1);
28165 var import_components27 = __toESM(require_components(), 1);
28166 var import_compose13 = __toESM(require_compose(), 1);
28167 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
28168 var DataViewsSearch = (0, import_element99.memo)(function Search({ label }) {
28169 const { view, onChangeView } = (0, import_element99.useContext)(dataviews_context_default);
28170 const [search, setSearch, debouncedSearch] = (0, import_compose13.useDebouncedInput)(
28171 view.search
28172 );
28173 (0, import_element99.useEffect)(() => {
28174 if (view.search !== debouncedSearch) {
28175 setSearch(view.search ?? "");
28176 }
28177 }, [view.search, setSearch]);
28178 const onChangeViewRef = (0, import_element99.useRef)(onChangeView);
28179 const viewRef = (0, import_element99.useRef)(view);
28180 (0, import_element99.useEffect)(() => {
28181 onChangeViewRef.current = onChangeView;
28182 viewRef.current = view;
28183 }, [onChangeView, view]);
28184 (0, import_element99.useEffect)(() => {
28185 if (debouncedSearch !== viewRef.current?.search) {
28186 onChangeViewRef.current({
28187 ...viewRef.current,
28188 page: view.page ? 1 : void 0,
28189 startPosition: view.startPosition ? 1 : void 0,
28190 search: debouncedSearch
28191 });
28192 }
28193 }, [debouncedSearch]);
28194 const searchLabel = label || (0, import_i18n36.__)("Search");
28195 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28196 import_components27.SearchControl,
28197 {
28198 className: "dataviews-search",
28199 onChange: setSearch,
28200 value: search,
28201 label: searchLabel,
28202 placeholder: searchLabel,
28203 size: "compact"
28204 }
28205 );
28206 });
28207 var dataviews_search_default = DataViewsSearch;
28208
28209 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
28210 var import_components28 = __toESM(require_components(), 1);
28211 var import_i18n37 = __toESM(require_i18n(), 1);
28212 var import_element100 = __toESM(require_element(), 1);
28213 var import_warning = __toESM(require_warning(), 1);
28214 var import_compose14 = __toESM(require_compose(), 1);
28215 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
28216 var { Menu: Menu6 } = unlock3(import_components28.privateApis);
28217 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
28218 className: "dataviews-config__popover",
28219 placement: "bottom-end",
28220 offset: 9
28221 };
28222 function ViewTypeMenu() {
28223 const { view, onChangeView, defaultLayouts } = (0, import_element100.useContext)(dataviews_context_default);
28224 const availableLayouts = Object.keys(defaultLayouts);
28225 if (availableLayouts.length <= 1) {
28226 return null;
28227 }
28228 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
28229 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(Menu6, { children: [
28230 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28231 Menu6.TriggerButton,
28232 {
28233 render: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28234 import_components28.Button,
28235 {
28236 size: "compact",
28237 icon: activeView?.icon,
28238 label: (0, import_i18n37.__)("Layout")
28239 }
28240 )
28241 }
28242 ),
28243 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(Menu6.Popover, { children: availableLayouts.map((layout) => {
28244 const config = VIEW_LAYOUTS.find(
28245 (v2) => v2.type === layout
28246 );
28247 if (!config) {
28248 return null;
28249 }
28250 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28251 Menu6.RadioItem,
28252 {
28253 value: layout,
28254 name: "view-actions-available-view",
28255 checked: layout === view.type,
28256 hideOnClick: true,
28257 onChange: (e2) => {
28258 switch (e2.target.value) {
28259 case "list":
28260 case "grid":
28261 case "table":
28262 case "pickerGrid":
28263 case "pickerTable":
28264 case "activity":
28265 const viewWithoutLayout = { ...view };
28266 if ("layout" in viewWithoutLayout) {
28267 delete viewWithoutLayout.layout;
28268 }
28269 return onChangeView({
28270 ...viewWithoutLayout,
28271 type: e2.target.value,
28272 ...defaultLayouts[e2.target.value]
28273 });
28274 }
28275 (0, import_warning.default)("Invalid dataview");
28276 },
28277 children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(Menu6.ItemLabel, { children: config.label })
28278 },
28279 layout
28280 );
28281 }) })
28282 ] });
28283 }
28284 function SortFieldControl() {
28285 const { view, fields: fields2, onChangeView } = (0, import_element100.useContext)(dataviews_context_default);
28286 const orderOptions = (0, import_element100.useMemo)(() => {
28287 const sortableFields = fields2.filter(
28288 (field) => field.enableSorting !== false
28289 );
28290 return sortableFields.map((field) => {
28291 return {
28292 label: field.label,
28293 value: field.id
28294 };
28295 });
28296 }, [fields2]);
28297 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28298 import_components28.SelectControl,
28299 {
28300 __next40pxDefaultSize: true,
28301 label: (0, import_i18n37.__)("Sort by"),
28302 value: view.sort?.field,
28303 options: orderOptions,
28304 onChange: (value) => {
28305 onChangeView({
28306 ...view,
28307 sort: {
28308 direction: view?.sort?.direction || "desc",
28309 field: value
28310 },
28311 showLevels: false
28312 });
28313 }
28314 }
28315 );
28316 }
28317 function SortDirectionControl() {
28318 const { view, fields: fields2, onChangeView } = (0, import_element100.useContext)(dataviews_context_default);
28319 const sortableFields = fields2.filter(
28320 (field) => field.enableSorting !== false
28321 );
28322 if (sortableFields.length === 0) {
28323 return null;
28324 }
28325 let value = view.sort?.direction;
28326 if (!value && view.sort?.field) {
28327 value = "desc";
28328 }
28329 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28330 import_components28.__experimentalToggleGroupControl,
28331 {
28332 className: "dataviews-view-config__sort-direction",
28333 __next40pxDefaultSize: true,
28334 isBlock: true,
28335 label: (0, import_i18n37.__)("Order"),
28336 value,
28337 onChange: (newDirection) => {
28338 if (newDirection === "asc" || newDirection === "desc") {
28339 onChangeView({
28340 ...view,
28341 sort: {
28342 direction: newDirection,
28343 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
28344 fields2.find(
28345 (field) => field.enableSorting !== false
28346 )?.id || ""
28347 },
28348 showLevels: false
28349 });
28350 return;
28351 }
28352 (0, import_warning.default)("Invalid direction");
28353 },
28354 children: SORTING_DIRECTIONS.map((direction) => {
28355 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28356 import_components28.__experimentalToggleGroupControlOptionIcon,
28357 {
28358 value: direction,
28359 icon: sortIcons[direction],
28360 label: sortLabels[direction]
28361 },
28362 direction
28363 );
28364 })
28365 }
28366 );
28367 }
28368 function ItemsPerPageControl() {
28369 const { view, config, onChangeView } = (0, import_element100.useContext)(dataviews_context_default);
28370 const { infiniteScrollEnabled } = view;
28371 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
28372 return null;
28373 }
28374 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28375 import_components28.__experimentalToggleGroupControl,
28376 {
28377 __next40pxDefaultSize: true,
28378 isBlock: true,
28379 label: (0, import_i18n37.__)("Items per page"),
28380 value: view.perPage || 10,
28381 disabled: !view?.sort?.field,
28382 onChange: (newItemsPerPage) => {
28383 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
28384 onChangeView({
28385 ...view,
28386 perPage: newItemsPerPageNumber,
28387 page: 1
28388 });
28389 },
28390 children: config.perPageSizes.map((value) => {
28391 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28392 import_components28.__experimentalToggleGroupControlOption,
28393 {
28394 value,
28395 label: value.toString()
28396 },
28397 value
28398 );
28399 })
28400 }
28401 );
28402 }
28403 function ResetViewButton() {
28404 const { onReset } = (0, import_element100.useContext)(dataviews_context_default);
28405 if (onReset === void 0) {
28406 return null;
28407 }
28408 const isDisabled = onReset === false;
28409 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28410 import_components28.Button,
28411 {
28412 variant: "tertiary",
28413 size: "compact",
28414 disabled: isDisabled,
28415 accessibleWhenDisabled: true,
28416 className: "dataviews-view-config__reset-button",
28417 onClick: () => {
28418 if (typeof onReset === "function") {
28419 onReset();
28420 }
28421 },
28422 children: (0, import_i18n37.__)("Reset view")
28423 }
28424 );
28425 }
28426 function DataviewsViewConfigDropdown() {
28427 const { view, onReset } = (0, import_element100.useContext)(dataviews_context_default);
28428 const popoverId = (0, import_compose14.useInstanceId)(
28429 _DataViewsViewConfig,
28430 "dataviews-view-config-dropdown"
28431 );
28432 const activeLayout = VIEW_LAYOUTS.find(
28433 (layout) => layout.type === view.type
28434 );
28435 const isModified = typeof onReset === "function";
28436 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28437 import_components28.Dropdown,
28438 {
28439 expandOnMobile: true,
28440 popoverProps: {
28441 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
28442 id: popoverId
28443 },
28444 renderToggle: ({ onToggle, isOpen }) => {
28445 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
28446 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28447 import_components28.Button,
28448 {
28449 size: "compact",
28450 icon: cog_default,
28451 label: (0, import_i18n37._x)(
28452 "View options",
28453 "View is used as a noun"
28454 ),
28455 onClick: onToggle,
28456 "aria-expanded": isOpen ? "true" : "false",
28457 "aria-controls": popoverId
28458 }
28459 ),
28460 isModified && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
28461 ] });
28462 },
28463 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28464 import_components28.__experimentalDropdownContentWrapper,
28465 {
28466 paddingSize: "medium",
28467 className: "dataviews-config__popover-content-wrapper",
28468 children: /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28469 Stack,
28470 {
28471 direction: "column",
28472 className: "dataviews-view-config",
28473 gap: "xl",
28474 children: [
28475 /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28476 Stack,
28477 {
28478 direction: "row",
28479 justify: "space-between",
28480 align: "center",
28481 className: "dataviews-view-config__header",
28482 children: [
28483 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28484 import_components28.__experimentalHeading,
28485 {
28486 level: 2,
28487 className: "dataviews-settings-section__title",
28488 children: (0, import_i18n37.__)("Appearance")
28489 }
28490 ),
28491 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(ResetViewButton, {})
28492 ]
28493 }
28494 ),
28495 /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(Stack, { direction: "column", gap: "lg", children: [
28496 /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28497 Stack,
28498 {
28499 direction: "row",
28500 gap: "sm",
28501 className: "dataviews-view-config__sort-controls",
28502 children: [
28503 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(SortFieldControl, {}),
28504 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(SortDirectionControl, {})
28505 ]
28506 }
28507 ),
28508 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(activeLayout.viewConfigOptions, {}),
28509 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(ItemsPerPageControl, {}),
28510 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(PropertiesSection, {})
28511 ] })
28512 ]
28513 }
28514 )
28515 }
28516 )
28517 }
28518 );
28519 }
28520 function _DataViewsViewConfig() {
28521 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(import_jsx_runtime129.Fragment, { children: [
28522 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(ViewTypeMenu, {}),
28523 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(DataviewsViewConfigDropdown, {})
28524 ] });
28525 }
28526 var DataViewsViewConfig = (0, import_element100.memo)(_DataViewsViewConfig);
28527 var dataviews_view_config_default = DataViewsViewConfig;
28528
28529 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
28530 var import_components29 = __toESM(require_components(), 1);
28531 var import_element101 = __toESM(require_element(), 1);
28532
28533 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
28534 function getCustomValidity(isValid2, validity) {
28535 let customValidity;
28536 if (isValid2?.required && validity?.required) {
28537 customValidity = validity?.required?.message ? validity.required : void 0;
28538 } else if (isValid2?.pattern && validity?.pattern) {
28539 customValidity = validity.pattern;
28540 } else if (isValid2?.min && validity?.min) {
28541 customValidity = validity.min;
28542 } else if (isValid2?.max && validity?.max) {
28543 customValidity = validity.max;
28544 } else if (isValid2?.minLength && validity?.minLength) {
28545 customValidity = validity.minLength;
28546 } else if (isValid2?.maxLength && validity?.maxLength) {
28547 customValidity = validity.maxLength;
28548 } else if (isValid2?.elements && validity?.elements) {
28549 customValidity = validity.elements;
28550 } else if (validity?.custom) {
28551 customValidity = validity.custom;
28552 }
28553 return customValidity;
28554 }
28555
28556 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
28557 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
28558 var { ValidatedCheckboxControl } = unlock3(import_components29.privateApis);
28559 function Checkbox({
28560 field,
28561 onChange,
28562 data,
28563 hideLabelFromVision,
28564 markWhenOptional,
28565 validity
28566 }) {
28567 const { getValue, setValue, label, description, isValid: isValid2 } = field;
28568 const disabled2 = field.isDisabled({ item: data, field });
28569 const onChangeControl = (0, import_element101.useCallback)(() => {
28570 onChange(
28571 setValue({ item: data, value: !getValue({ item: data }) })
28572 );
28573 }, [data, getValue, onChange, setValue]);
28574 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28575 ValidatedCheckboxControl,
28576 {
28577 required: !!field.isValid?.required,
28578 markWhenOptional,
28579 customValidity: getCustomValidity(isValid2, validity),
28580 hidden: hideLabelFromVision,
28581 label,
28582 help: description,
28583 checked: getValue({ item: data }),
28584 onChange: onChangeControl,
28585 disabled: disabled2
28586 }
28587 );
28588 }
28589
28590 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
28591 var import_components30 = __toESM(require_components(), 1);
28592 var import_element102 = __toESM(require_element(), 1);
28593 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
28594 var { ValidatedComboboxControl } = unlock3(import_components30.privateApis);
28595 function Combobox3({
28596 data,
28597 field,
28598 onChange,
28599 hideLabelFromVision,
28600 validity
28601 }) {
28602 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
28603 const value = getValue({ item: data }) ?? "";
28604 const onChangeControl = (0, import_element102.useCallback)(
28605 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
28606 [data, onChange, setValue]
28607 );
28608 const { elements, isLoading } = useElements({
28609 elements: field.elements,
28610 getElements: field.getElements
28611 });
28612 if (isLoading) {
28613 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(import_components30.Spinner, {});
28614 }
28615 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
28616 ValidatedComboboxControl,
28617 {
28618 required: !!field.isValid?.required,
28619 customValidity: getCustomValidity(isValid2, validity),
28620 label,
28621 value,
28622 help: description,
28623 placeholder,
28624 options: elements,
28625 onChange: onChangeControl,
28626 hideLabelFromVision,
28627 allowReset: true,
28628 expandOnFocus: true
28629 }
28630 );
28631 }
28632
28633 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
28634 var import_components32 = __toESM(require_components(), 1);
28635 var import_element105 = __toESM(require_element(), 1);
28636 var import_i18n39 = __toESM(require_i18n(), 1);
28637 var import_date3 = __toESM(require_date(), 1);
28638
28639 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
28640 var import_components31 = __toESM(require_components(), 1);
28641 var import_element103 = __toESM(require_element(), 1);
28642 var import_i18n38 = __toESM(require_i18n(), 1);
28643 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
28644 var TIME_UNITS_OPTIONS = {
28645 [OPERATOR_IN_THE_PAST]: [
28646 { value: "days", label: (0, import_i18n38.__)("Days") },
28647 { value: "weeks", label: (0, import_i18n38.__)("Weeks") },
28648 { value: "months", label: (0, import_i18n38.__)("Months") },
28649 { value: "years", label: (0, import_i18n38.__)("Years") }
28650 ],
28651 [OPERATOR_OVER]: [
28652 { value: "days", label: (0, import_i18n38.__)("Days ago") },
28653 { value: "weeks", label: (0, import_i18n38.__)("Weeks ago") },
28654 { value: "months", label: (0, import_i18n38.__)("Months ago") },
28655 { value: "years", label: (0, import_i18n38.__)("Years ago") }
28656 ]
28657 };
28658 function RelativeDateControl({
28659 className,
28660 data,
28661 field,
28662 onChange,
28663 hideLabelFromVision,
28664 operator
28665 }) {
28666 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
28667 const { id, label, description, getValue, setValue } = field;
28668 const disabled2 = field.isDisabled({ item: data, field });
28669 const fieldValue = getValue({ item: data });
28670 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
28671 const onChangeValue = (0, import_element103.useCallback)(
28672 (newValue) => onChange(
28673 setValue({
28674 item: data,
28675 value: { value: Number(newValue), unit }
28676 })
28677 ),
28678 [onChange, setValue, data, unit]
28679 );
28680 const onChangeUnit = (0, import_element103.useCallback)(
28681 (newUnit) => onChange(
28682 setValue({
28683 item: data,
28684 value: { value: relValue, unit: newUnit }
28685 })
28686 ),
28687 [onChange, setValue, data, relValue]
28688 );
28689 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28690 import_components31.BaseControl,
28691 {
28692 id,
28693 className: clsx_default(className, "dataviews-controls__relative-date"),
28694 label,
28695 hideLabelFromVision,
28696 help: description,
28697 children: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(Stack, { direction: "row", gap: "sm", children: [
28698 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28699 import_components31.__experimentalNumberControl,
28700 {
28701 __next40pxDefaultSize: true,
28702 className: "dataviews-controls__relative-date-number",
28703 spinControls: "none",
28704 min: 1,
28705 step: 1,
28706 value: relValue,
28707 onChange: onChangeValue,
28708 disabled: disabled2
28709 }
28710 ),
28711 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28712 import_components31.SelectControl,
28713 {
28714 className: "dataviews-controls__relative-date-unit",
28715 __next40pxDefaultSize: true,
28716 label: (0, import_i18n38.__)("Unit"),
28717 value: unit,
28718 options,
28719 onChange: onChangeUnit,
28720 hideLabelFromVision: true,
28721 disabled: disabled2
28722 }
28723 )
28724 ] })
28725 }
28726 );
28727 }
28728
28729 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
28730 var import_element104 = __toESM(require_element(), 1);
28731 function useDisabledDateMatchers(isValid2, parseDateFn) {
28732 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
28733 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
28734 const disabledMatchers = (0, import_element104.useMemo)(() => {
28735 const matchers = [];
28736 if (minConstraint) {
28737 const minDate = parseDateFn(minConstraint);
28738 if (minDate) {
28739 matchers.push({ before: minDate });
28740 }
28741 }
28742 if (maxConstraint) {
28743 const maxDate = parseDateFn(maxConstraint);
28744 if (maxDate) {
28745 matchers.push({ after: maxDate });
28746 }
28747 }
28748 return matchers.length > 0 ? matchers : void 0;
28749 }, [minConstraint, maxConstraint, parseDateFn]);
28750 return { minConstraint, maxConstraint, disabledMatchers };
28751 }
28752
28753 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
28754 var import_date2 = __toESM(require_date(), 1);
28755 function parseDateTime(dateTimeString) {
28756 if (!dateTimeString) {
28757 return null;
28758 }
28759 const parsed = (0, import_date2.getDate)(dateTimeString);
28760 return parsed && isValid(parsed) ? parsed : null;
28761 }
28762
28763 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
28764 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
28765 var { DateCalendar, ValidatedInputControl } = unlock3(import_components32.privateApis);
28766 var formatDateTime = (value) => {
28767 if (!value) {
28768 return "";
28769 }
28770 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
28771 };
28772 function CalendarDateTimeControl({
28773 data,
28774 field,
28775 onChange,
28776 hideLabelFromVision,
28777 markWhenOptional,
28778 validity,
28779 config
28780 }) {
28781 const { compact } = config || {};
28782 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
28783 const disabled2 = field.isDisabled({ item: data, field });
28784 const fieldValue = getValue({ item: data });
28785 const value = typeof fieldValue === "string" ? fieldValue : void 0;
28786 const [calendarMonth, setCalendarMonth] = (0, import_element105.useState)(() => {
28787 const parsedDate = parseDateTime(value);
28788 return parsedDate || /* @__PURE__ */ new Date();
28789 });
28790 const inputControlRef = (0, import_element105.useRef)(null);
28791 const validationTimeoutRef = (0, import_element105.useRef)(void 0);
28792 const previousFocusRef = (0, import_element105.useRef)(null);
28793 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
28794 const onChangeCallback = (0, import_element105.useCallback)(
28795 (newValue) => onChange(setValue({ item: data, value: newValue })),
28796 [data, onChange, setValue]
28797 );
28798 (0, import_element105.useEffect)(() => {
28799 return () => {
28800 if (validationTimeoutRef.current) {
28801 clearTimeout(validationTimeoutRef.current);
28802 }
28803 };
28804 }, []);
28805 const onSelectDate = (0, import_element105.useCallback)(
28806 (newDate) => {
28807 let dateTimeValue;
28808 if (newDate) {
28809 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
28810 let wpTime;
28811 if (value) {
28812 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
28813 } else {
28814 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
28815 }
28816 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
28817 dateTimeValue = finalDateTime.toISOString();
28818 onChangeCallback(dateTimeValue);
28819 if (validationTimeoutRef.current) {
28820 clearTimeout(validationTimeoutRef.current);
28821 }
28822 } else {
28823 onChangeCallback(void 0);
28824 }
28825 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
28826 validationTimeoutRef.current = setTimeout(() => {
28827 if (inputControlRef.current) {
28828 inputControlRef.current.focus();
28829 inputControlRef.current.blur();
28830 onChangeCallback(dateTimeValue);
28831 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
28832 previousFocusRef.current.focus();
28833 }
28834 }
28835 }, 0);
28836 },
28837 [onChangeCallback, value]
28838 );
28839 const handleManualDateTimeChange = (0, import_element105.useCallback)(
28840 (newValue) => {
28841 if (newValue) {
28842 const dateTime = (0, import_date3.getDate)(newValue);
28843 onChangeCallback(dateTime.toISOString());
28844 const parsedDate = parseDateTime(dateTime.toISOString());
28845 if (parsedDate) {
28846 setCalendarMonth(parsedDate);
28847 }
28848 } else {
28849 onChangeCallback(void 0);
28850 }
28851 },
28852 [onChangeCallback]
28853 );
28854 const { format: fieldFormat } = field;
28855 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
28856 const {
28857 timezone: { string: timezoneString }
28858 } = (0, import_date3.getSettings)();
28859 let displayLabel = label;
28860 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
28861 displayLabel = `${label} (${(0, import_i18n39.__)("Required")})`;
28862 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
28863 displayLabel = `${label} (${(0, import_i18n39.__)("Optional")})`;
28864 }
28865 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28866 import_components32.BaseControl,
28867 {
28868 id,
28869 label: displayLabel,
28870 help: description,
28871 hideLabelFromVision,
28872 children: /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(Stack, { direction: "column", gap: "lg", children: [
28873 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28874 ValidatedInputControl,
28875 {
28876 ref: inputControlRef,
28877 __next40pxDefaultSize: true,
28878 required: !!isValid2?.required,
28879 customValidity: getCustomValidity(isValid2, validity),
28880 type: "datetime-local",
28881 label: (0, import_i18n39.__)("Date time"),
28882 hideLabelFromVision: true,
28883 value: formatDateTime(value),
28884 onChange: handleManualDateTimeChange,
28885 disabled: disabled2,
28886 min: minConstraint ? formatDateTime(minConstraint) : void 0,
28887 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
28888 }
28889 ),
28890 !compact && /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28891 DateCalendar,
28892 {
28893 style: { width: "100%" },
28894 selected: value ? parseDateTime(value) || void 0 : void 0,
28895 onSelect: onSelectDate,
28896 month: calendarMonth,
28897 onMonthChange: setCalendarMonth,
28898 timeZone: timezoneString || void 0,
28899 weekStartsOn,
28900 disabled: disabled2 || disabledMatchers
28901 }
28902 )
28903 ] })
28904 }
28905 );
28906 }
28907 function DateTime({
28908 data,
28909 field,
28910 onChange,
28911 hideLabelFromVision,
28912 markWhenOptional,
28913 operator,
28914 validity,
28915 config
28916 }) {
28917 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
28918 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28919 RelativeDateControl,
28920 {
28921 className: "dataviews-controls__datetime",
28922 data,
28923 field,
28924 onChange,
28925 hideLabelFromVision,
28926 operator
28927 }
28928 );
28929 }
28930 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28931 CalendarDateTimeControl,
28932 {
28933 data,
28934 field,
28935 onChange,
28936 hideLabelFromVision,
28937 markWhenOptional,
28938 validity,
28939 config
28940 }
28941 );
28942 }
28943
28944 // packages/dataviews/build-module/components/dataform-controls/date.mjs
28945 var import_components33 = __toESM(require_components(), 1);
28946 var import_element106 = __toESM(require_element(), 1);
28947 var import_i18n40 = __toESM(require_i18n(), 1);
28948 var import_date4 = __toESM(require_date(), 1);
28949 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
28950 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components33.privateApis);
28951 var DATE_PRESETS = [
28952 {
28953 id: "today",
28954 label: (0, import_i18n40.__)("Today"),
28955 getValue: () => (0, import_date4.getDate)(null)
28956 },
28957 {
28958 id: "yesterday",
28959 label: (0, import_i18n40.__)("Yesterday"),
28960 getValue: () => {
28961 const today = (0, import_date4.getDate)(null);
28962 return subDays(today, 1);
28963 }
28964 },
28965 {
28966 id: "past-week",
28967 label: (0, import_i18n40.__)("Past week"),
28968 getValue: () => {
28969 const today = (0, import_date4.getDate)(null);
28970 return subDays(today, 7);
28971 }
28972 },
28973 {
28974 id: "past-month",
28975 label: (0, import_i18n40.__)("Past month"),
28976 getValue: () => {
28977 const today = (0, import_date4.getDate)(null);
28978 return subMonths(today, 1);
28979 }
28980 }
28981 ];
28982 var DATE_RANGE_PRESETS = [
28983 {
28984 id: "last-7-days",
28985 label: (0, import_i18n40.__)("Last 7 days"),
28986 getValue: () => {
28987 const today = (0, import_date4.getDate)(null);
28988 return [subDays(today, 7), today];
28989 }
28990 },
28991 {
28992 id: "last-30-days",
28993 label: (0, import_i18n40.__)("Last 30 days"),
28994 getValue: () => {
28995 const today = (0, import_date4.getDate)(null);
28996 return [subDays(today, 30), today];
28997 }
28998 },
28999 {
29000 id: "month-to-date",
29001 label: (0, import_i18n40.__)("Month to date"),
29002 getValue: () => {
29003 const today = (0, import_date4.getDate)(null);
29004 return [startOfMonth(today), today];
29005 }
29006 },
29007 {
29008 id: "last-year",
29009 label: (0, import_i18n40.__)("Last year"),
29010 getValue: () => {
29011 const today = (0, import_date4.getDate)(null);
29012 return [subYears(today, 1), today];
29013 }
29014 },
29015 {
29016 id: "year-to-date",
29017 label: (0, import_i18n40.__)("Year to date"),
29018 getValue: () => {
29019 const today = (0, import_date4.getDate)(null);
29020 return [startOfYear(today), today];
29021 }
29022 }
29023 ];
29024 var parseDate = (dateString) => {
29025 if (!dateString) {
29026 return null;
29027 }
29028 const parsed = (0, import_date4.getDate)(dateString);
29029 return parsed && isValid(parsed) ? parsed : null;
29030 };
29031 var formatDate = (date) => {
29032 if (!date) {
29033 return "";
29034 }
29035 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
29036 };
29037 function ValidatedDateControl({
29038 field,
29039 validity,
29040 inputRefs,
29041 isTouched,
29042 setIsTouched,
29043 children
29044 }) {
29045 const { isValid: isValid2 } = field;
29046 const [customValidity, setCustomValidity] = (0, import_element106.useState)(void 0);
29047 const validateRefs = (0, import_element106.useCallback)(() => {
29048 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29049 for (const ref of refs) {
29050 const input = ref.current;
29051 if (input && !input.validity.valid) {
29052 setCustomValidity({
29053 type: "invalid",
29054 message: input.validationMessage
29055 });
29056 return;
29057 }
29058 }
29059 setCustomValidity(void 0);
29060 }, [inputRefs]);
29061 (0, import_element106.useEffect)(() => {
29062 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29063 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
29064 for (const ref of refs) {
29065 const input = ref.current;
29066 if (input) {
29067 input.setCustomValidity(
29068 result?.type === "invalid" && result.message ? result.message : ""
29069 );
29070 }
29071 }
29072 }, [inputRefs, isValid2, validity]);
29073 (0, import_element106.useEffect)(() => {
29074 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29075 const handleInvalid = (event) => {
29076 event.preventDefault();
29077 setIsTouched(true);
29078 };
29079 for (const ref of refs) {
29080 ref.current?.addEventListener("invalid", handleInvalid);
29081 }
29082 return () => {
29083 for (const ref of refs) {
29084 ref.current?.removeEventListener("invalid", handleInvalid);
29085 }
29086 };
29087 }, [inputRefs, setIsTouched]);
29088 (0, import_element106.useEffect)(() => {
29089 if (!isTouched) {
29090 return;
29091 }
29092 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
29093 if (result) {
29094 setCustomValidity(result);
29095 } else {
29096 validateRefs();
29097 }
29098 }, [isTouched, isValid2, validity, validateRefs]);
29099 const onBlur = (event) => {
29100 if (isTouched) {
29101 return;
29102 }
29103 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
29104 setIsTouched(true);
29105 }
29106 };
29107 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { onBlur, children: [
29108 children,
29109 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
29110 "p",
29111 {
29112 className: clsx_default(
29113 "components-validated-control__indicator",
29114 customValidity.type === "invalid" ? "is-invalid" : void 0
29115 ),
29116 children: [
29117 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29118 import_components33.Icon,
29119 {
29120 className: "components-validated-control__indicator-icon",
29121 icon: error_default,
29122 size: 16,
29123 fill: "currentColor"
29124 }
29125 ),
29126 customValidity.message
29127 ]
29128 }
29129 ) })
29130 ] });
29131 }
29132 function CalendarDateControl({
29133 data,
29134 field,
29135 onChange,
29136 hideLabelFromVision,
29137 markWhenOptional,
29138 validity
29139 }) {
29140 const {
29141 id,
29142 label,
29143 description,
29144 setValue,
29145 getValue,
29146 isValid: isValid2,
29147 format: fieldFormat
29148 } = field;
29149 const disabled2 = field.isDisabled({ item: data, field });
29150 const [selectedPresetId, setSelectedPresetId] = (0, import_element106.useState)(
29151 null
29152 );
29153 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
29154 const fieldValue = getValue({ item: data });
29155 const value = typeof fieldValue === "string" ? fieldValue : void 0;
29156 const [calendarMonth, setCalendarMonth] = (0, import_element106.useState)(() => {
29157 const parsedDate = parseDate(value);
29158 return parsedDate || /* @__PURE__ */ new Date();
29159 });
29160 const [isTouched, setIsTouched] = (0, import_element106.useState)(false);
29161 const validityTargetRef = (0, import_element106.useRef)(null);
29162 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
29163 const onChangeCallback = (0, import_element106.useCallback)(
29164 (newValue) => onChange(setValue({ item: data, value: newValue })),
29165 [data, onChange, setValue]
29166 );
29167 const onSelectDate = (0, import_element106.useCallback)(
29168 (newDate) => {
29169 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
29170 onChangeCallback(dateValue);
29171 setSelectedPresetId(null);
29172 setIsTouched(true);
29173 },
29174 [onChangeCallback]
29175 );
29176 const handlePresetClick = (0, import_element106.useCallback)(
29177 (preset) => {
29178 const presetDate = preset.getValue();
29179 const dateValue = formatDate(presetDate);
29180 setCalendarMonth(presetDate);
29181 onChangeCallback(dateValue);
29182 setSelectedPresetId(preset.id);
29183 setIsTouched(true);
29184 },
29185 [onChangeCallback]
29186 );
29187 const handleManualDateChange = (0, import_element106.useCallback)(
29188 (newValue) => {
29189 onChangeCallback(newValue);
29190 if (newValue) {
29191 const parsedDate = parseDate(newValue);
29192 if (parsedDate) {
29193 setCalendarMonth(parsedDate);
29194 }
29195 }
29196 setSelectedPresetId(null);
29197 setIsTouched(true);
29198 },
29199 [onChangeCallback]
29200 );
29201 const {
29202 timezone: { string: timezoneString }
29203 } = (0, import_date4.getSettings)();
29204 let displayLabel = label;
29205 if (isValid2?.required && !markWhenOptional) {
29206 displayLabel = `${label} (${(0, import_i18n40.__)("Required")})`;
29207 } else if (!isValid2?.required && markWhenOptional) {
29208 displayLabel = `${label} (${(0, import_i18n40.__)("Optional")})`;
29209 }
29210 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29211 ValidatedDateControl,
29212 {
29213 field,
29214 validity,
29215 inputRefs: validityTargetRef,
29216 isTouched,
29217 setIsTouched,
29218 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29219 import_components33.BaseControl,
29220 {
29221 id,
29222 className: "dataviews-controls__date",
29223 label: displayLabel,
29224 help: description,
29225 hideLabelFromVision,
29226 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(Stack, { direction: "column", gap: "lg", children: [
29227 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
29228 Stack,
29229 {
29230 direction: "row",
29231 gap: "sm",
29232 wrap: "wrap",
29233 justify: "flex-start",
29234 children: [
29235 DATE_PRESETS.map((preset) => {
29236 const isSelected2 = selectedPresetId === preset.id;
29237 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29238 import_components33.Button,
29239 {
29240 className: "dataviews-controls__date-preset",
29241 variant: "tertiary",
29242 isPressed: isSelected2,
29243 size: "small",
29244 disabled: disabled2,
29245 accessibleWhenDisabled: true,
29246 onClick: () => handlePresetClick(preset),
29247 children: preset.label
29248 },
29249 preset.id
29250 );
29251 }),
29252 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29253 import_components33.Button,
29254 {
29255 className: "dataviews-controls__date-preset",
29256 variant: "tertiary",
29257 isPressed: !selectedPresetId,
29258 size: "small",
29259 disabled: !!selectedPresetId || disabled2,
29260 accessibleWhenDisabled: true,
29261 children: (0, import_i18n40.__)("Custom")
29262 }
29263 )
29264 ]
29265 }
29266 ),
29267 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29268 import_components33.__experimentalInputControl,
29269 {
29270 __next40pxDefaultSize: true,
29271 ref: validityTargetRef,
29272 type: "date",
29273 label: (0, import_i18n40.__)("Date"),
29274 hideLabelFromVision: true,
29275 value,
29276 onChange: handleManualDateChange,
29277 required: !!field.isValid?.required,
29278 disabled: disabled2,
29279 min: minConstraint,
29280 max: maxConstraint
29281 }
29282 ),
29283 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29284 DateCalendar2,
29285 {
29286 style: { width: "100%" },
29287 selected: value ? parseDate(value) || void 0 : void 0,
29288 onSelect: onSelectDate,
29289 month: calendarMonth,
29290 onMonthChange: setCalendarMonth,
29291 timeZone: timezoneString || void 0,
29292 weekStartsOn,
29293 disabled: disabled2 || disabledMatchers,
29294 disableNavigation: disabled2
29295 }
29296 )
29297 ] })
29298 }
29299 )
29300 }
29301 );
29302 }
29303 function CalendarDateRangeControl({
29304 data,
29305 field,
29306 onChange,
29307 hideLabelFromVision,
29308 markWhenOptional,
29309 validity
29310 }) {
29311 const {
29312 id,
29313 label,
29314 description,
29315 getValue,
29316 setValue,
29317 isValid: isValid2,
29318 format: fieldFormat
29319 } = field;
29320 const disabled2 = field.isDisabled({ item: data, field });
29321 let value;
29322 const fieldValue = getValue({ item: data });
29323 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
29324 value = fieldValue;
29325 }
29326 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
29327 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
29328 const onChangeCallback = (0, import_element106.useCallback)(
29329 (newValue) => {
29330 onChange(
29331 setValue({
29332 item: data,
29333 value: newValue
29334 })
29335 );
29336 },
29337 [data, onChange, setValue]
29338 );
29339 const [selectedPresetId, setSelectedPresetId] = (0, import_element106.useState)(
29340 null
29341 );
29342 const selectedRange = (0, import_element106.useMemo)(() => {
29343 if (!value) {
29344 return { from: void 0, to: void 0 };
29345 }
29346 const [from, to] = value;
29347 return {
29348 from: parseDate(from) || void 0,
29349 to: parseDate(to) || void 0
29350 };
29351 }, [value]);
29352 const [calendarMonth, setCalendarMonth] = (0, import_element106.useState)(() => {
29353 return selectedRange.from || /* @__PURE__ */ new Date();
29354 });
29355 const [isTouched, setIsTouched] = (0, import_element106.useState)(false);
29356 const fromInputRef = (0, import_element106.useRef)(null);
29357 const toInputRef = (0, import_element106.useRef)(null);
29358 const updateDateRange = (0, import_element106.useCallback)(
29359 (fromDate, toDate2) => {
29360 if (fromDate && toDate2) {
29361 onChangeCallback([
29362 formatDate(fromDate),
29363 formatDate(toDate2)
29364 ]);
29365 } else if (!fromDate && !toDate2) {
29366 onChangeCallback(void 0);
29367 }
29368 },
29369 [onChangeCallback]
29370 );
29371 const onSelectCalendarRange = (0, import_element106.useCallback)(
29372 (newRange) => {
29373 updateDateRange(newRange?.from, newRange?.to);
29374 setSelectedPresetId(null);
29375 setIsTouched(true);
29376 },
29377 [updateDateRange]
29378 );
29379 const handlePresetClick = (0, import_element106.useCallback)(
29380 (preset) => {
29381 const [startDate, endDate] = preset.getValue();
29382 setCalendarMonth(startDate);
29383 updateDateRange(startDate, endDate);
29384 setSelectedPresetId(preset.id);
29385 setIsTouched(true);
29386 },
29387 [updateDateRange]
29388 );
29389 const handleManualDateChange = (0, import_element106.useCallback)(
29390 (fromOrTo, newValue) => {
29391 const [currentFrom, currentTo] = value || [
29392 void 0,
29393 void 0
29394 ];
29395 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
29396 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
29397 updateDateRange(updatedFrom, updatedTo);
29398 if (newValue) {
29399 const parsedDate = parseDate(newValue);
29400 if (parsedDate) {
29401 setCalendarMonth(parsedDate);
29402 }
29403 }
29404 setSelectedPresetId(null);
29405 setIsTouched(true);
29406 },
29407 [value, updateDateRange]
29408 );
29409 const { timezone } = (0, import_date4.getSettings)();
29410 let displayLabel = label;
29411 if (field.isValid?.required && !markWhenOptional) {
29412 displayLabel = `${label} (${(0, import_i18n40.__)("Required")})`;
29413 } else if (!field.isValid?.required && markWhenOptional) {
29414 displayLabel = `${label} (${(0, import_i18n40.__)("Optional")})`;
29415 }
29416 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29417 ValidatedDateControl,
29418 {
29419 field,
29420 validity,
29421 inputRefs: [fromInputRef, toInputRef],
29422 isTouched,
29423 setIsTouched,
29424 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29425 import_components33.BaseControl,
29426 {
29427 id,
29428 className: "dataviews-controls__date",
29429 label: displayLabel,
29430 help: description,
29431 hideLabelFromVision,
29432 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(Stack, { direction: "column", gap: "lg", children: [
29433 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
29434 Stack,
29435 {
29436 direction: "row",
29437 gap: "sm",
29438 wrap: "wrap",
29439 justify: "flex-start",
29440 children: [
29441 DATE_RANGE_PRESETS.map((preset) => {
29442 const isSelected2 = selectedPresetId === preset.id;
29443 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29444 import_components33.Button,
29445 {
29446 className: "dataviews-controls__date-preset",
29447 variant: "tertiary",
29448 isPressed: isSelected2,
29449 size: "small",
29450 disabled: disabled2,
29451 accessibleWhenDisabled: true,
29452 onClick: () => handlePresetClick(preset),
29453 children: preset.label
29454 },
29455 preset.id
29456 );
29457 }),
29458 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29459 import_components33.Button,
29460 {
29461 className: "dataviews-controls__date-preset",
29462 variant: "tertiary",
29463 isPressed: !selectedPresetId,
29464 size: "small",
29465 accessibleWhenDisabled: true,
29466 disabled: !!selectedPresetId || disabled2,
29467 children: (0, import_i18n40.__)("Custom")
29468 }
29469 )
29470 ]
29471 }
29472 ),
29473 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
29474 Stack,
29475 {
29476 direction: "row",
29477 gap: "sm",
29478 justify: "space-between",
29479 className: "dataviews-controls__date-range-inputs",
29480 children: [
29481 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29482 import_components33.__experimentalInputControl,
29483 {
29484 __next40pxDefaultSize: true,
29485 ref: fromInputRef,
29486 type: "date",
29487 label: (0, import_i18n40.__)("From"),
29488 hideLabelFromVision: true,
29489 value: value?.[0],
29490 onChange: (newValue) => handleManualDateChange("from", newValue),
29491 required: !!field.isValid?.required,
29492 disabled: disabled2,
29493 min: minConstraint,
29494 max: maxConstraint
29495 }
29496 ),
29497 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29498 import_components33.__experimentalInputControl,
29499 {
29500 __next40pxDefaultSize: true,
29501 ref: toInputRef,
29502 type: "date",
29503 label: (0, import_i18n40.__)("To"),
29504 hideLabelFromVision: true,
29505 value: value?.[1],
29506 onChange: (newValue) => handleManualDateChange("to", newValue),
29507 required: !!field.isValid?.required,
29508 disabled: disabled2,
29509 min: minConstraint,
29510 max: maxConstraint
29511 }
29512 )
29513 ]
29514 }
29515 ),
29516 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29517 DateRangeCalendar,
29518 {
29519 style: { width: "100%" },
29520 selected: selectedRange,
29521 onSelect: onSelectCalendarRange,
29522 month: calendarMonth,
29523 onMonthChange: setCalendarMonth,
29524 timeZone: timezone.string || void 0,
29525 weekStartsOn,
29526 disabled: disabled2 || disabledMatchers
29527 }
29528 )
29529 ] })
29530 }
29531 )
29532 }
29533 );
29534 }
29535 function DateControl({
29536 data,
29537 field,
29538 onChange,
29539 hideLabelFromVision,
29540 markWhenOptional,
29541 operator,
29542 validity
29543 }) {
29544 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
29545 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29546 RelativeDateControl,
29547 {
29548 className: "dataviews-controls__date",
29549 data,
29550 field,
29551 onChange,
29552 hideLabelFromVision,
29553 operator
29554 }
29555 );
29556 }
29557 if (operator === OPERATOR_BETWEEN) {
29558 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29559 CalendarDateRangeControl,
29560 {
29561 data,
29562 field,
29563 onChange,
29564 hideLabelFromVision,
29565 markWhenOptional,
29566 validity
29567 }
29568 );
29569 }
29570 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29571 CalendarDateControl,
29572 {
29573 data,
29574 field,
29575 onChange,
29576 hideLabelFromVision,
29577 markWhenOptional,
29578 validity
29579 }
29580 );
29581 }
29582
29583 // packages/dataviews/build-module/components/dataform-controls/select.mjs
29584 var import_components34 = __toESM(require_components(), 1);
29585 var import_element107 = __toESM(require_element(), 1);
29586 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
29587 var { ValidatedSelectControl } = unlock3(import_components34.privateApis);
29588 function Select({
29589 data,
29590 field,
29591 onChange,
29592 hideLabelFromVision,
29593 markWhenOptional,
29594 validity
29595 }) {
29596 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
29597 const disabled2 = field.isDisabled({ item: data, field });
29598 const isMultiple = type === "array";
29599 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
29600 const onChangeControl = (0, import_element107.useCallback)(
29601 (newValue) => onChange(setValue({ item: data, value: newValue })),
29602 [data, onChange, setValue]
29603 );
29604 const { elements, isLoading } = useElements({
29605 elements: field.elements,
29606 getElements: field.getElements
29607 });
29608 if (isLoading) {
29609 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_components34.Spinner, {});
29610 }
29611 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
29612 ValidatedSelectControl,
29613 {
29614 required: !!field.isValid?.required,
29615 markWhenOptional,
29616 customValidity: getCustomValidity(isValid2, validity),
29617 label,
29618 value,
29619 help: description,
29620 options: elements,
29621 onChange: onChangeControl,
29622 __next40pxDefaultSize: true,
29623 hideLabelFromVision,
29624 multiple: isMultiple,
29625 disabled: disabled2
29626 }
29627 );
29628 }
29629
29630 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
29631 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
29632 var ELEMENTS_THRESHOLD = 10;
29633 function AdaptiveSelect(props) {
29634 const { field } = props;
29635 const { elements } = useElements({
29636 elements: field.elements,
29637 getElements: field.getElements
29638 });
29639 if (elements.length >= ELEMENTS_THRESHOLD) {
29640 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(Combobox3, { ...props });
29641 }
29642 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(Select, { ...props });
29643 }
29644
29645 // packages/dataviews/build-module/components/dataform-controls/email.mjs
29646 var import_components36 = __toESM(require_components(), 1);
29647
29648 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
29649 var import_components35 = __toESM(require_components(), 1);
29650 var import_element108 = __toESM(require_element(), 1);
29651 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
29652 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components35.privateApis);
29653 function ValidatedText({
29654 data,
29655 field,
29656 onChange,
29657 hideLabelFromVision,
29658 markWhenOptional,
29659 type,
29660 prefix,
29661 suffix,
29662 validity
29663 }) {
29664 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
29665 const value = getValue({ item: data });
29666 const disabled2 = field.isDisabled({ item: data, field });
29667 const onChangeControl = (0, import_element108.useCallback)(
29668 (newValue) => onChange(
29669 setValue({
29670 item: data,
29671 value: newValue
29672 })
29673 ),
29674 [data, setValue, onChange]
29675 );
29676 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29677 ValidatedInputControl2,
29678 {
29679 required: !!isValid2.required,
29680 markWhenOptional,
29681 customValidity: getCustomValidity(isValid2, validity),
29682 label,
29683 placeholder,
29684 value: value ?? "",
29685 help: description,
29686 onChange: onChangeControl,
29687 hideLabelFromVision,
29688 type,
29689 prefix,
29690 suffix,
29691 disabled: disabled2,
29692 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
29693 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
29694 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
29695 __next40pxDefaultSize: true
29696 }
29697 );
29698 }
29699
29700 // packages/dataviews/build-module/components/dataform-controls/email.mjs
29701 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
29702 function Email({
29703 data,
29704 field,
29705 onChange,
29706 hideLabelFromVision,
29707 markWhenOptional,
29708 validity
29709 }) {
29710 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29711 ValidatedText,
29712 {
29713 ...{
29714 data,
29715 field,
29716 onChange,
29717 hideLabelFromVision,
29718 markWhenOptional,
29719 validity,
29720 type: "email",
29721 prefix: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_components36.Icon, { icon: envelope_default }) })
29722 }
29723 }
29724 );
29725 }
29726
29727 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
29728 var import_components37 = __toESM(require_components(), 1);
29729 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
29730 function Telephone({
29731 data,
29732 field,
29733 onChange,
29734 hideLabelFromVision,
29735 markWhenOptional,
29736 validity
29737 }) {
29738 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29739 ValidatedText,
29740 {
29741 ...{
29742 data,
29743 field,
29744 onChange,
29745 hideLabelFromVision,
29746 markWhenOptional,
29747 validity,
29748 type: "tel",
29749 prefix: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components37.Icon, { icon: mobile_default }) })
29750 }
29751 }
29752 );
29753 }
29754
29755 // packages/dataviews/build-module/components/dataform-controls/url.mjs
29756 var import_components38 = __toESM(require_components(), 1);
29757 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
29758 function Url({
29759 data,
29760 field,
29761 onChange,
29762 hideLabelFromVision,
29763 markWhenOptional,
29764 validity
29765 }) {
29766 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29767 ValidatedText,
29768 {
29769 ...{
29770 data,
29771 field,
29772 onChange,
29773 hideLabelFromVision,
29774 markWhenOptional,
29775 validity,
29776 type: "url",
29777 prefix: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components38.Icon, { icon: link_default }) })
29778 }
29779 }
29780 );
29781 }
29782
29783 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
29784 var import_components39 = __toESM(require_components(), 1);
29785 var import_element109 = __toESM(require_element(), 1);
29786 var import_i18n41 = __toESM(require_i18n(), 1);
29787 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
29788 var { ValidatedNumberControl } = unlock3(import_components39.privateApis);
29789 function toNumberOrEmpty(value) {
29790 if (value === "" || value === void 0) {
29791 return "";
29792 }
29793 const number = Number(value);
29794 return Number.isFinite(number) ? number : "";
29795 }
29796 function BetweenControls({
29797 value,
29798 onChange,
29799 hideLabelFromVision,
29800 step
29801 }) {
29802 const [min2 = "", max2 = ""] = value;
29803 const onChangeMin = (0, import_element109.useCallback)(
29804 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
29805 [onChange, max2]
29806 );
29807 const onChangeMax = (0, import_element109.useCallback)(
29808 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
29809 [onChange, min2]
29810 );
29811 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29812 import_components39.BaseControl,
29813 {
29814 help: (0, import_i18n41.__)("The max. value must be greater than the min. value."),
29815 children: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(import_components39.Flex, { direction: "row", gap: 4, children: [
29816 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29817 import_components39.__experimentalNumberControl,
29818 {
29819 label: (0, import_i18n41.__)("Min."),
29820 value: min2,
29821 max: max2 ? Number(max2) - step : void 0,
29822 onChange: onChangeMin,
29823 __next40pxDefaultSize: true,
29824 hideLabelFromVision,
29825 step
29826 }
29827 ),
29828 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29829 import_components39.__experimentalNumberControl,
29830 {
29831 label: (0, import_i18n41.__)("Max."),
29832 value: max2,
29833 min: min2 ? Number(min2) + step : void 0,
29834 onChange: onChangeMax,
29835 __next40pxDefaultSize: true,
29836 hideLabelFromVision,
29837 step
29838 }
29839 )
29840 ] })
29841 }
29842 );
29843 }
29844 function ValidatedNumber({
29845 data,
29846 field,
29847 onChange,
29848 hideLabelFromVision,
29849 markWhenOptional,
29850 operator,
29851 validity
29852 }) {
29853 const decimals = field.format?.decimals ?? 0;
29854 const step = Math.pow(10, Math.abs(decimals) * -1);
29855 const { label, description, getValue, setValue, isValid: isValid2 } = field;
29856 const value = getValue({ item: data }) ?? "";
29857 const disabled2 = field.isDisabled({ item: data, field });
29858 const onChangeControl = (0, import_element109.useCallback)(
29859 (newValue) => {
29860 onChange(
29861 setValue({
29862 item: data,
29863 // Do not convert an empty string or undefined to a number,
29864 // otherwise there's a mismatch between the UI control (empty)
29865 // and the data relied by onChange (0).
29866 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
29867 })
29868 );
29869 },
29870 [data, onChange, setValue]
29871 );
29872 const onChangeBetweenControls = (0, import_element109.useCallback)(
29873 (newValue) => {
29874 onChange(
29875 setValue({
29876 item: data,
29877 value: newValue
29878 })
29879 );
29880 },
29881 [data, onChange, setValue]
29882 );
29883 if (operator === OPERATOR_BETWEEN) {
29884 let valueBetween = ["", ""];
29885 if (Array.isArray(value) && value.length === 2 && value.every(
29886 (element) => typeof element === "number" || element === ""
29887 )) {
29888 valueBetween = value;
29889 }
29890 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29891 BetweenControls,
29892 {
29893 value: valueBetween,
29894 onChange: onChangeBetweenControls,
29895 hideLabelFromVision,
29896 step
29897 }
29898 );
29899 }
29900 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29901 ValidatedNumberControl,
29902 {
29903 required: !!isValid2.required,
29904 markWhenOptional,
29905 customValidity: getCustomValidity(isValid2, validity),
29906 label,
29907 help: description,
29908 value,
29909 onChange: onChangeControl,
29910 __next40pxDefaultSize: true,
29911 hideLabelFromVision,
29912 step,
29913 min: isValid2.min ? isValid2.min.constraint : void 0,
29914 max: isValid2.max ? isValid2.max.constraint : void 0,
29915 disabled: disabled2
29916 }
29917 );
29918 }
29919
29920 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
29921 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
29922 function Integer(props) {
29923 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(ValidatedNumber, { ...props });
29924 }
29925
29926 // packages/dataviews/build-module/components/dataform-controls/number.mjs
29927 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
29928 function Number2(props) {
29929 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(ValidatedNumber, { ...props });
29930 }
29931
29932 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
29933 var import_components40 = __toESM(require_components(), 1);
29934 var import_element110 = __toESM(require_element(), 1);
29935 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
29936 var { ValidatedRadioControl } = unlock3(import_components40.privateApis);
29937 function Radio({
29938 data,
29939 field,
29940 onChange,
29941 hideLabelFromVision,
29942 markWhenOptional,
29943 validity
29944 }) {
29945 const { label, description, getValue, setValue, isValid: isValid2 } = field;
29946 const disabled2 = field.isDisabled({ item: data, field });
29947 const { elements, isLoading } = useElements({
29948 elements: field.elements,
29949 getElements: field.getElements
29950 });
29951 const value = getValue({ item: data });
29952 const onChangeControl = (0, import_element110.useCallback)(
29953 (newValue) => onChange(setValue({ item: data, value: newValue })),
29954 [data, onChange, setValue]
29955 );
29956 if (isLoading) {
29957 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components40.Spinner, {});
29958 }
29959 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
29960 ValidatedRadioControl,
29961 {
29962 required: !!field.isValid?.required,
29963 markWhenOptional,
29964 customValidity: getCustomValidity(isValid2, validity),
29965 label,
29966 help: description,
29967 onChange: onChangeControl,
29968 options: elements,
29969 selected: value,
29970 hideLabelFromVision,
29971 disabled: disabled2
29972 }
29973 );
29974 }
29975
29976 // packages/dataviews/build-module/components/dataform-controls/text.mjs
29977 var import_element111 = __toESM(require_element(), 1);
29978 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
29979 function Text3({
29980 data,
29981 field,
29982 onChange,
29983 hideLabelFromVision,
29984 markWhenOptional,
29985 config,
29986 validity
29987 }) {
29988 const { prefix, suffix } = config || {};
29989 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
29990 ValidatedText,
29991 {
29992 ...{
29993 data,
29994 field,
29995 onChange,
29996 hideLabelFromVision,
29997 markWhenOptional,
29998 validity,
29999 prefix: prefix ? (0, import_element111.createElement)(prefix) : void 0,
30000 suffix: suffix ? (0, import_element111.createElement)(suffix) : void 0
30001 }
30002 }
30003 );
30004 }
30005
30006 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
30007 var import_components41 = __toESM(require_components(), 1);
30008 var import_element112 = __toESM(require_element(), 1);
30009 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
30010 var { ValidatedToggleControl } = unlock3(import_components41.privateApis);
30011 function Toggle({
30012 field,
30013 onChange,
30014 data,
30015 hideLabelFromVision,
30016 markWhenOptional,
30017 validity
30018 }) {
30019 const { label, description, getValue, setValue, isValid: isValid2 } = field;
30020 const disabled2 = field.isDisabled({ item: data, field });
30021 const onChangeControl = (0, import_element112.useCallback)(() => {
30022 onChange(
30023 setValue({ item: data, value: !getValue({ item: data }) })
30024 );
30025 }, [onChange, setValue, data, getValue]);
30026 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30027 ValidatedToggleControl,
30028 {
30029 required: !!isValid2.required,
30030 markWhenOptional,
30031 customValidity: getCustomValidity(isValid2, validity),
30032 hidden: hideLabelFromVision,
30033 label,
30034 help: description,
30035 checked: getValue({ item: data }),
30036 onChange: onChangeControl,
30037 disabled: disabled2
30038 }
30039 );
30040 }
30041
30042 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
30043 var import_components42 = __toESM(require_components(), 1);
30044 var import_element113 = __toESM(require_element(), 1);
30045 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
30046 var { ValidatedTextareaControl } = unlock3(import_components42.privateApis);
30047 function Textarea({
30048 data,
30049 field,
30050 onChange,
30051 hideLabelFromVision,
30052 markWhenOptional,
30053 config,
30054 validity
30055 }) {
30056 const { rows = 4 } = config || {};
30057 const disabled2 = field.isDisabled({ item: data, field });
30058 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
30059 const value = field.getValue({ item: data });
30060 const onChangeControl = (0, import_element113.useCallback)(
30061 (newValue) => onChange(setValue({ item: data, value: newValue })),
30062 [data, onChange, setValue]
30063 );
30064 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30065 ValidatedTextareaControl,
30066 {
30067 required: !!isValid2.required,
30068 markWhenOptional,
30069 customValidity: getCustomValidity(isValid2, validity),
30070 label,
30071 placeholder,
30072 value: value ?? "",
30073 help: description,
30074 onChange: onChangeControl,
30075 rows,
30076 disabled: disabled2,
30077 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
30078 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
30079 __next40pxDefaultSize: true,
30080 hideLabelFromVision
30081 }
30082 );
30083 }
30084
30085 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
30086 var import_components43 = __toESM(require_components(), 1);
30087 var import_element114 = __toESM(require_element(), 1);
30088 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
30089 var { ValidatedToggleGroupControl } = unlock3(import_components43.privateApis);
30090 function ToggleGroup({
30091 data,
30092 field,
30093 onChange,
30094 hideLabelFromVision,
30095 markWhenOptional,
30096 validity
30097 }) {
30098 const { getValue, setValue, isValid: isValid2 } = field;
30099 const disabled2 = field.isDisabled({ item: data, field });
30100 const value = getValue({ item: data });
30101 const onChangeControl = (0, import_element114.useCallback)(
30102 (newValue) => onChange(setValue({ item: data, value: newValue })),
30103 [data, onChange, setValue]
30104 );
30105 const { elements, isLoading } = useElements({
30106 elements: field.elements,
30107 getElements: field.getElements
30108 });
30109 if (isLoading) {
30110 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(import_components43.Spinner, {});
30111 }
30112 if (elements.length === 0) {
30113 return null;
30114 }
30115 const selectedOption = elements.find((el) => el.value === value);
30116 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
30117 ValidatedToggleGroupControl,
30118 {
30119 required: !!field.isValid?.required,
30120 markWhenOptional,
30121 customValidity: getCustomValidity(isValid2, validity),
30122 __next40pxDefaultSize: true,
30123 isBlock: true,
30124 label: field.label,
30125 help: selectedOption?.description || field.description,
30126 onChange: onChangeControl,
30127 value,
30128 hideLabelFromVision,
30129 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
30130 import_components43.__experimentalToggleGroupControlOption,
30131 {
30132 label: el.label,
30133 value: el.value,
30134 disabled: disabled2
30135 },
30136 el.value
30137 ))
30138 }
30139 );
30140 }
30141
30142 // packages/dataviews/build-module/components/dataform-controls/array.mjs
30143 var import_components44 = __toESM(require_components(), 1);
30144 var import_element115 = __toESM(require_element(), 1);
30145 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
30146 var { ValidatedFormTokenField } = unlock3(import_components44.privateApis);
30147 function ArrayControl({
30148 data,
30149 field,
30150 onChange,
30151 hideLabelFromVision,
30152 markWhenOptional,
30153 validity
30154 }) {
30155 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
30156 const value = getValue({ item: data });
30157 const disabled2 = field.isDisabled({ item: data, field });
30158 const { elements, isLoading } = useElements({
30159 elements: field.elements,
30160 getElements: field.getElements
30161 });
30162 const arrayValueAsElements = (0, import_element115.useMemo)(
30163 () => Array.isArray(value) ? value.map((token) => {
30164 const element = elements?.find(
30165 (suggestion) => suggestion.value === token
30166 );
30167 return element || { value: token, label: token };
30168 }) : [],
30169 [value, elements]
30170 );
30171 const onChangeControl = (0, import_element115.useCallback)(
30172 (tokens) => {
30173 const valueTokens = tokens.map((token) => {
30174 if (typeof token === "object" && "value" in token) {
30175 return token.value;
30176 }
30177 return token;
30178 });
30179 onChange(setValue({ item: data, value: valueTokens }));
30180 },
30181 [onChange, setValue, data]
30182 );
30183 if (isLoading) {
30184 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_components44.Spinner, {});
30185 }
30186 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
30187 ValidatedFormTokenField,
30188 {
30189 required: !!isValid2?.required,
30190 markWhenOptional,
30191 customValidity: getCustomValidity(isValid2, validity),
30192 label: hideLabelFromVision ? void 0 : label,
30193 value: arrayValueAsElements,
30194 onChange: onChangeControl,
30195 placeholder,
30196 suggestions: elements?.map((element) => element.value),
30197 disabled: disabled2,
30198 __experimentalValidateInput: (token) => {
30199 if (field.isValid?.elements && elements) {
30200 return elements.some(
30201 (element) => element.value === token || element.label === token
30202 );
30203 }
30204 return true;
30205 },
30206 __experimentalExpandOnFocus: elements && elements.length > 0,
30207 help: description ?? (field.isValid?.elements ? "" : void 0),
30208 displayTransform: (token) => {
30209 if (typeof token === "object" && "label" in token) {
30210 return token.label;
30211 }
30212 if (typeof token === "string" && elements) {
30213 const element = elements.find(
30214 (el) => el.value === token
30215 );
30216 return element?.label || token;
30217 }
30218 return token;
30219 },
30220 __experimentalRenderItem: ({ item }) => {
30221 if (typeof item === "string" && elements) {
30222 const element = elements.find(
30223 (el) => el.value === item
30224 );
30225 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("span", { children: element?.label || item });
30226 }
30227 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("span", { children: item });
30228 }
30229 }
30230 );
30231 }
30232
30233 // node_modules/colord/index.mjs
30234 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
30235 var t = function(r3) {
30236 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
30237 };
30238 var n = function(r3, t2, n2) {
30239 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
30240 };
30241 var e = function(r3, t2, n2) {
30242 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
30243 };
30244 var u = function(r3) {
30245 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
30246 };
30247 var a = function(r3) {
30248 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
30249 };
30250 var o = function(r3) {
30251 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
30252 };
30253 var i = /^#([0-9a-f]{3,8})$/i;
30254 var s = function(r3) {
30255 var t2 = r3.toString(16);
30256 return t2.length < 2 ? "0" + t2 : t2;
30257 };
30258 var h = function(r3) {
30259 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;
30260 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
30261 };
30262 var b = function(r3) {
30263 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
30264 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
30265 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;
30266 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 };
30267 };
30268 var g = function(r3) {
30269 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
30270 };
30271 var d = function(r3) {
30272 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
30273 };
30274 var f = function(r3) {
30275 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 }));
30276 var t2, n2, e2;
30277 };
30278 var c = function(r3) {
30279 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 };
30280 var t2, n2, e2, u2;
30281 };
30282 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30283 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30284 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30285 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30286 var y = { string: [[function(r3) {
30287 var t2 = i.exec(r3);
30288 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;
30289 }, "hex"], [function(r3) {
30290 var t2 = v.exec(r3) || m.exec(r3);
30291 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;
30292 }, "rgb"], [function(t2) {
30293 var n2 = l.exec(t2) || p.exec(t2);
30294 if (!n2) return null;
30295 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) });
30296 return f(a2);
30297 }, "hsl"]], object: [[function(r3) {
30298 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
30299 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
30300 }, "rgb"], [function(r3) {
30301 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
30302 if (!t(n2) || !t(e2) || !t(u2)) return null;
30303 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
30304 return f(i2);
30305 }, "hsl"], [function(r3) {
30306 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
30307 if (!t(n2) || !t(a2) || !t(o2)) return null;
30308 var h2 = (function(r4) {
30309 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
30310 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
30311 return b(h2);
30312 }, "hsv"]] };
30313 var N = function(r3, t2) {
30314 for (var n2 = 0; n2 < t2.length; n2++) {
30315 var e2 = t2[n2][0](r3);
30316 if (e2) return [e2, t2[n2][1]];
30317 }
30318 return [null, void 0];
30319 };
30320 var x = function(r3) {
30321 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
30322 };
30323 var M = function(r3, t2) {
30324 var n2 = c(r3);
30325 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
30326 };
30327 var H = function(r3) {
30328 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
30329 };
30330 var $ = function(r3, t2) {
30331 var n2 = c(r3);
30332 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
30333 };
30334 var j = (function() {
30335 function r3(r4) {
30336 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
30337 }
30338 return r3.prototype.isValid = function() {
30339 return null !== this.parsed;
30340 }, r3.prototype.brightness = function() {
30341 return n(H(this.rgba), 2);
30342 }, r3.prototype.isDark = function() {
30343 return H(this.rgba) < 0.5;
30344 }, r3.prototype.isLight = function() {
30345 return H(this.rgba) >= 0.5;
30346 }, r3.prototype.toHex = function() {
30347 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;
30348 var r4, t2, e2, u2, a2, i2;
30349 }, r3.prototype.toRgb = function() {
30350 return o(this.rgba);
30351 }, r3.prototype.toRgbString = function() {
30352 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 + ")";
30353 var r4, t2, n2, e2, u2;
30354 }, r3.prototype.toHsl = function() {
30355 return d(c(this.rgba));
30356 }, r3.prototype.toHslString = function() {
30357 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 + "%)";
30358 var r4, t2, n2, e2, u2;
30359 }, r3.prototype.toHsv = function() {
30360 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
30361 var r4;
30362 }, r3.prototype.invert = function() {
30363 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
30364 var r4;
30365 }, r3.prototype.saturate = function(r4) {
30366 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
30367 }, r3.prototype.desaturate = function(r4) {
30368 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
30369 }, r3.prototype.grayscale = function() {
30370 return w(M(this.rgba, -1));
30371 }, r3.prototype.lighten = function(r4) {
30372 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
30373 }, r3.prototype.darken = function(r4) {
30374 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
30375 }, r3.prototype.rotate = function(r4) {
30376 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
30377 }, r3.prototype.alpha = function(r4) {
30378 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
30379 var t2;
30380 }, r3.prototype.hue = function(r4) {
30381 var t2 = c(this.rgba);
30382 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
30383 }, r3.prototype.isEqual = function(r4) {
30384 return this.toHex() === w(r4).toHex();
30385 }, r3;
30386 })();
30387 var w = function(r3) {
30388 return r3 instanceof j ? r3 : new j(r3);
30389 };
30390
30391 // packages/dataviews/build-module/components/dataform-controls/color.mjs
30392 var import_components45 = __toESM(require_components(), 1);
30393 var import_element116 = __toESM(require_element(), 1);
30394 var import_i18n42 = __toESM(require_i18n(), 1);
30395 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
30396 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components45.privateApis);
30397 var ColorPickerDropdown = ({
30398 color,
30399 onColorChange,
30400 disabled: disabled2
30401 }) => {
30402 const validColor = color && w(color).isValid() ? color : "#ffffff";
30403 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30404 import_components45.Dropdown,
30405 {
30406 className: "dataviews-controls__color-picker-dropdown",
30407 popoverProps: { resize: false },
30408 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30409 import_components45.Button,
30410 {
30411 onClick: onToggle,
30412 "aria-label": (0, import_i18n42.__)("Open color picker"),
30413 size: "small",
30414 disabled: disabled2,
30415 accessibleWhenDisabled: true,
30416 icon: () => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
30417 }
30418 ),
30419 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30420 import_components45.ColorPicker,
30421 {
30422 color: validColor,
30423 onChange: onColorChange,
30424 enableAlpha: true
30425 }
30426 ) })
30427 }
30428 );
30429 };
30430 function Color({
30431 data,
30432 field,
30433 onChange,
30434 hideLabelFromVision,
30435 markWhenOptional,
30436 validity
30437 }) {
30438 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
30439 const disabled2 = field.isDisabled({ item: data, field });
30440 const value = field.getValue({ item: data }) || "";
30441 const handleColorChange = (0, import_element116.useCallback)(
30442 (newColor) => {
30443 onChange(setValue({ item: data, value: newColor }));
30444 },
30445 [data, onChange, setValue]
30446 );
30447 const handleInputChange = (0, import_element116.useCallback)(
30448 (newValue) => {
30449 onChange(setValue({ item: data, value: newValue || "" }));
30450 },
30451 [data, onChange, setValue]
30452 );
30453 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30454 ValidatedInputControl3,
30455 {
30456 required: !!field.isValid?.required,
30457 markWhenOptional,
30458 customValidity: getCustomValidity(isValid2, validity),
30459 label,
30460 placeholder,
30461 value,
30462 help: description,
30463 onChange: handleInputChange,
30464 hideLabelFromVision,
30465 type: "text",
30466 disabled: disabled2,
30467 prefix: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30468 ColorPickerDropdown,
30469 {
30470 color: value,
30471 onColorChange: handleColorChange,
30472 disabled: disabled2
30473 }
30474 ) })
30475 }
30476 );
30477 }
30478
30479 // packages/dataviews/build-module/components/dataform-controls/password.mjs
30480 var import_components46 = __toESM(require_components(), 1);
30481 var import_element117 = __toESM(require_element(), 1);
30482 var import_i18n43 = __toESM(require_i18n(), 1);
30483 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1);
30484 function Password({
30485 data,
30486 field,
30487 onChange,
30488 hideLabelFromVision,
30489 markWhenOptional,
30490 validity
30491 }) {
30492 const [isVisible2, setIsVisible] = (0, import_element117.useState)(false);
30493 const disabled2 = field.isDisabled({ item: data, field });
30494 const toggleVisibility = (0, import_element117.useCallback)(() => {
30495 setIsVisible((prev) => !prev);
30496 }, []);
30497 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
30498 ValidatedText,
30499 {
30500 ...{
30501 data,
30502 field,
30503 onChange,
30504 hideLabelFromVision,
30505 markWhenOptional,
30506 validity,
30507 type: isVisible2 ? "text" : "password",
30508 suffix: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
30509 import_components46.Button,
30510 {
30511 icon: isVisible2 ? unseen_default : seen_default,
30512 onClick: toggleVisibility,
30513 size: "small",
30514 label: isVisible2 ? (0, import_i18n43.__)("Hide password") : (0, import_i18n43.__)("Show password"),
30515 disabled: disabled2,
30516 accessibleWhenDisabled: true
30517 }
30518 ) })
30519 }
30520 }
30521 );
30522 }
30523
30524 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
30525 function hasElements(field) {
30526 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
30527 }
30528
30529 // packages/dataviews/build-module/components/dataform-controls/index.mjs
30530 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1);
30531 var FORM_CONTROLS = {
30532 adaptiveSelect: AdaptiveSelect,
30533 array: ArrayControl,
30534 checkbox: Checkbox,
30535 color: Color,
30536 combobox: Combobox3,
30537 datetime: DateTime,
30538 date: DateControl,
30539 email: Email,
30540 telephone: Telephone,
30541 url: Url,
30542 integer: Integer,
30543 number: Number2,
30544 password: Password,
30545 radio: Radio,
30546 select: Select,
30547 text: Text3,
30548 toggle: Toggle,
30549 textarea: Textarea,
30550 toggleGroup: ToggleGroup
30551 };
30552 function isEditConfig(value) {
30553 return value && typeof value === "object" && typeof value.control === "string";
30554 }
30555 function createConfiguredControl(config) {
30556 const { control, ...controlConfig } = config;
30557 const BaseControlType = getControlByType(control);
30558 if (BaseControlType === null) {
30559 return null;
30560 }
30561 return function ConfiguredControl(props) {
30562 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(BaseControlType, { ...props, config: controlConfig });
30563 };
30564 }
30565 function getControl(field, fallback) {
30566 if (typeof field.Edit === "function") {
30567 return field.Edit;
30568 }
30569 if (typeof field.Edit === "string") {
30570 return getControlByType(field.Edit);
30571 }
30572 if (isEditConfig(field.Edit)) {
30573 return createConfiguredControl(field.Edit);
30574 }
30575 if (hasElements(field) && field.type !== "array") {
30576 return getControlByType("adaptiveSelect");
30577 }
30578 if (fallback === null) {
30579 return null;
30580 }
30581 return getControlByType(fallback);
30582 }
30583 function getControlByType(type) {
30584 if (Object.keys(FORM_CONTROLS).includes(type)) {
30585 return FORM_CONTROLS[type];
30586 }
30587 return null;
30588 }
30589
30590 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
30591 function getFilterBy(field, defaultOperators, validOperators) {
30592 if (field.filterBy === false) {
30593 return false;
30594 }
30595 const operators = field.filterBy?.operators?.filter(
30596 (op) => validOperators.includes(op)
30597 ) ?? defaultOperators;
30598 if (operators.length === 0) {
30599 return false;
30600 }
30601 return {
30602 isPrimary: !!field.filterBy?.isPrimary,
30603 operators
30604 };
30605 }
30606 var get_filter_by_default = getFilterBy;
30607
30608 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
30609 var getValueFromId = (id) => ({ item }) => {
30610 const path = id.split(".");
30611 let value = item;
30612 for (const segment of path) {
30613 if (value.hasOwnProperty(segment)) {
30614 value = value[segment];
30615 } else {
30616 value = void 0;
30617 }
30618 }
30619 return value;
30620 };
30621 var get_value_from_id_default = getValueFromId;
30622
30623 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
30624 var setValueFromId = (id) => ({ value }) => {
30625 const path = id.split(".");
30626 const result = {};
30627 let current = result;
30628 for (const segment of path.slice(0, -1)) {
30629 current[segment] = {};
30630 current = current[segment];
30631 }
30632 current[path.at(-1)] = value;
30633 return result;
30634 };
30635 var set_value_from_id_default = setValueFromId;
30636
30637 // packages/dataviews/build-module/field-types/email.mjs
30638 var import_i18n44 = __toESM(require_i18n(), 1);
30639
30640 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
30641 function RenderFromElements({
30642 item,
30643 field
30644 }) {
30645 const { elements, isLoading } = useElements({
30646 elements: field.elements,
30647 getElements: field.getElements
30648 });
30649 const value = field.getValue({ item });
30650 if (isLoading) {
30651 return value;
30652 }
30653 if (elements.length === 0) {
30654 return value;
30655 }
30656 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
30657 }
30658
30659 // packages/dataviews/build-module/field-types/utils/render-default.mjs
30660 var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1);
30661 function render({
30662 item,
30663 field
30664 }) {
30665 if (field.hasElements) {
30666 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(RenderFromElements, { item, field });
30667 }
30668 return field.getValueFormatted({ item, field });
30669 }
30670
30671 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
30672 var sort_text_default = (a2, b2, direction) => {
30673 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
30674 };
30675
30676 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
30677 function isValidRequired(item, field) {
30678 const value = field.getValue({ item });
30679 return ![void 0, "", null].includes(value);
30680 }
30681
30682 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
30683 function isValidMinLength(item, field) {
30684 if (typeof field.isValid.minLength?.constraint !== "number") {
30685 return false;
30686 }
30687 const value = field.getValue({ item });
30688 if ([void 0, "", null].includes(value)) {
30689 return true;
30690 }
30691 return String(value).length >= field.isValid.minLength.constraint;
30692 }
30693
30694 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
30695 function isValidMaxLength(item, field) {
30696 if (typeof field.isValid.maxLength?.constraint !== "number") {
30697 return false;
30698 }
30699 const value = field.getValue({ item });
30700 if ([void 0, "", null].includes(value)) {
30701 return true;
30702 }
30703 return String(value).length <= field.isValid.maxLength.constraint;
30704 }
30705
30706 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
30707 function isValidPattern(item, field) {
30708 if (field.isValid.pattern?.constraint === void 0) {
30709 return true;
30710 }
30711 try {
30712 const regexp = new RegExp(field.isValid.pattern.constraint);
30713 const value = field.getValue({ item });
30714 if ([void 0, "", null].includes(value)) {
30715 return true;
30716 }
30717 return regexp.test(String(value));
30718 } catch {
30719 return false;
30720 }
30721 }
30722
30723 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
30724 function isValidElements(item, field) {
30725 const elements = field.elements ?? [];
30726 const validValues = elements.map((el) => el.value);
30727 if (validValues.length === 0) {
30728 return true;
30729 }
30730 const value = field.getValue({ item });
30731 return [].concat(value).every((v2) => validValues.includes(v2));
30732 }
30733
30734 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
30735 function getValueFormatted({
30736 item,
30737 field
30738 }) {
30739 return field.getValue({ item });
30740 }
30741 var get_value_formatted_default_default = getValueFormatted;
30742
30743 // packages/dataviews/build-module/field-types/email.mjs
30744 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])?)*$/;
30745 function isValidCustom(item, field) {
30746 const value = field.getValue({ item });
30747 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
30748 return (0, import_i18n44.__)("Value must be a valid email address.");
30749 }
30750 return null;
30751 }
30752 var email_default = {
30753 type: "email",
30754 render,
30755 Edit: "email",
30756 sort: sort_text_default,
30757 enableSorting: true,
30758 enableGlobalSearch: false,
30759 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
30760 validOperators: [
30761 OPERATOR_IS,
30762 OPERATOR_IS_NOT,
30763 OPERATOR_CONTAINS,
30764 OPERATOR_NOT_CONTAINS,
30765 OPERATOR_STARTS_WITH,
30766 // Multiple selection
30767 OPERATOR_IS_ANY,
30768 OPERATOR_IS_NONE,
30769 OPERATOR_IS_ALL,
30770 OPERATOR_IS_NOT_ALL
30771 ],
30772 format: {},
30773 getValueFormatted: get_value_formatted_default_default,
30774 validate: {
30775 required: isValidRequired,
30776 pattern: isValidPattern,
30777 minLength: isValidMinLength,
30778 maxLength: isValidMaxLength,
30779 elements: isValidElements,
30780 custom: isValidCustom
30781 }
30782 };
30783
30784 // packages/dataviews/build-module/field-types/integer.mjs
30785 var import_i18n45 = __toESM(require_i18n(), 1);
30786
30787 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
30788 var sort_number_default = (a2, b2, direction) => {
30789 return direction === "asc" ? a2 - b2 : b2 - a2;
30790 };
30791
30792 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
30793 function isValidMin(item, field) {
30794 if (typeof field.isValid.min?.constraint !== "number") {
30795 return false;
30796 }
30797 const value = field.getValue({ item });
30798 if ([void 0, "", null].includes(value)) {
30799 return true;
30800 }
30801 return Number(value) >= field.isValid.min.constraint;
30802 }
30803
30804 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
30805 function isValidMax(item, field) {
30806 if (typeof field.isValid.max?.constraint !== "number") {
30807 return false;
30808 }
30809 const value = field.getValue({ item });
30810 if ([void 0, "", null].includes(value)) {
30811 return true;
30812 }
30813 return Number(value) <= field.isValid.max.constraint;
30814 }
30815
30816 // packages/dataviews/build-module/field-types/integer.mjs
30817 var format2 = {
30818 separatorThousand: ","
30819 };
30820 function getValueFormatted2({
30821 item,
30822 field
30823 }) {
30824 let value = field.getValue({ item });
30825 if (value === null || value === void 0) {
30826 return "";
30827 }
30828 value = Number(value);
30829 if (!Number.isFinite(value)) {
30830 return String(value);
30831 }
30832 let formatInteger;
30833 if (field.type !== "integer") {
30834 formatInteger = format2;
30835 } else {
30836 formatInteger = field.format;
30837 }
30838 const { separatorThousand } = formatInteger;
30839 const integerValue = Math.trunc(value);
30840 if (!separatorThousand) {
30841 return String(integerValue);
30842 }
30843 return String(integerValue).replace(
30844 /\B(?=(\d{3})+(?!\d))/g,
30845 separatorThousand
30846 );
30847 }
30848 function isValidCustom2(item, field) {
30849 const value = field.getValue({ item });
30850 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
30851 return (0, import_i18n45.__)("Value must be an integer.");
30852 }
30853 return null;
30854 }
30855 var integer_default = {
30856 type: "integer",
30857 render,
30858 Edit: "integer",
30859 sort: sort_number_default,
30860 enableSorting: true,
30861 enableGlobalSearch: false,
30862 defaultOperators: [
30863 OPERATOR_IS,
30864 OPERATOR_IS_NOT,
30865 OPERATOR_LESS_THAN,
30866 OPERATOR_GREATER_THAN,
30867 OPERATOR_LESS_THAN_OR_EQUAL,
30868 OPERATOR_GREATER_THAN_OR_EQUAL,
30869 OPERATOR_BETWEEN
30870 ],
30871 validOperators: [
30872 // Single-selection
30873 OPERATOR_IS,
30874 OPERATOR_IS_NOT,
30875 OPERATOR_LESS_THAN,
30876 OPERATOR_GREATER_THAN,
30877 OPERATOR_LESS_THAN_OR_EQUAL,
30878 OPERATOR_GREATER_THAN_OR_EQUAL,
30879 OPERATOR_BETWEEN,
30880 // Multiple-selection
30881 OPERATOR_IS_ANY,
30882 OPERATOR_IS_NONE,
30883 OPERATOR_IS_ALL,
30884 OPERATOR_IS_NOT_ALL
30885 ],
30886 format: format2,
30887 getValueFormatted: getValueFormatted2,
30888 validate: {
30889 required: isValidRequired,
30890 min: isValidMin,
30891 max: isValidMax,
30892 elements: isValidElements,
30893 custom: isValidCustom2
30894 }
30895 };
30896
30897 // packages/dataviews/build-module/field-types/number.mjs
30898 var import_i18n46 = __toESM(require_i18n(), 1);
30899 var format3 = {
30900 separatorThousand: ",",
30901 separatorDecimal: ".",
30902 decimals: 2
30903 };
30904 function getValueFormatted3({
30905 item,
30906 field
30907 }) {
30908 let value = field.getValue({ item });
30909 if (value === null || value === void 0) {
30910 return "";
30911 }
30912 value = Number(value);
30913 if (!Number.isFinite(value)) {
30914 return String(value);
30915 }
30916 let formatNumber;
30917 if (field.type !== "number") {
30918 formatNumber = format3;
30919 } else {
30920 formatNumber = field.format;
30921 }
30922 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
30923 const fixedValue = value.toFixed(decimals);
30924 const [integerPart, decimalPart] = fixedValue.split(".");
30925 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
30926 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
30927 }
30928 function isEmpty2(value) {
30929 return value === "" || value === void 0 || value === null;
30930 }
30931 function isValidCustom3(item, field) {
30932 const value = field.getValue({ item });
30933 if (!isEmpty2(value) && !Number.isFinite(value)) {
30934 return (0, import_i18n46.__)("Value must be a number.");
30935 }
30936 return null;
30937 }
30938 var number_default = {
30939 type: "number",
30940 render,
30941 Edit: "number",
30942 sort: sort_number_default,
30943 enableSorting: true,
30944 enableGlobalSearch: false,
30945 defaultOperators: [
30946 OPERATOR_IS,
30947 OPERATOR_IS_NOT,
30948 OPERATOR_LESS_THAN,
30949 OPERATOR_GREATER_THAN,
30950 OPERATOR_LESS_THAN_OR_EQUAL,
30951 OPERATOR_GREATER_THAN_OR_EQUAL,
30952 OPERATOR_BETWEEN
30953 ],
30954 validOperators: [
30955 // Single-selection
30956 OPERATOR_IS,
30957 OPERATOR_IS_NOT,
30958 OPERATOR_LESS_THAN,
30959 OPERATOR_GREATER_THAN,
30960 OPERATOR_LESS_THAN_OR_EQUAL,
30961 OPERATOR_GREATER_THAN_OR_EQUAL,
30962 OPERATOR_BETWEEN,
30963 // Multiple-selection
30964 OPERATOR_IS_ANY,
30965 OPERATOR_IS_NONE,
30966 OPERATOR_IS_ALL,
30967 OPERATOR_IS_NOT_ALL
30968 ],
30969 format: format3,
30970 getValueFormatted: getValueFormatted3,
30971 validate: {
30972 required: isValidRequired,
30973 min: isValidMin,
30974 max: isValidMax,
30975 elements: isValidElements,
30976 custom: isValidCustom3
30977 }
30978 };
30979
30980 // packages/dataviews/build-module/field-types/text.mjs
30981 var text_default = {
30982 type: "text",
30983 render,
30984 Edit: "text",
30985 sort: sort_text_default,
30986 enableSorting: true,
30987 enableGlobalSearch: false,
30988 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
30989 validOperators: [
30990 // Single selection
30991 OPERATOR_IS,
30992 OPERATOR_IS_NOT,
30993 OPERATOR_CONTAINS,
30994 OPERATOR_NOT_CONTAINS,
30995 OPERATOR_STARTS_WITH,
30996 // Multiple selection
30997 OPERATOR_IS_ANY,
30998 OPERATOR_IS_NONE,
30999 OPERATOR_IS_ALL,
31000 OPERATOR_IS_NOT_ALL
31001 ],
31002 format: {},
31003 getValueFormatted: get_value_formatted_default_default,
31004 validate: {
31005 required: isValidRequired,
31006 pattern: isValidPattern,
31007 minLength: isValidMinLength,
31008 maxLength: isValidMaxLength,
31009 elements: isValidElements
31010 }
31011 };
31012
31013 // packages/dataviews/build-module/field-types/datetime.mjs
31014 var import_date7 = __toESM(require_date(), 1);
31015
31016 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
31017 var import_date6 = __toESM(require_date(), 1);
31018 function parseDateLike(value) {
31019 if (!value) {
31020 return null;
31021 }
31022 if (!isValid(new Date(value))) {
31023 return null;
31024 }
31025 const parsed = (0, import_date6.getDate)(value);
31026 return parsed && isValid(parsed) ? parsed : null;
31027 }
31028 function validateDateLikeBoundary(item, field, boundary) {
31029 const constraint = field.isValid[boundary]?.constraint;
31030 if (typeof constraint !== "string") {
31031 return false;
31032 }
31033 const value = field.getValue({ item });
31034 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
31035 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
31036 return true;
31037 }
31038 const parsedConstraint = parseDateLike(constraint);
31039 const parsedValue = parseDateLike(String(boundaryValue));
31040 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
31041 }
31042 function isValidMinDate(item, field) {
31043 return validateDateLikeBoundary(item, field, "min");
31044 }
31045 function isValidMaxDate(item, field) {
31046 return validateDateLikeBoundary(item, field, "max");
31047 }
31048
31049 // packages/dataviews/build-module/field-types/datetime.mjs
31050 var format4 = {
31051 datetime: (0, import_date7.getSettings)().formats.datetime,
31052 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
31053 };
31054 function getValueFormatted4({
31055 item,
31056 field
31057 }) {
31058 const value = field.getValue({ item });
31059 if (["", void 0, null].includes(value)) {
31060 return "";
31061 }
31062 let formatDatetime;
31063 if (field.type !== "datetime") {
31064 formatDatetime = format4;
31065 } else {
31066 formatDatetime = field.format;
31067 }
31068 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
31069 }
31070 var sort = (a2, b2, direction) => {
31071 const timeA = new Date(a2).getTime();
31072 const timeB = new Date(b2).getTime();
31073 return direction === "asc" ? timeA - timeB : timeB - timeA;
31074 };
31075 var datetime_default = {
31076 type: "datetime",
31077 render,
31078 Edit: "datetime",
31079 sort,
31080 enableSorting: true,
31081 enableGlobalSearch: false,
31082 defaultOperators: [
31083 OPERATOR_ON,
31084 OPERATOR_NOT_ON,
31085 OPERATOR_BEFORE,
31086 OPERATOR_AFTER,
31087 OPERATOR_BEFORE_INC,
31088 OPERATOR_AFTER_INC,
31089 OPERATOR_IN_THE_PAST,
31090 OPERATOR_OVER
31091 ],
31092 validOperators: [
31093 OPERATOR_ON,
31094 OPERATOR_NOT_ON,
31095 OPERATOR_BEFORE,
31096 OPERATOR_AFTER,
31097 OPERATOR_BEFORE_INC,
31098 OPERATOR_AFTER_INC,
31099 OPERATOR_IN_THE_PAST,
31100 OPERATOR_OVER
31101 ],
31102 format: format4,
31103 getValueFormatted: getValueFormatted4,
31104 validate: {
31105 required: isValidRequired,
31106 elements: isValidElements,
31107 min: isValidMinDate,
31108 max: isValidMaxDate
31109 }
31110 };
31111
31112 // packages/dataviews/build-module/field-types/date.mjs
31113 var import_date8 = __toESM(require_date(), 1);
31114 var format5 = {
31115 date: (0, import_date8.getSettings)().formats.date,
31116 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
31117 };
31118 function getValueFormatted5({
31119 item,
31120 field
31121 }) {
31122 const value = field.getValue({ item });
31123 if (["", void 0, null].includes(value)) {
31124 return "";
31125 }
31126 let formatDate2;
31127 if (field.type !== "date") {
31128 formatDate2 = format5;
31129 } else {
31130 formatDate2 = field.format;
31131 }
31132 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
31133 }
31134 var sort2 = (a2, b2, direction) => {
31135 const timeA = new Date(a2).getTime();
31136 const timeB = new Date(b2).getTime();
31137 return direction === "asc" ? timeA - timeB : timeB - timeA;
31138 };
31139 var date_default = {
31140 type: "date",
31141 render,
31142 Edit: "date",
31143 sort: sort2,
31144 enableSorting: true,
31145 enableGlobalSearch: false,
31146 defaultOperators: [
31147 OPERATOR_ON,
31148 OPERATOR_NOT_ON,
31149 OPERATOR_BEFORE,
31150 OPERATOR_AFTER,
31151 OPERATOR_BEFORE_INC,
31152 OPERATOR_AFTER_INC,
31153 OPERATOR_IN_THE_PAST,
31154 OPERATOR_OVER,
31155 OPERATOR_BETWEEN
31156 ],
31157 validOperators: [
31158 OPERATOR_ON,
31159 OPERATOR_NOT_ON,
31160 OPERATOR_BEFORE,
31161 OPERATOR_AFTER,
31162 OPERATOR_BEFORE_INC,
31163 OPERATOR_AFTER_INC,
31164 OPERATOR_IN_THE_PAST,
31165 OPERATOR_OVER,
31166 OPERATOR_BETWEEN
31167 ],
31168 format: format5,
31169 getValueFormatted: getValueFormatted5,
31170 validate: {
31171 required: isValidRequired,
31172 elements: isValidElements,
31173 min: isValidMinDate,
31174 max: isValidMaxDate
31175 }
31176 };
31177
31178 // packages/dataviews/build-module/field-types/boolean.mjs
31179 var import_i18n47 = __toESM(require_i18n(), 1);
31180
31181 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
31182 function isValidRequiredForBool(item, field) {
31183 const value = field.getValue({ item });
31184 return value === true;
31185 }
31186
31187 // packages/dataviews/build-module/field-types/boolean.mjs
31188 function getValueFormatted6({
31189 item,
31190 field
31191 }) {
31192 const value = field.getValue({ item });
31193 if (value === true) {
31194 return (0, import_i18n47.__)("True");
31195 }
31196 if (value === false) {
31197 return (0, import_i18n47.__)("False");
31198 }
31199 return "";
31200 }
31201 function isValidCustom4(item, field) {
31202 const value = field.getValue({ item });
31203 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
31204 return (0, import_i18n47.__)("Value must be true, false, or undefined");
31205 }
31206 return null;
31207 }
31208 var sort3 = (a2, b2, direction) => {
31209 const boolA = Boolean(a2);
31210 const boolB = Boolean(b2);
31211 if (boolA === boolB) {
31212 return 0;
31213 }
31214 if (direction === "asc") {
31215 return boolA ? 1 : -1;
31216 }
31217 return boolA ? -1 : 1;
31218 };
31219 var boolean_default = {
31220 type: "boolean",
31221 render,
31222 Edit: "checkbox",
31223 sort: sort3,
31224 validate: {
31225 required: isValidRequiredForBool,
31226 elements: isValidElements,
31227 custom: isValidCustom4
31228 },
31229 enableSorting: true,
31230 enableGlobalSearch: false,
31231 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31232 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31233 format: {},
31234 getValueFormatted: getValueFormatted6
31235 };
31236
31237 // packages/dataviews/build-module/field-types/media.mjs
31238 var media_default = {
31239 type: "media",
31240 render: () => null,
31241 Edit: null,
31242 sort: () => 0,
31243 enableSorting: false,
31244 enableGlobalSearch: false,
31245 defaultOperators: [],
31246 validOperators: [],
31247 format: {},
31248 getValueFormatted: get_value_formatted_default_default,
31249 // cannot validate any constraint, so
31250 // the only available validation for the field author
31251 // would be providing a custom validator.
31252 validate: {}
31253 };
31254
31255 // packages/dataviews/build-module/field-types/array.mjs
31256 var import_i18n48 = __toESM(require_i18n(), 1);
31257
31258 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
31259 function isValidRequiredForArray(item, field) {
31260 const value = field.getValue({ item });
31261 return Array.isArray(value) && value.length > 0 && value.every(
31262 (element) => ![void 0, "", null].includes(element)
31263 );
31264 }
31265
31266 // packages/dataviews/build-module/field-types/array.mjs
31267 function getValueFormatted7({
31268 item,
31269 field
31270 }) {
31271 const value = field.getValue({ item });
31272 const arr = Array.isArray(value) ? value : [];
31273 return arr.join(", ");
31274 }
31275 function render2({ item, field }) {
31276 return getValueFormatted7({ item, field });
31277 }
31278 function isValidCustom5(item, field) {
31279 const value = field.getValue({ item });
31280 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
31281 return (0, import_i18n48.__)("Value must be an array.");
31282 }
31283 if (!value.every((v2) => typeof v2 === "string")) {
31284 return (0, import_i18n48.__)("Every value must be a string.");
31285 }
31286 return null;
31287 }
31288 var sort4 = (a2, b2, direction) => {
31289 const arrA = Array.isArray(a2) ? a2 : [];
31290 const arrB = Array.isArray(b2) ? b2 : [];
31291 if (arrA.length !== arrB.length) {
31292 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
31293 }
31294 const joinedA = arrA.join(",");
31295 const joinedB = arrB.join(",");
31296 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
31297 };
31298 var array_default = {
31299 type: "array",
31300 render: render2,
31301 Edit: "array",
31302 sort: sort4,
31303 enableSorting: true,
31304 enableGlobalSearch: false,
31305 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31306 validOperators: [
31307 OPERATOR_IS_ANY,
31308 OPERATOR_IS_NONE,
31309 OPERATOR_IS_ALL,
31310 OPERATOR_IS_NOT_ALL
31311 ],
31312 format: {},
31313 getValueFormatted: getValueFormatted7,
31314 validate: {
31315 required: isValidRequiredForArray,
31316 elements: isValidElements,
31317 custom: isValidCustom5
31318 }
31319 };
31320
31321 // packages/dataviews/build-module/field-types/password.mjs
31322 function getValueFormatted8({
31323 item,
31324 field
31325 }) {
31326 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
31327 }
31328 var password_default = {
31329 type: "password",
31330 render,
31331 Edit: "password",
31332 sort: () => 0,
31333 // Passwords should not be sortable for security reasons
31334 enableSorting: false,
31335 enableGlobalSearch: false,
31336 defaultOperators: [],
31337 validOperators: [],
31338 format: {},
31339 getValueFormatted: getValueFormatted8,
31340 validate: {
31341 required: isValidRequired,
31342 pattern: isValidPattern,
31343 minLength: isValidMinLength,
31344 maxLength: isValidMaxLength,
31345 elements: isValidElements
31346 }
31347 };
31348
31349 // packages/dataviews/build-module/field-types/telephone.mjs
31350 var telephone_default = {
31351 type: "telephone",
31352 render,
31353 Edit: "telephone",
31354 sort: sort_text_default,
31355 enableSorting: true,
31356 enableGlobalSearch: false,
31357 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31358 validOperators: [
31359 OPERATOR_IS,
31360 OPERATOR_IS_NOT,
31361 OPERATOR_CONTAINS,
31362 OPERATOR_NOT_CONTAINS,
31363 OPERATOR_STARTS_WITH,
31364 // Multiple selection
31365 OPERATOR_IS_ANY,
31366 OPERATOR_IS_NONE,
31367 OPERATOR_IS_ALL,
31368 OPERATOR_IS_NOT_ALL
31369 ],
31370 format: {},
31371 getValueFormatted: get_value_formatted_default_default,
31372 validate: {
31373 required: isValidRequired,
31374 pattern: isValidPattern,
31375 minLength: isValidMinLength,
31376 maxLength: isValidMaxLength,
31377 elements: isValidElements
31378 }
31379 };
31380
31381 // packages/dataviews/build-module/field-types/color.mjs
31382 var import_i18n49 = __toESM(require_i18n(), 1);
31383 var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1);
31384 function render3({ item, field }) {
31385 if (field.hasElements) {
31386 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(RenderFromElements, { item, field });
31387 }
31388 const value = get_value_formatted_default_default({ item, field });
31389 if (!value || !w(value).isValid()) {
31390 return value;
31391 }
31392 return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
31393 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
31394 "div",
31395 {
31396 style: {
31397 width: "16px",
31398 height: "16px",
31399 borderRadius: "50%",
31400 backgroundColor: value,
31401 border: "1px solid #ddd",
31402 flexShrink: 0
31403 }
31404 }
31405 ),
31406 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: value })
31407 ] });
31408 }
31409 function isValidCustom6(item, field) {
31410 const value = field.getValue({ item });
31411 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
31412 return (0, import_i18n49.__)("Value must be a valid color.");
31413 }
31414 return null;
31415 }
31416 var sort5 = (a2, b2, direction) => {
31417 const colorA = w(a2);
31418 const colorB = w(b2);
31419 if (!colorA.isValid() && !colorB.isValid()) {
31420 return 0;
31421 }
31422 if (!colorA.isValid()) {
31423 return direction === "asc" ? 1 : -1;
31424 }
31425 if (!colorB.isValid()) {
31426 return direction === "asc" ? -1 : 1;
31427 }
31428 const hslA = colorA.toHsl();
31429 const hslB = colorB.toHsl();
31430 if (hslA.h !== hslB.h) {
31431 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
31432 }
31433 if (hslA.s !== hslB.s) {
31434 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
31435 }
31436 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
31437 };
31438 var color_default = {
31439 type: "color",
31440 render: render3,
31441 Edit: "color",
31442 sort: sort5,
31443 enableSorting: true,
31444 enableGlobalSearch: false,
31445 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31446 validOperators: [
31447 OPERATOR_IS,
31448 OPERATOR_IS_NOT,
31449 OPERATOR_IS_ANY,
31450 OPERATOR_IS_NONE
31451 ],
31452 format: {},
31453 getValueFormatted: get_value_formatted_default_default,
31454 validate: {
31455 required: isValidRequired,
31456 elements: isValidElements,
31457 custom: isValidCustom6
31458 }
31459 };
31460
31461 // packages/dataviews/build-module/field-types/url.mjs
31462 var url_default = {
31463 type: "url",
31464 render,
31465 Edit: "url",
31466 sort: sort_text_default,
31467 enableSorting: true,
31468 enableGlobalSearch: false,
31469 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31470 validOperators: [
31471 OPERATOR_IS,
31472 OPERATOR_IS_NOT,
31473 OPERATOR_CONTAINS,
31474 OPERATOR_NOT_CONTAINS,
31475 OPERATOR_STARTS_WITH,
31476 // Multiple selection
31477 OPERATOR_IS_ANY,
31478 OPERATOR_IS_NONE,
31479 OPERATOR_IS_ALL,
31480 OPERATOR_IS_NOT_ALL
31481 ],
31482 format: {},
31483 getValueFormatted: get_value_formatted_default_default,
31484 validate: {
31485 required: isValidRequired,
31486 pattern: isValidPattern,
31487 minLength: isValidMinLength,
31488 maxLength: isValidMaxLength,
31489 elements: isValidElements
31490 }
31491 };
31492
31493 // packages/dataviews/build-module/field-types/no-type.mjs
31494 var sort6 = (a2, b2, direction) => {
31495 if (typeof a2 === "number" && typeof b2 === "number") {
31496 return sort_number_default(a2, b2, direction);
31497 }
31498 return sort_text_default(a2, b2, direction);
31499 };
31500 var no_type_default = {
31501 // type: no type for this one
31502 render,
31503 Edit: null,
31504 sort: sort6,
31505 enableSorting: true,
31506 enableGlobalSearch: false,
31507 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31508 validOperators: getAllOperatorNames(),
31509 format: {},
31510 getValueFormatted: get_value_formatted_default_default,
31511 validate: {
31512 required: isValidRequired,
31513 elements: isValidElements
31514 }
31515 };
31516
31517 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
31518 function supportsNumericRangeConstraint(type) {
31519 return type === "integer" || type === "number";
31520 }
31521 function supportsDateRangeConstraint(type) {
31522 return type === "date" || type === "datetime";
31523 }
31524 function normalizeRangeRule(value, fieldType, key2) {
31525 const validator = fieldType.validate[key2];
31526 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
31527 return { constraint: value, validate: validator };
31528 }
31529 return void 0;
31530 }
31531 function getIsValid(field, fieldType) {
31532 const rules = field.isValid;
31533 let required;
31534 if (rules?.required === true && fieldType.validate.required !== void 0) {
31535 required = {
31536 constraint: true,
31537 validate: fieldType.validate.required
31538 };
31539 }
31540 let elements;
31541 if ((rules?.elements === true || // elements is enabled unless the field opts-out
31542 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
31543 elements = {
31544 constraint: true,
31545 validate: fieldType.validate.elements
31546 };
31547 }
31548 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
31549 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
31550 const minLengthValue = rules?.minLength;
31551 let minLength;
31552 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
31553 minLength = {
31554 constraint: minLengthValue,
31555 validate: fieldType.validate.minLength
31556 };
31557 }
31558 const maxLengthValue = rules?.maxLength;
31559 let maxLength;
31560 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
31561 maxLength = {
31562 constraint: maxLengthValue,
31563 validate: fieldType.validate.maxLength
31564 };
31565 }
31566 const patternValue = rules?.pattern;
31567 let pattern;
31568 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
31569 pattern = {
31570 constraint: patternValue,
31571 validate: fieldType.validate.pattern
31572 };
31573 }
31574 const custom = rules?.custom ?? fieldType.validate.custom;
31575 return {
31576 required,
31577 elements,
31578 min: min2,
31579 max: max2,
31580 minLength,
31581 maxLength,
31582 pattern,
31583 custom
31584 };
31585 }
31586
31587 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
31588 function getFilter(fieldType) {
31589 return fieldType.validOperators.reduce((accumulator, operator) => {
31590 const operatorObj = getOperatorByName(operator);
31591 if (operatorObj?.filter) {
31592 accumulator[operator] = operatorObj.filter;
31593 }
31594 return accumulator;
31595 }, {});
31596 }
31597
31598 // packages/dataviews/build-module/field-types/utils/get-format.mjs
31599 function getFormat(field, fieldType) {
31600 return {
31601 ...fieldType.format,
31602 ...field.format
31603 };
31604 }
31605 var get_format_default = getFormat;
31606
31607 // packages/dataviews/build-module/field-types/index.mjs
31608 function getFieldTypeByName(type) {
31609 const found = [
31610 email_default,
31611 integer_default,
31612 number_default,
31613 text_default,
31614 datetime_default,
31615 date_default,
31616 boolean_default,
31617 media_default,
31618 array_default,
31619 password_default,
31620 telephone_default,
31621 color_default,
31622 url_default
31623 ].find((fieldType) => fieldType?.type === type);
31624 if (!!found) {
31625 return found;
31626 }
31627 return no_type_default;
31628 }
31629 function normalizeFields(fields2) {
31630 return fields2.map((field) => {
31631 const fieldType = getFieldTypeByName(field.type);
31632 const getValue = field.getValue || get_value_from_id_default(field.id);
31633 const sort7 = function(a2, b2, direction) {
31634 const aValue = getValue({ item: a2 });
31635 const bValue = getValue({ item: b2 });
31636 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
31637 };
31638 return {
31639 id: field.id,
31640 label: field.label || field.id,
31641 header: field.header || field.label || field.id,
31642 description: field.description,
31643 placeholder: field.placeholder,
31644 getValue,
31645 setValue: field.setValue || set_value_from_id_default(field.id),
31646 elements: field.elements,
31647 getElements: field.getElements,
31648 hasElements: hasElements(field),
31649 isVisible: field.isVisible,
31650 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
31651 enableHiding: field.enableHiding ?? true,
31652 readOnly: field.readOnly ?? false,
31653 // The type provides defaults for the following props
31654 type: fieldType.type,
31655 render: field.render ?? fieldType.render,
31656 Edit: getControl(field, fieldType.Edit),
31657 sort: sort7,
31658 enableSorting: field.enableSorting ?? fieldType.enableSorting,
31659 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
31660 isValid: getIsValid(field, fieldType),
31661 filterBy: get_filter_by_default(
31662 field,
31663 fieldType.defaultOperators,
31664 fieldType.validOperators
31665 ),
31666 filter: getFilter(fieldType),
31667 format: get_format_default(field, fieldType),
31668 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
31669 };
31670 });
31671 }
31672
31673 // packages/dataviews/build-module/hooks/use-data.mjs
31674 var import_element118 = __toESM(require_element(), 1);
31675 function useData({
31676 view,
31677 data: shownData,
31678 getItemId: getItemId2,
31679 isLoading,
31680 paginationInfo,
31681 selection
31682 }) {
31683 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
31684 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element118.useState)(
31685 !isLoading
31686 );
31687 (0, import_element118.useEffect)(() => {
31688 if (!isLoading) {
31689 setHasInitiallyLoaded(true);
31690 }
31691 }, [isLoading]);
31692 const previousDataRef = (0, import_element118.useRef)(shownData);
31693 const previousPaginationInfoRef = (0, import_element118.useRef)(paginationInfo);
31694 (0, import_element118.useEffect)(() => {
31695 if (!isLoading) {
31696 previousDataRef.current = shownData;
31697 previousPaginationInfoRef.current = paginationInfo;
31698 }
31699 }, [shownData, isLoading, paginationInfo]);
31700 const [visibleEntries, setVisibleEntries] = (0, import_element118.useState)([]);
31701 const positionMapRef = (0, import_element118.useRef)(/* @__PURE__ */ new Map());
31702 const allLoadedRecordsRef = (0, import_element118.useRef)([]);
31703 const prevViewParamsRef = (0, import_element118.useRef)({
31704 search: void 0,
31705 filters: void 0,
31706 perPage: void 0
31707 });
31708 const scrollDirectionRef = (0, import_element118.useRef)(void 0);
31709 const prevStartPositionRef = (0, import_element118.useRef)(void 0);
31710 const hasInitializedRef = (0, import_element118.useRef)(false);
31711 const allLoadedRecords = (0, import_element118.useMemo)(() => {
31712 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
31713 if (view.startPosition < prevStartPositionRef.current) {
31714 scrollDirectionRef.current = "up";
31715 } else if (view.startPosition > prevStartPositionRef.current) {
31716 scrollDirectionRef.current = "down";
31717 }
31718 }
31719 prevStartPositionRef.current = view.startPosition;
31720 const currentFiltersKey = JSON.stringify(view.filters ?? []);
31721 const prevFiltersKey = prevViewParamsRef.current.filters;
31722 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
31723 hasInitializedRef.current = true;
31724 prevViewParamsRef.current = {
31725 search: view.search,
31726 filters: currentFiltersKey,
31727 perPage: view.perPage
31728 };
31729 if (shouldReset) {
31730 positionMapRef.current.clear();
31731 scrollDirectionRef.current = void 0;
31732 const startPosition = view.search ? 1 : view.startPosition ?? 1;
31733 const records = shownData.map((record, index2) => {
31734 const position = startPosition + index2;
31735 positionMapRef.current.set(getItemId2(record), position);
31736 return {
31737 ...record,
31738 position
31739 };
31740 });
31741 allLoadedRecordsRef.current = records;
31742 return records;
31743 }
31744 const prev = allLoadedRecordsRef.current;
31745 const shownDataIds = new Set(shownData.map(getItemId2));
31746 const scrollDirection = scrollDirectionRef.current;
31747 const basePosition = view.search ? 1 : view.startPosition ?? 1;
31748 const newRecords = shownData.map((record, index2) => {
31749 const itemId = getItemId2(record);
31750 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
31751 if (position !== void 0) {
31752 positionMapRef.current.set(itemId, position);
31753 }
31754 return {
31755 ...record,
31756 position
31757 };
31758 });
31759 if (newRecords.length === 0) {
31760 return prev;
31761 }
31762 const prevWithoutDuplicates = prev.filter(
31763 (record) => !shownDataIds.has(getItemId2(record))
31764 );
31765 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
31766 allRecords.sort((a2, b2) => {
31767 const posA = a2.position;
31768 const posB = b2.position;
31769 return posA - posB;
31770 });
31771 let result = allRecords;
31772 if (visibleEntries.length > 0) {
31773 const visibleMin = Math.min(...visibleEntries);
31774 const visibleMax = Math.max(...visibleEntries);
31775 const buffer = 20;
31776 const recordPositions = allRecords.map(
31777 (r3) => r3.position
31778 );
31779 const minRecordPos = Math.min(...recordPositions);
31780 const maxRecordPos = Math.max(...recordPositions);
31781 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
31782 if (hasOverlap) {
31783 result = allRecords.filter((record) => {
31784 const itemId = getItemId2(record);
31785 const isSelected2 = selection?.includes(itemId);
31786 if (isSelected2) {
31787 return true;
31788 }
31789 const itemPosition = record.position;
31790 if (scrollDirection === "up") {
31791 return itemPosition <= visibleMax + buffer;
31792 } else if (scrollDirection === "down") {
31793 return itemPosition >= visibleMin - buffer;
31794 }
31795 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
31796 });
31797 }
31798 }
31799 allLoadedRecordsRef.current = result;
31800 return result;
31801 }, [
31802 shownData,
31803 view.search,
31804 view.filters,
31805 view.perPage,
31806 view.startPosition,
31807 view.infiniteScrollEnabled,
31808 visibleEntries,
31809 selection,
31810 getItemId2
31811 ]);
31812 if (!isInfiniteScrollEnabled) {
31813 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
31814 return {
31815 data: dataToReturn.map((item) => ({
31816 ...item,
31817 position: void 0
31818 })),
31819 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
31820 hasInitiallyLoaded,
31821 setVisibleEntries: void 0
31822 };
31823 }
31824 return {
31825 data: allLoadedRecords,
31826 paginationInfo,
31827 hasInitiallyLoaded,
31828 setVisibleEntries
31829 };
31830 }
31831
31832 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
31833 var import_element119 = __toESM(require_element(), 1);
31834 var import_compose15 = __toESM(require_compose(), 1);
31835 function captureAnchorElement(container, anchorElementRef, direction) {
31836 const containerRect = container.getBoundingClientRect();
31837 const centerY = containerRect.top + containerRect.height / 2;
31838 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
31839 if (items.length === 0) {
31840 return false;
31841 }
31842 const bestAnchor = items.reduce((best, item) => {
31843 const itemRect = item.getBoundingClientRect();
31844 const itemCenterY = itemRect.top + itemRect.height / 2;
31845 const distance = Math.abs(itemCenterY - centerY);
31846 const bestRect = best.getBoundingClientRect();
31847 const bestCenterY = bestRect.top + bestRect.height / 2;
31848 const bestDistance = Math.abs(bestCenterY - centerY);
31849 return distance < bestDistance ? item : best;
31850 });
31851 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
31852 const anchorRect = bestAnchor.getBoundingClientRect();
31853 anchorElementRef.current = {
31854 posinset,
31855 viewportOffset: anchorRect.top - containerRect.top,
31856 direction
31857 };
31858 return true;
31859 }
31860 function useInfiniteScroll({
31861 view,
31862 onChangeView,
31863 isLoading,
31864 paginationInfo,
31865 containerRef,
31866 setVisibleEntries
31867 }) {
31868 const anchorElementRef = (0, import_element119.useRef)(null);
31869 const viewRef = (0, import_element119.useRef)(view);
31870 const isLoadingRef = (0, import_element119.useRef)(isLoading);
31871 const onChangeViewRef = (0, import_element119.useRef)(onChangeView);
31872 const totalItemsRef = (0, import_element119.useRef)(paginationInfo.totalItems);
31873 (0, import_element119.useLayoutEffect)(() => {
31874 viewRef.current = view;
31875 isLoadingRef.current = isLoading;
31876 onChangeViewRef.current = onChangeView;
31877 totalItemsRef.current = paginationInfo.totalItems;
31878 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
31879 const intersectionObserverCallback = (0, import_element119.useCallback)(
31880 (entries) => {
31881 if (!setVisibleEntries) {
31882 return;
31883 }
31884 setVisibleEntries((prev) => {
31885 const newVisibleEntries = new Set(prev);
31886 let hasChanged = false;
31887 entries.forEach((entry) => {
31888 const posInSet = Number(
31889 entry.target?.attributes?.getNamedItem(
31890 "aria-posinset"
31891 )?.value
31892 );
31893 if (isNaN(posInSet)) {
31894 return;
31895 }
31896 if (entry.isIntersecting) {
31897 if (!newVisibleEntries.has(posInSet)) {
31898 newVisibleEntries.add(posInSet);
31899 hasChanged = true;
31900 }
31901 } else if (newVisibleEntries.has(posInSet)) {
31902 newVisibleEntries.delete(posInSet);
31903 hasChanged = true;
31904 }
31905 });
31906 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
31907 });
31908 },
31909 [setVisibleEntries]
31910 );
31911 (0, import_element119.useLayoutEffect)(() => {
31912 const container = containerRef.current;
31913 const anchor = anchorElementRef.current;
31914 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
31915 return;
31916 }
31917 const anchorElement = container.querySelector(
31918 `[aria-posinset="${anchor.posinset}"]`
31919 );
31920 if (anchorElement) {
31921 const containerRect = container.getBoundingClientRect();
31922 const anchorRect = anchorElement.getBoundingClientRect();
31923 const currentOffset = anchorRect.top - containerRect.top;
31924 const scrollAdjustment = currentOffset - anchor.viewportOffset;
31925 if (Math.abs(scrollAdjustment) > 1) {
31926 container.scrollTop += scrollAdjustment;
31927 }
31928 }
31929 anchorElementRef.current = null;
31930 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
31931 const intersectionObserverRef = (0, import_element119.useRef)(
31932 null
31933 );
31934 (0, import_element119.useEffect)(() => {
31935 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
31936 if (intersectionObserverRef.current) {
31937 intersectionObserverRef.current.disconnect();
31938 intersectionObserverRef.current = null;
31939 }
31940 return;
31941 }
31942 intersectionObserverRef.current = new IntersectionObserver(
31943 intersectionObserverCallback,
31944 { root: null, rootMargin: "0px", threshold: 0.1 }
31945 );
31946 return () => {
31947 if (intersectionObserverRef.current) {
31948 intersectionObserverRef.current.disconnect();
31949 intersectionObserverRef.current = null;
31950 }
31951 };
31952 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
31953 (0, import_element119.useEffect)(() => {
31954 if (!view.infiniteScrollEnabled || !containerRef.current) {
31955 return;
31956 }
31957 let lastScrollTop = 0;
31958 const BOTTOM_THRESHOLD = 600;
31959 const TOP_THRESHOLD = 800;
31960 const handleScroll = (0, import_compose15.throttle)((event) => {
31961 const currentView = viewRef.current;
31962 const totalItems = totalItemsRef.current;
31963 const target = event.target;
31964 const scrollTop = target.scrollTop;
31965 const scrollHeight = target.scrollHeight;
31966 const clientHeight = target.clientHeight;
31967 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
31968 lastScrollTop = scrollTop;
31969 if (isLoadingRef.current) {
31970 return;
31971 }
31972 const currentStartPosition = currentView.startPosition || 1;
31973 const batchSize = currentView.perPage || 10;
31974 const currentEndPosition = Math.min(
31975 currentStartPosition + batchSize,
31976 totalItems
31977 );
31978 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
31979 if (currentEndPosition < totalItems) {
31980 const newStartPosition = currentEndPosition;
31981 captureAnchorElement(target, anchorElementRef, "down");
31982 onChangeViewRef.current({
31983 ...currentView,
31984 startPosition: newStartPosition
31985 });
31986 }
31987 }
31988 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
31989 if (currentStartPosition > 1) {
31990 const calculatedStartPosition = currentStartPosition - batchSize;
31991 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
31992 captureAnchorElement(target, anchorElementRef, "up");
31993 onChangeViewRef.current({
31994 ...currentView,
31995 startPosition: newStartPosition
31996 });
31997 }
31998 }
31999 }, 50);
32000 const container = containerRef.current;
32001 container.addEventListener("scroll", handleScroll);
32002 return () => {
32003 container.removeEventListener("scroll", handleScroll);
32004 handleScroll.cancel();
32005 };
32006 }, [containerRef, view.infiniteScrollEnabled]);
32007 return {
32008 intersectionObserver: intersectionObserverRef.current
32009 };
32010 }
32011
32012 // packages/dataviews/build-module/dataviews-picker/index.mjs
32013 var import_element120 = __toESM(require_element(), 1);
32014 var import_compose16 = __toESM(require_compose(), 1);
32015 var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1);
32016 var isItemClickable = () => false;
32017 var dataViewsPickerLayouts = VIEW_LAYOUTS.filter(
32018 (viewLayout) => viewLayout.isPicker
32019 );
32020 var defaultGetItemId = (item) => item.id;
32021 var EMPTY_ARRAY5 = [];
32022 var DEFAULT_PICKER_LAYOUTS = {
32023 pickerGrid: true,
32024 pickerTable: true
32025 };
32026 function DefaultUI({
32027 search = true,
32028 searchLabel = void 0
32029 }) {
32030 const { view } = (0, import_element120.useContext)(dataviews_context_default);
32031 const isInfiniteScroll = view.infiniteScrollEnabled;
32032 return /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_jsx_runtime155.Fragment, { children: [
32033 /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(
32034 Stack,
32035 {
32036 direction: "row",
32037 align: "top",
32038 justify: "space-between",
32039 className: clsx_default("dataviews__view-actions", {
32040 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
32041 }),
32042 gap: "xs",
32043 children: [
32044 /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(
32045 Stack,
32046 {
32047 direction: "row",
32048 gap: "sm",
32049 justify: "start",
32050 className: "dataviews__search",
32051 children: [
32052 search && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(dataviews_search_default, { label: searchLabel }),
32053 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(toggle_default, {})
32054 ]
32055 }
32056 ),
32057 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(dataviews_view_config_default, {}) })
32058 ]
32059 }
32060 ),
32061 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
32062 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(DataViewsLayout, {}),
32063 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(DataViewsPickerFooter, {})
32064 ] });
32065 }
32066 function DataViewsPicker({
32067 view,
32068 onChangeView,
32069 fields: fields2,
32070 search = true,
32071 searchLabel = void 0,
32072 actions = EMPTY_ARRAY5,
32073 data,
32074 getItemId: getItemId2 = defaultGetItemId,
32075 isLoading = false,
32076 paginationInfo,
32077 defaultLayouts: defaultLayoutsProperty = DEFAULT_PICKER_LAYOUTS,
32078 selection,
32079 onChangeSelection,
32080 children,
32081 config = { perPageSizes: [10, 20, 50, 100] },
32082 itemListLabel,
32083 empty,
32084 onReset
32085 }) {
32086 const { data: displayData, setVisibleEntries } = useData({
32087 view,
32088 data,
32089 getItemId: getItemId2,
32090 selection,
32091 paginationInfo
32092 });
32093 const containerRef = (0, import_element120.useRef)(null);
32094 const [containerWidth, setContainerWidth] = (0, import_element120.useState)(0);
32095 const resizeObserverRef = (0, import_compose16.useResizeObserver)(
32096 (resizeObserverEntries) => {
32097 setContainerWidth(
32098 resizeObserverEntries[0].borderBoxSize[0].inlineSize
32099 );
32100 },
32101 { box: "border-box" }
32102 );
32103 const [openedFilter, setOpenedFilter] = (0, import_element120.useState)(null);
32104 function setSelectionWithChange(value) {
32105 const newValue = typeof value === "function" ? value(selection) : value;
32106 if (onChangeSelection) {
32107 onChangeSelection(newValue);
32108 }
32109 }
32110 const _fields = (0, import_element120.useMemo)(() => normalizeFields(fields2), [fields2]);
32111 const filters = use_filters_default(_fields, view);
32112 const hasPrimaryOrLockedFilters = (0, import_element120.useMemo)(
32113 () => (filters || []).some(
32114 (filter) => filter.isPrimary || filter.isLocked
32115 ),
32116 [filters]
32117 );
32118 const [isShowingFilter, setIsShowingFilter] = (0, import_element120.useState)(
32119 hasPrimaryOrLockedFilters
32120 );
32121 const { intersectionObserver } = useInfiniteScroll({
32122 view,
32123 onChangeView,
32124 isLoading,
32125 paginationInfo,
32126 containerRef,
32127 setVisibleEntries
32128 });
32129 (0, import_element120.useEffect)(() => {
32130 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
32131 setIsShowingFilter(true);
32132 }
32133 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
32134 const defaultLayouts = (0, import_element120.useMemo)(
32135 () => Object.fromEntries(
32136 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
32137 return dataViewsPickerLayouts.some(
32138 (viewLayout) => viewLayout.type === layoutType
32139 );
32140 }).map(([key2, value]) => [
32141 key2,
32142 value === true ? {} : value
32143 ])
32144 ),
32145 [defaultLayoutsProperty]
32146 );
32147 if (!defaultLayouts[view.type]) {
32148 return null;
32149 }
32150 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
32151 dataviews_context_default.Provider,
32152 {
32153 value: {
32154 view,
32155 onChangeView,
32156 fields: _fields,
32157 actions,
32158 data: displayData,
32159 isLoading,
32160 paginationInfo,
32161 isItemClickable,
32162 selection,
32163 onChangeSelection: setSelectionWithChange,
32164 openedFilter,
32165 setOpenedFilter,
32166 getItemId: getItemId2,
32167 containerWidth,
32168 containerRef,
32169 resizeObserverRef,
32170 defaultLayouts,
32171 filters,
32172 isShowingFilter,
32173 setIsShowingFilter,
32174 config,
32175 itemListLabel,
32176 empty,
32177 onReset,
32178 hasInitiallyLoaded: true,
32179 intersectionObserver
32180 },
32181 children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("div", { className: "dataviews-picker-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(DefaultUI, { search, searchLabel }) })
32182 }
32183 );
32184 }
32185 var DataViewsPickerSubComponents = DataViewsPicker;
32186 DataViewsPickerSubComponents.BulkActionToolbar = DataViewsPickerFooter;
32187 DataViewsPickerSubComponents.Filters = filters_default;
32188 DataViewsPickerSubComponents.FiltersToggled = filters_toggled_default;
32189 DataViewsPickerSubComponents.FiltersToggle = toggle_default;
32190 DataViewsPickerSubComponents.Layout = DataViewsLayout;
32191 DataViewsPickerSubComponents.LayoutSwitcher = ViewTypeMenu;
32192 DataViewsPickerSubComponents.Pagination = DataViewsPagination;
32193 DataViewsPickerSubComponents.Search = dataviews_search_default;
32194 DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown;
32195 var dataviews_picker_default = DataViewsPickerSubComponents;
32196
32197 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
32198 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
32199 var import_deprecated = __toESM(require_deprecated(), 1);
32200 function normalizeSearchInput2(input = "") {
32201 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
32202 }
32203 var EMPTY_ARRAY6 = [];
32204 function filterSortAndPaginate(data, view, fields2) {
32205 if (!data) {
32206 return {
32207 data: EMPTY_ARRAY6,
32208 paginationInfo: { totalItems: 0, totalPages: 0 }
32209 };
32210 }
32211 const _fields = normalizeFields(fields2);
32212 let filteredData = [...data];
32213 if (view.search) {
32214 const normalizedSearch = normalizeSearchInput2(view.search);
32215 filteredData = filteredData.filter((item) => {
32216 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
32217 const fieldValue = field.getValue({ item });
32218 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
32219 return values.some(
32220 (value) => normalizeSearchInput2(String(value)).includes(
32221 normalizedSearch
32222 )
32223 );
32224 });
32225 });
32226 }
32227 if (view.filters && view.filters?.length > 0) {
32228 view.filters.forEach((filter) => {
32229 const field = _fields.find(
32230 (_field) => _field.id === filter.field
32231 );
32232 if (field) {
32233 if (filter.operator === OPERATOR_IS_NOT_ALL) {
32234 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
32235 since: "7.0",
32236 alternative: "'isNone'"
32237 });
32238 }
32239 const handler = field.filter[filter.operator];
32240 if (handler) {
32241 filteredData = filteredData.filter(
32242 (item) => handler(item, field, filter.value)
32243 );
32244 }
32245 }
32246 });
32247 }
32248 const sortByField = view.sort?.field ? _fields.find((field) => {
32249 return field.enableSorting !== false && field.id === view.sort?.field;
32250 }) : null;
32251 const groupByField = view.groupBy?.field ? _fields.find((field) => {
32252 return field.enableSorting !== false && field.id === view.groupBy?.field;
32253 }) : null;
32254 if (sortByField || groupByField) {
32255 filteredData.sort((a2, b2) => {
32256 if (groupByField) {
32257 const groupCompare = groupByField.sort(
32258 a2,
32259 b2,
32260 view.groupBy?.direction ?? "asc"
32261 );
32262 if (groupCompare !== 0) {
32263 return groupCompare;
32264 }
32265 }
32266 if (sortByField) {
32267 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
32268 }
32269 return 0;
32270 });
32271 }
32272 let totalItems = filteredData.length;
32273 let totalPages = 1;
32274 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
32275 const start = view.startPosition - 1;
32276 const end = Math.min(start + view.perPage, totalItems);
32277 filteredData = filteredData?.slice(start, end);
32278 } else if (view.page !== void 0 && view.perPage !== void 0) {
32279 const start = (view.page - 1) * view.perPage;
32280 totalItems = filteredData?.length || 0;
32281 totalPages = Math.ceil(totalItems / view.perPage);
32282 filteredData = filteredData?.slice(start, start + view.perPage);
32283 }
32284 return {
32285 data: filteredData,
32286 paginationInfo: {
32287 totalItems,
32288 totalPages
32289 }
32290 };
32291 }
32292
32293 // routes/dashboard/widget-dashboard/components/widget-picker/widget-picker.tsx
32294 var import_element123 = __toESM(require_element());
32295 var import_i18n50 = __toESM(require_i18n());
32296
32297 // routes/dashboard/widget-dashboard/components/widget-render/widget-render.tsx
32298 var import_element122 = __toESM(require_element());
32299
32300 // routes/dashboard/widget-dashboard/utils/get-lazy-widget-component/get-lazy-widget-component.ts
32301 var import_element121 = __toESM(require_element());
32302 function isValidWidgetModule(module) {
32303 return typeof module === "object" && module !== null && "default" in module && typeof module.default === "function";
32304 }
32305 var componentCache = /* @__PURE__ */ new Map();
32306 function getLazyWidgetComponent(renderModule, resolveWidgetModule) {
32307 const cached = componentCache.get(renderModule);
32308 if (cached) {
32309 return cached;
32310 }
32311 const lazyComponent = (0, import_element121.lazy)(async () => {
32312 const module = await resolveWidgetModule(renderModule);
32313 if (!isValidWidgetModule(module)) {
32314 throw new Error(`Invalid widget module: ${renderModule}`);
32315 }
32316 return module;
32317 });
32318 componentCache.set(renderModule, lazyComponent);
32319 return lazyComponent;
32320 }
32321
32322 // routes/dashboard/widget-dashboard/components/widget-render/widget-render.tsx
32323 var import_jsx_runtime156 = __toESM(require_jsx_runtime());
32324 function WidgetRenderImpl({ widget, widgetType }) {
32325 const { layout, onLayoutChange, resolveWidgetModule } = useDashboardInternalContext();
32326 const WidgetComponent = getLazyWidgetComponent(
32327 widgetType.renderModule,
32328 resolveWidgetModule
32329 );
32330 const setAttributes = (0, import_element122.useCallback)(
32331 (next) => {
32332 onLayoutChange(
32333 layout.map(
32334 (w2) => w2.uuid === widget.uuid ? {
32335 ...w2,
32336 attributes: {
32337 ...w2.attributes,
32338 ...next
32339 }
32340 } : w2
32341 )
32342 );
32343 },
32344 [widget.uuid, layout, onLayoutChange]
32345 );
32346 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_jsx_runtime156.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
32347 WidgetComponent,
32348 {
32349 attributes: widget.attributes,
32350 setAttributes
32351 }
32352 ) });
32353 }
32354 var WidgetRender = WidgetRenderImpl;
32355
32356 // routes/dashboard/widget-dashboard/components/widget-picker/widget-picker.module.css
32357 if (typeof process === "undefined" || true) {
32358 registerStyle35("5f9f70868a", "._32fba4d898ff4e12__preview{height:100%;overflow:hidden;padding:var(--wpds-dimension-padding-md,12px)}");
32359 }
32360 var widget_picker_default = { "preview": "_32fba4d898ff4e12__preview" };
32361
32362 // routes/dashboard/widget-dashboard/components/widget-picker/widget-picker.tsx
32363 var import_jsx_runtime157 = __toESM(require_jsx_runtime());
32364 var DEFAULT_VIEW = {
32365 type: "pickerGrid",
32366 page: 1,
32367 search: "",
32368 mediaField: "preview",
32369 titleField: "title"
32370 };
32371 var getItemId = (item) => item.name;
32372 function WidgetPreview({ item }) {
32373 const exampleWidget = (0, import_element123.useMemo)(
32374 () => createDashboardWidget(item, item.example?.attributes),
32375 [item]
32376 );
32377 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("div", { className: widget_picker_default.preview, ...{ inert: "" }, children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(import_element123.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(WidgetRender, { widget: exampleWidget, widgetType: item }) }) });
32378 }
32379 var fields = [
32380 {
32381 id: "title",
32382 type: "text",
32383 label: (0, import_i18n50.__)("Title"),
32384 filterBy: false
32385 },
32386 {
32387 id: "preview",
32388 type: "media",
32389 render: WidgetPreview
32390 },
32391 {
32392 id: "name",
32393 type: "text",
32394 enableGlobalSearch: true,
32395 enableHiding: false,
32396 enableSorting: false,
32397 filterBy: false,
32398 getValue: ({ item }) => `${item.name.replace(/[\/,\-_]/g, " ")} ${item.title}`
32399 }
32400 ];
32401 function WidgetPicker({
32402 onSelect,
32403 itemListLabel = (0, import_i18n50.__)("Widget list")
32404 }) {
32405 const { widgetTypes: registeredTypes } = useDashboardInternalContext();
32406 const [selection, setSelection] = (0, import_element123.useState)([]);
32407 const [view, setView] = (0, import_element123.useState)(DEFAULT_VIEW);
32408 const { data: widgetTypes } = filterSortAndPaginate(
32409 registeredTypes,
32410 view,
32411 fields
32412 );
32413 const actions = (0, import_element123.useMemo)(
32414 () => [
32415 {
32416 id: "select",
32417 label: (0, import_i18n50.__)("Select"),
32418 isPrimary: true,
32419 supportsBulk: true,
32420 callback: (items) => onSelect(items)
32421 }
32422 ],
32423 [onSelect]
32424 );
32425 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
32426 dataviews_picker_default,
32427 {
32428 data: widgetTypes,
32429 fields,
32430 view,
32431 actions,
32432 defaultLayouts: { pickerGrid: {} },
32433 onChangeView: setView,
32434 isLoading: false,
32435 paginationInfo: {
32436 totalItems: widgetTypes.length,
32437 totalPages: 1
32438 },
32439 selection,
32440 onChangeSelection: setSelection,
32441 getItemId,
32442 itemListLabel
32443 }
32444 );
32445 }
32446
32447 // routes/dashboard/widget-dashboard/components/inserter/inserter.tsx
32448 var import_jsx_runtime158 = __toESM(require_jsx_runtime());
32449 function Inserter() {
32450 const { layout, onLayoutChange } = useDashboardInternalContext();
32451 const { inserterOpen, setInserterOpen } = useDashboardUIContext();
32452 const insertWidgets = (0, import_element124.useCallback)(
32453 (widgetTypes) => {
32454 if (widgetTypes.length > 0) {
32455 const newWidgets = widgetTypes.map(
32456 (widgetType) => createDashboardWidget(widgetType)
32457 );
32458 onLayoutChange([...layout, ...newWidgets]);
32459 }
32460 setInserterOpen(false);
32461 },
32462 [layout, onLayoutChange, setInserterOpen]
32463 );
32464 if (!inserterOpen) {
32465 return null;
32466 }
32467 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(dialog_exports.Root, { open: inserterOpen, onOpenChange: setInserterOpen, children: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
32468 dialog_exports.Popup,
32469 {
32470 size: "large",
32471 portal: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
32472 dialog_exports.Portal,
32473 {
32474 style: {
32475 "--wp-ui-dialog-z-index": 99999
32476 }
32477 }
32478 ),
32479 children: [
32480 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(dialog_exports.Header, { children: [
32481 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(dialog_exports.Title, { children: (0, import_i18n51.__)("Add widget") }),
32482 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(dialog_exports.CloseIcon, {})
32483 ] }),
32484 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(dialog_exports.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(WidgetPicker, { onSelect: insertWidgets }) })
32485 ]
32486 }
32487 ) });
32488 }
32489
32490 // routes/dashboard/widget-dashboard/components/widget-chrome/widget-chrome.tsx
32491 var import_components47 = __toESM(require_components());
32492 var import_element126 = __toESM(require_element());
32493 var import_i18n52 = __toESM(require_i18n());
32494
32495 // routes/dashboard/widget-dashboard/context/widget-context.tsx
32496 var import_element125 = __toESM(require_element());
32497 var import_jsx_runtime159 = __toESM(require_jsx_runtime());
32498 var WidgetContext = (0, import_element125.createContext)(null);
32499 function WidgetContextProvider({
32500 value,
32501 children
32502 }) {
32503 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(WidgetContext.Provider, { value, children });
32504 }
32505
32506 // routes/dashboard/widget-dashboard/components/widget-chrome/widget-chrome.module.css
32507 if (typeof process === "undefined" || true) {
32508 registerStyle35("a89e624f79", "._22b961782d58cf14__widgetChrome{height:100%}._2e38cde45383ef41__widgetChromeHeaderIcon{color:var(--wpds-color-fg-content-neutral-weak,#707070);display:inline-flex}._65ccc0ffeadb15bf__widgetChromeContent{flex:1}.d86427717f1c6168__loading{height:100%}");
32509 }
32510 var widget_chrome_default = { "widgetChrome": "_22b961782d58cf14__widgetChrome", "widgetChromeHeaderIcon": "_2e38cde45383ef41__widgetChromeHeaderIcon", "widgetChromeContent": "_65ccc0ffeadb15bf__widgetChromeContent", "loading": "d86427717f1c6168__loading" };
32511
32512 // routes/dashboard/widget-dashboard/components/widget-chrome/widget-chrome.tsx
32513 var import_jsx_runtime160 = __toESM(require_jsx_runtime());
32514 var WidgetErrorBoundary = class extends import_element126.Component {
32515 state = { hasError: false };
32516 static getDerivedStateFromError() {
32517 return { hasError: true };
32518 }
32519 render() {
32520 if (this.state.hasError) {
32521 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(notice_exports.Root, { intent: "error", children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(notice_exports.Description, { children: (0, import_i18n52.__)("This widget encountered an error.") }) });
32522 }
32523 return this.props.children;
32524 }
32525 };
32526 function LoadingOverlay() {
32527 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(Stack, { justify: "center", align: "center", className: widget_chrome_default.loading, children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(import_components47.Spinner, {}) });
32528 }
32529 function Header4({ titleId, widgetType }) {
32530 if (!widgetType.title) {
32531 return null;
32532 }
32533 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(card_exports.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(Stack, { direction: "row", align: "center", gap: "sm", children: [
32534 widgetType.icon && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
32535 "span",
32536 {
32537 className: widget_chrome_default.widgetChromeHeaderIcon,
32538 "aria-hidden": "true",
32539 children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(import_components47.Icon, { icon: widgetType.icon })
32540 }
32541 ),
32542 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(card_exports.Title, { id: titleId, render: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("h3", {}), children: widgetType.title })
32543 ] }) });
32544 }
32545 var WidgetChrome = (0, import_element126.forwardRef)(
32546 function WidgetChrome2({ widget, index: index2 }, ref) {
32547 const { widgetTypes, editMode } = useDashboardInternalContext();
32548 const widgetType = widgetTypes.find((t2) => t2.name === widget.type);
32549 const titleId = (0, import_element126.useId)();
32550 const contextValue = (0, import_element126.useMemo)(
32551 () => ({
32552 uuid: widget.uuid,
32553 name: widget.type,
32554 index: index2
32555 }),
32556 [widget.uuid, widget.type, index2]
32557 );
32558 if (!widgetType) {
32559 return null;
32560 }
32561 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(WidgetContextProvider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(
32562 card_exports.Root,
32563 {
32564 render: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("section", {}),
32565 ref,
32566 className: widget_chrome_default.widgetChrome,
32567 "aria-labelledby": widgetType.title ? titleId : void 0,
32568 ...editMode ? { inert: "" } : {},
32569 children: [
32570 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(Header4, { titleId, widgetType }),
32571 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(card_exports.Content, { className: widget_chrome_default.widgetChromeContent, children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(WidgetErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(import_element126.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(LoadingOverlay, {}), children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
32572 WidgetRender,
32573 {
32574 widget,
32575 widgetType
32576 }
32577 ) }) }) })
32578 ]
32579 }
32580 ) });
32581 }
32582 );
32583
32584 // routes/dashboard/widget-dashboard/components/widgets/widgets.tsx
32585 var import_element130 = __toESM(require_element());
32586
32587 // node_modules/@dnd-kit/core/dist/core.esm.js
32588 var import_react40 = __toESM(require_react());
32589 var import_react_dom5 = __toESM(require_react_dom());
32590
32591 // node_modules/@dnd-kit/utilities/dist/utilities.esm.js
32592 var import_react38 = __toESM(require_react());
32593 function useCombinedRefs() {
32594 for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
32595 refs[_key] = arguments[_key];
32596 }
32597 return (0, import_react38.useMemo)(
32598 () => (node) => {
32599 refs.forEach((ref) => ref(node));
32600 },
32601 // eslint-disable-next-line react-hooks/exhaustive-deps
32602 refs
32603 );
32604 }
32605 var canUseDOM2 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
32606 function isWindow(element) {
32607 const elementString = Object.prototype.toString.call(element);
32608 return elementString === "[object Window]" || // In Electron context the Window object serializes to [object global]
32609 elementString === "[object global]";
32610 }
32611 function isNode2(node) {
32612 return "nodeType" in node;
32613 }
32614 function getWindow3(target) {
32615 var _target$ownerDocument, _target$ownerDocument2;
32616 if (!target) {
32617 return window;
32618 }
32619 if (isWindow(target)) {
32620 return target;
32621 }
32622 if (!isNode2(target)) {
32623 return window;
32624 }
32625 return (_target$ownerDocument = (_target$ownerDocument2 = target.ownerDocument) == null ? void 0 : _target$ownerDocument2.defaultView) != null ? _target$ownerDocument : window;
32626 }
32627 function isDocument(node) {
32628 const {
32629 Document
32630 } = getWindow3(node);
32631 return node instanceof Document;
32632 }
32633 function isHTMLElement2(node) {
32634 if (isWindow(node)) {
32635 return false;
32636 }
32637 return node instanceof getWindow3(node).HTMLElement;
32638 }
32639 function isSVGElement(node) {
32640 return node instanceof getWindow3(node).SVGElement;
32641 }
32642 function getOwnerDocument(target) {
32643 if (!target) {
32644 return document;
32645 }
32646 if (isWindow(target)) {
32647 return target.document;
32648 }
32649 if (!isNode2(target)) {
32650 return document;
32651 }
32652 if (isDocument(target)) {
32653 return target;
32654 }
32655 if (isHTMLElement2(target) || isSVGElement(target)) {
32656 return target.ownerDocument;
32657 }
32658 return document;
32659 }
32660 var useIsomorphicLayoutEffect = canUseDOM2 ? import_react38.useLayoutEffect : import_react38.useEffect;
32661 function useEvent3(handler) {
32662 const handlerRef = (0, import_react38.useRef)(handler);
32663 useIsomorphicLayoutEffect(() => {
32664 handlerRef.current = handler;
32665 });
32666 return (0, import_react38.useCallback)(function() {
32667 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32668 args[_key] = arguments[_key];
32669 }
32670 return handlerRef.current == null ? void 0 : handlerRef.current(...args);
32671 }, []);
32672 }
32673 function useInterval() {
32674 const intervalRef = (0, import_react38.useRef)(null);
32675 const set3 = (0, import_react38.useCallback)((listener, duration) => {
32676 intervalRef.current = setInterval(listener, duration);
32677 }, []);
32678 const clear = (0, import_react38.useCallback)(() => {
32679 if (intervalRef.current !== null) {
32680 clearInterval(intervalRef.current);
32681 intervalRef.current = null;
32682 }
32683 }, []);
32684 return [set3, clear];
32685 }
32686 function useLatestValue(value, dependencies) {
32687 if (dependencies === void 0) {
32688 dependencies = [value];
32689 }
32690 const valueRef = (0, import_react38.useRef)(value);
32691 useIsomorphicLayoutEffect(() => {
32692 if (valueRef.current !== value) {
32693 valueRef.current = value;
32694 }
32695 }, dependencies);
32696 return valueRef;
32697 }
32698 function useLazyMemo(callback, dependencies) {
32699 const valueRef = (0, import_react38.useRef)();
32700 return (0, import_react38.useMemo)(
32701 () => {
32702 const newValue = callback(valueRef.current);
32703 valueRef.current = newValue;
32704 return newValue;
32705 },
32706 // eslint-disable-next-line react-hooks/exhaustive-deps
32707 [...dependencies]
32708 );
32709 }
32710 function useNodeRef(onChange) {
32711 const onChangeHandler = useEvent3(onChange);
32712 const node = (0, import_react38.useRef)(null);
32713 const setNodeRef = (0, import_react38.useCallback)(
32714 (element) => {
32715 if (element !== node.current) {
32716 onChangeHandler == null ? void 0 : onChangeHandler(element, node.current);
32717 }
32718 node.current = element;
32719 },
32720 //eslint-disable-next-line
32721 []
32722 );
32723 return [node, setNodeRef];
32724 }
32725 function usePrevious2(value) {
32726 const ref = (0, import_react38.useRef)();
32727 (0, import_react38.useEffect)(() => {
32728 ref.current = value;
32729 }, [value]);
32730 return ref.current;
32731 }
32732 var ids = {};
32733 function useUniqueId(prefix, value) {
32734 return (0, import_react38.useMemo)(() => {
32735 if (value) {
32736 return value;
32737 }
32738 const id = ids[prefix] == null ? 0 : ids[prefix] + 1;
32739 ids[prefix] = id;
32740 return prefix + "-" + id;
32741 }, [prefix, value]);
32742 }
32743 function createAdjustmentFn(modifier) {
32744 return function(object) {
32745 for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
32746 adjustments[_key - 1] = arguments[_key];
32747 }
32748 return adjustments.reduce((accumulator, adjustment) => {
32749 const entries = Object.entries(adjustment);
32750 for (const [key2, valueAdjustment] of entries) {
32751 const value = accumulator[key2];
32752 if (value != null) {
32753 accumulator[key2] = value + modifier * valueAdjustment;
32754 }
32755 }
32756 return accumulator;
32757 }, {
32758 ...object
32759 });
32760 };
32761 }
32762 var add = /* @__PURE__ */ createAdjustmentFn(1);
32763 var subtract = /* @__PURE__ */ createAdjustmentFn(-1);
32764 function hasViewportRelativeCoordinates(event) {
32765 return "clientX" in event && "clientY" in event;
32766 }
32767 function isKeyboardEvent(event) {
32768 if (!event) {
32769 return false;
32770 }
32771 const {
32772 KeyboardEvent: KeyboardEvent2
32773 } = getWindow3(event.target);
32774 return KeyboardEvent2 && event instanceof KeyboardEvent2;
32775 }
32776 function isTouchEvent(event) {
32777 if (!event) {
32778 return false;
32779 }
32780 const {
32781 TouchEvent
32782 } = getWindow3(event.target);
32783 return TouchEvent && event instanceof TouchEvent;
32784 }
32785 function getEventCoordinates(event) {
32786 if (isTouchEvent(event)) {
32787 if (event.touches && event.touches.length) {
32788 const {
32789 clientX: x2,
32790 clientY: y2
32791 } = event.touches[0];
32792 return {
32793 x: x2,
32794 y: y2
32795 };
32796 } else if (event.changedTouches && event.changedTouches.length) {
32797 const {
32798 clientX: x2,
32799 clientY: y2
32800 } = event.changedTouches[0];
32801 return {
32802 x: x2,
32803 y: y2
32804 };
32805 }
32806 }
32807 if (hasViewportRelativeCoordinates(event)) {
32808 return {
32809 x: event.clientX,
32810 y: event.clientY
32811 };
32812 }
32813 return null;
32814 }
32815 var CSS2 = /* @__PURE__ */ Object.freeze({
32816 Translate: {
32817 toString(transform) {
32818 if (!transform) {
32819 return;
32820 }
32821 const {
32822 x: x2,
32823 y: y2
32824 } = transform;
32825 return "translate3d(" + (x2 ? Math.round(x2) : 0) + "px, " + (y2 ? Math.round(y2) : 0) + "px, 0)";
32826 }
32827 },
32828 Scale: {
32829 toString(transform) {
32830 if (!transform) {
32831 return;
32832 }
32833 const {
32834 scaleX,
32835 scaleY
32836 } = transform;
32837 return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
32838 }
32839 },
32840 Transform: {
32841 toString(transform) {
32842 if (!transform) {
32843 return;
32844 }
32845 return [CSS2.Translate.toString(transform), CSS2.Scale.toString(transform)].join(" ");
32846 }
32847 },
32848 Transition: {
32849 toString(_ref) {
32850 let {
32851 property,
32852 duration,
32853 easing
32854 } = _ref;
32855 return property + " " + duration + "ms " + easing;
32856 }
32857 }
32858 });
32859 var SELECTOR = "a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";
32860 function findFirstFocusableNode(element) {
32861 if (element.matches(SELECTOR)) {
32862 return element;
32863 }
32864 return element.querySelector(SELECTOR);
32865 }
32866
32867 // node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js
32868 var import_react39 = __toESM(require_react());
32869 var hiddenStyles = {
32870 display: "none"
32871 };
32872 function HiddenText(_ref) {
32873 let {
32874 id,
32875 value
32876 } = _ref;
32877 return import_react39.default.createElement("div", {
32878 id,
32879 style: hiddenStyles
32880 }, value);
32881 }
32882 function LiveRegion(_ref) {
32883 let {
32884 id,
32885 announcement,
32886 ariaLiveType = "assertive"
32887 } = _ref;
32888 const visuallyHidden2 = {
32889 position: "fixed",
32890 top: 0,
32891 left: 0,
32892 width: 1,
32893 height: 1,
32894 margin: -1,
32895 border: 0,
32896 padding: 0,
32897 overflow: "hidden",
32898 clip: "rect(0 0 0 0)",
32899 clipPath: "inset(100%)",
32900 whiteSpace: "nowrap"
32901 };
32902 return import_react39.default.createElement("div", {
32903 id,
32904 style: visuallyHidden2,
32905 role: "status",
32906 "aria-live": ariaLiveType,
32907 "aria-atomic": true
32908 }, announcement);
32909 }
32910 function useAnnouncement() {
32911 const [announcement, setAnnouncement] = (0, import_react39.useState)("");
32912 const announce = (0, import_react39.useCallback)((value) => {
32913 if (value != null) {
32914 setAnnouncement(value);
32915 }
32916 }, []);
32917 return {
32918 announce,
32919 announcement
32920 };
32921 }
32922
32923 // node_modules/@dnd-kit/core/dist/core.esm.js
32924 var DndMonitorContext = /* @__PURE__ */ (0, import_react40.createContext)(null);
32925 function useDndMonitor(listener) {
32926 const registerListener = (0, import_react40.useContext)(DndMonitorContext);
32927 (0, import_react40.useEffect)(() => {
32928 if (!registerListener) {
32929 throw new Error("useDndMonitor must be used within a children of <DndContext>");
32930 }
32931 const unsubscribe = registerListener(listener);
32932 return unsubscribe;
32933 }, [listener, registerListener]);
32934 }
32935 function useDndMonitorProvider() {
32936 const [listeners] = (0, import_react40.useState)(() => /* @__PURE__ */ new Set());
32937 const registerListener = (0, import_react40.useCallback)((listener) => {
32938 listeners.add(listener);
32939 return () => listeners.delete(listener);
32940 }, [listeners]);
32941 const dispatch2 = (0, import_react40.useCallback)((_ref) => {
32942 let {
32943 type,
32944 event
32945 } = _ref;
32946 listeners.forEach((listener) => {
32947 var _listener$type;
32948 return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
32949 });
32950 }, [listeners]);
32951 return [dispatch2, registerListener];
32952 }
32953 var defaultScreenReaderInstructions = {
32954 draggable: "\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "
32955 };
32956 var defaultAnnouncements = {
32957 onDragStart(_ref) {
32958 let {
32959 active
32960 } = _ref;
32961 return "Picked up draggable item " + active.id + ".";
32962 },
32963 onDragOver(_ref2) {
32964 let {
32965 active,
32966 over
32967 } = _ref2;
32968 if (over) {
32969 return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
32970 }
32971 return "Draggable item " + active.id + " is no longer over a droppable area.";
32972 },
32973 onDragEnd(_ref3) {
32974 let {
32975 active,
32976 over
32977 } = _ref3;
32978 if (over) {
32979 return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
32980 }
32981 return "Draggable item " + active.id + " was dropped.";
32982 },
32983 onDragCancel(_ref4) {
32984 let {
32985 active
32986 } = _ref4;
32987 return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
32988 }
32989 };
32990 function Accessibility(_ref) {
32991 let {
32992 announcements = defaultAnnouncements,
32993 container,
32994 hiddenTextDescribedById,
32995 screenReaderInstructions = defaultScreenReaderInstructions
32996 } = _ref;
32997 const {
32998 announce,
32999 announcement
33000 } = useAnnouncement();
33001 const liveRegionId = useUniqueId("DndLiveRegion");
33002 const [mounted, setMounted] = (0, import_react40.useState)(false);
33003 (0, import_react40.useEffect)(() => {
33004 setMounted(true);
33005 }, []);
33006 useDndMonitor((0, import_react40.useMemo)(() => ({
33007 onDragStart(_ref2) {
33008 let {
33009 active
33010 } = _ref2;
33011 announce(announcements.onDragStart({
33012 active
33013 }));
33014 },
33015 onDragMove(_ref3) {
33016 let {
33017 active,
33018 over
33019 } = _ref3;
33020 if (announcements.onDragMove) {
33021 announce(announcements.onDragMove({
33022 active,
33023 over
33024 }));
33025 }
33026 },
33027 onDragOver(_ref4) {
33028 let {
33029 active,
33030 over
33031 } = _ref4;
33032 announce(announcements.onDragOver({
33033 active,
33034 over
33035 }));
33036 },
33037 onDragEnd(_ref5) {
33038 let {
33039 active,
33040 over
33041 } = _ref5;
33042 announce(announcements.onDragEnd({
33043 active,
33044 over
33045 }));
33046 },
33047 onDragCancel(_ref6) {
33048 let {
33049 active,
33050 over
33051 } = _ref6;
33052 announce(announcements.onDragCancel({
33053 active,
33054 over
33055 }));
33056 }
33057 }), [announce, announcements]));
33058 if (!mounted) {
33059 return null;
33060 }
33061 const markup = import_react40.default.createElement(import_react40.default.Fragment, null, import_react40.default.createElement(HiddenText, {
33062 id: hiddenTextDescribedById,
33063 value: screenReaderInstructions.draggable
33064 }), import_react40.default.createElement(LiveRegion, {
33065 id: liveRegionId,
33066 announcement
33067 }));
33068 return container ? (0, import_react_dom5.createPortal)(markup, container) : markup;
33069 }
33070 var Action2;
33071 (function(Action3) {
33072 Action3["DragStart"] = "dragStart";
33073 Action3["DragMove"] = "dragMove";
33074 Action3["DragEnd"] = "dragEnd";
33075 Action3["DragCancel"] = "dragCancel";
33076 Action3["DragOver"] = "dragOver";
33077 Action3["RegisterDroppable"] = "registerDroppable";
33078 Action3["SetDroppableDisabled"] = "setDroppableDisabled";
33079 Action3["UnregisterDroppable"] = "unregisterDroppable";
33080 })(Action2 || (Action2 = {}));
33081 function noop6() {
33082 }
33083 function useSensor(sensor, options) {
33084 return (0, import_react40.useMemo)(
33085 () => ({
33086 sensor,
33087 options: options != null ? options : {}
33088 }),
33089 // eslint-disable-next-line react-hooks/exhaustive-deps
33090 [sensor, options]
33091 );
33092 }
33093 function useSensors() {
33094 for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
33095 sensors[_key] = arguments[_key];
33096 }
33097 return (0, import_react40.useMemo)(
33098 () => [...sensors].filter((sensor) => sensor != null),
33099 // eslint-disable-next-line react-hooks/exhaustive-deps
33100 [...sensors]
33101 );
33102 }
33103 var defaultCoordinates = /* @__PURE__ */ Object.freeze({
33104 x: 0,
33105 y: 0
33106 });
33107 function distanceBetween(p1, p2) {
33108 return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
33109 }
33110 function getRelativeTransformOrigin(event, rect) {
33111 const eventCoordinates = getEventCoordinates(event);
33112 if (!eventCoordinates) {
33113 return "0 0";
33114 }
33115 const transformOrigin = {
33116 x: (eventCoordinates.x - rect.left) / rect.width * 100,
33117 y: (eventCoordinates.y - rect.top) / rect.height * 100
33118 };
33119 return transformOrigin.x + "% " + transformOrigin.y + "%";
33120 }
33121 function sortCollisionsAsc(_ref, _ref2) {
33122 let {
33123 data: {
33124 value: a2
33125 }
33126 } = _ref;
33127 let {
33128 data: {
33129 value: b2
33130 }
33131 } = _ref2;
33132 return a2 - b2;
33133 }
33134 function sortCollisionsDesc(_ref3, _ref4) {
33135 let {
33136 data: {
33137 value: a2
33138 }
33139 } = _ref3;
33140 let {
33141 data: {
33142 value: b2
33143 }
33144 } = _ref4;
33145 return b2 - a2;
33146 }
33147 function cornersOfRectangle(_ref5) {
33148 let {
33149 left,
33150 top,
33151 height,
33152 width
33153 } = _ref5;
33154 return [{
33155 x: left,
33156 y: top
33157 }, {
33158 x: left + width,
33159 y: top
33160 }, {
33161 x: left,
33162 y: top + height
33163 }, {
33164 x: left + width,
33165 y: top + height
33166 }];
33167 }
33168 function getFirstCollision(collisions, property) {
33169 if (!collisions || collisions.length === 0) {
33170 return null;
33171 }
33172 const [firstCollision] = collisions;
33173 return property ? firstCollision[property] : firstCollision;
33174 }
33175 var closestCorners = (_ref) => {
33176 let {
33177 collisionRect,
33178 droppableRects,
33179 droppableContainers
33180 } = _ref;
33181 const corners = cornersOfRectangle(collisionRect);
33182 const collisions = [];
33183 for (const droppableContainer of droppableContainers) {
33184 const {
33185 id
33186 } = droppableContainer;
33187 const rect = droppableRects.get(id);
33188 if (rect) {
33189 const rectCorners = cornersOfRectangle(rect);
33190 const distances = corners.reduce((accumulator, corner, index2) => {
33191 return accumulator + distanceBetween(rectCorners[index2], corner);
33192 }, 0);
33193 const effectiveDistance = Number((distances / 4).toFixed(4));
33194 collisions.push({
33195 id,
33196 data: {
33197 droppableContainer,
33198 value: effectiveDistance
33199 }
33200 });
33201 }
33202 }
33203 return collisions.sort(sortCollisionsAsc);
33204 };
33205 function getIntersectionRatio(entry, target) {
33206 const top = Math.max(target.top, entry.top);
33207 const left = Math.max(target.left, entry.left);
33208 const right = Math.min(target.left + target.width, entry.left + entry.width);
33209 const bottom = Math.min(target.top + target.height, entry.top + entry.height);
33210 const width = right - left;
33211 const height = bottom - top;
33212 if (left < right && top < bottom) {
33213 const targetArea = target.width * target.height;
33214 const entryArea = entry.width * entry.height;
33215 const intersectionArea = width * height;
33216 const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
33217 return Number(intersectionRatio.toFixed(4));
33218 }
33219 return 0;
33220 }
33221 var rectIntersection = (_ref) => {
33222 let {
33223 collisionRect,
33224 droppableRects,
33225 droppableContainers
33226 } = _ref;
33227 const collisions = [];
33228 for (const droppableContainer of droppableContainers) {
33229 const {
33230 id
33231 } = droppableContainer;
33232 const rect = droppableRects.get(id);
33233 if (rect) {
33234 const intersectionRatio = getIntersectionRatio(rect, collisionRect);
33235 if (intersectionRatio > 0) {
33236 collisions.push({
33237 id,
33238 data: {
33239 droppableContainer,
33240 value: intersectionRatio
33241 }
33242 });
33243 }
33244 }
33245 }
33246 return collisions.sort(sortCollisionsDesc);
33247 };
33248 function adjustScale(transform, rect1, rect2) {
33249 return {
33250 ...transform,
33251 scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
33252 scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
33253 };
33254 }
33255 function getRectDelta(rect1, rect2) {
33256 return rect1 && rect2 ? {
33257 x: rect1.left - rect2.left,
33258 y: rect1.top - rect2.top
33259 } : defaultCoordinates;
33260 }
33261 function createRectAdjustmentFn(modifier) {
33262 return function adjustClientRect(rect) {
33263 for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
33264 adjustments[_key - 1] = arguments[_key];
33265 }
33266 return adjustments.reduce((acc, adjustment) => ({
33267 ...acc,
33268 top: acc.top + modifier * adjustment.y,
33269 bottom: acc.bottom + modifier * adjustment.y,
33270 left: acc.left + modifier * adjustment.x,
33271 right: acc.right + modifier * adjustment.x
33272 }), {
33273 ...rect
33274 });
33275 };
33276 }
33277 var getAdjustedRect = /* @__PURE__ */ createRectAdjustmentFn(1);
33278 function parseTransform(transform) {
33279 if (transform.startsWith("matrix3d(")) {
33280 const transformArray = transform.slice(9, -1).split(/, /);
33281 return {
33282 x: +transformArray[12],
33283 y: +transformArray[13],
33284 scaleX: +transformArray[0],
33285 scaleY: +transformArray[5]
33286 };
33287 } else if (transform.startsWith("matrix(")) {
33288 const transformArray = transform.slice(7, -1).split(/, /);
33289 return {
33290 x: +transformArray[4],
33291 y: +transformArray[5],
33292 scaleX: +transformArray[0],
33293 scaleY: +transformArray[3]
33294 };
33295 }
33296 return null;
33297 }
33298 function inverseTransform(rect, transform, transformOrigin) {
33299 const parsedTransform = parseTransform(transform);
33300 if (!parsedTransform) {
33301 return rect;
33302 }
33303 const {
33304 scaleX,
33305 scaleY,
33306 x: translateX,
33307 y: translateY
33308 } = parsedTransform;
33309 const x2 = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
33310 const y2 = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(" ") + 1));
33311 const w2 = scaleX ? rect.width / scaleX : rect.width;
33312 const h2 = scaleY ? rect.height / scaleY : rect.height;
33313 return {
33314 width: w2,
33315 height: h2,
33316 top: y2,
33317 right: x2 + w2,
33318 bottom: y2 + h2,
33319 left: x2
33320 };
33321 }
33322 var defaultOptions2 = {
33323 ignoreTransform: false
33324 };
33325 function getClientRect(element, options) {
33326 if (options === void 0) {
33327 options = defaultOptions2;
33328 }
33329 let rect = element.getBoundingClientRect();
33330 if (options.ignoreTransform) {
33331 const {
33332 transform,
33333 transformOrigin
33334 } = getWindow3(element).getComputedStyle(element);
33335 if (transform) {
33336 rect = inverseTransform(rect, transform, transformOrigin);
33337 }
33338 }
33339 const {
33340 top,
33341 left,
33342 width,
33343 height,
33344 bottom,
33345 right
33346 } = rect;
33347 return {
33348 top,
33349 left,
33350 width,
33351 height,
33352 bottom,
33353 right
33354 };
33355 }
33356 function getTransformAgnosticClientRect(element) {
33357 return getClientRect(element, {
33358 ignoreTransform: true
33359 });
33360 }
33361 function getWindowClientRect(element) {
33362 const width = element.innerWidth;
33363 const height = element.innerHeight;
33364 return {
33365 top: 0,
33366 left: 0,
33367 right: width,
33368 bottom: height,
33369 width,
33370 height
33371 };
33372 }
33373 function isFixed(node, computedStyle) {
33374 if (computedStyle === void 0) {
33375 computedStyle = getWindow3(node).getComputedStyle(node);
33376 }
33377 return computedStyle.position === "fixed";
33378 }
33379 function isScrollable(element, computedStyle) {
33380 if (computedStyle === void 0) {
33381 computedStyle = getWindow3(element).getComputedStyle(element);
33382 }
33383 const overflowRegex = /(auto|scroll|overlay)/;
33384 const properties2 = ["overflow", "overflowX", "overflowY"];
33385 return properties2.some((property) => {
33386 const value = computedStyle[property];
33387 return typeof value === "string" ? overflowRegex.test(value) : false;
33388 });
33389 }
33390 function getScrollableAncestors(element, limit) {
33391 const scrollParents = [];
33392 function findScrollableAncestors(node) {
33393 if (limit != null && scrollParents.length >= limit) {
33394 return scrollParents;
33395 }
33396 if (!node) {
33397 return scrollParents;
33398 }
33399 if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
33400 scrollParents.push(node.scrollingElement);
33401 return scrollParents;
33402 }
33403 if (!isHTMLElement2(node) || isSVGElement(node)) {
33404 return scrollParents;
33405 }
33406 if (scrollParents.includes(node)) {
33407 return scrollParents;
33408 }
33409 const computedStyle = getWindow3(element).getComputedStyle(node);
33410 if (node !== element) {
33411 if (isScrollable(node, computedStyle)) {
33412 scrollParents.push(node);
33413 }
33414 }
33415 if (isFixed(node, computedStyle)) {
33416 return scrollParents;
33417 }
33418 return findScrollableAncestors(node.parentNode);
33419 }
33420 if (!element) {
33421 return scrollParents;
33422 }
33423 return findScrollableAncestors(element);
33424 }
33425 function getFirstScrollableAncestor(node) {
33426 const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
33427 return firstScrollableAncestor != null ? firstScrollableAncestor : null;
33428 }
33429 function getScrollableElement(element) {
33430 if (!canUseDOM2 || !element) {
33431 return null;
33432 }
33433 if (isWindow(element)) {
33434 return element;
33435 }
33436 if (!isNode2(element)) {
33437 return null;
33438 }
33439 if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
33440 return window;
33441 }
33442 if (isHTMLElement2(element)) {
33443 return element;
33444 }
33445 return null;
33446 }
33447 function getScrollXCoordinate(element) {
33448 if (isWindow(element)) {
33449 return element.scrollX;
33450 }
33451 return element.scrollLeft;
33452 }
33453 function getScrollYCoordinate(element) {
33454 if (isWindow(element)) {
33455 return element.scrollY;
33456 }
33457 return element.scrollTop;
33458 }
33459 function getScrollCoordinates(element) {
33460 return {
33461 x: getScrollXCoordinate(element),
33462 y: getScrollYCoordinate(element)
33463 };
33464 }
33465 var Direction;
33466 (function(Direction2) {
33467 Direction2[Direction2["Forward"] = 1] = "Forward";
33468 Direction2[Direction2["Backward"] = -1] = "Backward";
33469 })(Direction || (Direction = {}));
33470 function isDocumentScrollingElement(element) {
33471 if (!canUseDOM2 || !element) {
33472 return false;
33473 }
33474 return element === document.scrollingElement;
33475 }
33476 function getScrollPosition(scrollingContainer) {
33477 const minScroll = {
33478 x: 0,
33479 y: 0
33480 };
33481 const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
33482 height: window.innerHeight,
33483 width: window.innerWidth
33484 } : {
33485 height: scrollingContainer.clientHeight,
33486 width: scrollingContainer.clientWidth
33487 };
33488 const maxScroll = {
33489 x: scrollingContainer.scrollWidth - dimensions.width,
33490 y: scrollingContainer.scrollHeight - dimensions.height
33491 };
33492 const isTop = scrollingContainer.scrollTop <= minScroll.y;
33493 const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
33494 const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
33495 const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
33496 return {
33497 isTop,
33498 isLeft,
33499 isBottom,
33500 isRight,
33501 maxScroll,
33502 minScroll
33503 };
33504 }
33505 var defaultThreshold = {
33506 x: 0.2,
33507 y: 0.2
33508 };
33509 function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
33510 let {
33511 top,
33512 left,
33513 right,
33514 bottom
33515 } = _ref;
33516 if (acceleration === void 0) {
33517 acceleration = 10;
33518 }
33519 if (thresholdPercentage === void 0) {
33520 thresholdPercentage = defaultThreshold;
33521 }
33522 const {
33523 isTop,
33524 isBottom,
33525 isLeft,
33526 isRight
33527 } = getScrollPosition(scrollContainer);
33528 const direction = {
33529 x: 0,
33530 y: 0
33531 };
33532 const speed = {
33533 x: 0,
33534 y: 0
33535 };
33536 const threshold = {
33537 height: scrollContainerRect.height * thresholdPercentage.y,
33538 width: scrollContainerRect.width * thresholdPercentage.x
33539 };
33540 if (!isTop && top <= scrollContainerRect.top + threshold.height) {
33541 direction.y = Direction.Backward;
33542 speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
33543 } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
33544 direction.y = Direction.Forward;
33545 speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
33546 }
33547 if (!isRight && right >= scrollContainerRect.right - threshold.width) {
33548 direction.x = Direction.Forward;
33549 speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
33550 } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
33551 direction.x = Direction.Backward;
33552 speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
33553 }
33554 return {
33555 direction,
33556 speed
33557 };
33558 }
33559 function getScrollElementRect(element) {
33560 if (element === document.scrollingElement) {
33561 const {
33562 innerWidth,
33563 innerHeight
33564 } = window;
33565 return {
33566 top: 0,
33567 left: 0,
33568 right: innerWidth,
33569 bottom: innerHeight,
33570 width: innerWidth,
33571 height: innerHeight
33572 };
33573 }
33574 const {
33575 top,
33576 left,
33577 right,
33578 bottom
33579 } = element.getBoundingClientRect();
33580 return {
33581 top,
33582 left,
33583 right,
33584 bottom,
33585 width: element.clientWidth,
33586 height: element.clientHeight
33587 };
33588 }
33589 function getScrollOffsets(scrollableAncestors) {
33590 return scrollableAncestors.reduce((acc, node) => {
33591 return add(acc, getScrollCoordinates(node));
33592 }, defaultCoordinates);
33593 }
33594 function getScrollXOffset(scrollableAncestors) {
33595 return scrollableAncestors.reduce((acc, node) => {
33596 return acc + getScrollXCoordinate(node);
33597 }, 0);
33598 }
33599 function getScrollYOffset(scrollableAncestors) {
33600 return scrollableAncestors.reduce((acc, node) => {
33601 return acc + getScrollYCoordinate(node);
33602 }, 0);
33603 }
33604 function scrollIntoViewIfNeeded2(element, measure) {
33605 if (measure === void 0) {
33606 measure = getClientRect;
33607 }
33608 if (!element) {
33609 return;
33610 }
33611 const {
33612 top,
33613 left,
33614 bottom,
33615 right
33616 } = measure(element);
33617 const firstScrollableAncestor = getFirstScrollableAncestor(element);
33618 if (!firstScrollableAncestor) {
33619 return;
33620 }
33621 if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
33622 element.scrollIntoView({
33623 block: "center",
33624 inline: "center"
33625 });
33626 }
33627 }
33628 var properties = [["x", ["left", "right"], getScrollXOffset], ["y", ["top", "bottom"], getScrollYOffset]];
33629 var Rect = class {
33630 constructor(rect, element) {
33631 this.rect = void 0;
33632 this.width = void 0;
33633 this.height = void 0;
33634 this.top = void 0;
33635 this.bottom = void 0;
33636 this.right = void 0;
33637 this.left = void 0;
33638 const scrollableAncestors = getScrollableAncestors(element);
33639 const scrollOffsets = getScrollOffsets(scrollableAncestors);
33640 this.rect = {
33641 ...rect
33642 };
33643 this.width = rect.width;
33644 this.height = rect.height;
33645 for (const [axis, keys, getScrollOffset] of properties) {
33646 for (const key2 of keys) {
33647 Object.defineProperty(this, key2, {
33648 get: () => {
33649 const currentOffsets = getScrollOffset(scrollableAncestors);
33650 const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
33651 return this.rect[key2] + scrollOffsetsDeltla;
33652 },
33653 enumerable: true
33654 });
33655 }
33656 }
33657 Object.defineProperty(this, "rect", {
33658 enumerable: false
33659 });
33660 }
33661 };
33662 var Listeners = class {
33663 constructor(target) {
33664 this.target = void 0;
33665 this.listeners = [];
33666 this.removeAll = () => {
33667 this.listeners.forEach((listener) => {
33668 var _this$target;
33669 return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
33670 });
33671 };
33672 this.target = target;
33673 }
33674 add(eventName, handler, options) {
33675 var _this$target2;
33676 (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
33677 this.listeners.push([eventName, handler, options]);
33678 }
33679 };
33680 function getEventListenerTarget(target) {
33681 const {
33682 EventTarget
33683 } = getWindow3(target);
33684 return target instanceof EventTarget ? target : getOwnerDocument(target);
33685 }
33686 function hasExceededDistance(delta, measurement) {
33687 const dx = Math.abs(delta.x);
33688 const dy = Math.abs(delta.y);
33689 if (typeof measurement === "number") {
33690 return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
33691 }
33692 if ("x" in measurement && "y" in measurement) {
33693 return dx > measurement.x && dy > measurement.y;
33694 }
33695 if ("x" in measurement) {
33696 return dx > measurement.x;
33697 }
33698 if ("y" in measurement) {
33699 return dy > measurement.y;
33700 }
33701 return false;
33702 }
33703 var EventName;
33704 (function(EventName2) {
33705 EventName2["Click"] = "click";
33706 EventName2["DragStart"] = "dragstart";
33707 EventName2["Keydown"] = "keydown";
33708 EventName2["ContextMenu"] = "contextmenu";
33709 EventName2["Resize"] = "resize";
33710 EventName2["SelectionChange"] = "selectionchange";
33711 EventName2["VisibilityChange"] = "visibilitychange";
33712 })(EventName || (EventName = {}));
33713 function preventDefault(event) {
33714 event.preventDefault();
33715 }
33716 function stopPropagation(event) {
33717 event.stopPropagation();
33718 }
33719 var KeyboardCode;
33720 (function(KeyboardCode2) {
33721 KeyboardCode2["Space"] = "Space";
33722 KeyboardCode2["Down"] = "ArrowDown";
33723 KeyboardCode2["Right"] = "ArrowRight";
33724 KeyboardCode2["Left"] = "ArrowLeft";
33725 KeyboardCode2["Up"] = "ArrowUp";
33726 KeyboardCode2["Esc"] = "Escape";
33727 KeyboardCode2["Enter"] = "Enter";
33728 KeyboardCode2["Tab"] = "Tab";
33729 })(KeyboardCode || (KeyboardCode = {}));
33730 var defaultKeyboardCodes = {
33731 start: [KeyboardCode.Space, KeyboardCode.Enter],
33732 cancel: [KeyboardCode.Esc],
33733 end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab]
33734 };
33735 var defaultKeyboardCoordinateGetter = (event, _ref) => {
33736 let {
33737 currentCoordinates
33738 } = _ref;
33739 switch (event.code) {
33740 case KeyboardCode.Right:
33741 return {
33742 ...currentCoordinates,
33743 x: currentCoordinates.x + 25
33744 };
33745 case KeyboardCode.Left:
33746 return {
33747 ...currentCoordinates,
33748 x: currentCoordinates.x - 25
33749 };
33750 case KeyboardCode.Down:
33751 return {
33752 ...currentCoordinates,
33753 y: currentCoordinates.y + 25
33754 };
33755 case KeyboardCode.Up:
33756 return {
33757 ...currentCoordinates,
33758 y: currentCoordinates.y - 25
33759 };
33760 }
33761 return void 0;
33762 };
33763 var KeyboardSensor = class {
33764 constructor(props) {
33765 this.props = void 0;
33766 this.autoScrollEnabled = false;
33767 this.referenceCoordinates = void 0;
33768 this.listeners = void 0;
33769 this.windowListeners = void 0;
33770 this.props = props;
33771 const {
33772 event: {
33773 target
33774 }
33775 } = props;
33776 this.props = props;
33777 this.listeners = new Listeners(getOwnerDocument(target));
33778 this.windowListeners = new Listeners(getWindow3(target));
33779 this.handleKeyDown = this.handleKeyDown.bind(this);
33780 this.handleCancel = this.handleCancel.bind(this);
33781 this.attach();
33782 }
33783 attach() {
33784 this.handleStart();
33785 this.windowListeners.add(EventName.Resize, this.handleCancel);
33786 this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
33787 setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
33788 }
33789 handleStart() {
33790 const {
33791 activeNode,
33792 onStart
33793 } = this.props;
33794 const node = activeNode.node.current;
33795 if (node) {
33796 scrollIntoViewIfNeeded2(node);
33797 }
33798 onStart(defaultCoordinates);
33799 }
33800 handleKeyDown(event) {
33801 if (isKeyboardEvent(event)) {
33802 const {
33803 active,
33804 context,
33805 options
33806 } = this.props;
33807 const {
33808 keyboardCodes = defaultKeyboardCodes,
33809 coordinateGetter = defaultKeyboardCoordinateGetter,
33810 scrollBehavior = "smooth"
33811 } = options;
33812 const {
33813 code
33814 } = event;
33815 if (keyboardCodes.end.includes(code)) {
33816 this.handleEnd(event);
33817 return;
33818 }
33819 if (keyboardCodes.cancel.includes(code)) {
33820 this.handleCancel(event);
33821 return;
33822 }
33823 const {
33824 collisionRect
33825 } = context.current;
33826 const currentCoordinates = collisionRect ? {
33827 x: collisionRect.left,
33828 y: collisionRect.top
33829 } : defaultCoordinates;
33830 if (!this.referenceCoordinates) {
33831 this.referenceCoordinates = currentCoordinates;
33832 }
33833 const newCoordinates = coordinateGetter(event, {
33834 active,
33835 context: context.current,
33836 currentCoordinates
33837 });
33838 if (newCoordinates) {
33839 const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
33840 const scrollDelta = {
33841 x: 0,
33842 y: 0
33843 };
33844 const {
33845 scrollableAncestors
33846 } = context.current;
33847 for (const scrollContainer of scrollableAncestors) {
33848 const direction = event.code;
33849 const {
33850 isTop,
33851 isRight,
33852 isLeft,
33853 isBottom,
33854 maxScroll,
33855 minScroll
33856 } = getScrollPosition(scrollContainer);
33857 const scrollElementRect = getScrollElementRect(scrollContainer);
33858 const clampedCoordinates = {
33859 x: Math.min(direction === KeyboardCode.Right ? scrollElementRect.right - scrollElementRect.width / 2 : scrollElementRect.right, Math.max(direction === KeyboardCode.Right ? scrollElementRect.left : scrollElementRect.left + scrollElementRect.width / 2, newCoordinates.x)),
33860 y: Math.min(direction === KeyboardCode.Down ? scrollElementRect.bottom - scrollElementRect.height / 2 : scrollElementRect.bottom, Math.max(direction === KeyboardCode.Down ? scrollElementRect.top : scrollElementRect.top + scrollElementRect.height / 2, newCoordinates.y))
33861 };
33862 const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
33863 const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
33864 if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
33865 const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
33866 const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
33867 if (canScrollToNewCoordinates && !coordinatesDelta.y) {
33868 scrollContainer.scrollTo({
33869 left: newScrollCoordinates,
33870 behavior: scrollBehavior
33871 });
33872 return;
33873 }
33874 if (canScrollToNewCoordinates) {
33875 scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
33876 } else {
33877 scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
33878 }
33879 if (scrollDelta.x) {
33880 scrollContainer.scrollBy({
33881 left: -scrollDelta.x,
33882 behavior: scrollBehavior
33883 });
33884 }
33885 break;
33886 } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
33887 const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
33888 const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
33889 if (canScrollToNewCoordinates && !coordinatesDelta.x) {
33890 scrollContainer.scrollTo({
33891 top: newScrollCoordinates,
33892 behavior: scrollBehavior
33893 });
33894 return;
33895 }
33896 if (canScrollToNewCoordinates) {
33897 scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
33898 } else {
33899 scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
33900 }
33901 if (scrollDelta.y) {
33902 scrollContainer.scrollBy({
33903 top: -scrollDelta.y,
33904 behavior: scrollBehavior
33905 });
33906 }
33907 break;
33908 }
33909 }
33910 this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
33911 }
33912 }
33913 }
33914 handleMove(event, coordinates) {
33915 const {
33916 onMove
33917 } = this.props;
33918 event.preventDefault();
33919 onMove(coordinates);
33920 }
33921 handleEnd(event) {
33922 const {
33923 onEnd
33924 } = this.props;
33925 event.preventDefault();
33926 this.detach();
33927 onEnd();
33928 }
33929 handleCancel(event) {
33930 const {
33931 onCancel
33932 } = this.props;
33933 event.preventDefault();
33934 this.detach();
33935 onCancel();
33936 }
33937 detach() {
33938 this.listeners.removeAll();
33939 this.windowListeners.removeAll();
33940 }
33941 };
33942 KeyboardSensor.activators = [{
33943 eventName: "onKeyDown",
33944 handler: (event, _ref, _ref2) => {
33945 let {
33946 keyboardCodes = defaultKeyboardCodes,
33947 onActivation
33948 } = _ref;
33949 let {
33950 active
33951 } = _ref2;
33952 const {
33953 code
33954 } = event.nativeEvent;
33955 if (keyboardCodes.start.includes(code)) {
33956 const activator = active.activatorNode.current;
33957 if (activator && event.target !== activator) {
33958 return false;
33959 }
33960 event.preventDefault();
33961 onActivation == null ? void 0 : onActivation({
33962 event: event.nativeEvent
33963 });
33964 return true;
33965 }
33966 return false;
33967 }
33968 }];
33969 function isDistanceConstraint(constraint) {
33970 return Boolean(constraint && "distance" in constraint);
33971 }
33972 function isDelayConstraint(constraint) {
33973 return Boolean(constraint && "delay" in constraint);
33974 }
33975 var AbstractPointerSensor = class {
33976 constructor(props, events2, listenerTarget) {
33977 var _getEventCoordinates;
33978 if (listenerTarget === void 0) {
33979 listenerTarget = getEventListenerTarget(props.event.target);
33980 }
33981 this.props = void 0;
33982 this.events = void 0;
33983 this.autoScrollEnabled = true;
33984 this.document = void 0;
33985 this.activated = false;
33986 this.initialCoordinates = void 0;
33987 this.timeoutId = null;
33988 this.listeners = void 0;
33989 this.documentListeners = void 0;
33990 this.windowListeners = void 0;
33991 this.props = props;
33992 this.events = events2;
33993 const {
33994 event
33995 } = props;
33996 const {
33997 target
33998 } = event;
33999 this.props = props;
34000 this.events = events2;
34001 this.document = getOwnerDocument(target);
34002 this.documentListeners = new Listeners(this.document);
34003 this.listeners = new Listeners(listenerTarget);
34004 this.windowListeners = new Listeners(getWindow3(target));
34005 this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
34006 this.handleStart = this.handleStart.bind(this);
34007 this.handleMove = this.handleMove.bind(this);
34008 this.handleEnd = this.handleEnd.bind(this);
34009 this.handleCancel = this.handleCancel.bind(this);
34010 this.handleKeydown = this.handleKeydown.bind(this);
34011 this.removeTextSelection = this.removeTextSelection.bind(this);
34012 this.attach();
34013 }
34014 attach() {
34015 const {
34016 events: events2,
34017 props: {
34018 options: {
34019 activationConstraint,
34020 bypassActivationConstraint
34021 }
34022 }
34023 } = this;
34024 this.listeners.add(events2.move.name, this.handleMove, {
34025 passive: false
34026 });
34027 this.listeners.add(events2.end.name, this.handleEnd);
34028 if (events2.cancel) {
34029 this.listeners.add(events2.cancel.name, this.handleCancel);
34030 }
34031 this.windowListeners.add(EventName.Resize, this.handleCancel);
34032 this.windowListeners.add(EventName.DragStart, preventDefault);
34033 this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
34034 this.windowListeners.add(EventName.ContextMenu, preventDefault);
34035 this.documentListeners.add(EventName.Keydown, this.handleKeydown);
34036 if (activationConstraint) {
34037 if (bypassActivationConstraint != null && bypassActivationConstraint({
34038 event: this.props.event,
34039 activeNode: this.props.activeNode,
34040 options: this.props.options
34041 })) {
34042 return this.handleStart();
34043 }
34044 if (isDelayConstraint(activationConstraint)) {
34045 this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
34046 this.handlePending(activationConstraint);
34047 return;
34048 }
34049 if (isDistanceConstraint(activationConstraint)) {
34050 this.handlePending(activationConstraint);
34051 return;
34052 }
34053 }
34054 this.handleStart();
34055 }
34056 detach() {
34057 this.listeners.removeAll();
34058 this.windowListeners.removeAll();
34059 setTimeout(this.documentListeners.removeAll, 50);
34060 if (this.timeoutId !== null) {
34061 clearTimeout(this.timeoutId);
34062 this.timeoutId = null;
34063 }
34064 }
34065 handlePending(constraint, offset4) {
34066 const {
34067 active,
34068 onPending
34069 } = this.props;
34070 onPending(active, constraint, this.initialCoordinates, offset4);
34071 }
34072 handleStart() {
34073 const {
34074 initialCoordinates
34075 } = this;
34076 const {
34077 onStart
34078 } = this.props;
34079 if (initialCoordinates) {
34080 this.activated = true;
34081 this.documentListeners.add(EventName.Click, stopPropagation, {
34082 capture: true
34083 });
34084 this.removeTextSelection();
34085 this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
34086 onStart(initialCoordinates);
34087 }
34088 }
34089 handleMove(event) {
34090 var _getEventCoordinates2;
34091 const {
34092 activated,
34093 initialCoordinates,
34094 props
34095 } = this;
34096 const {
34097 onMove,
34098 options: {
34099 activationConstraint
34100 }
34101 } = props;
34102 if (!initialCoordinates) {
34103 return;
34104 }
34105 const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
34106 const delta = subtract(initialCoordinates, coordinates);
34107 if (!activated && activationConstraint) {
34108 if (isDistanceConstraint(activationConstraint)) {
34109 if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
34110 return this.handleCancel();
34111 }
34112 if (hasExceededDistance(delta, activationConstraint.distance)) {
34113 return this.handleStart();
34114 }
34115 }
34116 if (isDelayConstraint(activationConstraint)) {
34117 if (hasExceededDistance(delta, activationConstraint.tolerance)) {
34118 return this.handleCancel();
34119 }
34120 }
34121 this.handlePending(activationConstraint, delta);
34122 return;
34123 }
34124 if (event.cancelable) {
34125 event.preventDefault();
34126 }
34127 onMove(coordinates);
34128 }
34129 handleEnd() {
34130 const {
34131 onAbort,
34132 onEnd
34133 } = this.props;
34134 this.detach();
34135 if (!this.activated) {
34136 onAbort(this.props.active);
34137 }
34138 onEnd();
34139 }
34140 handleCancel() {
34141 const {
34142 onAbort,
34143 onCancel
34144 } = this.props;
34145 this.detach();
34146 if (!this.activated) {
34147 onAbort(this.props.active);
34148 }
34149 onCancel();
34150 }
34151 handleKeydown(event) {
34152 if (event.code === KeyboardCode.Esc) {
34153 this.handleCancel();
34154 }
34155 }
34156 removeTextSelection() {
34157 var _this$document$getSel;
34158 (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
34159 }
34160 };
34161 var events = {
34162 cancel: {
34163 name: "pointercancel"
34164 },
34165 move: {
34166 name: "pointermove"
34167 },
34168 end: {
34169 name: "pointerup"
34170 }
34171 };
34172 var PointerSensor = class extends AbstractPointerSensor {
34173 constructor(props) {
34174 const {
34175 event
34176 } = props;
34177 const listenerTarget = getOwnerDocument(event.target);
34178 super(props, events, listenerTarget);
34179 }
34180 };
34181 PointerSensor.activators = [{
34182 eventName: "onPointerDown",
34183 handler: (_ref, _ref2) => {
34184 let {
34185 nativeEvent: event
34186 } = _ref;
34187 let {
34188 onActivation
34189 } = _ref2;
34190 if (!event.isPrimary || event.button !== 0) {
34191 return false;
34192 }
34193 onActivation == null ? void 0 : onActivation({
34194 event
34195 });
34196 return true;
34197 }
34198 }];
34199 var events$1 = {
34200 move: {
34201 name: "mousemove"
34202 },
34203 end: {
34204 name: "mouseup"
34205 }
34206 };
34207 var MouseButton;
34208 (function(MouseButton2) {
34209 MouseButton2[MouseButton2["RightClick"] = 2] = "RightClick";
34210 })(MouseButton || (MouseButton = {}));
34211 var MouseSensor = class extends AbstractPointerSensor {
34212 constructor(props) {
34213 super(props, events$1, getOwnerDocument(props.event.target));
34214 }
34215 };
34216 MouseSensor.activators = [{
34217 eventName: "onMouseDown",
34218 handler: (_ref, _ref2) => {
34219 let {
34220 nativeEvent: event
34221 } = _ref;
34222 let {
34223 onActivation
34224 } = _ref2;
34225 if (event.button === MouseButton.RightClick) {
34226 return false;
34227 }
34228 onActivation == null ? void 0 : onActivation({
34229 event
34230 });
34231 return true;
34232 }
34233 }];
34234 var events$2 = {
34235 cancel: {
34236 name: "touchcancel"
34237 },
34238 move: {
34239 name: "touchmove"
34240 },
34241 end: {
34242 name: "touchend"
34243 }
34244 };
34245 var TouchSensor = class extends AbstractPointerSensor {
34246 constructor(props) {
34247 super(props, events$2);
34248 }
34249 static setup() {
34250 window.addEventListener(events$2.move.name, noop7, {
34251 capture: false,
34252 passive: false
34253 });
34254 return function teardown() {
34255 window.removeEventListener(events$2.move.name, noop7);
34256 };
34257 function noop7() {
34258 }
34259 }
34260 };
34261 TouchSensor.activators = [{
34262 eventName: "onTouchStart",
34263 handler: (_ref, _ref2) => {
34264 let {
34265 nativeEvent: event
34266 } = _ref;
34267 let {
34268 onActivation
34269 } = _ref2;
34270 const {
34271 touches
34272 } = event;
34273 if (touches.length > 1) {
34274 return false;
34275 }
34276 onActivation == null ? void 0 : onActivation({
34277 event
34278 });
34279 return true;
34280 }
34281 }];
34282 var AutoScrollActivator;
34283 (function(AutoScrollActivator2) {
34284 AutoScrollActivator2[AutoScrollActivator2["Pointer"] = 0] = "Pointer";
34285 AutoScrollActivator2[AutoScrollActivator2["DraggableRect"] = 1] = "DraggableRect";
34286 })(AutoScrollActivator || (AutoScrollActivator = {}));
34287 var TraversalOrder;
34288 (function(TraversalOrder2) {
34289 TraversalOrder2[TraversalOrder2["TreeOrder"] = 0] = "TreeOrder";
34290 TraversalOrder2[TraversalOrder2["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
34291 })(TraversalOrder || (TraversalOrder = {}));
34292 function useAutoScroller(_ref) {
34293 let {
34294 acceleration,
34295 activator = AutoScrollActivator.Pointer,
34296 canScroll,
34297 draggingRect,
34298 enabled,
34299 interval = 5,
34300 order = TraversalOrder.TreeOrder,
34301 pointerCoordinates,
34302 scrollableAncestors,
34303 scrollableAncestorRects,
34304 delta,
34305 threshold
34306 } = _ref;
34307 const scrollIntent = useScrollIntent({
34308 delta,
34309 disabled: !enabled
34310 });
34311 const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
34312 const scrollSpeed = (0, import_react40.useRef)({
34313 x: 0,
34314 y: 0
34315 });
34316 const scrollDirection = (0, import_react40.useRef)({
34317 x: 0,
34318 y: 0
34319 });
34320 const rect = (0, import_react40.useMemo)(() => {
34321 switch (activator) {
34322 case AutoScrollActivator.Pointer:
34323 return pointerCoordinates ? {
34324 top: pointerCoordinates.y,
34325 bottom: pointerCoordinates.y,
34326 left: pointerCoordinates.x,
34327 right: pointerCoordinates.x
34328 } : null;
34329 case AutoScrollActivator.DraggableRect:
34330 return draggingRect;
34331 }
34332 }, [activator, draggingRect, pointerCoordinates]);
34333 const scrollContainerRef = (0, import_react40.useRef)(null);
34334 const autoScroll = (0, import_react40.useCallback)(() => {
34335 const scrollContainer = scrollContainerRef.current;
34336 if (!scrollContainer) {
34337 return;
34338 }
34339 const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
34340 const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
34341 scrollContainer.scrollBy(scrollLeft, scrollTop);
34342 }, []);
34343 const sortedScrollableAncestors = (0, import_react40.useMemo)(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
34344 (0, import_react40.useEffect)(
34345 () => {
34346 if (!enabled || !scrollableAncestors.length || !rect) {
34347 clearAutoScrollInterval();
34348 return;
34349 }
34350 for (const scrollContainer of sortedScrollableAncestors) {
34351 if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
34352 continue;
34353 }
34354 const index2 = scrollableAncestors.indexOf(scrollContainer);
34355 const scrollContainerRect = scrollableAncestorRects[index2];
34356 if (!scrollContainerRect) {
34357 continue;
34358 }
34359 const {
34360 direction,
34361 speed
34362 } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
34363 for (const axis of ["x", "y"]) {
34364 if (!scrollIntent[axis][direction[axis]]) {
34365 speed[axis] = 0;
34366 direction[axis] = 0;
34367 }
34368 }
34369 if (speed.x > 0 || speed.y > 0) {
34370 clearAutoScrollInterval();
34371 scrollContainerRef.current = scrollContainer;
34372 setAutoScrollInterval(autoScroll, interval);
34373 scrollSpeed.current = speed;
34374 scrollDirection.current = direction;
34375 return;
34376 }
34377 }
34378 scrollSpeed.current = {
34379 x: 0,
34380 y: 0
34381 };
34382 scrollDirection.current = {
34383 x: 0,
34384 y: 0
34385 };
34386 clearAutoScrollInterval();
34387 },
34388 // eslint-disable-next-line react-hooks/exhaustive-deps
34389 [
34390 acceleration,
34391 autoScroll,
34392 canScroll,
34393 clearAutoScrollInterval,
34394 enabled,
34395 interval,
34396 // eslint-disable-next-line react-hooks/exhaustive-deps
34397 JSON.stringify(rect),
34398 // eslint-disable-next-line react-hooks/exhaustive-deps
34399 JSON.stringify(scrollIntent),
34400 setAutoScrollInterval,
34401 scrollableAncestors,
34402 sortedScrollableAncestors,
34403 scrollableAncestorRects,
34404 // eslint-disable-next-line react-hooks/exhaustive-deps
34405 JSON.stringify(threshold)
34406 ]
34407 );
34408 }
34409 var defaultScrollIntent = {
34410 x: {
34411 [Direction.Backward]: false,
34412 [Direction.Forward]: false
34413 },
34414 y: {
34415 [Direction.Backward]: false,
34416 [Direction.Forward]: false
34417 }
34418 };
34419 function useScrollIntent(_ref2) {
34420 let {
34421 delta,
34422 disabled: disabled2
34423 } = _ref2;
34424 const previousDelta = usePrevious2(delta);
34425 return useLazyMemo((previousIntent) => {
34426 if (disabled2 || !previousDelta || !previousIntent) {
34427 return defaultScrollIntent;
34428 }
34429 const direction = {
34430 x: Math.sign(delta.x - previousDelta.x),
34431 y: Math.sign(delta.y - previousDelta.y)
34432 };
34433 return {
34434 x: {
34435 [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
34436 [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
34437 },
34438 y: {
34439 [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
34440 [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
34441 }
34442 };
34443 }, [disabled2, delta, previousDelta]);
34444 }
34445 function useCachedNode(draggableNodes, id) {
34446 const draggableNode = id != null ? draggableNodes.get(id) : void 0;
34447 const node = draggableNode ? draggableNode.node.current : null;
34448 return useLazyMemo((cachedNode) => {
34449 var _ref;
34450 if (id == null) {
34451 return null;
34452 }
34453 return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
34454 }, [node, id]);
34455 }
34456 function useCombineActivators(sensors, getSyntheticHandler) {
34457 return (0, import_react40.useMemo)(() => sensors.reduce((accumulator, sensor) => {
34458 const {
34459 sensor: Sensor
34460 } = sensor;
34461 const sensorActivators = Sensor.activators.map((activator) => ({
34462 eventName: activator.eventName,
34463 handler: getSyntheticHandler(activator.handler, sensor)
34464 }));
34465 return [...accumulator, ...sensorActivators];
34466 }, []), [sensors, getSyntheticHandler]);
34467 }
34468 var MeasuringStrategy;
34469 (function(MeasuringStrategy2) {
34470 MeasuringStrategy2[MeasuringStrategy2["Always"] = 0] = "Always";
34471 MeasuringStrategy2[MeasuringStrategy2["BeforeDragging"] = 1] = "BeforeDragging";
34472 MeasuringStrategy2[MeasuringStrategy2["WhileDragging"] = 2] = "WhileDragging";
34473 })(MeasuringStrategy || (MeasuringStrategy = {}));
34474 var MeasuringFrequency;
34475 (function(MeasuringFrequency2) {
34476 MeasuringFrequency2["Optimized"] = "optimized";
34477 })(MeasuringFrequency || (MeasuringFrequency = {}));
34478 var defaultValue2 = /* @__PURE__ */ new Map();
34479 function useDroppableMeasuring(containers, _ref) {
34480 let {
34481 dragging,
34482 dependencies,
34483 config
34484 } = _ref;
34485 const [queue, setQueue] = (0, import_react40.useState)(null);
34486 const {
34487 frequency,
34488 measure,
34489 strategy
34490 } = config;
34491 const containersRef = (0, import_react40.useRef)(containers);
34492 const disabled2 = isDisabled();
34493 const disabledRef = useLatestValue(disabled2);
34494 const measureDroppableContainers = (0, import_react40.useCallback)(function(ids2) {
34495 if (ids2 === void 0) {
34496 ids2 = [];
34497 }
34498 if (disabledRef.current) {
34499 return;
34500 }
34501 setQueue((value) => {
34502 if (value === null) {
34503 return ids2;
34504 }
34505 return value.concat(ids2.filter((id) => !value.includes(id)));
34506 });
34507 }, [disabledRef]);
34508 const timeoutId = (0, import_react40.useRef)(null);
34509 const droppableRects = useLazyMemo((previousValue) => {
34510 if (disabled2 && !dragging) {
34511 return defaultValue2;
34512 }
34513 if (!previousValue || previousValue === defaultValue2 || containersRef.current !== containers || queue != null) {
34514 const map = /* @__PURE__ */ new Map();
34515 for (let container of containers) {
34516 if (!container) {
34517 continue;
34518 }
34519 if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
34520 map.set(container.id, container.rect.current);
34521 continue;
34522 }
34523 const node = container.node.current;
34524 const rect = node ? new Rect(measure(node), node) : null;
34525 container.rect.current = rect;
34526 if (rect) {
34527 map.set(container.id, rect);
34528 }
34529 }
34530 return map;
34531 }
34532 return previousValue;
34533 }, [containers, queue, dragging, disabled2, measure]);
34534 (0, import_react40.useEffect)(() => {
34535 containersRef.current = containers;
34536 }, [containers]);
34537 (0, import_react40.useEffect)(
34538 () => {
34539 if (disabled2) {
34540 return;
34541 }
34542 measureDroppableContainers();
34543 },
34544 // eslint-disable-next-line react-hooks/exhaustive-deps
34545 [dragging, disabled2]
34546 );
34547 (0, import_react40.useEffect)(
34548 () => {
34549 if (queue && queue.length > 0) {
34550 setQueue(null);
34551 }
34552 },
34553 //eslint-disable-next-line react-hooks/exhaustive-deps
34554 [JSON.stringify(queue)]
34555 );
34556 (0, import_react40.useEffect)(
34557 () => {
34558 if (disabled2 || typeof frequency !== "number" || timeoutId.current !== null) {
34559 return;
34560 }
34561 timeoutId.current = setTimeout(() => {
34562 measureDroppableContainers();
34563 timeoutId.current = null;
34564 }, frequency);
34565 },
34566 // eslint-disable-next-line react-hooks/exhaustive-deps
34567 [frequency, disabled2, measureDroppableContainers, ...dependencies]
34568 );
34569 return {
34570 droppableRects,
34571 measureDroppableContainers,
34572 measuringScheduled: queue != null
34573 };
34574 function isDisabled() {
34575 switch (strategy) {
34576 case MeasuringStrategy.Always:
34577 return false;
34578 case MeasuringStrategy.BeforeDragging:
34579 return dragging;
34580 default:
34581 return !dragging;
34582 }
34583 }
34584 }
34585 function useInitialValue2(value, computeFn) {
34586 return useLazyMemo((previousValue) => {
34587 if (!value) {
34588 return null;
34589 }
34590 if (previousValue) {
34591 return previousValue;
34592 }
34593 return typeof computeFn === "function" ? computeFn(value) : value;
34594 }, [computeFn, value]);
34595 }
34596 function useInitialRect(node, measure) {
34597 return useInitialValue2(node, measure);
34598 }
34599 function useMutationObserver(_ref) {
34600 let {
34601 callback,
34602 disabled: disabled2
34603 } = _ref;
34604 const handleMutations = useEvent3(callback);
34605 const mutationObserver = (0, import_react40.useMemo)(() => {
34606 if (disabled2 || typeof window === "undefined" || typeof window.MutationObserver === "undefined") {
34607 return void 0;
34608 }
34609 const {
34610 MutationObserver: MutationObserver2
34611 } = window;
34612 return new MutationObserver2(handleMutations);
34613 }, [handleMutations, disabled2]);
34614 (0, import_react40.useEffect)(() => {
34615 return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
34616 }, [mutationObserver]);
34617 return mutationObserver;
34618 }
34619 function useResizeObserver2(_ref) {
34620 let {
34621 callback,
34622 disabled: disabled2
34623 } = _ref;
34624 const handleResize = useEvent3(callback);
34625 const resizeObserver = (0, import_react40.useMemo)(
34626 () => {
34627 if (disabled2 || typeof window === "undefined" || typeof window.ResizeObserver === "undefined") {
34628 return void 0;
34629 }
34630 const {
34631 ResizeObserver: ResizeObserver2
34632 } = window;
34633 return new ResizeObserver2(handleResize);
34634 },
34635 // eslint-disable-next-line react-hooks/exhaustive-deps
34636 [disabled2]
34637 );
34638 (0, import_react40.useEffect)(() => {
34639 return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
34640 }, [resizeObserver]);
34641 return resizeObserver;
34642 }
34643 function defaultMeasure(element) {
34644 return new Rect(getClientRect(element), element);
34645 }
34646 function useRect(element, measure, fallbackRect) {
34647 if (measure === void 0) {
34648 measure = defaultMeasure;
34649 }
34650 const [rect, setRect] = (0, import_react40.useState)(null);
34651 function measureRect() {
34652 setRect((currentRect) => {
34653 if (!element) {
34654 return null;
34655 }
34656 if (element.isConnected === false) {
34657 var _ref;
34658 return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
34659 }
34660 const newRect = measure(element);
34661 if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
34662 return currentRect;
34663 }
34664 return newRect;
34665 });
34666 }
34667 const mutationObserver = useMutationObserver({
34668 callback(records) {
34669 if (!element) {
34670 return;
34671 }
34672 for (const record of records) {
34673 const {
34674 type,
34675 target
34676 } = record;
34677 if (type === "childList" && target instanceof HTMLElement && target.contains(element)) {
34678 measureRect();
34679 break;
34680 }
34681 }
34682 }
34683 });
34684 const resizeObserver = useResizeObserver2({
34685 callback: measureRect
34686 });
34687 useIsomorphicLayoutEffect(() => {
34688 measureRect();
34689 if (element) {
34690 resizeObserver == null ? void 0 : resizeObserver.observe(element);
34691 mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
34692 childList: true,
34693 subtree: true
34694 });
34695 } else {
34696 resizeObserver == null ? void 0 : resizeObserver.disconnect();
34697 mutationObserver == null ? void 0 : mutationObserver.disconnect();
34698 }
34699 }, [element]);
34700 return rect;
34701 }
34702 function useRectDelta(rect) {
34703 const initialRect = useInitialValue2(rect);
34704 return getRectDelta(rect, initialRect);
34705 }
34706 var defaultValue$1 = [];
34707 function useScrollableAncestors(node) {
34708 const previousNode = (0, import_react40.useRef)(node);
34709 const ancestors = useLazyMemo((previousValue) => {
34710 if (!node) {
34711 return defaultValue$1;
34712 }
34713 if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
34714 return previousValue;
34715 }
34716 return getScrollableAncestors(node);
34717 }, [node]);
34718 (0, import_react40.useEffect)(() => {
34719 previousNode.current = node;
34720 }, [node]);
34721 return ancestors;
34722 }
34723 function useScrollOffsets(elements) {
34724 const [scrollCoordinates, setScrollCoordinates] = (0, import_react40.useState)(null);
34725 const prevElements = (0, import_react40.useRef)(elements);
34726 const handleScroll = (0, import_react40.useCallback)((event) => {
34727 const scrollingElement = getScrollableElement(event.target);
34728 if (!scrollingElement) {
34729 return;
34730 }
34731 setScrollCoordinates((scrollCoordinates2) => {
34732 if (!scrollCoordinates2) {
34733 return null;
34734 }
34735 scrollCoordinates2.set(scrollingElement, getScrollCoordinates(scrollingElement));
34736 return new Map(scrollCoordinates2);
34737 });
34738 }, []);
34739 (0, import_react40.useEffect)(() => {
34740 const previousElements = prevElements.current;
34741 if (elements !== previousElements) {
34742 cleanup(previousElements);
34743 const entries = elements.map((element) => {
34744 const scrollableElement = getScrollableElement(element);
34745 if (scrollableElement) {
34746 scrollableElement.addEventListener("scroll", handleScroll, {
34747 passive: true
34748 });
34749 return [scrollableElement, getScrollCoordinates(scrollableElement)];
34750 }
34751 return null;
34752 }).filter((entry) => entry != null);
34753 setScrollCoordinates(entries.length ? new Map(entries) : null);
34754 prevElements.current = elements;
34755 }
34756 return () => {
34757 cleanup(elements);
34758 cleanup(previousElements);
34759 };
34760 function cleanup(elements2) {
34761 elements2.forEach((element) => {
34762 const scrollableElement = getScrollableElement(element);
34763 scrollableElement == null ? void 0 : scrollableElement.removeEventListener("scroll", handleScroll);
34764 });
34765 }
34766 }, [handleScroll, elements]);
34767 return (0, import_react40.useMemo)(() => {
34768 if (elements.length) {
34769 return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
34770 }
34771 return defaultCoordinates;
34772 }, [elements, scrollCoordinates]);
34773 }
34774 function useScrollOffsetsDelta(scrollOffsets, dependencies) {
34775 if (dependencies === void 0) {
34776 dependencies = [];
34777 }
34778 const initialScrollOffsets = (0, import_react40.useRef)(null);
34779 (0, import_react40.useEffect)(
34780 () => {
34781 initialScrollOffsets.current = null;
34782 },
34783 // eslint-disable-next-line react-hooks/exhaustive-deps
34784 dependencies
34785 );
34786 (0, import_react40.useEffect)(() => {
34787 const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
34788 if (hasScrollOffsets && !initialScrollOffsets.current) {
34789 initialScrollOffsets.current = scrollOffsets;
34790 }
34791 if (!hasScrollOffsets && initialScrollOffsets.current) {
34792 initialScrollOffsets.current = null;
34793 }
34794 }, [scrollOffsets]);
34795 return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
34796 }
34797 function useSensorSetup(sensors) {
34798 (0, import_react40.useEffect)(
34799 () => {
34800 if (!canUseDOM2) {
34801 return;
34802 }
34803 const teardownFns = sensors.map((_ref) => {
34804 let {
34805 sensor
34806 } = _ref;
34807 return sensor.setup == null ? void 0 : sensor.setup();
34808 });
34809 return () => {
34810 for (const teardown of teardownFns) {
34811 teardown == null ? void 0 : teardown();
34812 }
34813 };
34814 },
34815 // TO-DO: Sensors length could theoretically change which would not be a valid dependency
34816 // eslint-disable-next-line react-hooks/exhaustive-deps
34817 sensors.map((_ref2) => {
34818 let {
34819 sensor
34820 } = _ref2;
34821 return sensor;
34822 })
34823 );
34824 }
34825 function useSyntheticListeners(listeners, id) {
34826 return (0, import_react40.useMemo)(() => {
34827 return listeners.reduce((acc, _ref) => {
34828 let {
34829 eventName,
34830 handler
34831 } = _ref;
34832 acc[eventName] = (event) => {
34833 handler(event, id);
34834 };
34835 return acc;
34836 }, {});
34837 }, [listeners, id]);
34838 }
34839 function useWindowRect(element) {
34840 return (0, import_react40.useMemo)(() => element ? getWindowClientRect(element) : null, [element]);
34841 }
34842 var defaultValue$2 = [];
34843 function useRects(elements, measure) {
34844 if (measure === void 0) {
34845 measure = getClientRect;
34846 }
34847 const [firstElement] = elements;
34848 const windowRect = useWindowRect(firstElement ? getWindow3(firstElement) : null);
34849 const [rects, setRects] = (0, import_react40.useState)(defaultValue$2);
34850 function measureRects() {
34851 setRects(() => {
34852 if (!elements.length) {
34853 return defaultValue$2;
34854 }
34855 return elements.map((element) => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
34856 });
34857 }
34858 const resizeObserver = useResizeObserver2({
34859 callback: measureRects
34860 });
34861 useIsomorphicLayoutEffect(() => {
34862 resizeObserver == null ? void 0 : resizeObserver.disconnect();
34863 measureRects();
34864 elements.forEach((element) => resizeObserver == null ? void 0 : resizeObserver.observe(element));
34865 }, [elements]);
34866 return rects;
34867 }
34868 function getMeasurableNode(node) {
34869 if (!node) {
34870 return null;
34871 }
34872 if (node.children.length > 1) {
34873 return node;
34874 }
34875 const firstChild = node.children[0];
34876 return isHTMLElement2(firstChild) ? firstChild : node;
34877 }
34878 function useDragOverlayMeasuring(_ref) {
34879 let {
34880 measure
34881 } = _ref;
34882 const [rect, setRect] = (0, import_react40.useState)(null);
34883 const handleResize = (0, import_react40.useCallback)((entries) => {
34884 for (const {
34885 target
34886 } of entries) {
34887 if (isHTMLElement2(target)) {
34888 setRect((rect2) => {
34889 const newRect = measure(target);
34890 return rect2 ? {
34891 ...rect2,
34892 width: newRect.width,
34893 height: newRect.height
34894 } : newRect;
34895 });
34896 break;
34897 }
34898 }
34899 }, [measure]);
34900 const resizeObserver = useResizeObserver2({
34901 callback: handleResize
34902 });
34903 const handleNodeChange = (0, import_react40.useCallback)((element) => {
34904 const node = getMeasurableNode(element);
34905 resizeObserver == null ? void 0 : resizeObserver.disconnect();
34906 if (node) {
34907 resizeObserver == null ? void 0 : resizeObserver.observe(node);
34908 }
34909 setRect(node ? measure(node) : null);
34910 }, [measure, resizeObserver]);
34911 const [nodeRef, setRef2] = useNodeRef(handleNodeChange);
34912 return (0, import_react40.useMemo)(() => ({
34913 nodeRef,
34914 rect,
34915 setRef: setRef2
34916 }), [rect, nodeRef, setRef2]);
34917 }
34918 var defaultSensors = [{
34919 sensor: PointerSensor,
34920 options: {}
34921 }, {
34922 sensor: KeyboardSensor,
34923 options: {}
34924 }];
34925 var defaultData = {
34926 current: {}
34927 };
34928 var defaultMeasuringConfiguration = {
34929 draggable: {
34930 measure: getTransformAgnosticClientRect
34931 },
34932 droppable: {
34933 measure: getTransformAgnosticClientRect,
34934 strategy: MeasuringStrategy.WhileDragging,
34935 frequency: MeasuringFrequency.Optimized
34936 },
34937 dragOverlay: {
34938 measure: getClientRect
34939 }
34940 };
34941 var DroppableContainersMap = class extends Map {
34942 get(id) {
34943 var _super$get;
34944 return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
34945 }
34946 toArray() {
34947 return Array.from(this.values());
34948 }
34949 getEnabled() {
34950 return this.toArray().filter((_ref) => {
34951 let {
34952 disabled: disabled2
34953 } = _ref;
34954 return !disabled2;
34955 });
34956 }
34957 getNodeFor(id) {
34958 var _this$get$node$curren, _this$get;
34959 return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
34960 }
34961 };
34962 var defaultPublicContext = {
34963 activatorEvent: null,
34964 active: null,
34965 activeNode: null,
34966 activeNodeRect: null,
34967 collisions: null,
34968 containerNodeRect: null,
34969 draggableNodes: /* @__PURE__ */ new Map(),
34970 droppableRects: /* @__PURE__ */ new Map(),
34971 droppableContainers: /* @__PURE__ */ new DroppableContainersMap(),
34972 over: null,
34973 dragOverlay: {
34974 nodeRef: {
34975 current: null
34976 },
34977 rect: null,
34978 setRef: noop6
34979 },
34980 scrollableAncestors: [],
34981 scrollableAncestorRects: [],
34982 measuringConfiguration: defaultMeasuringConfiguration,
34983 measureDroppableContainers: noop6,
34984 windowRect: null,
34985 measuringScheduled: false
34986 };
34987 var defaultInternalContext = {
34988 activatorEvent: null,
34989 activators: [],
34990 active: null,
34991 activeNodeRect: null,
34992 ariaDescribedById: {
34993 draggable: ""
34994 },
34995 dispatch: noop6,
34996 draggableNodes: /* @__PURE__ */ new Map(),
34997 over: null,
34998 measureDroppableContainers: noop6
34999 };
35000 var InternalContext = /* @__PURE__ */ (0, import_react40.createContext)(defaultInternalContext);
35001 var PublicContext = /* @__PURE__ */ (0, import_react40.createContext)(defaultPublicContext);
35002 function getInitialState() {
35003 return {
35004 draggable: {
35005 active: null,
35006 initialCoordinates: {
35007 x: 0,
35008 y: 0
35009 },
35010 nodes: /* @__PURE__ */ new Map(),
35011 translate: {
35012 x: 0,
35013 y: 0
35014 }
35015 },
35016 droppable: {
35017 containers: new DroppableContainersMap()
35018 }
35019 };
35020 }
35021 function reducer(state, action) {
35022 switch (action.type) {
35023 case Action2.DragStart:
35024 return {
35025 ...state,
35026 draggable: {
35027 ...state.draggable,
35028 initialCoordinates: action.initialCoordinates,
35029 active: action.active
35030 }
35031 };
35032 case Action2.DragMove:
35033 if (state.draggable.active == null) {
35034 return state;
35035 }
35036 return {
35037 ...state,
35038 draggable: {
35039 ...state.draggable,
35040 translate: {
35041 x: action.coordinates.x - state.draggable.initialCoordinates.x,
35042 y: action.coordinates.y - state.draggable.initialCoordinates.y
35043 }
35044 }
35045 };
35046 case Action2.DragEnd:
35047 case Action2.DragCancel:
35048 return {
35049 ...state,
35050 draggable: {
35051 ...state.draggable,
35052 active: null,
35053 initialCoordinates: {
35054 x: 0,
35055 y: 0
35056 },
35057 translate: {
35058 x: 0,
35059 y: 0
35060 }
35061 }
35062 };
35063 case Action2.RegisterDroppable: {
35064 const {
35065 element
35066 } = action;
35067 const {
35068 id
35069 } = element;
35070 const containers = new DroppableContainersMap(state.droppable.containers);
35071 containers.set(id, element);
35072 return {
35073 ...state,
35074 droppable: {
35075 ...state.droppable,
35076 containers
35077 }
35078 };
35079 }
35080 case Action2.SetDroppableDisabled: {
35081 const {
35082 id,
35083 key: key2,
35084 disabled: disabled2
35085 } = action;
35086 const element = state.droppable.containers.get(id);
35087 if (!element || key2 !== element.key) {
35088 return state;
35089 }
35090 const containers = new DroppableContainersMap(state.droppable.containers);
35091 containers.set(id, {
35092 ...element,
35093 disabled: disabled2
35094 });
35095 return {
35096 ...state,
35097 droppable: {
35098 ...state.droppable,
35099 containers
35100 }
35101 };
35102 }
35103 case Action2.UnregisterDroppable: {
35104 const {
35105 id,
35106 key: key2
35107 } = action;
35108 const element = state.droppable.containers.get(id);
35109 if (!element || key2 !== element.key) {
35110 return state;
35111 }
35112 const containers = new DroppableContainersMap(state.droppable.containers);
35113 containers.delete(id);
35114 return {
35115 ...state,
35116 droppable: {
35117 ...state.droppable,
35118 containers
35119 }
35120 };
35121 }
35122 default: {
35123 return state;
35124 }
35125 }
35126 }
35127 function RestoreFocus(_ref) {
35128 let {
35129 disabled: disabled2
35130 } = _ref;
35131 const {
35132 active,
35133 activatorEvent,
35134 draggableNodes
35135 } = (0, import_react40.useContext)(InternalContext);
35136 const previousActivatorEvent = usePrevious2(activatorEvent);
35137 const previousActiveId = usePrevious2(active == null ? void 0 : active.id);
35138 (0, import_react40.useEffect)(() => {
35139 if (disabled2) {
35140 return;
35141 }
35142 if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
35143 if (!isKeyboardEvent(previousActivatorEvent)) {
35144 return;
35145 }
35146 if (document.activeElement === previousActivatorEvent.target) {
35147 return;
35148 }
35149 const draggableNode = draggableNodes.get(previousActiveId);
35150 if (!draggableNode) {
35151 return;
35152 }
35153 const {
35154 activatorNode,
35155 node
35156 } = draggableNode;
35157 if (!activatorNode.current && !node.current) {
35158 return;
35159 }
35160 requestAnimationFrame(() => {
35161 for (const element of [activatorNode.current, node.current]) {
35162 if (!element) {
35163 continue;
35164 }
35165 const focusableNode = findFirstFocusableNode(element);
35166 if (focusableNode) {
35167 focusableNode.focus();
35168 break;
35169 }
35170 }
35171 });
35172 }
35173 }, [activatorEvent, disabled2, draggableNodes, previousActiveId, previousActivatorEvent]);
35174 return null;
35175 }
35176 function applyModifiers(modifiers, _ref) {
35177 let {
35178 transform,
35179 ...args
35180 } = _ref;
35181 return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
35182 return modifier({
35183 transform: accumulator,
35184 ...args
35185 });
35186 }, transform) : transform;
35187 }
35188 function useMeasuringConfiguration(config) {
35189 return (0, import_react40.useMemo)(
35190 () => ({
35191 draggable: {
35192 ...defaultMeasuringConfiguration.draggable,
35193 ...config == null ? void 0 : config.draggable
35194 },
35195 droppable: {
35196 ...defaultMeasuringConfiguration.droppable,
35197 ...config == null ? void 0 : config.droppable
35198 },
35199 dragOverlay: {
35200 ...defaultMeasuringConfiguration.dragOverlay,
35201 ...config == null ? void 0 : config.dragOverlay
35202 }
35203 }),
35204 // eslint-disable-next-line react-hooks/exhaustive-deps
35205 [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]
35206 );
35207 }
35208 function useLayoutShiftScrollCompensation(_ref) {
35209 let {
35210 activeNode,
35211 measure,
35212 initialRect,
35213 config = true
35214 } = _ref;
35215 const initialized = (0, import_react40.useRef)(false);
35216 const {
35217 x: x2,
35218 y: y2
35219 } = typeof config === "boolean" ? {
35220 x: config,
35221 y: config
35222 } : config;
35223 useIsomorphicLayoutEffect(() => {
35224 const disabled2 = !x2 && !y2;
35225 if (disabled2 || !activeNode) {
35226 initialized.current = false;
35227 return;
35228 }
35229 if (initialized.current || !initialRect) {
35230 return;
35231 }
35232 const node = activeNode == null ? void 0 : activeNode.node.current;
35233 if (!node || node.isConnected === false) {
35234 return;
35235 }
35236 const rect = measure(node);
35237 const rectDelta = getRectDelta(rect, initialRect);
35238 if (!x2) {
35239 rectDelta.x = 0;
35240 }
35241 if (!y2) {
35242 rectDelta.y = 0;
35243 }
35244 initialized.current = true;
35245 if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
35246 const firstScrollableAncestor = getFirstScrollableAncestor(node);
35247 if (firstScrollableAncestor) {
35248 firstScrollableAncestor.scrollBy({
35249 top: rectDelta.y,
35250 left: rectDelta.x
35251 });
35252 }
35253 }
35254 }, [activeNode, x2, y2, initialRect, measure]);
35255 }
35256 var ActiveDraggableContext = /* @__PURE__ */ (0, import_react40.createContext)({
35257 ...defaultCoordinates,
35258 scaleX: 1,
35259 scaleY: 1
35260 });
35261 var Status;
35262 (function(Status2) {
35263 Status2[Status2["Uninitialized"] = 0] = "Uninitialized";
35264 Status2[Status2["Initializing"] = 1] = "Initializing";
35265 Status2[Status2["Initialized"] = 2] = "Initialized";
35266 })(Status || (Status = {}));
35267 var DndContext = /* @__PURE__ */ (0, import_react40.memo)(function DndContext2(_ref) {
35268 var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
35269 let {
35270 id,
35271 accessibility,
35272 autoScroll = true,
35273 children,
35274 sensors = defaultSensors,
35275 collisionDetection = rectIntersection,
35276 measuring,
35277 modifiers,
35278 ...props
35279 } = _ref;
35280 const store = (0, import_react40.useReducer)(reducer, void 0, getInitialState);
35281 const [state, dispatch2] = store;
35282 const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
35283 const [status, setStatus] = (0, import_react40.useState)(Status.Uninitialized);
35284 const isInitialized = status === Status.Initialized;
35285 const {
35286 draggable: {
35287 active: activeId,
35288 nodes: draggableNodes,
35289 translate
35290 },
35291 droppable: {
35292 containers: droppableContainers
35293 }
35294 } = state;
35295 const node = activeId != null ? draggableNodes.get(activeId) : null;
35296 const activeRects = (0, import_react40.useRef)({
35297 initial: null,
35298 translated: null
35299 });
35300 const active = (0, import_react40.useMemo)(() => {
35301 var _node$data;
35302 return activeId != null ? {
35303 id: activeId,
35304 // It's possible for the active node to unmount while dragging
35305 data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
35306 rect: activeRects
35307 } : null;
35308 }, [activeId, node]);
35309 const activeRef = (0, import_react40.useRef)(null);
35310 const [activeSensor, setActiveSensor] = (0, import_react40.useState)(null);
35311 const [activatorEvent, setActivatorEvent] = (0, import_react40.useState)(null);
35312 const latestProps = useLatestValue(props, Object.values(props));
35313 const draggableDescribedById = useUniqueId("DndDescribedBy", id);
35314 const enabledDroppableContainers = (0, import_react40.useMemo)(() => droppableContainers.getEnabled(), [droppableContainers]);
35315 const measuringConfiguration = useMeasuringConfiguration(measuring);
35316 const {
35317 droppableRects,
35318 measureDroppableContainers,
35319 measuringScheduled
35320 } = useDroppableMeasuring(enabledDroppableContainers, {
35321 dragging: isInitialized,
35322 dependencies: [translate.x, translate.y],
35323 config: measuringConfiguration.droppable
35324 });
35325 const activeNode = useCachedNode(draggableNodes, activeId);
35326 const activationCoordinates = (0, import_react40.useMemo)(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
35327 const autoScrollOptions = getAutoScrollerOptions();
35328 const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
35329 useLayoutShiftScrollCompensation({
35330 activeNode: activeId != null ? draggableNodes.get(activeId) : null,
35331 config: autoScrollOptions.layoutShiftCompensation,
35332 initialRect: initialActiveNodeRect,
35333 measure: measuringConfiguration.draggable.measure
35334 });
35335 const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
35336 const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
35337 const sensorContext = (0, import_react40.useRef)({
35338 activatorEvent: null,
35339 active: null,
35340 activeNode,
35341 collisionRect: null,
35342 collisions: null,
35343 droppableRects,
35344 draggableNodes,
35345 draggingNode: null,
35346 draggingNodeRect: null,
35347 droppableContainers,
35348 over: null,
35349 scrollableAncestors: [],
35350 scrollAdjustedTranslate: null
35351 });
35352 const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
35353 const dragOverlay = useDragOverlayMeasuring({
35354 measure: measuringConfiguration.dragOverlay.measure
35355 });
35356 const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
35357 const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
35358 const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect);
35359 const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect);
35360 const windowRect = useWindowRect(draggingNode ? getWindow3(draggingNode) : null);
35361 const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
35362 const scrollableAncestorRects = useRects(scrollableAncestors);
35363 const modifiedTranslate = applyModifiers(modifiers, {
35364 transform: {
35365 x: translate.x - nodeRectDelta.x,
35366 y: translate.y - nodeRectDelta.y,
35367 scaleX: 1,
35368 scaleY: 1
35369 },
35370 activatorEvent,
35371 active,
35372 activeNodeRect,
35373 containerNodeRect,
35374 draggingNodeRect,
35375 over: sensorContext.current.over,
35376 overlayNodeRect: dragOverlay.rect,
35377 scrollableAncestors,
35378 scrollableAncestorRects,
35379 windowRect
35380 });
35381 const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
35382 const scrollOffsets = useScrollOffsets(scrollableAncestors);
35383 const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);
35384 const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
35385 const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
35386 const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
35387 const collisions = active && collisionRect ? collisionDetection({
35388 active,
35389 collisionRect,
35390 droppableRects,
35391 droppableContainers: enabledDroppableContainers,
35392 pointerCoordinates
35393 }) : null;
35394 const overId = getFirstCollision(collisions, "id");
35395 const [over, setOver] = (0, import_react40.useState)(null);
35396 const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
35397 const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
35398 const activeSensorRef = (0, import_react40.useRef)(null);
35399 const instantiateSensor = (0, import_react40.useCallback)(
35400 (event, _ref2) => {
35401 let {
35402 sensor: Sensor,
35403 options
35404 } = _ref2;
35405 if (activeRef.current == null) {
35406 return;
35407 }
35408 const activeNode2 = draggableNodes.get(activeRef.current);
35409 if (!activeNode2) {
35410 return;
35411 }
35412 const activatorEvent2 = event.nativeEvent;
35413 const sensorInstance = new Sensor({
35414 active: activeRef.current,
35415 activeNode: activeNode2,
35416 event: activatorEvent2,
35417 options,
35418 // Sensors need to be instantiated with refs for arguments that change over time
35419 // otherwise they are frozen in time with the stale arguments
35420 context: sensorContext,
35421 onAbort(id2) {
35422 const draggableNode = draggableNodes.get(id2);
35423 if (!draggableNode) {
35424 return;
35425 }
35426 const {
35427 onDragAbort
35428 } = latestProps.current;
35429 const event2 = {
35430 id: id2
35431 };
35432 onDragAbort == null ? void 0 : onDragAbort(event2);
35433 dispatchMonitorEvent({
35434 type: "onDragAbort",
35435 event: event2
35436 });
35437 },
35438 onPending(id2, constraint, initialCoordinates, offset4) {
35439 const draggableNode = draggableNodes.get(id2);
35440 if (!draggableNode) {
35441 return;
35442 }
35443 const {
35444 onDragPending
35445 } = latestProps.current;
35446 const event2 = {
35447 id: id2,
35448 constraint,
35449 initialCoordinates,
35450 offset: offset4
35451 };
35452 onDragPending == null ? void 0 : onDragPending(event2);
35453 dispatchMonitorEvent({
35454 type: "onDragPending",
35455 event: event2
35456 });
35457 },
35458 onStart(initialCoordinates) {
35459 const id2 = activeRef.current;
35460 if (id2 == null) {
35461 return;
35462 }
35463 const draggableNode = draggableNodes.get(id2);
35464 if (!draggableNode) {
35465 return;
35466 }
35467 const {
35468 onDragStart
35469 } = latestProps.current;
35470 const event2 = {
35471 activatorEvent: activatorEvent2,
35472 active: {
35473 id: id2,
35474 data: draggableNode.data,
35475 rect: activeRects
35476 }
35477 };
35478 (0, import_react_dom5.unstable_batchedUpdates)(() => {
35479 onDragStart == null ? void 0 : onDragStart(event2);
35480 setStatus(Status.Initializing);
35481 dispatch2({
35482 type: Action2.DragStart,
35483 initialCoordinates,
35484 active: id2
35485 });
35486 dispatchMonitorEvent({
35487 type: "onDragStart",
35488 event: event2
35489 });
35490 setActiveSensor(activeSensorRef.current);
35491 setActivatorEvent(activatorEvent2);
35492 });
35493 },
35494 onMove(coordinates) {
35495 dispatch2({
35496 type: Action2.DragMove,
35497 coordinates
35498 });
35499 },
35500 onEnd: createHandler(Action2.DragEnd),
35501 onCancel: createHandler(Action2.DragCancel)
35502 });
35503 activeSensorRef.current = sensorInstance;
35504 function createHandler(type) {
35505 return async function handler() {
35506 const {
35507 active: active2,
35508 collisions: collisions2,
35509 over: over2,
35510 scrollAdjustedTranslate: scrollAdjustedTranslate2
35511 } = sensorContext.current;
35512 let event2 = null;
35513 if (active2 && scrollAdjustedTranslate2) {
35514 const {
35515 cancelDrop
35516 } = latestProps.current;
35517 event2 = {
35518 activatorEvent: activatorEvent2,
35519 active: active2,
35520 collisions: collisions2,
35521 delta: scrollAdjustedTranslate2,
35522 over: over2
35523 };
35524 if (type === Action2.DragEnd && typeof cancelDrop === "function") {
35525 const shouldCancel = await Promise.resolve(cancelDrop(event2));
35526 if (shouldCancel) {
35527 type = Action2.DragCancel;
35528 }
35529 }
35530 }
35531 activeRef.current = null;
35532 (0, import_react_dom5.unstable_batchedUpdates)(() => {
35533 dispatch2({
35534 type
35535 });
35536 setStatus(Status.Uninitialized);
35537 setOver(null);
35538 setActiveSensor(null);
35539 setActivatorEvent(null);
35540 activeSensorRef.current = null;
35541 const eventName = type === Action2.DragEnd ? "onDragEnd" : "onDragCancel";
35542 if (event2) {
35543 const handler2 = latestProps.current[eventName];
35544 handler2 == null ? void 0 : handler2(event2);
35545 dispatchMonitorEvent({
35546 type: eventName,
35547 event: event2
35548 });
35549 }
35550 });
35551 };
35552 }
35553 },
35554 // eslint-disable-next-line react-hooks/exhaustive-deps
35555 [draggableNodes]
35556 );
35557 const bindActivatorToSensorInstantiator = (0, import_react40.useCallback)((handler, sensor) => {
35558 return (event, active2) => {
35559 const nativeEvent = event.nativeEvent;
35560 const activeDraggableNode = draggableNodes.get(active2);
35561 if (
35562 // Another sensor is already instantiating
35563 activeRef.current !== null || // No active draggable
35564 !activeDraggableNode || // Event has already been captured
35565 nativeEvent.dndKit || nativeEvent.defaultPrevented
35566 ) {
35567 return;
35568 }
35569 const activationContext = {
35570 active: activeDraggableNode
35571 };
35572 const shouldActivate = handler(event, sensor.options, activationContext);
35573 if (shouldActivate === true) {
35574 nativeEvent.dndKit = {
35575 capturedBy: sensor.sensor
35576 };
35577 activeRef.current = active2;
35578 instantiateSensor(event, sensor);
35579 }
35580 };
35581 }, [draggableNodes, instantiateSensor]);
35582 const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
35583 useSensorSetup(sensors);
35584 useIsomorphicLayoutEffect(() => {
35585 if (activeNodeRect && status === Status.Initializing) {
35586 setStatus(Status.Initialized);
35587 }
35588 }, [activeNodeRect, status]);
35589 (0, import_react40.useEffect)(
35590 () => {
35591 const {
35592 onDragMove
35593 } = latestProps.current;
35594 const {
35595 active: active2,
35596 activatorEvent: activatorEvent2,
35597 collisions: collisions2,
35598 over: over2
35599 } = sensorContext.current;
35600 if (!active2 || !activatorEvent2) {
35601 return;
35602 }
35603 const event = {
35604 active: active2,
35605 activatorEvent: activatorEvent2,
35606 collisions: collisions2,
35607 delta: {
35608 x: scrollAdjustedTranslate.x,
35609 y: scrollAdjustedTranslate.y
35610 },
35611 over: over2
35612 };
35613 (0, import_react_dom5.unstable_batchedUpdates)(() => {
35614 onDragMove == null ? void 0 : onDragMove(event);
35615 dispatchMonitorEvent({
35616 type: "onDragMove",
35617 event
35618 });
35619 });
35620 },
35621 // eslint-disable-next-line react-hooks/exhaustive-deps
35622 [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]
35623 );
35624 (0, import_react40.useEffect)(
35625 () => {
35626 const {
35627 active: active2,
35628 activatorEvent: activatorEvent2,
35629 collisions: collisions2,
35630 droppableContainers: droppableContainers2,
35631 scrollAdjustedTranslate: scrollAdjustedTranslate2
35632 } = sensorContext.current;
35633 if (!active2 || activeRef.current == null || !activatorEvent2 || !scrollAdjustedTranslate2) {
35634 return;
35635 }
35636 const {
35637 onDragOver
35638 } = latestProps.current;
35639 const overContainer = droppableContainers2.get(overId);
35640 const over2 = overContainer && overContainer.rect.current ? {
35641 id: overContainer.id,
35642 rect: overContainer.rect.current,
35643 data: overContainer.data,
35644 disabled: overContainer.disabled
35645 } : null;
35646 const event = {
35647 active: active2,
35648 activatorEvent: activatorEvent2,
35649 collisions: collisions2,
35650 delta: {
35651 x: scrollAdjustedTranslate2.x,
35652 y: scrollAdjustedTranslate2.y
35653 },
35654 over: over2
35655 };
35656 (0, import_react_dom5.unstable_batchedUpdates)(() => {
35657 setOver(over2);
35658 onDragOver == null ? void 0 : onDragOver(event);
35659 dispatchMonitorEvent({
35660 type: "onDragOver",
35661 event
35662 });
35663 });
35664 },
35665 // eslint-disable-next-line react-hooks/exhaustive-deps
35666 [overId]
35667 );
35668 useIsomorphicLayoutEffect(() => {
35669 sensorContext.current = {
35670 activatorEvent,
35671 active,
35672 activeNode,
35673 collisionRect,
35674 collisions,
35675 droppableRects,
35676 draggableNodes,
35677 draggingNode,
35678 draggingNodeRect,
35679 droppableContainers,
35680 over,
35681 scrollableAncestors,
35682 scrollAdjustedTranslate
35683 };
35684 activeRects.current = {
35685 initial: draggingNodeRect,
35686 translated: collisionRect
35687 };
35688 }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
35689 useAutoScroller({
35690 ...autoScrollOptions,
35691 delta: translate,
35692 draggingRect: collisionRect,
35693 pointerCoordinates,
35694 scrollableAncestors,
35695 scrollableAncestorRects
35696 });
35697 const publicContext = (0, import_react40.useMemo)(() => {
35698 const context = {
35699 active,
35700 activeNode,
35701 activeNodeRect,
35702 activatorEvent,
35703 collisions,
35704 containerNodeRect,
35705 dragOverlay,
35706 draggableNodes,
35707 droppableContainers,
35708 droppableRects,
35709 over,
35710 measureDroppableContainers,
35711 scrollableAncestors,
35712 scrollableAncestorRects,
35713 measuringConfiguration,
35714 measuringScheduled,
35715 windowRect
35716 };
35717 return context;
35718 }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
35719 const internalContext = (0, import_react40.useMemo)(() => {
35720 const context = {
35721 activatorEvent,
35722 activators,
35723 active,
35724 activeNodeRect,
35725 ariaDescribedById: {
35726 draggable: draggableDescribedById
35727 },
35728 dispatch: dispatch2,
35729 draggableNodes,
35730 over,
35731 measureDroppableContainers
35732 };
35733 return context;
35734 }, [activatorEvent, activators, active, activeNodeRect, dispatch2, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
35735 return import_react40.default.createElement(DndMonitorContext.Provider, {
35736 value: registerMonitorListener
35737 }, import_react40.default.createElement(InternalContext.Provider, {
35738 value: internalContext
35739 }, import_react40.default.createElement(PublicContext.Provider, {
35740 value: publicContext
35741 }, import_react40.default.createElement(ActiveDraggableContext.Provider, {
35742 value: transform
35743 }, children)), import_react40.default.createElement(RestoreFocus, {
35744 disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
35745 })), import_react40.default.createElement(Accessibility, {
35746 ...accessibility,
35747 hiddenTextDescribedById: draggableDescribedById
35748 }));
35749 function getAutoScrollerOptions() {
35750 const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
35751 const autoScrollGloballyDisabled = typeof autoScroll === "object" ? autoScroll.enabled === false : autoScroll === false;
35752 const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
35753 if (typeof autoScroll === "object") {
35754 return {
35755 ...autoScroll,
35756 enabled
35757 };
35758 }
35759 return {
35760 enabled
35761 };
35762 }
35763 });
35764 var NullContext = /* @__PURE__ */ (0, import_react40.createContext)(null);
35765 var defaultRole = "button";
35766 var ID_PREFIX = "Draggable";
35767 function useDraggable(_ref) {
35768 let {
35769 id,
35770 data,
35771 disabled: disabled2 = false,
35772 attributes
35773 } = _ref;
35774 const key2 = useUniqueId(ID_PREFIX);
35775 const {
35776 activators,
35777 activatorEvent,
35778 active,
35779 activeNodeRect,
35780 ariaDescribedById,
35781 draggableNodes,
35782 over
35783 } = (0, import_react40.useContext)(InternalContext);
35784 const {
35785 role = defaultRole,
35786 roleDescription = "draggable",
35787 tabIndex = 0
35788 } = attributes != null ? attributes : {};
35789 const isDragging = (active == null ? void 0 : active.id) === id;
35790 const transform = (0, import_react40.useContext)(isDragging ? ActiveDraggableContext : NullContext);
35791 const [node, setNodeRef] = useNodeRef();
35792 const [activatorNode, setActivatorNodeRef] = useNodeRef();
35793 const listeners = useSyntheticListeners(activators, id);
35794 const dataRef = useLatestValue(data);
35795 useIsomorphicLayoutEffect(
35796 () => {
35797 draggableNodes.set(id, {
35798 id,
35799 key: key2,
35800 node,
35801 activatorNode,
35802 data: dataRef
35803 });
35804 return () => {
35805 const node2 = draggableNodes.get(id);
35806 if (node2 && node2.key === key2) {
35807 draggableNodes.delete(id);
35808 }
35809 };
35810 },
35811 // eslint-disable-next-line react-hooks/exhaustive-deps
35812 [draggableNodes, id]
35813 );
35814 const memoizedAttributes = (0, import_react40.useMemo)(() => ({
35815 role,
35816 tabIndex,
35817 "aria-disabled": disabled2,
35818 "aria-pressed": isDragging && role === defaultRole ? true : void 0,
35819 "aria-roledescription": roleDescription,
35820 "aria-describedby": ariaDescribedById.draggable
35821 }), [disabled2, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
35822 return {
35823 active,
35824 activatorEvent,
35825 activeNodeRect,
35826 attributes: memoizedAttributes,
35827 isDragging,
35828 listeners: disabled2 ? void 0 : listeners,
35829 node,
35830 over,
35831 setNodeRef,
35832 setActivatorNodeRef,
35833 transform
35834 };
35835 }
35836 function useDndContext() {
35837 return (0, import_react40.useContext)(PublicContext);
35838 }
35839 var ID_PREFIX$1 = "Droppable";
35840 var defaultResizeObserverConfig = {
35841 timeout: 25
35842 };
35843 function useDroppable(_ref) {
35844 let {
35845 data,
35846 disabled: disabled2 = false,
35847 id,
35848 resizeObserverConfig
35849 } = _ref;
35850 const key2 = useUniqueId(ID_PREFIX$1);
35851 const {
35852 active,
35853 dispatch: dispatch2,
35854 over,
35855 measureDroppableContainers
35856 } = (0, import_react40.useContext)(InternalContext);
35857 const previous = (0, import_react40.useRef)({
35858 disabled: disabled2
35859 });
35860 const resizeObserverConnected = (0, import_react40.useRef)(false);
35861 const rect = (0, import_react40.useRef)(null);
35862 const callbackId = (0, import_react40.useRef)(null);
35863 const {
35864 disabled: resizeObserverDisabled,
35865 updateMeasurementsFor,
35866 timeout: resizeObserverTimeout
35867 } = {
35868 ...defaultResizeObserverConfig,
35869 ...resizeObserverConfig
35870 };
35871 const ids2 = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
35872 const handleResize = (0, import_react40.useCallback)(
35873 () => {
35874 if (!resizeObserverConnected.current) {
35875 resizeObserverConnected.current = true;
35876 return;
35877 }
35878 if (callbackId.current != null) {
35879 clearTimeout(callbackId.current);
35880 }
35881 callbackId.current = setTimeout(() => {
35882 measureDroppableContainers(Array.isArray(ids2.current) ? ids2.current : [ids2.current]);
35883 callbackId.current = null;
35884 }, resizeObserverTimeout);
35885 },
35886 //eslint-disable-next-line react-hooks/exhaustive-deps
35887 [resizeObserverTimeout]
35888 );
35889 const resizeObserver = useResizeObserver2({
35890 callback: handleResize,
35891 disabled: resizeObserverDisabled || !active
35892 });
35893 const handleNodeChange = (0, import_react40.useCallback)((newElement, previousElement) => {
35894 if (!resizeObserver) {
35895 return;
35896 }
35897 if (previousElement) {
35898 resizeObserver.unobserve(previousElement);
35899 resizeObserverConnected.current = false;
35900 }
35901 if (newElement) {
35902 resizeObserver.observe(newElement);
35903 }
35904 }, [resizeObserver]);
35905 const [nodeRef, setNodeRef] = useNodeRef(handleNodeChange);
35906 const dataRef = useLatestValue(data);
35907 (0, import_react40.useEffect)(() => {
35908 if (!resizeObserver || !nodeRef.current) {
35909 return;
35910 }
35911 resizeObserver.disconnect();
35912 resizeObserverConnected.current = false;
35913 resizeObserver.observe(nodeRef.current);
35914 }, [nodeRef, resizeObserver]);
35915 (0, import_react40.useEffect)(
35916 () => {
35917 dispatch2({
35918 type: Action2.RegisterDroppable,
35919 element: {
35920 id,
35921 key: key2,
35922 disabled: disabled2,
35923 node: nodeRef,
35924 rect,
35925 data: dataRef
35926 }
35927 });
35928 return () => dispatch2({
35929 type: Action2.UnregisterDroppable,
35930 key: key2,
35931 id
35932 });
35933 },
35934 // eslint-disable-next-line react-hooks/exhaustive-deps
35935 [id]
35936 );
35937 (0, import_react40.useEffect)(() => {
35938 if (disabled2 !== previous.current.disabled) {
35939 dispatch2({
35940 type: Action2.SetDroppableDisabled,
35941 id,
35942 key: key2,
35943 disabled: disabled2
35944 });
35945 previous.current.disabled = disabled2;
35946 }
35947 }, [id, key2, disabled2, dispatch2]);
35948 return {
35949 active,
35950 rect,
35951 isOver: (over == null ? void 0 : over.id) === id,
35952 node: nodeRef,
35953 over,
35954 setNodeRef
35955 };
35956 }
35957 function AnimationManager(_ref) {
35958 let {
35959 animation,
35960 children
35961 } = _ref;
35962 const [clonedChildren, setClonedChildren] = (0, import_react40.useState)(null);
35963 const [element, setElement] = (0, import_react40.useState)(null);
35964 const previousChildren = usePrevious2(children);
35965 if (!children && !clonedChildren && previousChildren) {
35966 setClonedChildren(previousChildren);
35967 }
35968 useIsomorphicLayoutEffect(() => {
35969 if (!element) {
35970 return;
35971 }
35972 const key2 = clonedChildren == null ? void 0 : clonedChildren.key;
35973 const id = clonedChildren == null ? void 0 : clonedChildren.props.id;
35974 if (key2 == null || id == null) {
35975 setClonedChildren(null);
35976 return;
35977 }
35978 Promise.resolve(animation(id, element)).then(() => {
35979 setClonedChildren(null);
35980 });
35981 }, [animation, clonedChildren, element]);
35982 return import_react40.default.createElement(import_react40.default.Fragment, null, children, clonedChildren ? (0, import_react40.cloneElement)(clonedChildren, {
35983 ref: setElement
35984 }) : null);
35985 }
35986 var defaultTransform = {
35987 x: 0,
35988 y: 0,
35989 scaleX: 1,
35990 scaleY: 1
35991 };
35992 function NullifiedContextProvider(_ref) {
35993 let {
35994 children
35995 } = _ref;
35996 return import_react40.default.createElement(InternalContext.Provider, {
35997 value: defaultInternalContext
35998 }, import_react40.default.createElement(ActiveDraggableContext.Provider, {
35999 value: defaultTransform
36000 }, children));
36001 }
36002 var baseStyles = {
36003 position: "fixed",
36004 touchAction: "none"
36005 };
36006 var defaultTransition = (activatorEvent) => {
36007 const isKeyboardActivator = isKeyboardEvent(activatorEvent);
36008 return isKeyboardActivator ? "transform 250ms ease" : void 0;
36009 };
36010 var PositionedOverlay = /* @__PURE__ */ (0, import_react40.forwardRef)((_ref, ref) => {
36011 let {
36012 as,
36013 activatorEvent,
36014 adjustScale: adjustScale2,
36015 children,
36016 className,
36017 rect,
36018 style,
36019 transform,
36020 transition = defaultTransition
36021 } = _ref;
36022 if (!rect) {
36023 return null;
36024 }
36025 const scaleAdjustedTransform = adjustScale2 ? transform : {
36026 ...transform,
36027 scaleX: 1,
36028 scaleY: 1
36029 };
36030 const styles = {
36031 ...baseStyles,
36032 width: rect.width,
36033 height: rect.height,
36034 top: rect.top,
36035 left: rect.left,
36036 transform: CSS2.Transform.toString(scaleAdjustedTransform),
36037 transformOrigin: adjustScale2 && activatorEvent ? getRelativeTransformOrigin(activatorEvent, rect) : void 0,
36038 transition: typeof transition === "function" ? transition(activatorEvent) : transition,
36039 ...style
36040 };
36041 return import_react40.default.createElement(as, {
36042 className,
36043 style: styles,
36044 ref
36045 }, children);
36046 });
36047 var defaultDropAnimationSideEffects = (options) => (_ref) => {
36048 let {
36049 active,
36050 dragOverlay
36051 } = _ref;
36052 const originalStyles = {};
36053 const {
36054 styles,
36055 className
36056 } = options;
36057 if (styles != null && styles.active) {
36058 for (const [key2, value] of Object.entries(styles.active)) {
36059 if (value === void 0) {
36060 continue;
36061 }
36062 originalStyles[key2] = active.node.style.getPropertyValue(key2);
36063 active.node.style.setProperty(key2, value);
36064 }
36065 }
36066 if (styles != null && styles.dragOverlay) {
36067 for (const [key2, value] of Object.entries(styles.dragOverlay)) {
36068 if (value === void 0) {
36069 continue;
36070 }
36071 dragOverlay.node.style.setProperty(key2, value);
36072 }
36073 }
36074 if (className != null && className.active) {
36075 active.node.classList.add(className.active);
36076 }
36077 if (className != null && className.dragOverlay) {
36078 dragOverlay.node.classList.add(className.dragOverlay);
36079 }
36080 return function cleanup() {
36081 for (const [key2, value] of Object.entries(originalStyles)) {
36082 active.node.style.setProperty(key2, value);
36083 }
36084 if (className != null && className.active) {
36085 active.node.classList.remove(className.active);
36086 }
36087 };
36088 };
36089 var defaultKeyframeResolver = (_ref2) => {
36090 let {
36091 transform: {
36092 initial,
36093 final
36094 }
36095 } = _ref2;
36096 return [{
36097 transform: CSS2.Transform.toString(initial)
36098 }, {
36099 transform: CSS2.Transform.toString(final)
36100 }];
36101 };
36102 var defaultDropAnimationConfiguration = {
36103 duration: 250,
36104 easing: "ease",
36105 keyframes: defaultKeyframeResolver,
36106 sideEffects: /* @__PURE__ */ defaultDropAnimationSideEffects({
36107 styles: {
36108 active: {
36109 opacity: "0"
36110 }
36111 }
36112 })
36113 };
36114 function useDropAnimation(_ref3) {
36115 let {
36116 config,
36117 draggableNodes,
36118 droppableContainers,
36119 measuringConfiguration
36120 } = _ref3;
36121 return useEvent3((id, node) => {
36122 if (config === null) {
36123 return;
36124 }
36125 const activeDraggable = draggableNodes.get(id);
36126 if (!activeDraggable) {
36127 return;
36128 }
36129 const activeNode = activeDraggable.node.current;
36130 if (!activeNode) {
36131 return;
36132 }
36133 const measurableNode = getMeasurableNode(node);
36134 if (!measurableNode) {
36135 return;
36136 }
36137 const {
36138 transform
36139 } = getWindow3(node).getComputedStyle(node);
36140 const parsedTransform = parseTransform(transform);
36141 if (!parsedTransform) {
36142 return;
36143 }
36144 const animation = typeof config === "function" ? config : createDefaultDropAnimation(config);
36145 scrollIntoViewIfNeeded2(activeNode, measuringConfiguration.draggable.measure);
36146 return animation({
36147 active: {
36148 id,
36149 data: activeDraggable.data,
36150 node: activeNode,
36151 rect: measuringConfiguration.draggable.measure(activeNode)
36152 },
36153 draggableNodes,
36154 dragOverlay: {
36155 node,
36156 rect: measuringConfiguration.dragOverlay.measure(measurableNode)
36157 },
36158 droppableContainers,
36159 measuringConfiguration,
36160 transform: parsedTransform
36161 });
36162 });
36163 }
36164 function createDefaultDropAnimation(options) {
36165 const {
36166 duration,
36167 easing,
36168 sideEffects,
36169 keyframes
36170 } = {
36171 ...defaultDropAnimationConfiguration,
36172 ...options
36173 };
36174 return (_ref4) => {
36175 let {
36176 active,
36177 dragOverlay,
36178 transform,
36179 ...rest
36180 } = _ref4;
36181 if (!duration) {
36182 return;
36183 }
36184 const delta = {
36185 x: dragOverlay.rect.left - active.rect.left,
36186 y: dragOverlay.rect.top - active.rect.top
36187 };
36188 const scale = {
36189 scaleX: transform.scaleX !== 1 ? active.rect.width * transform.scaleX / dragOverlay.rect.width : 1,
36190 scaleY: transform.scaleY !== 1 ? active.rect.height * transform.scaleY / dragOverlay.rect.height : 1
36191 };
36192 const finalTransform = {
36193 x: transform.x - delta.x,
36194 y: transform.y - delta.y,
36195 ...scale
36196 };
36197 const animationKeyframes = keyframes({
36198 ...rest,
36199 active,
36200 dragOverlay,
36201 transform: {
36202 initial: transform,
36203 final: finalTransform
36204 }
36205 });
36206 const [firstKeyframe] = animationKeyframes;
36207 const lastKeyframe = animationKeyframes[animationKeyframes.length - 1];
36208 if (JSON.stringify(firstKeyframe) === JSON.stringify(lastKeyframe)) {
36209 return;
36210 }
36211 const cleanup = sideEffects == null ? void 0 : sideEffects({
36212 active,
36213 dragOverlay,
36214 ...rest
36215 });
36216 const animation = dragOverlay.node.animate(animationKeyframes, {
36217 duration,
36218 easing,
36219 fill: "forwards"
36220 });
36221 return new Promise((resolve) => {
36222 animation.onfinish = () => {
36223 cleanup == null ? void 0 : cleanup();
36224 resolve();
36225 };
36226 });
36227 };
36228 }
36229 var key = 0;
36230 function useKey(id) {
36231 return (0, import_react40.useMemo)(() => {
36232 if (id == null) {
36233 return;
36234 }
36235 key++;
36236 return key;
36237 }, [id]);
36238 }
36239 var DragOverlay = /* @__PURE__ */ import_react40.default.memo((_ref) => {
36240 let {
36241 adjustScale: adjustScale2 = false,
36242 children,
36243 dropAnimation: dropAnimationConfig,
36244 style,
36245 transition,
36246 modifiers,
36247 wrapperElement = "div",
36248 className,
36249 zIndex = 999
36250 } = _ref;
36251 const {
36252 activatorEvent,
36253 active,
36254 activeNodeRect,
36255 containerNodeRect,
36256 draggableNodes,
36257 droppableContainers,
36258 dragOverlay,
36259 over,
36260 measuringConfiguration,
36261 scrollableAncestors,
36262 scrollableAncestorRects,
36263 windowRect
36264 } = useDndContext();
36265 const transform = (0, import_react40.useContext)(ActiveDraggableContext);
36266 const key2 = useKey(active == null ? void 0 : active.id);
36267 const modifiedTransform = applyModifiers(modifiers, {
36268 activatorEvent,
36269 active,
36270 activeNodeRect,
36271 containerNodeRect,
36272 draggingNodeRect: dragOverlay.rect,
36273 over,
36274 overlayNodeRect: dragOverlay.rect,
36275 scrollableAncestors,
36276 scrollableAncestorRects,
36277 transform,
36278 windowRect
36279 });
36280 const initialRect = useInitialValue2(activeNodeRect);
36281 const dropAnimation = useDropAnimation({
36282 config: dropAnimationConfig,
36283 draggableNodes,
36284 droppableContainers,
36285 measuringConfiguration
36286 });
36287 const ref = initialRect ? dragOverlay.setRef : void 0;
36288 return import_react40.default.createElement(NullifiedContextProvider, null, import_react40.default.createElement(AnimationManager, {
36289 animation: dropAnimation
36290 }, active && key2 ? import_react40.default.createElement(PositionedOverlay, {
36291 key: key2,
36292 id: active.id,
36293 ref,
36294 as: wrapperElement,
36295 activatorEvent,
36296 adjustScale: adjustScale2,
36297 className,
36298 transition,
36299 rect: initialRect,
36300 style: {
36301 zIndex,
36302 ...style
36303 },
36304 transform: modifiedTransform
36305 }, children) : null));
36306 });
36307
36308 // node_modules/@dnd-kit/sortable/dist/sortable.esm.js
36309 var import_react41 = __toESM(require_react());
36310 function arrayMove(array, from, to) {
36311 const newArray = array.slice();
36312 newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
36313 return newArray;
36314 }
36315 function getSortedRects(items, rects) {
36316 return items.reduce((accumulator, id, index2) => {
36317 const rect = rects.get(id);
36318 if (rect) {
36319 accumulator[index2] = rect;
36320 }
36321 return accumulator;
36322 }, Array(items.length));
36323 }
36324 function isValidIndex(index2) {
36325 return index2 !== null && index2 >= 0;
36326 }
36327 function itemsEqual(a2, b2) {
36328 if (a2 === b2) {
36329 return true;
36330 }
36331 if (a2.length !== b2.length) {
36332 return false;
36333 }
36334 for (let i2 = 0; i2 < a2.length; i2++) {
36335 if (a2[i2] !== b2[i2]) {
36336 return false;
36337 }
36338 }
36339 return true;
36340 }
36341 function normalizeDisabled(disabled2) {
36342 if (typeof disabled2 === "boolean") {
36343 return {
36344 draggable: disabled2,
36345 droppable: disabled2
36346 };
36347 }
36348 return disabled2;
36349 }
36350 var rectSortingStrategy = (_ref) => {
36351 let {
36352 rects,
36353 activeIndex,
36354 overIndex,
36355 index: index2
36356 } = _ref;
36357 const newRects = arrayMove(rects, overIndex, activeIndex);
36358 const oldRect = rects[index2];
36359 const newRect = newRects[index2];
36360 if (!newRect || !oldRect) {
36361 return null;
36362 }
36363 return {
36364 x: newRect.left - oldRect.left,
36365 y: newRect.top - oldRect.top,
36366 scaleX: newRect.width / oldRect.width,
36367 scaleY: newRect.height / oldRect.height
36368 };
36369 };
36370 var ID_PREFIX2 = "Sortable";
36371 var Context3 = /* @__PURE__ */ import_react41.default.createContext({
36372 activeIndex: -1,
36373 containerId: ID_PREFIX2,
36374 disableTransforms: false,
36375 items: [],
36376 overIndex: -1,
36377 useDragOverlay: false,
36378 sortedRects: [],
36379 strategy: rectSortingStrategy,
36380 disabled: {
36381 draggable: false,
36382 droppable: false
36383 }
36384 });
36385 function SortableContext(_ref) {
36386 let {
36387 children,
36388 id,
36389 items: userDefinedItems,
36390 strategy = rectSortingStrategy,
36391 disabled: disabledProp = false
36392 } = _ref;
36393 const {
36394 active,
36395 dragOverlay,
36396 droppableRects,
36397 over,
36398 measureDroppableContainers
36399 } = useDndContext();
36400 const containerId = useUniqueId(ID_PREFIX2, id);
36401 const useDragOverlay = Boolean(dragOverlay.rect !== null);
36402 const items = (0, import_react41.useMemo)(() => userDefinedItems.map((item) => typeof item === "object" && "id" in item ? item.id : item), [userDefinedItems]);
36403 const isDragging = active != null;
36404 const activeIndex = active ? items.indexOf(active.id) : -1;
36405 const overIndex = over ? items.indexOf(over.id) : -1;
36406 const previousItemsRef = (0, import_react41.useRef)(items);
36407 const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current);
36408 const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged;
36409 const disabled2 = normalizeDisabled(disabledProp);
36410 useIsomorphicLayoutEffect(() => {
36411 if (itemsHaveChanged && isDragging) {
36412 measureDroppableContainers(items);
36413 }
36414 }, [itemsHaveChanged, items, isDragging, measureDroppableContainers]);
36415 (0, import_react41.useEffect)(() => {
36416 previousItemsRef.current = items;
36417 }, [items]);
36418 const contextValue = (0, import_react41.useMemo)(
36419 () => ({
36420 activeIndex,
36421 containerId,
36422 disabled: disabled2,
36423 disableTransforms,
36424 items,
36425 overIndex,
36426 useDragOverlay,
36427 sortedRects: getSortedRects(items, droppableRects),
36428 strategy
36429 }),
36430 // eslint-disable-next-line react-hooks/exhaustive-deps
36431 [activeIndex, containerId, disabled2.draggable, disabled2.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]
36432 );
36433 return import_react41.default.createElement(Context3.Provider, {
36434 value: contextValue
36435 }, children);
36436 }
36437 var defaultNewIndexGetter = (_ref) => {
36438 let {
36439 id,
36440 items,
36441 activeIndex,
36442 overIndex
36443 } = _ref;
36444 return arrayMove(items, activeIndex, overIndex).indexOf(id);
36445 };
36446 var defaultAnimateLayoutChanges = (_ref2) => {
36447 let {
36448 containerId,
36449 isSorting,
36450 wasDragging,
36451 index: index2,
36452 items,
36453 newIndex,
36454 previousItems,
36455 previousContainerId,
36456 transition
36457 } = _ref2;
36458 if (!transition || !wasDragging) {
36459 return false;
36460 }
36461 if (previousItems !== items && index2 === newIndex) {
36462 return false;
36463 }
36464 if (isSorting) {
36465 return true;
36466 }
36467 return newIndex !== index2 && containerId === previousContainerId;
36468 };
36469 var defaultTransition2 = {
36470 duration: 200,
36471 easing: "ease"
36472 };
36473 var transitionProperty = "transform";
36474 var disabledTransition = /* @__PURE__ */ CSS2.Transition.toString({
36475 property: transitionProperty,
36476 duration: 0,
36477 easing: "linear"
36478 });
36479 var defaultAttributes = {
36480 roleDescription: "sortable"
36481 };
36482 function useDerivedTransform(_ref) {
36483 let {
36484 disabled: disabled2,
36485 index: index2,
36486 node,
36487 rect
36488 } = _ref;
36489 const [derivedTransform, setDerivedtransform] = (0, import_react41.useState)(null);
36490 const previousIndex = (0, import_react41.useRef)(index2);
36491 useIsomorphicLayoutEffect(() => {
36492 if (!disabled2 && index2 !== previousIndex.current && node.current) {
36493 const initial = rect.current;
36494 if (initial) {
36495 const current = getClientRect(node.current, {
36496 ignoreTransform: true
36497 });
36498 const delta = {
36499 x: initial.left - current.left,
36500 y: initial.top - current.top,
36501 scaleX: initial.width / current.width,
36502 scaleY: initial.height / current.height
36503 };
36504 if (delta.x || delta.y) {
36505 setDerivedtransform(delta);
36506 }
36507 }
36508 }
36509 if (index2 !== previousIndex.current) {
36510 previousIndex.current = index2;
36511 }
36512 }, [disabled2, index2, node, rect]);
36513 (0, import_react41.useEffect)(() => {
36514 if (derivedTransform) {
36515 setDerivedtransform(null);
36516 }
36517 }, [derivedTransform]);
36518 return derivedTransform;
36519 }
36520 function useSortable(_ref) {
36521 let {
36522 animateLayoutChanges = defaultAnimateLayoutChanges,
36523 attributes: userDefinedAttributes,
36524 disabled: localDisabled,
36525 data: customData,
36526 getNewIndex = defaultNewIndexGetter,
36527 id,
36528 strategy: localStrategy,
36529 resizeObserverConfig,
36530 transition = defaultTransition2
36531 } = _ref;
36532 const {
36533 items,
36534 containerId,
36535 activeIndex,
36536 disabled: globalDisabled,
36537 disableTransforms,
36538 sortedRects,
36539 overIndex,
36540 useDragOverlay,
36541 strategy: globalStrategy
36542 } = (0, import_react41.useContext)(Context3);
36543 const disabled2 = normalizeLocalDisabled(localDisabled, globalDisabled);
36544 const index2 = items.indexOf(id);
36545 const data = (0, import_react41.useMemo)(() => ({
36546 sortable: {
36547 containerId,
36548 index: index2,
36549 items
36550 },
36551 ...customData
36552 }), [containerId, customData, index2, items]);
36553 const itemsAfterCurrentSortable = (0, import_react41.useMemo)(() => items.slice(items.indexOf(id)), [items, id]);
36554 const {
36555 rect,
36556 node,
36557 isOver,
36558 setNodeRef: setDroppableNodeRef
36559 } = useDroppable({
36560 id,
36561 data,
36562 disabled: disabled2.droppable,
36563 resizeObserverConfig: {
36564 updateMeasurementsFor: itemsAfterCurrentSortable,
36565 ...resizeObserverConfig
36566 }
36567 });
36568 const {
36569 active,
36570 activatorEvent,
36571 activeNodeRect,
36572 attributes,
36573 setNodeRef: setDraggableNodeRef,
36574 listeners,
36575 isDragging,
36576 over,
36577 setActivatorNodeRef,
36578 transform
36579 } = useDraggable({
36580 id,
36581 data,
36582 attributes: {
36583 ...defaultAttributes,
36584 ...userDefinedAttributes
36585 },
36586 disabled: disabled2.draggable
36587 });
36588 const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
36589 const isSorting = Boolean(active);
36590 const displaceItem = isSorting && !disableTransforms && isValidIndex(activeIndex) && isValidIndex(overIndex);
36591 const shouldDisplaceDragSource = !useDragOverlay && isDragging;
36592 const dragSourceDisplacement = shouldDisplaceDragSource && displaceItem ? transform : null;
36593 const strategy = localStrategy != null ? localStrategy : globalStrategy;
36594 const finalTransform = displaceItem ? dragSourceDisplacement != null ? dragSourceDisplacement : strategy({
36595 rects: sortedRects,
36596 activeNodeRect,
36597 activeIndex,
36598 overIndex,
36599 index: index2
36600 }) : null;
36601 const newIndex = isValidIndex(activeIndex) && isValidIndex(overIndex) ? getNewIndex({
36602 id,
36603 items,
36604 activeIndex,
36605 overIndex
36606 }) : index2;
36607 const activeId = active == null ? void 0 : active.id;
36608 const previous = (0, import_react41.useRef)({
36609 activeId,
36610 items,
36611 newIndex,
36612 containerId
36613 });
36614 const itemsHaveChanged = items !== previous.current.items;
36615 const shouldAnimateLayoutChanges = animateLayoutChanges({
36616 active,
36617 containerId,
36618 isDragging,
36619 isSorting,
36620 id,
36621 index: index2,
36622 items,
36623 newIndex: previous.current.newIndex,
36624 previousItems: previous.current.items,
36625 previousContainerId: previous.current.containerId,
36626 transition,
36627 wasDragging: previous.current.activeId != null
36628 });
36629 const derivedTransform = useDerivedTransform({
36630 disabled: !shouldAnimateLayoutChanges,
36631 index: index2,
36632 node,
36633 rect
36634 });
36635 (0, import_react41.useEffect)(() => {
36636 if (isSorting && previous.current.newIndex !== newIndex) {
36637 previous.current.newIndex = newIndex;
36638 }
36639 if (containerId !== previous.current.containerId) {
36640 previous.current.containerId = containerId;
36641 }
36642 if (items !== previous.current.items) {
36643 previous.current.items = items;
36644 }
36645 }, [isSorting, newIndex, containerId, items]);
36646 (0, import_react41.useEffect)(() => {
36647 if (activeId === previous.current.activeId) {
36648 return;
36649 }
36650 if (activeId != null && previous.current.activeId == null) {
36651 previous.current.activeId = activeId;
36652 return;
36653 }
36654 const timeoutId = setTimeout(() => {
36655 previous.current.activeId = activeId;
36656 }, 50);
36657 return () => clearTimeout(timeoutId);
36658 }, [activeId]);
36659 return {
36660 active,
36661 activeIndex,
36662 attributes,
36663 data,
36664 rect,
36665 index: index2,
36666 newIndex,
36667 items,
36668 isOver,
36669 isSorting,
36670 isDragging,
36671 listeners,
36672 node,
36673 overIndex,
36674 over,
36675 setNodeRef,
36676 setActivatorNodeRef,
36677 setDroppableNodeRef,
36678 setDraggableNodeRef,
36679 transform: derivedTransform != null ? derivedTransform : finalTransform,
36680 transition: getTransition()
36681 };
36682 function getTransition() {
36683 if (
36684 // Temporarily disable transitions for a single frame to set up derived transforms
36685 derivedTransform || // Or to prevent items jumping to back to their "new" position when items change
36686 itemsHaveChanged && previous.current.newIndex === index2
36687 ) {
36688 return disabledTransition;
36689 }
36690 if (shouldDisplaceDragSource && !isKeyboardEvent(activatorEvent) || !transition) {
36691 return void 0;
36692 }
36693 if (isSorting || shouldAnimateLayoutChanges) {
36694 return CSS2.Transition.toString({
36695 ...transition,
36696 property: transitionProperty
36697 });
36698 }
36699 return void 0;
36700 }
36701 }
36702 function normalizeLocalDisabled(localDisabled, globalDisabled) {
36703 var _localDisabled$dragga, _localDisabled$droppa;
36704 if (typeof localDisabled === "boolean") {
36705 return {
36706 draggable: localDisabled,
36707 // Backwards compatibility
36708 droppable: false
36709 };
36710 }
36711 return {
36712 draggable: (_localDisabled$dragga = localDisabled == null ? void 0 : localDisabled.draggable) != null ? _localDisabled$dragga : globalDisabled.draggable,
36713 droppable: (_localDisabled$droppa = localDisabled == null ? void 0 : localDisabled.droppable) != null ? _localDisabled$droppa : globalDisabled.droppable
36714 };
36715 }
36716 function hasSortableData(entry) {
36717 if (!entry) {
36718 return false;
36719 }
36720 const data = entry.data.current;
36721 if (data && "sortable" in data && typeof data.sortable === "object" && "containerId" in data.sortable && "items" in data.sortable && "index" in data.sortable) {
36722 return true;
36723 }
36724 return false;
36725 }
36726 var directions = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
36727 var sortableKeyboardCoordinates = (event, _ref) => {
36728 let {
36729 context: {
36730 active,
36731 collisionRect,
36732 droppableRects,
36733 droppableContainers,
36734 over,
36735 scrollableAncestors
36736 }
36737 } = _ref;
36738 if (directions.includes(event.code)) {
36739 event.preventDefault();
36740 if (!active || !collisionRect) {
36741 return;
36742 }
36743 const filteredContainers = [];
36744 droppableContainers.getEnabled().forEach((entry) => {
36745 if (!entry || entry != null && entry.disabled) {
36746 return;
36747 }
36748 const rect = droppableRects.get(entry.id);
36749 if (!rect) {
36750 return;
36751 }
36752 switch (event.code) {
36753 case KeyboardCode.Down:
36754 if (collisionRect.top < rect.top) {
36755 filteredContainers.push(entry);
36756 }
36757 break;
36758 case KeyboardCode.Up:
36759 if (collisionRect.top > rect.top) {
36760 filteredContainers.push(entry);
36761 }
36762 break;
36763 case KeyboardCode.Left:
36764 if (collisionRect.left > rect.left) {
36765 filteredContainers.push(entry);
36766 }
36767 break;
36768 case KeyboardCode.Right:
36769 if (collisionRect.left < rect.left) {
36770 filteredContainers.push(entry);
36771 }
36772 break;
36773 }
36774 });
36775 const collisions = closestCorners({
36776 active,
36777 collisionRect,
36778 droppableRects,
36779 droppableContainers: filteredContainers,
36780 pointerCoordinates: null
36781 });
36782 let closestId = getFirstCollision(collisions, "id");
36783 if (closestId === (over == null ? void 0 : over.id) && collisions.length > 1) {
36784 closestId = collisions[1].id;
36785 }
36786 if (closestId != null) {
36787 const activeDroppable = droppableContainers.get(active.id);
36788 const newDroppable = droppableContainers.get(closestId);
36789 const newRect = newDroppable ? droppableRects.get(newDroppable.id) : null;
36790 const newNode = newDroppable == null ? void 0 : newDroppable.node.current;
36791 if (newNode && newRect && activeDroppable && newDroppable) {
36792 const newScrollAncestors = getScrollableAncestors(newNode);
36793 const hasDifferentScrollAncestors = newScrollAncestors.some((element, index2) => scrollableAncestors[index2] !== element);
36794 const hasSameContainer = isSameContainer(activeDroppable, newDroppable);
36795 const isAfterActive = isAfter(activeDroppable, newDroppable);
36796 const offset4 = hasDifferentScrollAncestors || !hasSameContainer ? {
36797 x: 0,
36798 y: 0
36799 } : {
36800 x: isAfterActive ? collisionRect.width - newRect.width : 0,
36801 y: isAfterActive ? collisionRect.height - newRect.height : 0
36802 };
36803 const rectCoordinates = {
36804 x: newRect.left,
36805 y: newRect.top
36806 };
36807 const newCoordinates = offset4.x && offset4.y ? rectCoordinates : subtract(rectCoordinates, offset4);
36808 return newCoordinates;
36809 }
36810 }
36811 }
36812 return void 0;
36813 };
36814 function isSameContainer(a2, b2) {
36815 if (!hasSortableData(a2) || !hasSortableData(b2)) {
36816 return false;
36817 }
36818 return a2.data.current.sortable.containerId === b2.data.current.sortable.containerId;
36819 }
36820 function isAfter(a2, b2) {
36821 if (!hasSortableData(a2) || !hasSortableData(b2)) {
36822 return false;
36823 }
36824 if (!isSameContainer(a2, b2)) {
36825 return false;
36826 }
36827 return a2.data.current.sortable.index < b2.data.current.sortable.index;
36828 }
36829
36830 // packages/grid/build-module/dashboard-grid/index.mjs
36831 var import_compose19 = __toESM(require_compose(), 1);
36832 var import_element129 = __toESM(require_element(), 1);
36833
36834 // packages/grid/build-module/dashboard-grid/grid-item.mjs
36835 var import_element128 = __toESM(require_element(), 1);
36836 var import_compose18 = __toESM(require_compose(), 1);
36837
36838 // packages/grid/build-module/shared/resize-handle.mjs
36839 var import_element127 = __toESM(require_element(), 1);
36840 var import_compose17 = __toESM(require_compose(), 1);
36841 var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1);
36842 var STYLE_HASH_ATTRIBUTE36 = "data-wp-hash";
36843 function getRuntime36() {
36844 const globalScope = globalThis;
36845 if (globalScope.__wpStyleRuntime) {
36846 return globalScope.__wpStyleRuntime;
36847 }
36848 globalScope.__wpStyleRuntime = {
36849 documents: /* @__PURE__ */ new Map(),
36850 styles: /* @__PURE__ */ new Map(),
36851 injectedStyles: /* @__PURE__ */ new WeakMap()
36852 };
36853 if (typeof document !== "undefined") {
36854 registerDocument36(document);
36855 }
36856 return globalScope.__wpStyleRuntime;
36857 }
36858 function documentContainsStyleHash36(targetDocument, hash) {
36859 if (!targetDocument.head) {
36860 return false;
36861 }
36862 for (const style of targetDocument.head.querySelectorAll(
36863 `style[${STYLE_HASH_ATTRIBUTE36}]`
36864 )) {
36865 if (style.getAttribute(STYLE_HASH_ATTRIBUTE36) === hash) {
36866 return true;
36867 }
36868 }
36869 return false;
36870 }
36871 function injectStyle36(targetDocument, hash, css) {
36872 if (!targetDocument.head) {
36873 return;
36874 }
36875 const runtime = getRuntime36();
36876 let injectedStyles = runtime.injectedStyles.get(targetDocument);
36877 if (!injectedStyles) {
36878 injectedStyles = /* @__PURE__ */ new Set();
36879 runtime.injectedStyles.set(targetDocument, injectedStyles);
36880 }
36881 if (injectedStyles.has(hash)) {
36882 return;
36883 }
36884 if (documentContainsStyleHash36(targetDocument, hash)) {
36885 injectedStyles.add(hash);
36886 return;
36887 }
36888 const style = targetDocument.createElement("style");
36889 style.setAttribute(STYLE_HASH_ATTRIBUTE36, hash);
36890 style.appendChild(targetDocument.createTextNode(css));
36891 targetDocument.head.appendChild(style);
36892 injectedStyles.add(hash);
36893 }
36894 function registerDocument36(targetDocument) {
36895 const runtime = getRuntime36();
36896 runtime.documents.set(
36897 targetDocument,
36898 (runtime.documents.get(targetDocument) ?? 0) + 1
36899 );
36900 for (const [hash, css] of runtime.styles) {
36901 injectStyle36(targetDocument, hash, css);
36902 }
36903 return () => {
36904 const count = runtime.documents.get(targetDocument);
36905 if (count === void 0) {
36906 return;
36907 }
36908 if (count <= 1) {
36909 runtime.documents.delete(targetDocument);
36910 return;
36911 }
36912 runtime.documents.set(targetDocument, count - 1);
36913 };
36914 }
36915 function registerStyle36(hash, css) {
36916 const runtime = getRuntime36();
36917 runtime.styles.set(hash, css);
36918 for (const targetDocument of runtime.documents.keys()) {
36919 injectStyle36(targetDocument, hash, css);
36920 }
36921 }
36922 if (typeof process === "undefined" || true) {
36923 registerStyle36("9ee34907fd", '._4da787f72dc00d8b__resize-handle{border-block-end:12px solid var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-inline-start:12px solid #0000;bottom:0;cursor:nwse-resize;height:0;inset-inline-end:0;position:absolute;width:0;z-index:1}._885412b44a137da0__is-horizontal-only{align-items:center;background:#0000;border-style:none;bottom:auto;cursor:ew-resize;display:flex;height:40px;justify-content:center;top:50%;transform:translateY(-50%);width:16px}._885412b44a137da0__is-horizontal-only:before{background-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));border-radius:2px;content:"";height:24px;width:4px}@media (forced-colors:active){._885412b44a137da0__is-horizontal-only:before{background-color:Highlight}}');
36924 }
36925 var resize_handle_default = { "resize-handle": "_4da787f72dc00d8b__resize-handle", "is-horizontal-only": "_885412b44a137da0__is-horizontal-only" };
36926 function ResizeHandle({
36927 itemId,
36928 verticalResizable = true,
36929 renderResizeHandle
36930 }) {
36931 const { attributes, listeners, setNodeRef, isDragging } = useDraggable({
36932 id: "draggable",
36933 data: { itemId }
36934 });
36935 const nodeRef = (0, import_element127.useRef)(null);
36936 const mergedRef = (0, import_compose17.useMergeRefs)([nodeRef, setNodeRef]);
36937 (0, import_element127.useEffect)(() => {
36938 if (!isDragging) {
36939 return;
36940 }
36941 const cursor = verticalResizable ? "nwse-resize" : "ew-resize";
36942 const root = (nodeRef.current?.ownerDocument ?? document).documentElement;
36943 const previous = root.style.cursor;
36944 root.style.cursor = cursor;
36945 return () => {
36946 root.style.cursor = previous;
36947 };
36948 }, [isDragging, verticalResizable]);
36949 if (renderResizeHandle) {
36950 const RenderResizeHandle = renderResizeHandle;
36951 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
36952 RenderResizeHandle,
36953 {
36954 ref: mergedRef,
36955 listeners,
36956 attributes,
36957 verticalResizable,
36958 isResizing: isDragging,
36959 itemId
36960 }
36961 );
36962 }
36963 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
36964 "div",
36965 {
36966 ref: mergedRef,
36967 className: clsx_default(
36968 resize_handle_default["resize-handle"],
36969 !verticalResizable && resize_handle_default["is-horizontal-only"]
36970 ),
36971 ...listeners,
36972 ...attributes
36973 }
36974 );
36975 }
36976 function ResizeHandleWrapper(props) {
36977 const throttleDelay = 16;
36978 const throttledResize = (0, import_compose17.useThrottle)((delta) => {
36979 if (props.onResize) {
36980 props.onResize(delta);
36981 }
36982 }, throttleDelay);
36983 const handleDragMove = (event) => {
36984 if (event.active.id !== "draggable") {
36985 return;
36986 }
36987 throttledResize({
36988 width: event.delta.x,
36989 height: event.delta.y
36990 });
36991 };
36992 const handleDragEnd = () => {
36993 if (props.onResizeEnd) {
36994 props.onResizeEnd();
36995 }
36996 };
36997 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(
36998 DndContext,
36999 {
37000 autoScroll: {
37001 threshold: { x: 5e-3, y: 5e-3 },
37002 acceleration: 1
37003 },
37004 onDragMove: handleDragMove,
37005 onDragEnd: handleDragEnd,
37006 children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(ResizeHandle, { ...props })
37007 }
37008 );
37009 }
37010
37011 // packages/grid/build-module/dashboard-grid/grid-item.mjs
37012 var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1);
37013 var STYLE_HASH_ATTRIBUTE37 = "data-wp-hash";
37014 function getRuntime37() {
37015 const globalScope = globalThis;
37016 if (globalScope.__wpStyleRuntime) {
37017 return globalScope.__wpStyleRuntime;
37018 }
37019 globalScope.__wpStyleRuntime = {
37020 documents: /* @__PURE__ */ new Map(),
37021 styles: /* @__PURE__ */ new Map(),
37022 injectedStyles: /* @__PURE__ */ new WeakMap()
37023 };
37024 if (typeof document !== "undefined") {
37025 registerDocument37(document);
37026 }
37027 return globalScope.__wpStyleRuntime;
37028 }
37029 function documentContainsStyleHash37(targetDocument, hash) {
37030 if (!targetDocument.head) {
37031 return false;
37032 }
37033 for (const style of targetDocument.head.querySelectorAll(
37034 `style[${STYLE_HASH_ATTRIBUTE37}]`
37035 )) {
37036 if (style.getAttribute(STYLE_HASH_ATTRIBUTE37) === hash) {
37037 return true;
37038 }
37039 }
37040 return false;
37041 }
37042 function injectStyle37(targetDocument, hash, css) {
37043 if (!targetDocument.head) {
37044 return;
37045 }
37046 const runtime = getRuntime37();
37047 let injectedStyles = runtime.injectedStyles.get(targetDocument);
37048 if (!injectedStyles) {
37049 injectedStyles = /* @__PURE__ */ new Set();
37050 runtime.injectedStyles.set(targetDocument, injectedStyles);
37051 }
37052 if (injectedStyles.has(hash)) {
37053 return;
37054 }
37055 if (documentContainsStyleHash37(targetDocument, hash)) {
37056 injectedStyles.add(hash);
37057 return;
37058 }
37059 const style = targetDocument.createElement("style");
37060 style.setAttribute(STYLE_HASH_ATTRIBUTE37, hash);
37061 style.appendChild(targetDocument.createTextNode(css));
37062 targetDocument.head.appendChild(style);
37063 injectedStyles.add(hash);
37064 }
37065 function registerDocument37(targetDocument) {
37066 const runtime = getRuntime37();
37067 runtime.documents.set(
37068 targetDocument,
37069 (runtime.documents.get(targetDocument) ?? 0) + 1
37070 );
37071 for (const [hash, css] of runtime.styles) {
37072 injectStyle37(targetDocument, hash, css);
37073 }
37074 return () => {
37075 const count = runtime.documents.get(targetDocument);
37076 if (count === void 0) {
37077 return;
37078 }
37079 if (count <= 1) {
37080 runtime.documents.delete(targetDocument);
37081 return;
37082 }
37083 runtime.documents.set(targetDocument, count - 1);
37084 };
37085 }
37086 function registerStyle37(hash, css) {
37087 const runtime = getRuntime37();
37088 runtime.styles.set(hash, css);
37089 for (const targetDocument of runtime.documents.keys()) {
37090 injectStyle37(targetDocument, hash, css);
37091 }
37092 }
37093 if (typeof process === "undefined" || true) {
37094 registerStyle37("d1d61343be", "._5d1abcb332a18701__item{position:relative}._54de57c12d3ce67e__item-content{height:100%;position:relative}._81d4e1a6c979f1e4__is-dragging{border-radius:var(--wp-grid-placeholder-radius,0);opacity:var(--wp-grid-placeholder-opacity,.4);outline:var(--wpds-border-width-sm,2px) dashed var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));pointer-events:none}@media (forced-colors:active){._81d4e1a6c979f1e4__is-dragging{outline-color:Highlight}}._2028fc095dbc5cb2__preview-overlay{background:#0000;border:var(--wpds-border-width-sm,2px) dashed var(--wp-grid-placeholder-outline-color,var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9)));inset-inline-start:0;pointer-events:none;position:absolute;top:0;z-index:1}@media (forced-colors:active){._2028fc095dbc5cb2__preview-overlay{border-color:Highlight}}");
37095 }
37096 var grid_item_default = { "item": "_5d1abcb332a18701__item", "item-content": "_54de57c12d3ce67e__item-content", "is-dragging": "_81d4e1a6c979f1e4__is-dragging", "preview-overlay": "_2028fc095dbc5cb2__preview-overlay" };
37097 function getItemCursor(disabled2, interacting) {
37098 if (disabled2) {
37099 return "default";
37100 }
37101 if (interacting) {
37102 return void 0;
37103 }
37104 return "grab";
37105 }
37106 function GridItem4({
37107 item,
37108 maxColumns,
37109 disabled: disabled2 = false,
37110 verticalResizable = true,
37111 interacting = false,
37112 children,
37113 actionableArea = null,
37114 onResize,
37115 onResizeEnd,
37116 renderResizeHandle
37117 }) {
37118 const [previewDelta, setPreviewDelta] = (0, import_element128.useState)(
37119 null
37120 );
37121 const itemRef = (0, import_element128.useRef)(null);
37122 const initialResizeRectRef = (0, import_element128.useRef)(null);
37123 const initialResizeScrollRef = (0, import_element128.useRef)(null);
37124 const lastResizeDeltaRef = (0, import_element128.useRef)(null);
37125 const {
37126 attributes,
37127 listeners,
37128 setNodeRef,
37129 setActivatorNodeRef,
37130 isDragging
37131 } = useSortable({
37132 id: item.key,
37133 disabled: disabled2
37134 });
37135 const mergedRef = (0, import_compose18.useMergeRefs)([itemRef, setNodeRef]);
37136 const style = {
37137 gridColumnEnd: `span ${item.width === "full" ? maxColumns : Math.min(
37138 typeof item.width === "number" ? item.width : 1,
37139 maxColumns
37140 )}`,
37141 gridRowEnd: `span ${item.height || 1}`
37142 };
37143 const itemClassName = clsx_default(
37144 grid_item_default.item,
37145 isDragging && grid_item_default["is-dragging"]
37146 );
37147 const handleResize = (delta) => {
37148 const clamped = {
37149 width: delta.width,
37150 height: verticalResizable ? delta.height : 0
37151 };
37152 const node = itemRef.current;
37153 if (node && !initialResizeRectRef.current) {
37154 initialResizeRectRef.current = node.getBoundingClientRect();
37155 const ownerWindow = node.ownerDocument.defaultView ?? window;
37156 initialResizeScrollRef.current = {
37157 x: ownerWindow.scrollX,
37158 y: ownerWindow.scrollY
37159 };
37160 }
37161 lastResizeDeltaRef.current = clamped;
37162 onResize(item.key, clamped);
37163 if (node && initialResizeRectRef.current && initialResizeScrollRef.current) {
37164 const currentRect = node.getBoundingClientRect();
37165 const ownerWindow = node.ownerDocument.defaultView ?? window;
37166 const scrollDelta = {
37167 x: ownerWindow.scrollX - initialResizeScrollRef.current.x,
37168 y: ownerWindow.scrollY - initialResizeScrollRef.current.y
37169 };
37170 const offsetX = currentRect.right - initialResizeRectRef.current.right;
37171 const offsetY = currentRect.bottom - initialResizeRectRef.current.bottom;
37172 setPreviewDelta({
37173 width: clamped.width - offsetX - scrollDelta.x,
37174 height: verticalResizable ? clamped.height - offsetY - scrollDelta.y : 0
37175 });
37176 }
37177 };
37178 (0, import_element128.useLayoutEffect)(() => {
37179 const lastDelta = lastResizeDeltaRef.current;
37180 const initialRect = initialResizeRectRef.current;
37181 const initialScroll = initialResizeScrollRef.current;
37182 const node = itemRef.current;
37183 if (!lastDelta || !initialRect || !initialScroll || !node) {
37184 return;
37185 }
37186 const currentRect = node.getBoundingClientRect();
37187 const ownerWindow = node.ownerDocument.defaultView ?? window;
37188 const scrollDelta = {
37189 x: ownerWindow.scrollX - initialScroll.x,
37190 y: ownerWindow.scrollY - initialScroll.y
37191 };
37192 const offsetX = currentRect.right - initialRect.right;
37193 const offsetY = currentRect.bottom - initialRect.bottom;
37194 const next = {
37195 width: lastDelta.width - offsetX - scrollDelta.x,
37196 height: verticalResizable ? lastDelta.height - offsetY - scrollDelta.y : 0
37197 };
37198 setPreviewDelta(
37199 (prev) => next.width === prev?.width && next.height === prev?.height ? prev : next
37200 );
37201 }, [item.width, item.height, verticalResizable]);
37202 const handleResizeEnd = () => {
37203 setPreviewDelta(null);
37204 initialResizeRectRef.current = null;
37205 initialResizeScrollRef.current = null;
37206 lastResizeDeltaRef.current = null;
37207 onResizeEnd();
37208 };
37209 const previewOverlay = previewDelta ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
37210 "div",
37211 {
37212 className: grid_item_default["preview-overlay"],
37213 style: {
37214 insetInlineEnd: -previewDelta.width,
37215 bottom: -previewDelta.height
37216 }
37217 }
37218 ) : null;
37219 return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)("div", { ref: mergedRef, className: itemClassName, style, children: [
37220 actionableArea ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
37221 "div",
37222 {
37223 style: { display: "contents" },
37224 ...interacting ? { inert: "" } : {},
37225 children: actionableArea
37226 }
37227 ) : null,
37228 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(
37229 "div",
37230 {
37231 ref: setActivatorNodeRef,
37232 ...attributes,
37233 ...listeners,
37234 style: {
37235 height: "100%",
37236 // Keyboard activation needs `attributes` (tabIndex)
37237 // and `listeners` (onKeyDown) on the same focused
37238 // node; `setActivatorNodeRef` points dnd-kit's
37239 // keyboard sensor here, the outer keeps `setNodeRef`
37240 // for measurement.
37241 //
37242 // Cursor lives on this wrapper so `actionableArea`
37243 // children (mounted outside it) keep their own;
37244 // `undefined` during a gesture defers to the resize
37245 // handle's document cursor lock.
37246 cursor: getItemCursor(disabled2, interacting)
37247 },
37248 children: [
37249 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)("div", { className: grid_item_default["item-content"], children: [
37250 children,
37251 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
37252 ResizeHandleWrapper,
37253 {
37254 itemId: item.key,
37255 verticalResizable,
37256 onResize: handleResize,
37257 onResizeEnd: handleResizeEnd,
37258 renderResizeHandle
37259 }
37260 )
37261 ] }),
37262 previewOverlay
37263 ]
37264 }
37265 )
37266 ] });
37267 }
37268
37269 // packages/grid/build-module/shared/grid-overlay.mjs
37270 var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1);
37271 var STYLE_HASH_ATTRIBUTE38 = "data-wp-hash";
37272 function getRuntime38() {
37273 const globalScope = globalThis;
37274 if (globalScope.__wpStyleRuntime) {
37275 return globalScope.__wpStyleRuntime;
37276 }
37277 globalScope.__wpStyleRuntime = {
37278 documents: /* @__PURE__ */ new Map(),
37279 styles: /* @__PURE__ */ new Map(),
37280 injectedStyles: /* @__PURE__ */ new WeakMap()
37281 };
37282 if (typeof document !== "undefined") {
37283 registerDocument38(document);
37284 }
37285 return globalScope.__wpStyleRuntime;
37286 }
37287 function documentContainsStyleHash38(targetDocument, hash) {
37288 if (!targetDocument.head) {
37289 return false;
37290 }
37291 for (const style of targetDocument.head.querySelectorAll(
37292 `style[${STYLE_HASH_ATTRIBUTE38}]`
37293 )) {
37294 if (style.getAttribute(STYLE_HASH_ATTRIBUTE38) === hash) {
37295 return true;
37296 }
37297 }
37298 return false;
37299 }
37300 function injectStyle38(targetDocument, hash, css) {
37301 if (!targetDocument.head) {
37302 return;
37303 }
37304 const runtime = getRuntime38();
37305 let injectedStyles = runtime.injectedStyles.get(targetDocument);
37306 if (!injectedStyles) {
37307 injectedStyles = /* @__PURE__ */ new Set();
37308 runtime.injectedStyles.set(targetDocument, injectedStyles);
37309 }
37310 if (injectedStyles.has(hash)) {
37311 return;
37312 }
37313 if (documentContainsStyleHash38(targetDocument, hash)) {
37314 injectedStyles.add(hash);
37315 return;
37316 }
37317 const style = targetDocument.createElement("style");
37318 style.setAttribute(STYLE_HASH_ATTRIBUTE38, hash);
37319 style.appendChild(targetDocument.createTextNode(css));
37320 targetDocument.head.appendChild(style);
37321 injectedStyles.add(hash);
37322 }
37323 function registerDocument38(targetDocument) {
37324 const runtime = getRuntime38();
37325 runtime.documents.set(
37326 targetDocument,
37327 (runtime.documents.get(targetDocument) ?? 0) + 1
37328 );
37329 for (const [hash, css] of runtime.styles) {
37330 injectStyle38(targetDocument, hash, css);
37331 }
37332 return () => {
37333 const count = runtime.documents.get(targetDocument);
37334 if (count === void 0) {
37335 return;
37336 }
37337 if (count <= 1) {
37338 runtime.documents.delete(targetDocument);
37339 return;
37340 }
37341 runtime.documents.set(targetDocument, count - 1);
37342 };
37343 }
37344 function registerStyle38(hash, css) {
37345 const runtime = getRuntime38();
37346 runtime.styles.set(hash, css);
37347 for (const targetDocument of runtime.documents.keys()) {
37348 injectStyle38(targetDocument, hash, css);
37349 }
37350 }
37351 if (typeof process === "undefined" || true) {
37352 registerStyle38("05bdcd8add", '._9d372b1b567c1c15__overlay{background-image:repeating-linear-gradient(135deg,var(--wp-grid-overlay-stripe-color,color-mix(in srgb,var(--wpds-color-bg-surface-info,#deebfa) 15%,#0000)) 0 6px,#0000 6px 12px);display:grid;inset:0;opacity:0;pointer-events:none;position:absolute;transition:opacity .2s ease,visibility 0s linear .2s;visibility:hidden}._9d372b1b567c1c15__overlay.acb42ab28bd5e371__is-active{opacity:1;transition:opacity .2s ease,visibility 0s linear 0s;visibility:visible}@media (prefers-reduced-motion:reduce){._9d372b1b567c1c15__overlay{transition:none}}._04ff499ab60b4891__column{background-color:var(--wp-grid-overlay-column-fill,color-mix(in srgb,var(--wpds-color-bg-surface-info,#deebfa) 10%,#0000));outline:1px dashed var(--wp-grid-overlay-track-color,var(--wpds-color-stroke-surface-neutral,#dbdbdb));position:relative}._1cee1202cb622c6b__has-rows ._04ff499ab60b4891__column:after{background-image:linear-gradient(to bottom,var(--wp-grid-overlay-track-color,var(--wpds-color-stroke-surface-neutral,#dbdbdb)) 0,var(--wp-grid-overlay-track-color,var(--wpds-color-stroke-surface-neutral,#dbdbdb)) 1px,#0000 1px,#0000 calc(var(--wp-grid-overlay-row-height) - 1px),var(--wp-grid-overlay-track-color,var(--wpds-color-stroke-surface-neutral,#dbdbdb)) calc(var(--wp-grid-overlay-row-height) - 1px),var(--wp-grid-overlay-track-color,var(--wpds-color-stroke-surface-neutral,#dbdbdb)) var(--wp-grid-overlay-row-height),#0000 var(--wp-grid-overlay-row-height),#0000 var(--wp-grid-overlay-row-tile));background-repeat:repeat;background-size:100% var(--wp-grid-overlay-row-tile);content:"";inset:0;mask-image:repeating-linear-gradient(90deg,#000 0 4px,#0000 4px 8px);-webkit-mask-image:repeating-linear-gradient(90deg,#000 0 4px,#0000 4px 8px);pointer-events:none;position:absolute}');
37353 }
37354 var grid_overlay_default = { "overlay": "_9d372b1b567c1c15__overlay", "is-active": "acb42ab28bd5e371__is-active", "column": "_04ff499ab60b4891__column", "has-rows": "_1cee1202cb622c6b__has-rows" };
37355 function GridOverlay({
37356 columns,
37357 gapPx,
37358 rowHeight,
37359 isActive
37360 }) {
37361 const showRows = typeof rowHeight === "number";
37362 const style = {
37363 gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
37364 gap: `${gapPx}px`,
37365 ...showRows ? {
37366 "--wp-grid-overlay-row-height": `${rowHeight}px`,
37367 "--wp-grid-overlay-row-tile": `${rowHeight + gapPx}px`
37368 } : {}
37369 };
37370 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
37371 "div",
37372 {
37373 "aria-hidden": true,
37374 className: clsx_default(
37375 grid_overlay_default.overlay,
37376 isActive && grid_overlay_default["is-active"],
37377 showRows && grid_overlay_default["has-rows"]
37378 ),
37379 style,
37380 children: Array.from({ length: columns }).map((_, i2) => /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: grid_overlay_default.column }, i2))
37381 }
37382 );
37383 }
37384
37385 // packages/grid/build-module/dashboard-grid/resolve-fill-widths.mjs
37386 function resolveFillWidths(sortedKeys, layoutMap, maxColumns) {
37387 const resolved = /* @__PURE__ */ new Map();
37388 const n2 = sortedKeys.length;
37389 const items = new Array(n2);
37390 const widths = new Array(n2);
37391 const heights = new Array(n2);
37392 let hasFill = false;
37393 let hasMultiRow = false;
37394 let totalRows = 0;
37395 for (let i2 = 0; i2 < n2; i2++) {
37396 const item = layoutMap.get(sortedKeys[i2]);
37397 items[i2] = item;
37398 widths[i2] = item && typeof item.width === "number" ? Math.min(item.width, maxColumns) : 1;
37399 const h2 = Math.max(1, Math.floor(item?.height ?? 1));
37400 heights[i2] = h2;
37401 if (item?.width === "fill") {
37402 hasFill = true;
37403 }
37404 if (h2 > 1) {
37405 hasMultiRow = true;
37406 }
37407 totalRows += h2;
37408 }
37409 if (!hasFill) {
37410 return resolved;
37411 }
37412 if (!hasMultiRow) {
37413 let currentCol = 0;
37414 for (let i2 = 0; i2 < n2; i2++) {
37415 const item = items[i2];
37416 if (!item) {
37417 continue;
37418 }
37419 if (item.width === "full") {
37420 currentCol = 0;
37421 continue;
37422 }
37423 if (item.width === "fill") {
37424 let reserved = 0;
37425 for (let j2 = i2 + 1; j2 < n2; j2++) {
37426 const next = items[j2];
37427 if (!next || next.width === "full" || next.width === "fill") {
37428 break;
37429 }
37430 const nextW = widths[j2];
37431 if (currentCol + 1 + reserved + nextW <= maxColumns) {
37432 reserved += nextW;
37433 } else {
37434 break;
37435 }
37436 }
37437 const fillCols = Math.max(
37438 1,
37439 maxColumns - currentCol - reserved
37440 );
37441 resolved.set(item.key, fillCols);
37442 currentCol += fillCols;
37443 } else {
37444 const w2 = widths[i2];
37445 if (currentCol + w2 > maxColumns) {
37446 currentCol = 0;
37447 }
37448 currentCol += w2;
37449 }
37450 if (currentCol >= maxColumns) {
37451 currentCol = 0;
37452 }
37453 }
37454 return resolved;
37455 }
37456 const rowOccupancy = new Array(maxColumns).fill(0);
37457 let cursorRow = 0;
37458 let cursorCol = 0;
37459 for (let i2 = 0; i2 < n2; i2++) {
37460 const item = items[i2];
37461 if (!item) {
37462 continue;
37463 }
37464 const h2 = heights[i2];
37465 if (item.width === "full") {
37466 let r22 = cursorRow;
37467 for (let c22 = 0; c22 < maxColumns; c22++) {
37468 if (rowOccupancy[c22] > r22) {
37469 r22 = rowOccupancy[c22];
37470 }
37471 }
37472 for (let c22 = 0; c22 < maxColumns; c22++) {
37473 rowOccupancy[c22] = r22 + h2;
37474 }
37475 cursorRow = r22 + h2;
37476 cursorCol = 0;
37477 continue;
37478 }
37479 if (item.width === "fill") {
37480 let r22 = cursorRow;
37481 let c22 = cursorCol;
37482 scan: for (; r22 <= totalRows; r22++) {
37483 const start = r22 === cursorRow ? cursorCol : 0;
37484 for (c22 = start; c22 < maxColumns; c22++) {
37485 if (rowOccupancy[c22] <= r22) {
37486 break scan;
37487 }
37488 }
37489 }
37490 const fillStartRow = r22;
37491 const fillStartCol = c22;
37492 let runLength = 0;
37493 while (fillStartCol + runLength < maxColumns && rowOccupancy[fillStartCol + runLength] <= fillStartRow) {
37494 runLength++;
37495 }
37496 let reserved = 0;
37497 for (let j2 = i2 + 1; j2 < n2; j2++) {
37498 const next = items[j2];
37499 if (!next || next.width === "full" || next.width === "fill") {
37500 break;
37501 }
37502 const nextW = widths[j2];
37503 if (1 + reserved + nextW <= runLength) {
37504 reserved += nextW;
37505 } else {
37506 break;
37507 }
37508 }
37509 const fillCols = Math.max(1, runLength - reserved);
37510 resolved.set(item.key, fillCols);
37511 for (let k = 0; k < fillCols; k++) {
37512 rowOccupancy[fillStartCol + k] = fillStartRow + h2;
37513 }
37514 cursorRow = fillStartRow;
37515 cursorCol = fillStartCol + fillCols;
37516 continue;
37517 }
37518 const w2 = widths[i2];
37519 let r3 = cursorRow;
37520 let c2 = cursorCol;
37521 place: for (; r3 <= totalRows; r3++) {
37522 c2 = r3 === cursorRow ? cursorCol : 0;
37523 while (c2 + w2 <= maxColumns) {
37524 let blocked = -1;
37525 for (let k = 0; k < w2; k++) {
37526 if (rowOccupancy[c2 + k] > r3) {
37527 blocked = c2 + k;
37528 break;
37529 }
37530 }
37531 if (blocked === -1) {
37532 break place;
37533 }
37534 c2 = blocked + 1;
37535 }
37536 }
37537 for (let k = 0; k < w2; k++) {
37538 rowOccupancy[c2 + k] = r3 + h2;
37539 }
37540 cursorRow = r3;
37541 cursorCol = c2 + w2;
37542 }
37543 return resolved;
37544 }
37545
37546 // packages/grid/build-module/dashboard-grid/index.mjs
37547 var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1);
37548 var STYLE_HASH_ATTRIBUTE39 = "data-wp-hash";
37549 function getRuntime39() {
37550 const globalScope = globalThis;
37551 if (globalScope.__wpStyleRuntime) {
37552 return globalScope.__wpStyleRuntime;
37553 }
37554 globalScope.__wpStyleRuntime = {
37555 documents: /* @__PURE__ */ new Map(),
37556 styles: /* @__PURE__ */ new Map(),
37557 injectedStyles: /* @__PURE__ */ new WeakMap()
37558 };
37559 if (typeof document !== "undefined") {
37560 registerDocument39(document);
37561 }
37562 return globalScope.__wpStyleRuntime;
37563 }
37564 function documentContainsStyleHash39(targetDocument, hash) {
37565 if (!targetDocument.head) {
37566 return false;
37567 }
37568 for (const style of targetDocument.head.querySelectorAll(
37569 `style[${STYLE_HASH_ATTRIBUTE39}]`
37570 )) {
37571 if (style.getAttribute(STYLE_HASH_ATTRIBUTE39) === hash) {
37572 return true;
37573 }
37574 }
37575 return false;
37576 }
37577 function injectStyle39(targetDocument, hash, css) {
37578 if (!targetDocument.head) {
37579 return;
37580 }
37581 const runtime = getRuntime39();
37582 let injectedStyles = runtime.injectedStyles.get(targetDocument);
37583 if (!injectedStyles) {
37584 injectedStyles = /* @__PURE__ */ new Set();
37585 runtime.injectedStyles.set(targetDocument, injectedStyles);
37586 }
37587 if (injectedStyles.has(hash)) {
37588 return;
37589 }
37590 if (documentContainsStyleHash39(targetDocument, hash)) {
37591 injectedStyles.add(hash);
37592 return;
37593 }
37594 const style = targetDocument.createElement("style");
37595 style.setAttribute(STYLE_HASH_ATTRIBUTE39, hash);
37596 style.appendChild(targetDocument.createTextNode(css));
37597 targetDocument.head.appendChild(style);
37598 injectedStyles.add(hash);
37599 }
37600 function registerDocument39(targetDocument) {
37601 const runtime = getRuntime39();
37602 runtime.documents.set(
37603 targetDocument,
37604 (runtime.documents.get(targetDocument) ?? 0) + 1
37605 );
37606 for (const [hash, css] of runtime.styles) {
37607 injectStyle39(targetDocument, hash, css);
37608 }
37609 return () => {
37610 const count = runtime.documents.get(targetDocument);
37611 if (count === void 0) {
37612 return;
37613 }
37614 if (count <= 1) {
37615 runtime.documents.delete(targetDocument);
37616 return;
37617 }
37618 runtime.documents.set(targetDocument, count - 1);
37619 };
37620 }
37621 function registerStyle39(hash, css) {
37622 const runtime = getRuntime39();
37623 runtime.styles.set(hash, css);
37624 for (const targetDocument of runtime.documents.keys()) {
37625 injectStyle39(targetDocument, hash, css);
37626 }
37627 }
37628 if (typeof process === "undefined" || true) {
37629 registerStyle39("faf48c5174", "._960c435c33759f46__grid{display:grid;position:relative}._48e8cd4225dcb813__drag-preview-frame{cursor:grabbing;height:100%;pointer-events:none;transform:scale(var(--wp-grid-drag-preview-scale,1.05))}@media (prefers-reduced-motion:reduce){._48e8cd4225dcb813__drag-preview-frame{transform:none}}");
37630 }
37631 var grid_default2 = { "grid": "_960c435c33759f46__grid", "drag-preview-frame": "_48e8cd4225dcb813__drag-preview-frame" };
37632 var NO_SORT_STRATEGY = () => null;
37633 var DashboardGrid = (0, import_element129.forwardRef)(
37634 function DashboardGrid2(props, ref) {
37635 const {
37636 layout,
37637 columns = 6,
37638 children,
37639 className,
37640 style,
37641 spacing = 2,
37642 rowHeight = "auto",
37643 minColumnWidth,
37644 editMode = false,
37645 onChangeLayout,
37646 onPreviewLayout,
37647 renderResizeHandle,
37648 renderDragPreview,
37649 renderGridOverlay,
37650 ...divProps
37651 } = props;
37652 const [temporaryLayout, setTemporaryLayout] = (0, import_element129.useState)();
37653 const [activeId, setActiveId] = (0, import_element129.useState)(null);
37654 const [isResizing, setIsResizing] = (0, import_element129.useState)(false);
37655 const latestLayoutRef = (0, import_element129.useRef)();
37656 const lastReorderCursorRef = (0, import_element129.useRef)(null);
37657 const resizeBaselineRef = (0, import_element129.useRef)(null);
37658 const activeLayout = temporaryLayout ?? layout;
37659 const rootRef = (0, import_element129.useRef)(null);
37660 const [containerWidth, setContainerWidth] = (0, import_element129.useState)(0);
37661 const resizeObserverRef = (0, import_compose19.useResizeObserver)(
37662 ([{ contentRect }]) => {
37663 setContainerWidth(contentRect.width);
37664 }
37665 );
37666 const mergedGridRef = (0, import_compose19.useMergeRefs)([
37667 rootRef,
37668 resizeObserverRef,
37669 ref
37670 ]);
37671 (0, import_element129.useLayoutEffect)(() => {
37672 if (rootRef.current) {
37673 const { width } = rootRef.current.getBoundingClientRect();
37674 if (width > 0) {
37675 setContainerWidth(width);
37676 }
37677 }
37678 }, []);
37679 const gapPx = spacing * 4;
37680 const effectiveColumns = (0, import_element129.useMemo)(() => {
37681 if (!minColumnWidth) {
37682 return columns;
37683 }
37684 const totalWidthPerColumn = minColumnWidth + gapPx;
37685 const maxColumns = Math.floor(
37686 (containerWidth + gapPx) / totalWidthPerColumn
37687 );
37688 return Math.max(1, maxColumns);
37689 }, [minColumnWidth, gapPx, containerWidth, columns]);
37690 const columnWidth = (containerWidth - (effectiveColumns - 1) * gapPx) / effectiveColumns;
37691 const layoutMap = (0, import_element129.useMemo)(() => {
37692 const map = /* @__PURE__ */ new Map();
37693 activeLayout.forEach((item) => map.set(item.key, item));
37694 return map;
37695 }, [activeLayout]);
37696 const layoutKeysSig = layout.map((item) => item.key).join("\0");
37697 const layoutKeysRef = (0, import_element129.useRef)(null);
37698 if (layoutKeysRef.current?.sig !== layoutKeysSig) {
37699 layoutKeysRef.current = {
37700 sig: layoutKeysSig,
37701 set: new Set(layout.map((item) => item.key))
37702 };
37703 }
37704 const layoutKeys = layoutKeysRef.current.set;
37705 const sortedItems = activeLayout.map((item, index2) => ({ item, index: index2 })).sort(
37706 (a2, b2) => (a2.item.order ?? a2.index) - (b2.item.order ?? b2.index)
37707 ).map(({ item }) => item.key);
37708 const itemsSig = sortedItems.join("\0");
37709 const itemsRef = (0, import_element129.useRef)(null);
37710 if (itemsRef.current?.sig !== itemsSig) {
37711 itemsRef.current = { sig: itemsSig, arr: sortedItems };
37712 }
37713 const items = itemsRef.current.arr;
37714 const resolvedItemMap = (0, import_element129.useMemo)(() => {
37715 const fillWidths = resolveFillWidths(
37716 items,
37717 layoutMap,
37718 effectiveColumns
37719 );
37720 if (fillWidths.size === 0) {
37721 return layoutMap;
37722 }
37723 const map = /* @__PURE__ */ new Map();
37724 for (const [key2, item] of layoutMap) {
37725 const fillW = fillWidths.get(key2);
37726 map.set(
37727 key2,
37728 fillW !== void 0 ? { ...item, width: fillW } : item
37729 );
37730 }
37731 return map;
37732 }, [items, layoutMap, effectiveColumns]);
37733 const [childrenMap, actionableAreaMap, remaining] = (0, import_element129.useMemo)(() => {
37734 const childMap = /* @__PURE__ */ new Map();
37735 const actionableMap = /* @__PURE__ */ new Map();
37736 const rest = [];
37737 import_element129.Children.forEach(children, (child) => {
37738 if (!(0, import_element129.isValidElement)(child)) {
37739 rest.push(child);
37740 return;
37741 }
37742 const key2 = child.key?.toString();
37743 if (key2 && layoutKeys.has(key2)) {
37744 const { actionableArea } = child.props;
37745 if (actionableArea !== void 0) {
37746 actionableMap.set(key2, actionableArea);
37747 childMap.set(
37748 key2,
37749 (0, import_element129.cloneElement)(child, { actionableArea: void 0 })
37750 );
37751 } else {
37752 childMap.set(key2, child);
37753 }
37754 } else {
37755 rest.push(child);
37756 }
37757 });
37758 return [childMap, actionableMap, rest];
37759 }, [children, layoutKeys]);
37760 const sensors = useSensors(
37761 useSensor(PointerSensor),
37762 useSensor(KeyboardSensor, {
37763 coordinateGetter: sortableKeyboardCoordinates
37764 })
37765 );
37766 const handleDragStart = (0, import_compose19.useEvent)((event) => {
37767 setActiveId(String(event.active.id));
37768 lastReorderCursorRef.current = null;
37769 });
37770 const handleDragCancel = (0, import_compose19.useEvent)(() => {
37771 setActiveId(null);
37772 latestLayoutRef.current = void 0;
37773 lastReorderCursorRef.current = null;
37774 resizeBaselineRef.current = null;
37775 setIsResizing(false);
37776 setTemporaryLayout(void 0);
37777 });
37778 const handleDragMove = (0, import_compose19.useEvent)((event) => {
37779 const { active, over } = event;
37780 if (!over || active.id === over.id) {
37781 return;
37782 }
37783 const activeRect = active.rect.current.translated;
37784 if (!activeRect) {
37785 return;
37786 }
37787 const activeCenterX = activeRect.left + activeRect.width / 2;
37788 const activeCenterY = activeRect.top + activeRect.height / 2;
37789 const lastCursor = lastReorderCursorRef.current;
37790 if (lastCursor) {
37791 const dx = activeCenterX - lastCursor.x;
37792 const dy = activeCenterY - lastCursor.y;
37793 if (dx * dx + dy * dy < 100) {
37794 return;
37795 }
37796 }
37797 const overCenterX = over.rect.left + over.rect.width / 2;
37798 const insertAfter = activeCenterX > overCenterX;
37799 const currentIndex = items.indexOf(String(active.id));
37800 const overIndex = items.indexOf(String(over.id));
37801 let newIndex;
37802 if (insertAfter) {
37803 newIndex = currentIndex > overIndex ? overIndex + 1 : overIndex;
37804 } else {
37805 newIndex = currentIndex > overIndex ? overIndex : overIndex - 1;
37806 }
37807 newIndex = Math.max(0, Math.min(newIndex, items.length - 1));
37808 if (newIndex === currentIndex) {
37809 return;
37810 }
37811 const updatedItems = arrayMove(items, currentIndex, newIndex);
37812 const updatedLayout = activeLayout.map((item) => ({
37813 ...item,
37814 order: updatedItems.indexOf(item.key)
37815 }));
37816 lastReorderCursorRef.current = {
37817 x: activeCenterX,
37818 y: activeCenterY
37819 };
37820 latestLayoutRef.current = updatedLayout;
37821 setTemporaryLayout(updatedLayout);
37822 onPreviewLayout?.(updatedLayout);
37823 });
37824 const persistTemporaryLayout = (0, import_compose19.useEvent)(() => {
37825 const latest = latestLayoutRef.current;
37826 latestLayoutRef.current = void 0;
37827 resizeBaselineRef.current = null;
37828 setIsResizing(false);
37829 if (!onChangeLayout || !latest) {
37830 return;
37831 }
37832 onChangeLayout(latest);
37833 setTemporaryLayout(void 0);
37834 });
37835 const handleResize = (0, import_compose19.useEvent)((id, delta) => {
37836 if (!editMode) {
37837 return;
37838 }
37839 if (!isResizing) {
37840 setIsResizing(true);
37841 }
37842 const relativeDelta = {
37843 width: Math.round(delta.width / (columnWidth + gapPx)),
37844 height: rowHeight === "auto" ? 0 : Math.round(delta.height / (rowHeight + gapPx))
37845 };
37846 if (!resizeBaselineRef.current) {
37847 const baseItem = activeLayout.find(
37848 (item) => item.key === id
37849 );
37850 const resolvedItem = resolvedItemMap.get(id);
37851 let baseWidth;
37852 if (baseItem?.width === "full") {
37853 baseWidth = effectiveColumns;
37854 } else if (baseItem?.width === "fill") {
37855 baseWidth = typeof resolvedItem?.width === "number" ? resolvedItem.width : 1;
37856 } else {
37857 baseWidth = baseItem?.width ?? 1;
37858 }
37859 resizeBaselineRef.current = {
37860 width: baseWidth,
37861 height: baseItem?.height ?? 1
37862 };
37863 }
37864 const baseline = resizeBaselineRef.current;
37865 const newWidth = Math.max(
37866 1,
37867 Math.min(
37868 baseline.width + relativeDelta.width,
37869 effectiveColumns
37870 )
37871 );
37872 const newHeight = Math.max(
37873 1,
37874 baseline.height + relativeDelta.height
37875 );
37876 const currentItem = activeLayout.find(
37877 (item) => item.key === id
37878 );
37879 if (currentItem && currentItem.width === newWidth && (currentItem.height ?? 1) === newHeight) {
37880 return;
37881 }
37882 const updatedLayout = activeLayout.map(
37883 (item) => item.key === id ? { ...item, width: newWidth, height: newHeight } : item
37884 );
37885 latestLayoutRef.current = updatedLayout;
37886 setTemporaryLayout(updatedLayout);
37887 onPreviewLayout?.(updatedLayout);
37888 });
37889 const activeClone = activeId ? childrenMap.get(activeId) : null;
37890 const DragPreview = renderDragPreview;
37891 const dragOverlayContent = activeId && activeClone ? /* @__PURE__ */ (0, import_jsx_runtime164.jsx)("div", { className: grid_default2["drag-preview-frame"], children: DragPreview ? /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(DragPreview, { itemId: activeId, children: activeClone }) : activeClone }) : null;
37892 const Overlay = renderGridOverlay ?? GridOverlay;
37893 const overlayRowHeight = typeof rowHeight === "number" ? rowHeight : void 0;
37894 const gridOverlay = (0, import_element129.useMemo)(
37895 () => /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
37896 Overlay,
37897 {
37898 columns: effectiveColumns,
37899 gapPx,
37900 rowHeight: overlayRowHeight,
37901 isActive: editMode
37902 }
37903 ),
37904 [Overlay, editMode, effectiveColumns, gapPx, overlayRowHeight]
37905 );
37906 return /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(
37907 DndContext,
37908 {
37909 sensors,
37910 onDragStart: handleDragStart,
37911 onDragCancel: handleDragCancel,
37912 onDragMove: handleDragMove,
37913 onDragEnd: () => {
37914 persistTemporaryLayout();
37915 setActiveId(null);
37916 lastReorderCursorRef.current = null;
37917 },
37918 children: [
37919 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(SortableContext, { items, strategy: NO_SORT_STRATEGY, children: /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(
37920 "div",
37921 {
37922 ...divProps,
37923 ref: mergedGridRef,
37924 className: clsx_default(grid_default2.grid, className),
37925 style: {
37926 ...style,
37927 gridTemplateColumns: `repeat(${effectiveColumns}, minmax(0, 1fr))`,
37928 gridAutoRows: rowHeight,
37929 gap: gapPx
37930 },
37931 children: [
37932 gridOverlay,
37933 items.map((id) => /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
37934 GridItem4,
37935 {
37936 item: resolvedItemMap.get(
37937 id
37938 ),
37939 maxColumns: effectiveColumns,
37940 disabled: !editMode,
37941 verticalResizable: rowHeight !== "auto",
37942 interacting: activeId !== null || isResizing,
37943 onResize: handleResize,
37944 onResizeEnd: persistTemporaryLayout,
37945 actionableArea: actionableAreaMap.get(id),
37946 renderResizeHandle,
37947 children: childrenMap.get(id)
37948 },
37949 id
37950 )),
37951 remaining
37952 ]
37953 }
37954 ) }),
37955 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(DragOverlay, { children: dragOverlayContent })
37956 ]
37957 }
37958 );
37959 }
37960 );
37961
37962 // routes/dashboard/widget-dashboard/components/widgets/widgets.module.css
37963 if (typeof process === "undefined" || true) {
37964 registerStyle35("b78cb44834", "._561eb2c5c7cbcb6b__grid{width:100%}._8fa4ad5c2e86a6b9__tile{border-radius:var(--wpds-border-radius-lg,8px);height:100%}._8a257ea80aac989e__tileEditMode{box-shadow:var(--wpds-elevation-xs,0 1px 1px 0 #00000008,0 1px 2px 0 #00000005,0 3px 3px 0 #00000005,0 4px 4px 0 #00000003)}._8a257ea80aac989e__tileEditMode:focus-visible,._8a257ea80aac989e__tileEditMode:hover{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)}._8a257ea80aac989e__tileEditMode:focus-visible{outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline-offset:2px}._48e2b8516636ed6b__dragPreview{height:100%}._48e2b8516636ed6b__dragPreview ._8fa4ad5c2e86a6b9__tile{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)}@media not (prefers-reduced-motion){._8fa4ad5c2e86a6b9__tile{transition:box-shadow var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}");
37965 }
37966 var widgets_default = { "grid": "_561eb2c5c7cbcb6b__grid", "tile": "_8fa4ad5c2e86a6b9__tile", "tileEditMode": "_8a257ea80aac989e__tileEditMode", "dragPreview": "_48e2b8516636ed6b__dragPreview" };
37967
37968 // routes/dashboard/widget-dashboard/components/widgets/widgets.tsx
37969 var import_jsx_runtime165 = __toESM(require_jsx_runtime());
37970 function toGridLayout(widgets) {
37971 return widgets.map((w2) => ({
37972 key: w2.uuid,
37973 ...w2.placement
37974 }));
37975 }
37976 function applyGridChange(widgets, gridLayout) {
37977 return gridLayout.map(({ key: key2, ...placement }) => {
37978 const existing = widgets.find((w2) => w2.uuid === key2);
37979 if (!existing) {
37980 return {
37981 uuid: key2,
37982 type: "",
37983 placement
37984 };
37985 }
37986 return {
37987 ...existing,
37988 placement
37989 };
37990 });
37991 }
37992 var Widgets = (0, import_element130.forwardRef)(
37993 function Widgets2({ className }, ref) {
37994 const { layout, onLayoutChange, editMode, gridSettings } = useDashboardInternalContext();
37995 const gridLayout = (0, import_element130.useMemo)(() => toGridLayout(layout), [layout]);
37996 const handleLayoutChange = (0, import_element130.useCallback)(
37997 (newGridLayout) => {
37998 onLayoutChange(applyGridChange(layout, newGridLayout));
37999 },
38000 [layout, onLayoutChange]
38001 );
38002 const children = layout.map((widget, index2) => /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
38003 "div",
38004 {
38005 className: clsx_default(widgets_default.tile, {
38006 [widgets_default.tileEditMode]: editMode
38007 }),
38008 tabIndex: editMode ? 0 : void 0,
38009 children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(WidgetChrome, { widget, index: index2 })
38010 },
38011 widget.uuid
38012 ));
38013 const renderDragPreview = (0, import_element130.useCallback)(
38014 ({ children: clone }) => /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("div", { className: widgets_default.dragPreview, children: clone }),
38015 []
38016 );
38017 const sharedProps = {
38018 layout: gridLayout,
38019 spacing: gridSettings.spacing,
38020 rowHeight: gridSettings.rowHeight,
38021 editMode,
38022 onChangeLayout: handleLayoutChange,
38023 renderDragPreview
38024 };
38025 return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("div", { ref, className: clsx_default(widgets_default.grid, className), children: gridSettings.columns !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
38026 DashboardGrid,
38027 {
38028 ...sharedProps,
38029 columns: gridSettings.columns,
38030 children
38031 }
38032 ) : /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
38033 DashboardGrid,
38034 {
38035 ...sharedProps,
38036 minColumnWidth: gridSettings.minColumnWidth,
38037 children
38038 }
38039 ) });
38040 }
38041 );
38042
38043 // routes/dashboard/widget-dashboard/components/no-widgets-state/no-widgets-state.tsx
38044 var import_i18n53 = __toESM(require_i18n());
38045
38046 // routes/dashboard/widget-dashboard/components/no-widgets-state/no-widgets-state.module.css
38047 if (typeof process === "undefined" || true) {
38048 registerStyle35("4dec2ea292", "._43aa5df1b0907556__root{padding-block-start:calc(var(--wpds-dimension-padding-3xl, 32px)*3.5)}");
38049 }
38050 var no_widgets_state_default = { "root": "_43aa5df1b0907556__root" };
38051
38052 // routes/dashboard/widget-dashboard/components/no-widgets-state/no-widgets-state.tsx
38053 var import_jsx_runtime166 = __toESM(require_jsx_runtime());
38054 function NoWidgetsStateImpl({ children }) {
38055 const { layout } = useDashboardInternalContext();
38056 if (layout.length > 0) {
38057 return null;
38058 }
38059 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(Stack, { justify: "center", align: "center", className: no_widgets_state_default.root, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(empty_state_exports.Root, { children: [
38060 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(empty_state_exports.Icon, { icon: home_default }),
38061 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(empty_state_exports.Title, { children: (0, import_i18n53.__)("Your dashboard is empty") }),
38062 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(empty_state_exports.Description, { children: (0, import_i18n53.__)(
38063 "Add widgets to start customizing your dashboard."
38064 ) })
38065 ] }) });
38066 }
38067 var NoWidgetsState = NoWidgetsStateImpl;
38068
38069 // routes/dashboard/widget-dashboard/widget-dashboard.tsx
38070 var import_jsx_runtime167 = __toESM(require_jsx_runtime());
38071 var WidgetDashboard = Object.assign(
38072 function WidgetDashboard2({
38073 layout,
38074 onLayoutChange,
38075 onLayoutReset,
38076 widgetTypes,
38077 editMode,
38078 onEditChange,
38079 resolveWidgetModule,
38080 gridSettings,
38081 children
38082 }) {
38083 return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
38084 WidgetDashboardProvider,
38085 {
38086 layout,
38087 onLayoutChange,
38088 onLayoutReset,
38089 widgetTypes,
38090 editMode,
38091 onEditChange,
38092 resolveWidgetModule,
38093 gridSettings,
38094 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(WidgetDashboardUIProvider, { children: [
38095 children ?? /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(import_jsx_runtime167.Fragment, { children: [
38096 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(NoWidgetsState, {}),
38097 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(Actions3, {}),
38098 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(Widgets, {})
38099 ] }),
38100 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(Inserter, {})
38101 ] })
38102 }
38103 );
38104 },
38105 { Actions: Actions3, Widgets, WidgetChrome, NoWidgetsState }
38106 );
38107
38108 // routes/dashboard/widget-types/hooks/use-widget-types.ts
38109 var import_data7 = __toESM(require_data());
38110 var import_core_data = __toESM(require_core_data());
38111 var import_element131 = __toESM(require_element());
38112 var import_i18n54 = __toESM(require_i18n());
38113 (0, import_data7.dispatch)(import_core_data.store).addEntities([
38114 {
38115 name: "widgetModule",
38116 kind: "root",
38117 key: "name",
38118 baseURL: "/wp/v2/widget-modules",
38119 plural: "widgetModules",
38120 label: (0, import_i18n54.__)("Widget modules"),
38121 supportsPagination: false
38122 }
38123 ]);
38124 function useWidgetTypes() {
38125 const records = (0, import_data7.useSelect)(
38126 (select) => select(import_core_data.store).getEntityRecords("root", "widgetModule"),
38127 []
38128 );
38129 const [widgetTypes, setWidgetTypes] = (0, import_element131.useState)([]);
38130 (0, import_element131.useEffect)(() => {
38131 if (!records) {
38132 return;
38133 }
38134 let cancelled = false;
38135 Promise.all(
38136 records.map(async (record) => {
38137 if (!record.widget_module) {
38138 return null;
38139 }
38140 try {
38141 const module = await import(
38142 /* webpackIgnore: true */
38143 record.widget_module
38144 );
38145 if (!module?.default) {
38146 return null;
38147 }
38148 return {
38149 ...module.default,
38150 name: record.name,
38151 renderModule: record.render_module ?? ""
38152 };
38153 } catch {
38154 return null;
38155 }
38156 })
38157 ).then((results) => {
38158 if (cancelled) {
38159 return;
38160 }
38161 setWidgetTypes(
38162 results.filter((t2) => t2 !== null)
38163 );
38164 });
38165 return () => {
38166 cancelled = true;
38167 };
38168 }, [records]);
38169 return widgetTypes;
38170 }
38171
38172 // routes/dashboard/stage.module.css
38173 if (typeof process === "undefined" || true) {
38174 registerStyle35("5a63b052df", "._2381d7918cf57baa__dashboard-widgets-container{margin:var(--wpds-dimension-padding-md,12px)}");
38175 }
38176 var stage_default = { "dashboard-widgets-container": "_2381d7918cf57baa__dashboard-widgets-container" };
38177
38178 // routes/dashboard/stage.tsx
38179 var import_jsx_runtime168 = __toESM(require_jsx_runtime());
38180 function Dashboard() {
38181 const [layout, setLayout, resetLayout] = useDashboardLayout(
38182 "gutenberg_dashboard"
38183 );
38184 const widgetTypes = useWidgetTypes();
38185 const [editMode, setEditMode] = (0, import_element132.useState)(false);
38186 const { createSuccessNotice } = (0, import_data8.useDispatch)(import_notices.store);
38187 const handleLayoutChange = (next) => {
38188 setLayout(next);
38189 void createSuccessNotice((0, import_i18n55.__)("Dashboard saved."), {
38190 type: "snackbar"
38191 });
38192 };
38193 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
38194 WidgetDashboard,
38195 {
38196 widgetTypes,
38197 layout,
38198 onLayoutChange: handleLayoutChange,
38199 onLayoutReset: resetLayout,
38200 editMode,
38201 onEditChange: setEditMode,
38202 children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
38203 page_default,
38204 {
38205 title: (0, import_i18n55.__)("Dashboard"),
38206 actions: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(WidgetDashboard.Actions, {}),
38207 children: /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)("div", { className: stage_default["dashboard-widgets-container"], children: [
38208 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(WidgetDashboard.NoWidgetsState, {}),
38209 /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(WidgetDashboard.Widgets, {})
38210 ] })
38211 }
38212 )
38213 }
38214 );
38215 }
38216 var stage = Dashboard;
38217 export {
38218 stage
38219 };
38220 /*! Bundled license information:
38221
38222 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
38223 (**
38224 * @license React
38225 * use-sync-external-store-shim.development.js
38226 *
38227 * Copyright (c) Meta Platforms, Inc. and affiliates.
38228 *
38229 * This source code is licensed under the MIT license found in the
38230 * LICENSE file in the root directory of this source tree.
38231 *)
38232
38233 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
38234 (**
38235 * @license React
38236 * use-sync-external-store-shim/with-selector.development.js
38237 *
38238 * Copyright (c) Meta Platforms, Inc. and affiliates.
38239 *
38240 * This source code is licensed under the MIT license found in the
38241 * LICENSE file in the root directory of this source tree.
38242 *)
38243
38244 tabbable/dist/index.esm.js:
38245 (*!
38246 * tabbable 6.4.0
38247 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
38248 *)
38249 */
38250