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

content.js in Gutenberg 23.1.1, at build/routes/pattern-list/content.js

19,055 lines 643.6 KB
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 __copyProps = (to, from, except, desc) => {
11 if (from && typeof from === "object" || typeof from === "function") {
12 for (let key of __getOwnPropNames(from))
13 if (!__hasOwnProp.call(to, key) && key !== except)
14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15 }
16 return to;
17 };
18 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19 // If the importer is in node compatibility mode or this is not an ESM
20 // file that has been converted to a CommonJS file using a Babel-
21 // compatible transform (i.e. "__esModule" has not been set), then set
22 // "default" to the CommonJS "module.exports" for node compatibility.
23 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24 mod
25 ));
26
27 // package-external:@wordpress/element
28 var require_element = __commonJS({
29 "package-external:@wordpress/element"(exports, module) {
30 module.exports = window.wp.element;
31 }
32 });
33
34 // package-external:@wordpress/data
35 var require_data = __commonJS({
36 "package-external:@wordpress/data"(exports, module) {
37 module.exports = window.wp.data;
38 }
39 });
40
41 // package-external:@wordpress/preferences
42 var require_preferences = __commonJS({
43 "package-external:@wordpress/preferences"(exports, module) {
44 module.exports = window.wp.preferences;
45 }
46 });
47
48 // package-external:@wordpress/core-data
49 var require_core_data = __commonJS({
50 "package-external:@wordpress/core-data"(exports, module) {
51 module.exports = window.wp.coreData;
52 }
53 });
54
55 // package-external:@wordpress/private-apis
56 var require_private_apis = __commonJS({
57 "package-external:@wordpress/private-apis"(exports, module) {
58 module.exports = window.wp.privateApis;
59 }
60 });
61
62 // package-external:@wordpress/compose
63 var require_compose = __commonJS({
64 "package-external:@wordpress/compose"(exports, module) {
65 module.exports = window.wp.compose;
66 }
67 });
68
69 // vendor-external:react
70 var require_react = __commonJS({
71 "vendor-external:react"(exports, module) {
72 module.exports = window.React;
73 }
74 });
75
76 // vendor-external:react/jsx-runtime
77 var require_jsx_runtime = __commonJS({
78 "vendor-external:react/jsx-runtime"(exports, module) {
79 module.exports = window.ReactJSXRuntime;
80 }
81 });
82
83 // vendor-external:react-dom
84 var require_react_dom = __commonJS({
85 "vendor-external:react-dom"(exports, module) {
86 module.exports = window.ReactDOM;
87 }
88 });
89
90 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
91 var require_use_sync_external_store_shim_development = __commonJS({
92 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
93 "use strict";
94 (function() {
95 function is(x2, y2) {
96 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
97 }
98 function useSyncExternalStore$2(subscribe2, getSnapshot) {
99 didWarnOld18Alpha || void 0 === React9.startTransition || (didWarnOld18Alpha = true, console.error(
100 "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."
101 ));
102 var value = getSnapshot();
103 if (!didWarnUncachedGetSnapshot) {
104 var cachedValue = getSnapshot();
105 objectIs(value, cachedValue) || (console.error(
106 "The result of getSnapshot should be cached to avoid an infinite loop"
107 ), didWarnUncachedGetSnapshot = true);
108 }
109 cachedValue = useState25({
110 inst: { value, getSnapshot }
111 });
112 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
113 useLayoutEffect3(
114 function() {
115 inst.value = value;
116 inst.getSnapshot = getSnapshot;
117 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
118 },
119 [subscribe2, value, getSnapshot]
120 );
121 useEffect21(
122 function() {
123 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
124 return subscribe2(function() {
125 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
126 });
127 },
128 [subscribe2]
129 );
130 useDebugValue(value);
131 return value;
132 }
133 function checkIfSnapshotChanged(inst) {
134 var latestGetSnapshot = inst.getSnapshot;
135 inst = inst.value;
136 try {
137 var nextValue = latestGetSnapshot();
138 return !objectIs(inst, nextValue);
139 } catch (error) {
140 return true;
141 }
142 }
143 function useSyncExternalStore$1(subscribe2, getSnapshot) {
144 return getSnapshot();
145 }
146 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
147 var React9 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState25 = React9.useState, useEffect21 = React9.useEffect, useLayoutEffect3 = React9.useLayoutEffect, useDebugValue = React9.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
148 exports.useSyncExternalStore = void 0 !== React9.useSyncExternalStore ? React9.useSyncExternalStore : shim;
149 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
150 })();
151 }
152 });
153
154 // node_modules/use-sync-external-store/shim/index.js
155 var require_shim = __commonJS({
156 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
157 "use strict";
158 if (false) {
159 module.exports = null;
160 } else {
161 module.exports = require_use_sync_external_store_shim_development();
162 }
163 }
164 });
165
166 // package-external:@wordpress/i18n
167 var require_i18n = __commonJS({
168 "package-external:@wordpress/i18n"(exports, module) {
169 module.exports = window.wp.i18n;
170 }
171 });
172
173 // package-external:@wordpress/primitives
174 var require_primitives = __commonJS({
175 "package-external:@wordpress/primitives"(exports, module) {
176 module.exports = window.wp.primitives;
177 }
178 });
179
180 // package-external:@wordpress/components
181 var require_components = __commonJS({
182 "package-external:@wordpress/components"(exports, module) {
183 module.exports = window.wp.components;
184 }
185 });
186
187 // package-external:@wordpress/keycodes
188 var require_keycodes = __commonJS({
189 "package-external:@wordpress/keycodes"(exports, module) {
190 module.exports = window.wp.keycodes;
191 }
192 });
193
194 // node_modules/remove-accents/index.js
195 var require_remove_accents = __commonJS({
196 "node_modules/remove-accents/index.js"(exports, module) {
197 var characterMap = {
198 "\xC0": "A",
199 "\xC1": "A",
200 "\xC2": "A",
201 "\xC3": "A",
202 "\xC4": "A",
203 "\xC5": "A",
204 "\u1EA4": "A",
205 "\u1EAE": "A",
206 "\u1EB2": "A",
207 "\u1EB4": "A",
208 "\u1EB6": "A",
209 "\xC6": "AE",
210 "\u1EA6": "A",
211 "\u1EB0": "A",
212 "\u0202": "A",
213 "\u1EA2": "A",
214 "\u1EA0": "A",
215 "\u1EA8": "A",
216 "\u1EAA": "A",
217 "\u1EAC": "A",
218 "\xC7": "C",
219 "\u1E08": "C",
220 "\xC8": "E",
221 "\xC9": "E",
222 "\xCA": "E",
223 "\xCB": "E",
224 "\u1EBE": "E",
225 "\u1E16": "E",
226 "\u1EC0": "E",
227 "\u1E14": "E",
228 "\u1E1C": "E",
229 "\u0206": "E",
230 "\u1EBA": "E",
231 "\u1EBC": "E",
232 "\u1EB8": "E",
233 "\u1EC2": "E",
234 "\u1EC4": "E",
235 "\u1EC6": "E",
236 "\xCC": "I",
237 "\xCD": "I",
238 "\xCE": "I",
239 "\xCF": "I",
240 "\u1E2E": "I",
241 "\u020A": "I",
242 "\u1EC8": "I",
243 "\u1ECA": "I",
244 "\xD0": "D",
245 "\xD1": "N",
246 "\xD2": "O",
247 "\xD3": "O",
248 "\xD4": "O",
249 "\xD5": "O",
250 "\xD6": "O",
251 "\xD8": "O",
252 "\u1ED0": "O",
253 "\u1E4C": "O",
254 "\u1E52": "O",
255 "\u020E": "O",
256 "\u1ECE": "O",
257 "\u1ECC": "O",
258 "\u1ED4": "O",
259 "\u1ED6": "O",
260 "\u1ED8": "O",
261 "\u1EDC": "O",
262 "\u1EDE": "O",
263 "\u1EE0": "O",
264 "\u1EDA": "O",
265 "\u1EE2": "O",
266 "\xD9": "U",
267 "\xDA": "U",
268 "\xDB": "U",
269 "\xDC": "U",
270 "\u1EE6": "U",
271 "\u1EE4": "U",
272 "\u1EEC": "U",
273 "\u1EEE": "U",
274 "\u1EF0": "U",
275 "\xDD": "Y",
276 "\xE0": "a",
277 "\xE1": "a",
278 "\xE2": "a",
279 "\xE3": "a",
280 "\xE4": "a",
281 "\xE5": "a",
282 "\u1EA5": "a",
283 "\u1EAF": "a",
284 "\u1EB3": "a",
285 "\u1EB5": "a",
286 "\u1EB7": "a",
287 "\xE6": "ae",
288 "\u1EA7": "a",
289 "\u1EB1": "a",
290 "\u0203": "a",
291 "\u1EA3": "a",
292 "\u1EA1": "a",
293 "\u1EA9": "a",
294 "\u1EAB": "a",
295 "\u1EAD": "a",
296 "\xE7": "c",
297 "\u1E09": "c",
298 "\xE8": "e",
299 "\xE9": "e",
300 "\xEA": "e",
301 "\xEB": "e",
302 "\u1EBF": "e",
303 "\u1E17": "e",
304 "\u1EC1": "e",
305 "\u1E15": "e",
306 "\u1E1D": "e",
307 "\u0207": "e",
308 "\u1EBB": "e",
309 "\u1EBD": "e",
310 "\u1EB9": "e",
311 "\u1EC3": "e",
312 "\u1EC5": "e",
313 "\u1EC7": "e",
314 "\xEC": "i",
315 "\xED": "i",
316 "\xEE": "i",
317 "\xEF": "i",
318 "\u1E2F": "i",
319 "\u020B": "i",
320 "\u1EC9": "i",
321 "\u1ECB": "i",
322 "\xF0": "d",
323 "\xF1": "n",
324 "\xF2": "o",
325 "\xF3": "o",
326 "\xF4": "o",
327 "\xF5": "o",
328 "\xF6": "o",
329 "\xF8": "o",
330 "\u1ED1": "o",
331 "\u1E4D": "o",
332 "\u1E53": "o",
333 "\u020F": "o",
334 "\u1ECF": "o",
335 "\u1ECD": "o",
336 "\u1ED5": "o",
337 "\u1ED7": "o",
338 "\u1ED9": "o",
339 "\u1EDD": "o",
340 "\u1EDF": "o",
341 "\u1EE1": "o",
342 "\u1EDB": "o",
343 "\u1EE3": "o",
344 "\xF9": "u",
345 "\xFA": "u",
346 "\xFB": "u",
347 "\xFC": "u",
348 "\u1EE7": "u",
349 "\u1EE5": "u",
350 "\u1EED": "u",
351 "\u1EEF": "u",
352 "\u1EF1": "u",
353 "\xFD": "y",
354 "\xFF": "y",
355 "\u0100": "A",
356 "\u0101": "a",
357 "\u0102": "A",
358 "\u0103": "a",
359 "\u0104": "A",
360 "\u0105": "a",
361 "\u0106": "C",
362 "\u0107": "c",
363 "\u0108": "C",
364 "\u0109": "c",
365 "\u010A": "C",
366 "\u010B": "c",
367 "\u010C": "C",
368 "\u010D": "c",
369 "C\u0306": "C",
370 "c\u0306": "c",
371 "\u010E": "D",
372 "\u010F": "d",
373 "\u0110": "D",
374 "\u0111": "d",
375 "\u0112": "E",
376 "\u0113": "e",
377 "\u0114": "E",
378 "\u0115": "e",
379 "\u0116": "E",
380 "\u0117": "e",
381 "\u0118": "E",
382 "\u0119": "e",
383 "\u011A": "E",
384 "\u011B": "e",
385 "\u011C": "G",
386 "\u01F4": "G",
387 "\u011D": "g",
388 "\u01F5": "g",
389 "\u011E": "G",
390 "\u011F": "g",
391 "\u0120": "G",
392 "\u0121": "g",
393 "\u0122": "G",
394 "\u0123": "g",
395 "\u0124": "H",
396 "\u0125": "h",
397 "\u0126": "H",
398 "\u0127": "h",
399 "\u1E2A": "H",
400 "\u1E2B": "h",
401 "\u0128": "I",
402 "\u0129": "i",
403 "\u012A": "I",
404 "\u012B": "i",
405 "\u012C": "I",
406 "\u012D": "i",
407 "\u012E": "I",
408 "\u012F": "i",
409 "\u0130": "I",
410 "\u0131": "i",
411 "\u0132": "IJ",
412 "\u0133": "ij",
413 "\u0134": "J",
414 "\u0135": "j",
415 "\u0136": "K",
416 "\u0137": "k",
417 "\u1E30": "K",
418 "\u1E31": "k",
419 "K\u0306": "K",
420 "k\u0306": "k",
421 "\u0139": "L",
422 "\u013A": "l",
423 "\u013B": "L",
424 "\u013C": "l",
425 "\u013D": "L",
426 "\u013E": "l",
427 "\u013F": "L",
428 "\u0140": "l",
429 "\u0141": "l",
430 "\u0142": "l",
431 "\u1E3E": "M",
432 "\u1E3F": "m",
433 "M\u0306": "M",
434 "m\u0306": "m",
435 "\u0143": "N",
436 "\u0144": "n",
437 "\u0145": "N",
438 "\u0146": "n",
439 "\u0147": "N",
440 "\u0148": "n",
441 "\u0149": "n",
442 "N\u0306": "N",
443 "n\u0306": "n",
444 "\u014C": "O",
445 "\u014D": "o",
446 "\u014E": "O",
447 "\u014F": "o",
448 "\u0150": "O",
449 "\u0151": "o",
450 "\u0152": "OE",
451 "\u0153": "oe",
452 "P\u0306": "P",
453 "p\u0306": "p",
454 "\u0154": "R",
455 "\u0155": "r",
456 "\u0156": "R",
457 "\u0157": "r",
458 "\u0158": "R",
459 "\u0159": "r",
460 "R\u0306": "R",
461 "r\u0306": "r",
462 "\u0212": "R",
463 "\u0213": "r",
464 "\u015A": "S",
465 "\u015B": "s",
466 "\u015C": "S",
467 "\u015D": "s",
468 "\u015E": "S",
469 "\u0218": "S",
470 "\u0219": "s",
471 "\u015F": "s",
472 "\u0160": "S",
473 "\u0161": "s",
474 "\u0162": "T",
475 "\u0163": "t",
476 "\u021B": "t",
477 "\u021A": "T",
478 "\u0164": "T",
479 "\u0165": "t",
480 "\u0166": "T",
481 "\u0167": "t",
482 "T\u0306": "T",
483 "t\u0306": "t",
484 "\u0168": "U",
485 "\u0169": "u",
486 "\u016A": "U",
487 "\u016B": "u",
488 "\u016C": "U",
489 "\u016D": "u",
490 "\u016E": "U",
491 "\u016F": "u",
492 "\u0170": "U",
493 "\u0171": "u",
494 "\u0172": "U",
495 "\u0173": "u",
496 "\u0216": "U",
497 "\u0217": "u",
498 "V\u0306": "V",
499 "v\u0306": "v",
500 "\u0174": "W",
501 "\u0175": "w",
502 "\u1E82": "W",
503 "\u1E83": "w",
504 "X\u0306": "X",
505 "x\u0306": "x",
506 "\u0176": "Y",
507 "\u0177": "y",
508 "\u0178": "Y",
509 "Y\u0306": "Y",
510 "y\u0306": "y",
511 "\u0179": "Z",
512 "\u017A": "z",
513 "\u017B": "Z",
514 "\u017C": "z",
515 "\u017D": "Z",
516 "\u017E": "z",
517 "\u017F": "s",
518 "\u0192": "f",
519 "\u01A0": "O",
520 "\u01A1": "o",
521 "\u01AF": "U",
522 "\u01B0": "u",
523 "\u01CD": "A",
524 "\u01CE": "a",
525 "\u01CF": "I",
526 "\u01D0": "i",
527 "\u01D1": "O",
528 "\u01D2": "o",
529 "\u01D3": "U",
530 "\u01D4": "u",
531 "\u01D5": "U",
532 "\u01D6": "u",
533 "\u01D7": "U",
534 "\u01D8": "u",
535 "\u01D9": "U",
536 "\u01DA": "u",
537 "\u01DB": "U",
538 "\u01DC": "u",
539 "\u1EE8": "U",
540 "\u1EE9": "u",
541 "\u1E78": "U",
542 "\u1E79": "u",
543 "\u01FA": "A",
544 "\u01FB": "a",
545 "\u01FC": "AE",
546 "\u01FD": "ae",
547 "\u01FE": "O",
548 "\u01FF": "o",
549 "\xDE": "TH",
550 "\xFE": "th",
551 "\u1E54": "P",
552 "\u1E55": "p",
553 "\u1E64": "S",
554 "\u1E65": "s",
555 "X\u0301": "X",
556 "x\u0301": "x",
557 "\u0403": "\u0413",
558 "\u0453": "\u0433",
559 "\u040C": "\u041A",
560 "\u045C": "\u043A",
561 "A\u030B": "A",
562 "a\u030B": "a",
563 "E\u030B": "E",
564 "e\u030B": "e",
565 "I\u030B": "I",
566 "i\u030B": "i",
567 "\u01F8": "N",
568 "\u01F9": "n",
569 "\u1ED2": "O",
570 "\u1ED3": "o",
571 "\u1E50": "O",
572 "\u1E51": "o",
573 "\u1EEA": "U",
574 "\u1EEB": "u",
575 "\u1E80": "W",
576 "\u1E81": "w",
577 "\u1EF2": "Y",
578 "\u1EF3": "y",
579 "\u0200": "A",
580 "\u0201": "a",
581 "\u0204": "E",
582 "\u0205": "e",
583 "\u0208": "I",
584 "\u0209": "i",
585 "\u020C": "O",
586 "\u020D": "o",
587 "\u0210": "R",
588 "\u0211": "r",
589 "\u0214": "U",
590 "\u0215": "u",
591 "B\u030C": "B",
592 "b\u030C": "b",
593 "\u010C\u0323": "C",
594 "\u010D\u0323": "c",
595 "\xCA\u030C": "E",
596 "\xEA\u030C": "e",
597 "F\u030C": "F",
598 "f\u030C": "f",
599 "\u01E6": "G",
600 "\u01E7": "g",
601 "\u021E": "H",
602 "\u021F": "h",
603 "J\u030C": "J",
604 "\u01F0": "j",
605 "\u01E8": "K",
606 "\u01E9": "k",
607 "M\u030C": "M",
608 "m\u030C": "m",
609 "P\u030C": "P",
610 "p\u030C": "p",
611 "Q\u030C": "Q",
612 "q\u030C": "q",
613 "\u0158\u0329": "R",
614 "\u0159\u0329": "r",
615 "\u1E66": "S",
616 "\u1E67": "s",
617 "V\u030C": "V",
618 "v\u030C": "v",
619 "W\u030C": "W",
620 "w\u030C": "w",
621 "X\u030C": "X",
622 "x\u030C": "x",
623 "Y\u030C": "Y",
624 "y\u030C": "y",
625 "A\u0327": "A",
626 "a\u0327": "a",
627 "B\u0327": "B",
628 "b\u0327": "b",
629 "\u1E10": "D",
630 "\u1E11": "d",
631 "\u0228": "E",
632 "\u0229": "e",
633 "\u0190\u0327": "E",
634 "\u025B\u0327": "e",
635 "\u1E28": "H",
636 "\u1E29": "h",
637 "I\u0327": "I",
638 "i\u0327": "i",
639 "\u0197\u0327": "I",
640 "\u0268\u0327": "i",
641 "M\u0327": "M",
642 "m\u0327": "m",
643 "O\u0327": "O",
644 "o\u0327": "o",
645 "Q\u0327": "Q",
646 "q\u0327": "q",
647 "U\u0327": "U",
648 "u\u0327": "u",
649 "X\u0327": "X",
650 "x\u0327": "x",
651 "Z\u0327": "Z",
652 "z\u0327": "z",
653 "\u0439": "\u0438",
654 "\u0419": "\u0418",
655 "\u0451": "\u0435",
656 "\u0401": "\u0415"
657 };
658 var chars = Object.keys(characterMap).join("|");
659 var allAccents = new RegExp(chars, "g");
660 var firstAccent = new RegExp(chars, "");
661 function matcher(match2) {
662 return characterMap[match2];
663 }
664 var removeAccents3 = function(string) {
665 return string.replace(allAccents, matcher);
666 };
667 var hasAccents = function(string) {
668 return !!string.match(firstAccent);
669 };
670 module.exports = removeAccents3;
671 module.exports.has = hasAccents;
672 module.exports.remove = removeAccents3;
673 }
674 });
675
676 // node_modules/fast-deep-equal/es6/index.js
677 var require_es6 = __commonJS({
678 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
679 "use strict";
680 module.exports = function equal(a2, b2) {
681 if (a2 === b2) return true;
682 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
683 if (a2.constructor !== b2.constructor) return false;
684 var length, i2, keys;
685 if (Array.isArray(a2)) {
686 length = a2.length;
687 if (length != b2.length) return false;
688 for (i2 = length; i2-- !== 0; )
689 if (!equal(a2[i2], b2[i2])) return false;
690 return true;
691 }
692 if (a2 instanceof Map && b2 instanceof Map) {
693 if (a2.size !== b2.size) return false;
694 for (i2 of a2.entries())
695 if (!b2.has(i2[0])) return false;
696 for (i2 of a2.entries())
697 if (!equal(i2[1], b2.get(i2[0]))) return false;
698 return true;
699 }
700 if (a2 instanceof Set && b2 instanceof Set) {
701 if (a2.size !== b2.size) return false;
702 for (i2 of a2.entries())
703 if (!b2.has(i2[0])) return false;
704 return true;
705 }
706 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
707 length = a2.length;
708 if (length != b2.length) return false;
709 for (i2 = length; i2-- !== 0; )
710 if (a2[i2] !== b2[i2]) return false;
711 return true;
712 }
713 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
714 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
715 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
716 keys = Object.keys(a2);
717 length = keys.length;
718 if (length !== Object.keys(b2).length) return false;
719 for (i2 = length; i2-- !== 0; )
720 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
721 for (i2 = length; i2-- !== 0; ) {
722 var key = keys[i2];
723 if (!equal(a2[key], b2[key])) return false;
724 }
725 return true;
726 }
727 return a2 !== a2 && b2 !== b2;
728 };
729 }
730 });
731
732 // package-external:@wordpress/date
733 var require_date = __commonJS({
734 "package-external:@wordpress/date"(exports, module) {
735 module.exports = window.wp.date;
736 }
737 });
738
739 // package-external:@wordpress/warning
740 var require_warning = __commonJS({
741 "package-external:@wordpress/warning"(exports, module) {
742 module.exports = window.wp.warning;
743 }
744 });
745
746 // package-external:@wordpress/deprecated
747 var require_deprecated = __commonJS({
748 "package-external:@wordpress/deprecated"(exports, module) {
749 module.exports = window.wp.deprecated;
750 }
751 });
752
753 // package-external:@wordpress/editor
754 var require_editor = __commonJS({
755 "package-external:@wordpress/editor"(exports, module) {
756 module.exports = window.wp.editor;
757 }
758 });
759
760 // package-external:@wordpress/patterns
761 var require_patterns = __commonJS({
762 "package-external:@wordpress/patterns"(exports, module) {
763 module.exports = window.wp.patterns;
764 }
765 });
766
767 // package-external:@wordpress/block-editor
768 var require_block_editor = __commonJS({
769 "package-external:@wordpress/block-editor"(exports, module) {
770 module.exports = window.wp.blockEditor;
771 }
772 });
773
774 // routes/pattern-list/stage.tsx
775 import {
776 useParams,
777 useNavigate,
778 useSearch,
779 Link,
780 useInvalidate
781 } from "@wordpress/route";
782
783 // node_modules/dequal/dist/index.mjs
784 var has = Object.prototype.hasOwnProperty;
785 function find(iter, tar, key) {
786 for (key of iter.keys()) {
787 if (dequal(key, tar)) return key;
788 }
789 }
790 function dequal(foo, bar) {
791 var ctor, len, tmp;
792 if (foo === bar) return true;
793 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
794 if (ctor === Date) return foo.getTime() === bar.getTime();
795 if (ctor === RegExp) return foo.toString() === bar.toString();
796 if (ctor === Array) {
797 if ((len = foo.length) === bar.length) {
798 while (len-- && dequal(foo[len], bar[len])) ;
799 }
800 return len === -1;
801 }
802 if (ctor === Set) {
803 if (foo.size !== bar.size) {
804 return false;
805 }
806 for (len of foo) {
807 tmp = len;
808 if (tmp && typeof tmp === "object") {
809 tmp = find(bar, tmp);
810 if (!tmp) return false;
811 }
812 if (!bar.has(tmp)) return false;
813 }
814 return true;
815 }
816 if (ctor === Map) {
817 if (foo.size !== bar.size) {
818 return false;
819 }
820 for (len of foo) {
821 tmp = len[0];
822 if (tmp && typeof tmp === "object") {
823 tmp = find(bar, tmp);
824 if (!tmp) return false;
825 }
826 if (!dequal(len[1], bar.get(tmp))) {
827 return false;
828 }
829 }
830 return true;
831 }
832 if (ctor === ArrayBuffer) {
833 foo = new Uint8Array(foo);
834 bar = new Uint8Array(bar);
835 } else if (ctor === DataView) {
836 if ((len = foo.byteLength) === bar.byteLength) {
837 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
838 }
839 return len === -1;
840 }
841 if (ArrayBuffer.isView(foo)) {
842 if ((len = foo.byteLength) === bar.byteLength) {
843 while (len-- && foo[len] === bar[len]) ;
844 }
845 return len === -1;
846 }
847 if (!ctor || typeof foo === "object") {
848 len = 0;
849 for (ctor in foo) {
850 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
851 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
852 }
853 return Object.keys(bar).length === len;
854 }
855 }
856 return foo !== foo && bar !== bar;
857 }
858
859 // packages/views/build-module/use-view.mjs
860 var import_element = __toESM(require_element(), 1);
861 var import_data = __toESM(require_data(), 1);
862 var import_preferences = __toESM(require_preferences(), 1);
863
864 // packages/views/build-module/preference-keys.mjs
865 function generatePreferenceKey(kind, name, slug) {
866 return `dataviews-${kind}-${name}-${slug}`;
867 }
868
869 // packages/views/build-module/filter-utils.mjs
870 var SCALAR_VALUES = [
871 "titleField",
872 "mediaField",
873 "descriptionField",
874 "showTitle",
875 "showMedia",
876 "showDescription",
877 "showLevels",
878 "infiniteScrollEnabled"
879 ];
880 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
881 if (!activeViewOverrides) {
882 return view;
883 }
884 let result = view;
885 for (const key of SCALAR_VALUES) {
886 if (key in activeViewOverrides) {
887 result = { ...result, [key]: activeViewOverrides[key] };
888 }
889 }
890 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
891 const activeFields = new Set(
892 activeViewOverrides.filters.map((f2) => f2.field)
893 );
894 const preserved = (view.filters ?? []).filter(
895 (f2) => !activeFields.has(f2.field)
896 );
897 result = {
898 ...result,
899 filters: [...preserved, ...activeViewOverrides.filters]
900 };
901 }
902 if (activeViewOverrides.sort) {
903 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
904 if (isDefaultSort) {
905 result = {
906 ...result,
907 sort: activeViewOverrides.sort
908 };
909 }
910 }
911 if (activeViewOverrides.layout) {
912 result = {
913 ...result,
914 layout: {
915 ...result.layout,
916 ...activeViewOverrides.layout
917 }
918 };
919 }
920 if (activeViewOverrides.groupBy) {
921 result = {
922 ...result,
923 groupBy: activeViewOverrides.groupBy
924 };
925 }
926 return result;
927 }
928 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
929 if (!activeViewOverrides) {
930 return view;
931 }
932 let result = view;
933 for (const key of SCALAR_VALUES) {
934 if (key in activeViewOverrides) {
935 const { [key]: _, ...rest } = result;
936 result = rest;
937 }
938 }
939 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
940 const activeFields = new Set(
941 activeViewOverrides.filters.map((f2) => f2.field)
942 );
943 result = {
944 ...result,
945 filters: (view.filters ?? []).filter(
946 (f2) => !activeFields.has(f2.field)
947 )
948 };
949 }
950 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
951 result = {
952 ...result,
953 sort: defaultView?.sort
954 };
955 }
956 if (activeViewOverrides.layout && "layout" in result && result.layout) {
957 const layout = { ...result.layout };
958 for (const key of Object.keys(activeViewOverrides.layout)) {
959 delete layout[key];
960 }
961 result = {
962 ...result,
963 layout: Object.keys(layout).length > 0 ? layout : void 0
964 };
965 }
966 if (activeViewOverrides.groupBy && "groupBy" in result) {
967 const { groupBy: _, ...rest } = result;
968 result = rest;
969 }
970 return result;
971 }
972
973 // packages/views/build-module/use-view.mjs
974 function omit(obj, keys) {
975 const result = { ...obj };
976 for (const key of keys) {
977 delete result[key];
978 }
979 return result;
980 }
981 function useView(config) {
982 const {
983 kind,
984 name,
985 slug,
986 defaultView,
987 activeViewOverrides,
988 queryParams,
989 onChangeQueryParams
990 } = config;
991 const preferenceKey = generatePreferenceKey(kind, name, slug);
992 const persistedView = (0, import_data.useSelect)(
993 (select2) => {
994 return select2(import_preferences.store).get(
995 "core/views",
996 preferenceKey
997 );
998 },
999 [preferenceKey]
1000 );
1001 const { set: set2 } = (0, import_data.useDispatch)(import_preferences.store);
1002 const baseView = (0, import_element.useMemo)(
1003 () => persistedView ?? defaultView ?? {},
1004 [persistedView, defaultView]
1005 );
1006 const page = Number(queryParams?.page ?? baseView.page ?? 1);
1007 const search = queryParams?.search ?? baseView.search ?? "";
1008 const combinedOverrides = (0, import_element.useMemo)(() => {
1009 const rawDefaults = config.defaultLayouts?.[baseView.type];
1010 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
1011 return { ...layoutTypeDefaults, ...activeViewOverrides };
1012 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
1013 const view = (0, import_element.useMemo)(() => {
1014 return mergeActiveViewOverrides(
1015 {
1016 ...baseView,
1017 page,
1018 search
1019 },
1020 combinedOverrides,
1021 defaultView
1022 );
1023 }, [baseView, page, search, combinedOverrides, defaultView]);
1024 const isModified = !!persistedView;
1025 const updateView = (0, import_element.useCallback)(
1026 (newView) => {
1027 const urlParams = {
1028 page: newView?.page,
1029 search: newView?.search
1030 };
1031 const preferenceView = stripActiveViewOverrides(
1032 omit(newView, ["page", "search"]),
1033 combinedOverrides,
1034 defaultView
1035 );
1036 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
1037 onChangeQueryParams(urlParams);
1038 }
1039 const comparableBaseView = stripActiveViewOverrides(
1040 baseView,
1041 combinedOverrides,
1042 defaultView
1043 );
1044 const comparableDefaultView = stripActiveViewOverrides(
1045 defaultView,
1046 combinedOverrides,
1047 defaultView
1048 );
1049 if (!dequal(comparableBaseView, preferenceView)) {
1050 if (dequal(preferenceView, comparableDefaultView)) {
1051 set2("core/views", preferenceKey, void 0);
1052 } else {
1053 set2("core/views", preferenceKey, preferenceView);
1054 }
1055 }
1056 },
1057 [
1058 onChangeQueryParams,
1059 page,
1060 search,
1061 baseView,
1062 defaultView,
1063 combinedOverrides,
1064 set2,
1065 preferenceKey
1066 ]
1067 );
1068 const resetToDefault = (0, import_element.useCallback)(() => {
1069 set2("core/views", preferenceKey, void 0);
1070 }, [preferenceKey, set2]);
1071 return {
1072 view,
1073 isModified,
1074 updateView,
1075 resetToDefault
1076 };
1077 }
1078
1079 // packages/views/build-module/load-view.mjs
1080 var import_data2 = __toESM(require_data(), 1);
1081 var import_preferences2 = __toESM(require_preferences(), 1);
1082
1083 // packages/views/build-module/use-view-config.mjs
1084 var import_data3 = __toESM(require_data(), 1);
1085 var import_core_data = __toESM(require_core_data(), 1);
1086
1087 // packages/views/build-module/lock-unlock.mjs
1088 var import_private_apis = __toESM(require_private_apis(), 1);
1089 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1090 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1091 "@wordpress/views"
1092 );
1093
1094 // node_modules/clsx/dist/clsx.mjs
1095 function r(e2) {
1096 var t2, f2, n2 = "";
1097 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1098 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1099 var o2 = e2.length;
1100 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1101 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1102 return n2;
1103 }
1104 function clsx() {
1105 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1106 return n2;
1107 }
1108 var clsx_default = clsx;
1109
1110 // packages/dataviews/build-module/dataviews/index.mjs
1111 var import_element60 = __toESM(require_element(), 1);
1112 var import_compose12 = __toESM(require_compose(), 1);
1113
1114 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1115 var React2 = __toESM(require_react(), 1);
1116 var UNINITIALIZED = {};
1117 function useRefWithInit(init2, initArg) {
1118 const ref = React2.useRef(UNINITIALIZED);
1119 if (ref.current === UNINITIALIZED) {
1120 ref.current = init2(initArg);
1121 }
1122 return ref;
1123 }
1124
1125 // node_modules/@base-ui/utils/esm/warn.js
1126 var set;
1127 if (true) {
1128 set = /* @__PURE__ */ new Set();
1129 }
1130 function warn(...messages) {
1131 if (true) {
1132 const messageKey = messages.join(" ");
1133 if (!set.has(messageKey)) {
1134 set.add(messageKey);
1135 console.warn(`Base UI: ${messageKey}`);
1136 }
1137 }
1138 }
1139
1140 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1141 var React5 = __toESM(require_react(), 1);
1142
1143 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1144 function useMergedRefs(a2, b2, c2, d2) {
1145 const forkRef = useRefWithInit(createForkRef).current;
1146 if (didChange(forkRef, a2, b2, c2, d2)) {
1147 update(forkRef, [a2, b2, c2, d2]);
1148 }
1149 return forkRef.callback;
1150 }
1151 function useMergedRefsN(refs) {
1152 const forkRef = useRefWithInit(createForkRef).current;
1153 if (didChangeN(forkRef, refs)) {
1154 update(forkRef, refs);
1155 }
1156 return forkRef.callback;
1157 }
1158 function createForkRef() {
1159 return {
1160 callback: null,
1161 cleanup: null,
1162 refs: []
1163 };
1164 }
1165 function didChange(forkRef, a2, b2, c2, d2) {
1166 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1167 }
1168 function didChangeN(forkRef, newRefs) {
1169 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1170 }
1171 function update(forkRef, refs) {
1172 forkRef.refs = refs;
1173 if (refs.every((ref) => ref == null)) {
1174 forkRef.callback = null;
1175 return;
1176 }
1177 forkRef.callback = (instance) => {
1178 if (forkRef.cleanup) {
1179 forkRef.cleanup();
1180 forkRef.cleanup = null;
1181 }
1182 if (instance != null) {
1183 const cleanupCallbacks = Array(refs.length).fill(null);
1184 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1185 const ref = refs[i2];
1186 if (ref == null) {
1187 continue;
1188 }
1189 switch (typeof ref) {
1190 case "function": {
1191 const refCleanup = ref(instance);
1192 if (typeof refCleanup === "function") {
1193 cleanupCallbacks[i2] = refCleanup;
1194 }
1195 break;
1196 }
1197 case "object": {
1198 ref.current = instance;
1199 break;
1200 }
1201 default:
1202 }
1203 }
1204 forkRef.cleanup = () => {
1205 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1206 const ref = refs[i2];
1207 if (ref == null) {
1208 continue;
1209 }
1210 switch (typeof ref) {
1211 case "function": {
1212 const cleanupCallback = cleanupCallbacks[i2];
1213 if (typeof cleanupCallback === "function") {
1214 cleanupCallback();
1215 } else {
1216 ref(null);
1217 }
1218 break;
1219 }
1220 case "object": {
1221 ref.current = null;
1222 break;
1223 }
1224 default:
1225 }
1226 }
1227 };
1228 }
1229 };
1230 }
1231
1232 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1233 var React4 = __toESM(require_react(), 1);
1234
1235 // node_modules/@base-ui/utils/esm/reactVersion.js
1236 var React3 = __toESM(require_react(), 1);
1237 var majorVersion = parseInt(React3.version, 10);
1238 function isReactVersionAtLeast(reactVersionToCheck) {
1239 return majorVersion >= reactVersionToCheck;
1240 }
1241
1242 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1243 function getReactElementRef(element) {
1244 if (!/* @__PURE__ */ React4.isValidElement(element)) {
1245 return null;
1246 }
1247 const reactElement = element;
1248 const propsWithRef = reactElement.props;
1249 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1250 }
1251
1252 // node_modules/@base-ui/utils/esm/mergeObjects.js
1253 function mergeObjects(a2, b2) {
1254 if (a2 && !b2) {
1255 return a2;
1256 }
1257 if (!a2 && b2) {
1258 return b2;
1259 }
1260 if (a2 || b2) {
1261 return {
1262 ...a2,
1263 ...b2
1264 };
1265 }
1266 return void 0;
1267 }
1268
1269 // node_modules/@base-ui/utils/esm/empty.js
1270 var EMPTY_ARRAY = Object.freeze([]);
1271 var EMPTY_OBJECT = Object.freeze({});
1272
1273 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1274 function getStateAttributesProps(state, customMapping) {
1275 const props = {};
1276 for (const key in state) {
1277 const value = state[key];
1278 if (customMapping?.hasOwnProperty(key)) {
1279 const customProps = customMapping[key](value);
1280 if (customProps != null) {
1281 Object.assign(props, customProps);
1282 }
1283 continue;
1284 }
1285 if (value === true) {
1286 props[`data-${key.toLowerCase()}`] = "";
1287 } else if (value) {
1288 props[`data-${key.toLowerCase()}`] = value.toString();
1289 }
1290 }
1291 return props;
1292 }
1293
1294 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1295 function resolveClassName(className, state) {
1296 return typeof className === "function" ? className(state) : className;
1297 }
1298
1299 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1300 function resolveStyle(style, state) {
1301 return typeof style === "function" ? style(state) : style;
1302 }
1303
1304 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1305 var EMPTY_PROPS = {};
1306 function mergeProps(a2, b2, c2, d2, e2) {
1307 if (!c2 && !d2 && !e2 && !a2) {
1308 return createInitialMergedProps(b2);
1309 }
1310 let merged = createInitialMergedProps(a2);
1311 if (b2) {
1312 merged = mergeInto(merged, b2);
1313 }
1314 if (c2) {
1315 merged = mergeInto(merged, c2);
1316 }
1317 if (d2) {
1318 merged = mergeInto(merged, d2);
1319 }
1320 if (e2) {
1321 merged = mergeInto(merged, e2);
1322 }
1323 return merged;
1324 }
1325 function mergePropsN(props) {
1326 if (props.length === 0) {
1327 return EMPTY_PROPS;
1328 }
1329 if (props.length === 1) {
1330 return createInitialMergedProps(props[0]);
1331 }
1332 let merged = createInitialMergedProps(props[0]);
1333 for (let i2 = 1; i2 < props.length; i2 += 1) {
1334 merged = mergeInto(merged, props[i2]);
1335 }
1336 return merged;
1337 }
1338 function createInitialMergedProps(inputProps) {
1339 if (isPropsGetter(inputProps)) {
1340 return {
1341 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1342 };
1343 }
1344 return copyInitialProps(inputProps);
1345 }
1346 function mergeInto(merged, inputProps) {
1347 if (isPropsGetter(inputProps)) {
1348 return resolvePropsGetter(inputProps, merged);
1349 }
1350 return mutablyMergeInto(merged, inputProps);
1351 }
1352 function copyInitialProps(inputProps) {
1353 const copiedProps = {
1354 ...inputProps
1355 };
1356 for (const propName in copiedProps) {
1357 const propValue = copiedProps[propName];
1358 if (isEventHandler(propName, propValue)) {
1359 copiedProps[propName] = wrapEventHandler(propValue);
1360 }
1361 }
1362 return copiedProps;
1363 }
1364 function mutablyMergeInto(mergedProps, externalProps) {
1365 if (!externalProps) {
1366 return mergedProps;
1367 }
1368 for (const propName in externalProps) {
1369 const externalPropValue = externalProps[propName];
1370 switch (propName) {
1371 case "style": {
1372 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1373 break;
1374 }
1375 case "className": {
1376 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1377 break;
1378 }
1379 default: {
1380 if (isEventHandler(propName, externalPropValue)) {
1381 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1382 } else {
1383 mergedProps[propName] = externalPropValue;
1384 }
1385 }
1386 }
1387 }
1388 return mergedProps;
1389 }
1390 function isEventHandler(key, value) {
1391 const code0 = key.charCodeAt(0);
1392 const code1 = key.charCodeAt(1);
1393 const code2 = key.charCodeAt(2);
1394 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1395 }
1396 function isPropsGetter(inputProps) {
1397 return typeof inputProps === "function";
1398 }
1399 function resolvePropsGetter(inputProps, previousProps) {
1400 if (isPropsGetter(inputProps)) {
1401 return inputProps(previousProps);
1402 }
1403 return inputProps ?? EMPTY_PROPS;
1404 }
1405 function mergeEventHandlers(ourHandler, theirHandler) {
1406 if (!theirHandler) {
1407 return ourHandler;
1408 }
1409 if (!ourHandler) {
1410 return wrapEventHandler(theirHandler);
1411 }
1412 return (...args) => {
1413 const event = args[0];
1414 if (isSyntheticEvent(event)) {
1415 const baseUIEvent = event;
1416 makeEventPreventable(baseUIEvent);
1417 const result2 = theirHandler(...args);
1418 if (!baseUIEvent.baseUIHandlerPrevented) {
1419 ourHandler?.(...args);
1420 }
1421 return result2;
1422 }
1423 const result = theirHandler(...args);
1424 ourHandler?.(...args);
1425 return result;
1426 };
1427 }
1428 function wrapEventHandler(handler) {
1429 if (!handler) {
1430 return handler;
1431 }
1432 return (...args) => {
1433 const event = args[0];
1434 if (isSyntheticEvent(event)) {
1435 makeEventPreventable(event);
1436 }
1437 return handler(...args);
1438 };
1439 }
1440 function makeEventPreventable(event) {
1441 event.preventBaseUIHandler = () => {
1442 event.baseUIHandlerPrevented = true;
1443 };
1444 return event;
1445 }
1446 function mergeClassNames(ourClassName, theirClassName) {
1447 if (theirClassName) {
1448 if (ourClassName) {
1449 return theirClassName + " " + ourClassName;
1450 }
1451 return theirClassName;
1452 }
1453 return ourClassName;
1454 }
1455 function isSyntheticEvent(event) {
1456 return event != null && typeof event === "object" && "nativeEvent" in event;
1457 }
1458
1459 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1460 var import_react = __toESM(require_react(), 1);
1461 function useRenderElement(element, componentProps, params = {}) {
1462 const renderProp = componentProps.render;
1463 const outProps = useRenderElementProps(componentProps, params);
1464 if (params.enabled === false) {
1465 return null;
1466 }
1467 const state = params.state ?? EMPTY_OBJECT;
1468 return evaluateRenderProp(element, renderProp, outProps, state);
1469 }
1470 function useRenderElementProps(componentProps, params = {}) {
1471 const {
1472 className: classNameProp,
1473 style: styleProp,
1474 render: renderProp
1475 } = componentProps;
1476 const {
1477 state = EMPTY_OBJECT,
1478 ref,
1479 props,
1480 stateAttributesMapping,
1481 enabled = true
1482 } = params;
1483 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1484 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1485 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
1486 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1487 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1488 if (typeof document !== "undefined") {
1489 if (!enabled) {
1490 useMergedRefs(null, null);
1491 } else if (Array.isArray(ref)) {
1492 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1493 } else {
1494 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1495 }
1496 }
1497 if (!enabled) {
1498 return EMPTY_OBJECT;
1499 }
1500 if (className !== void 0) {
1501 outProps.className = mergeClassNames(outProps.className, className);
1502 }
1503 if (style !== void 0) {
1504 outProps.style = mergeObjects(outProps.style, style);
1505 }
1506 return outProps;
1507 }
1508 function resolveRenderFunctionProps(props) {
1509 if (Array.isArray(props)) {
1510 return mergePropsN(props);
1511 }
1512 return mergeProps(void 0, props);
1513 }
1514 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1515 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1516 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1517 function evaluateRenderProp(element, render4, props, state) {
1518 if (render4) {
1519 if (typeof render4 === "function") {
1520 if (true) {
1521 warnIfRenderPropLooksLikeComponent(render4);
1522 }
1523 return render4(props, state);
1524 }
1525 const mergedProps = mergeProps(props, render4.props);
1526 mergedProps.ref = props.ref;
1527 let newElement = render4;
1528 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1529 const children = React5.Children.toArray(render4);
1530 newElement = children[0];
1531 }
1532 if (true) {
1533 if (!/* @__PURE__ */ React5.isValidElement(newElement)) {
1534 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"));
1535 }
1536 }
1537 return /* @__PURE__ */ React5.cloneElement(newElement, mergedProps);
1538 }
1539 if (element) {
1540 if (typeof element === "string") {
1541 return renderTag(element, props);
1542 }
1543 }
1544 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1545 }
1546 function warnIfRenderPropLooksLikeComponent(renderFn) {
1547 const functionName = renderFn.name;
1548 if (functionName.length === 0) {
1549 return;
1550 }
1551 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1552 return;
1553 }
1554 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1555 return;
1556 }
1557 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");
1558 }
1559 function renderTag(Tag, props) {
1560 if (Tag === "button") {
1561 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1562 type: "button",
1563 ...props,
1564 key: props.key
1565 });
1566 }
1567 if (Tag === "img") {
1568 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1569 alt: "",
1570 ...props,
1571 key: props.key
1572 });
1573 }
1574 return /* @__PURE__ */ React5.createElement(Tag, props);
1575 }
1576
1577 // node_modules/@base-ui/react/esm/use-render/useRender.js
1578 function useRender(params) {
1579 return useRenderElement(params.defaultTagName ?? "div", params, params);
1580 }
1581
1582 // packages/ui/build-module/text/text.mjs
1583 var import_element2 = __toESM(require_element(), 1);
1584 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
1585 function getRuntime() {
1586 const globalScope = globalThis;
1587 if (globalScope.__wpStyleRuntime) {
1588 return globalScope.__wpStyleRuntime;
1589 }
1590 globalScope.__wpStyleRuntime = {
1591 documents: /* @__PURE__ */ new Map(),
1592 styles: /* @__PURE__ */ new Map(),
1593 injectedStyles: /* @__PURE__ */ new WeakMap()
1594 };
1595 if (typeof document !== "undefined") {
1596 registerDocument(document);
1597 }
1598 return globalScope.__wpStyleRuntime;
1599 }
1600 function documentContainsStyleHash(targetDocument, hash) {
1601 if (!targetDocument.head) {
1602 return false;
1603 }
1604 for (const style of targetDocument.head.querySelectorAll(
1605 `style[${STYLE_HASH_ATTRIBUTE}]`
1606 )) {
1607 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
1608 return true;
1609 }
1610 }
1611 return false;
1612 }
1613 function injectStyle(targetDocument, hash, css) {
1614 if (!targetDocument.head) {
1615 return;
1616 }
1617 const runtime = getRuntime();
1618 let injectedStyles = runtime.injectedStyles.get(targetDocument);
1619 if (!injectedStyles) {
1620 injectedStyles = /* @__PURE__ */ new Set();
1621 runtime.injectedStyles.set(targetDocument, injectedStyles);
1622 }
1623 if (injectedStyles.has(hash)) {
1624 return;
1625 }
1626 if (documentContainsStyleHash(targetDocument, hash)) {
1627 injectedStyles.add(hash);
1628 return;
1629 }
1630 const style = targetDocument.createElement("style");
1631 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
1632 style.appendChild(targetDocument.createTextNode(css));
1633 targetDocument.head.appendChild(style);
1634 injectedStyles.add(hash);
1635 }
1636 function registerDocument(targetDocument) {
1637 const runtime = getRuntime();
1638 runtime.documents.set(
1639 targetDocument,
1640 (runtime.documents.get(targetDocument) ?? 0) + 1
1641 );
1642 for (const [hash, css] of runtime.styles) {
1643 injectStyle(targetDocument, hash, css);
1644 }
1645 return () => {
1646 const count = runtime.documents.get(targetDocument);
1647 if (count === void 0) {
1648 return;
1649 }
1650 if (count <= 1) {
1651 runtime.documents.delete(targetDocument);
1652 return;
1653 }
1654 runtime.documents.set(targetDocument, count - 1);
1655 };
1656 }
1657 function registerStyle(hash, css) {
1658 const runtime = getRuntime();
1659 runtime.styles.set(hash, css);
1660 for (const targetDocument of runtime.documents.keys()) {
1661 injectStyle(targetDocument, hash, css);
1662 }
1663 }
1664 if (typeof process === "undefined" || true) {
1665 registerStyle("4130d64bea", '@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);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);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);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);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);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-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-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-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-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)}}');
1666 }
1667 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" };
1668 if (typeof process === "undefined" || true) {
1669 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)}");
1670 }
1671 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" };
1672 var Text = (0, import_element2.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
1673 const element = useRender({
1674 render: render4,
1675 defaultTagName: "span",
1676 ref,
1677 props: mergeProps(props, {
1678 className: clsx_default(
1679 style_default.text,
1680 global_css_defense_default.heading,
1681 global_css_defense_default.p,
1682 style_default[variant],
1683 className
1684 )
1685 })
1686 });
1687 return element;
1688 });
1689
1690 // packages/icons/build-module/library/arrow-down.mjs
1691 var import_primitives = __toESM(require_primitives(), 1);
1692 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1693 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
1694
1695 // packages/icons/build-module/library/arrow-left.mjs
1696 var import_primitives2 = __toESM(require_primitives(), 1);
1697 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1698 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
1699
1700 // packages/icons/build-module/library/arrow-right.mjs
1701 var import_primitives3 = __toESM(require_primitives(), 1);
1702 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1703 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
1704
1705 // packages/icons/build-module/library/arrow-up.mjs
1706 var import_primitives4 = __toESM(require_primitives(), 1);
1707 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1708 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
1709
1710 // packages/icons/build-module/library/block-table.mjs
1711 var import_primitives5 = __toESM(require_primitives(), 1);
1712 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1713 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "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" }) });
1714
1715 // packages/icons/build-module/library/category.mjs
1716 var import_primitives6 = __toESM(require_primitives(), 1);
1717 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1718 var category_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { 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" }) });
1719
1720 // packages/icons/build-module/library/check.mjs
1721 var import_primitives7 = __toESM(require_primitives(), 1);
1722 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1723 var check_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
1724
1725 // packages/icons/build-module/library/close-small.mjs
1726 var import_primitives8 = __toESM(require_primitives(), 1);
1727 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
1728 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "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" }) });
1729
1730 // packages/icons/build-module/library/cog.mjs
1731 var import_primitives9 = __toESM(require_primitives(), 1);
1732 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
1733 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { 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" }) });
1734
1735 // packages/icons/build-module/library/envelope.mjs
1736 var import_primitives10 = __toESM(require_primitives(), 1);
1737 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1738 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { 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" }) });
1739
1740 // packages/icons/build-module/library/error.mjs
1741 var import_primitives11 = __toESM(require_primitives(), 1);
1742 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1743 var error_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
1744
1745 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
1746 var import_primitives12 = __toESM(require_primitives(), 1);
1747 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1748 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { 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" }) });
1749
1750 // packages/icons/build-module/library/format-list-bullets.mjs
1751 var import_primitives13 = __toESM(require_primitives(), 1);
1752 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1753 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { 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" }) });
1754
1755 // packages/icons/build-module/library/funnel.mjs
1756 var import_primitives14 = __toESM(require_primitives(), 1);
1757 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1758 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
1759
1760 // packages/icons/build-module/library/link.mjs
1761 var import_primitives15 = __toESM(require_primitives(), 1);
1762 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1763 var link_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { 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" }) });
1764
1765 // packages/icons/build-module/library/mobile.mjs
1766 var import_primitives16 = __toESM(require_primitives(), 1);
1767 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1768 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "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" }) });
1769
1770 // packages/icons/build-module/library/more-vertical.mjs
1771 var import_primitives17 = __toESM(require_primitives(), 1);
1772 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1773 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
1774
1775 // packages/icons/build-module/library/next.mjs
1776 var import_primitives18 = __toESM(require_primitives(), 1);
1777 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1778 var next_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "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" }) });
1779
1780 // packages/icons/build-module/library/previous.mjs
1781 var import_primitives19 = __toESM(require_primitives(), 1);
1782 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1783 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "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" }) });
1784
1785 // packages/icons/build-module/library/scheduled.mjs
1786 var import_primitives20 = __toESM(require_primitives(), 1);
1787 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1788 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.Path, { 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" }) });
1789
1790 // packages/icons/build-module/library/search.mjs
1791 var import_primitives21 = __toESM(require_primitives(), 1);
1792 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1793 var search_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "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" }) });
1794
1795 // packages/icons/build-module/library/seen.mjs
1796 var import_primitives22 = __toESM(require_primitives(), 1);
1797 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
1798 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "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" }) });
1799
1800 // packages/icons/build-module/library/unseen.mjs
1801 var import_primitives23 = __toESM(require_primitives(), 1);
1802 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
1803 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "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" }) });
1804
1805 // packages/ui/build-module/stack/stack.mjs
1806 var import_element3 = __toESM(require_element(), 1);
1807 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
1808 function getRuntime2() {
1809 const globalScope = globalThis;
1810 if (globalScope.__wpStyleRuntime) {
1811 return globalScope.__wpStyleRuntime;
1812 }
1813 globalScope.__wpStyleRuntime = {
1814 documents: /* @__PURE__ */ new Map(),
1815 styles: /* @__PURE__ */ new Map(),
1816 injectedStyles: /* @__PURE__ */ new WeakMap()
1817 };
1818 if (typeof document !== "undefined") {
1819 registerDocument2(document);
1820 }
1821 return globalScope.__wpStyleRuntime;
1822 }
1823 function documentContainsStyleHash2(targetDocument, hash) {
1824 if (!targetDocument.head) {
1825 return false;
1826 }
1827 for (const style of targetDocument.head.querySelectorAll(
1828 `style[${STYLE_HASH_ATTRIBUTE2}]`
1829 )) {
1830 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
1831 return true;
1832 }
1833 }
1834 return false;
1835 }
1836 function injectStyle2(targetDocument, hash, css) {
1837 if (!targetDocument.head) {
1838 return;
1839 }
1840 const runtime = getRuntime2();
1841 let injectedStyles = runtime.injectedStyles.get(targetDocument);
1842 if (!injectedStyles) {
1843 injectedStyles = /* @__PURE__ */ new Set();
1844 runtime.injectedStyles.set(targetDocument, injectedStyles);
1845 }
1846 if (injectedStyles.has(hash)) {
1847 return;
1848 }
1849 if (documentContainsStyleHash2(targetDocument, hash)) {
1850 injectedStyles.add(hash);
1851 return;
1852 }
1853 const style = targetDocument.createElement("style");
1854 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
1855 style.appendChild(targetDocument.createTextNode(css));
1856 targetDocument.head.appendChild(style);
1857 injectedStyles.add(hash);
1858 }
1859 function registerDocument2(targetDocument) {
1860 const runtime = getRuntime2();
1861 runtime.documents.set(
1862 targetDocument,
1863 (runtime.documents.get(targetDocument) ?? 0) + 1
1864 );
1865 for (const [hash, css] of runtime.styles) {
1866 injectStyle2(targetDocument, hash, css);
1867 }
1868 return () => {
1869 const count = runtime.documents.get(targetDocument);
1870 if (count === void 0) {
1871 return;
1872 }
1873 if (count <= 1) {
1874 runtime.documents.delete(targetDocument);
1875 return;
1876 }
1877 runtime.documents.set(targetDocument, count - 1);
1878 };
1879 }
1880 function registerStyle2(hash, css) {
1881 const runtime = getRuntime2();
1882 runtime.styles.set(hash, css);
1883 for (const targetDocument of runtime.documents.keys()) {
1884 injectStyle2(targetDocument, hash, css);
1885 }
1886 }
1887 if (typeof process === "undefined" || true) {
1888 registerStyle2("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
1889 }
1890 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
1891 var gapTokens = {
1892 xs: "var(--wpds-dimension-gap-xs, 4px)",
1893 sm: "var(--wpds-dimension-gap-sm, 8px)",
1894 md: "var(--wpds-dimension-gap-md, 12px)",
1895 lg: "var(--wpds-dimension-gap-lg, 16px)",
1896 xl: "var(--wpds-dimension-gap-xl, 24px)",
1897 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
1898 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
1899 };
1900 var Stack = (0, import_element3.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
1901 const style = {
1902 gap: gap && gapTokens[gap],
1903 alignItems: align,
1904 justifyContent: justify,
1905 flexDirection: direction,
1906 flexWrap: wrap
1907 };
1908 const element = useRender({
1909 render: render4,
1910 ref,
1911 props: mergeProps(props, { style, className: style_default2.stack })
1912 });
1913 return element;
1914 });
1915
1916 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
1917 var import_element4 = __toESM(require_element(), 1);
1918 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
1919 function getRuntime3() {
1920 const globalScope = globalThis;
1921 if (globalScope.__wpStyleRuntime) {
1922 return globalScope.__wpStyleRuntime;
1923 }
1924 globalScope.__wpStyleRuntime = {
1925 documents: /* @__PURE__ */ new Map(),
1926 styles: /* @__PURE__ */ new Map(),
1927 injectedStyles: /* @__PURE__ */ new WeakMap()
1928 };
1929 if (typeof document !== "undefined") {
1930 registerDocument3(document);
1931 }
1932 return globalScope.__wpStyleRuntime;
1933 }
1934 function documentContainsStyleHash3(targetDocument, hash) {
1935 if (!targetDocument.head) {
1936 return false;
1937 }
1938 for (const style of targetDocument.head.querySelectorAll(
1939 `style[${STYLE_HASH_ATTRIBUTE3}]`
1940 )) {
1941 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
1942 return true;
1943 }
1944 }
1945 return false;
1946 }
1947 function injectStyle3(targetDocument, hash, css) {
1948 if (!targetDocument.head) {
1949 return;
1950 }
1951 const runtime = getRuntime3();
1952 let injectedStyles = runtime.injectedStyles.get(targetDocument);
1953 if (!injectedStyles) {
1954 injectedStyles = /* @__PURE__ */ new Set();
1955 runtime.injectedStyles.set(targetDocument, injectedStyles);
1956 }
1957 if (injectedStyles.has(hash)) {
1958 return;
1959 }
1960 if (documentContainsStyleHash3(targetDocument, hash)) {
1961 injectedStyles.add(hash);
1962 return;
1963 }
1964 const style = targetDocument.createElement("style");
1965 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
1966 style.appendChild(targetDocument.createTextNode(css));
1967 targetDocument.head.appendChild(style);
1968 injectedStyles.add(hash);
1969 }
1970 function registerDocument3(targetDocument) {
1971 const runtime = getRuntime3();
1972 runtime.documents.set(
1973 targetDocument,
1974 (runtime.documents.get(targetDocument) ?? 0) + 1
1975 );
1976 for (const [hash, css] of runtime.styles) {
1977 injectStyle3(targetDocument, hash, css);
1978 }
1979 return () => {
1980 const count = runtime.documents.get(targetDocument);
1981 if (count === void 0) {
1982 return;
1983 }
1984 if (count <= 1) {
1985 runtime.documents.delete(targetDocument);
1986 return;
1987 }
1988 runtime.documents.set(targetDocument, count - 1);
1989 };
1990 }
1991 function registerStyle3(hash, css) {
1992 const runtime = getRuntime3();
1993 runtime.styles.set(hash, css);
1994 for (const targetDocument of runtime.documents.keys()) {
1995 injectStyle3(targetDocument, hash, css);
1996 }
1997 }
1998 if (typeof process === "undefined" || true) {
1999 registerStyle3("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}}");
2000 }
2001 var style_default3 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
2002 var VisuallyHidden = (0, import_element4.forwardRef)(
2003 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
2004 const element = useRender({
2005 render: render4,
2006 ref,
2007 props: mergeProps(
2008 { className: style_default3["visually-hidden"] },
2009 restProps,
2010 {
2011 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
2012 "data-visually-hidden": ""
2013 }
2014 )
2015 });
2016 return element;
2017 }
2018 );
2019
2020 // packages/dataviews/build-module/components/dataviews-context/index.mjs
2021 var import_element5 = __toESM(require_element(), 1);
2022
2023 // packages/dataviews/build-module/constants.mjs
2024 var import_i18n = __toESM(require_i18n(), 1);
2025 var OPERATOR_IS_ANY = "isAny";
2026 var OPERATOR_IS_NONE = "isNone";
2027 var OPERATOR_IS_ALL = "isAll";
2028 var OPERATOR_IS_NOT_ALL = "isNotAll";
2029 var OPERATOR_BETWEEN = "between";
2030 var OPERATOR_IN_THE_PAST = "inThePast";
2031 var OPERATOR_OVER = "over";
2032 var OPERATOR_IS = "is";
2033 var OPERATOR_IS_NOT = "isNot";
2034 var OPERATOR_LESS_THAN = "lessThan";
2035 var OPERATOR_GREATER_THAN = "greaterThan";
2036 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
2037 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
2038 var OPERATOR_BEFORE = "before";
2039 var OPERATOR_AFTER = "after";
2040 var OPERATOR_BEFORE_INC = "beforeInc";
2041 var OPERATOR_AFTER_INC = "afterInc";
2042 var OPERATOR_CONTAINS = "contains";
2043 var OPERATOR_NOT_CONTAINS = "notContains";
2044 var OPERATOR_STARTS_WITH = "startsWith";
2045 var OPERATOR_ON = "on";
2046 var OPERATOR_NOT_ON = "notOn";
2047 var SORTING_DIRECTIONS = ["asc", "desc"];
2048 var sortArrows = { asc: "\u2191", desc: "\u2193" };
2049 var sortValues = { asc: "ascending", desc: "descending" };
2050 var sortLabels = {
2051 asc: (0, import_i18n.__)("Sort ascending"),
2052 desc: (0, import_i18n.__)("Sort descending")
2053 };
2054 var sortIcons = {
2055 asc: arrow_up_default,
2056 desc: arrow_down_default
2057 };
2058 var LAYOUT_TABLE = "table";
2059 var LAYOUT_GRID = "grid";
2060 var LAYOUT_LIST = "list";
2061 var LAYOUT_ACTIVITY = "activity";
2062 var LAYOUT_PICKER_GRID = "pickerGrid";
2063 var LAYOUT_PICKER_TABLE = "pickerTable";
2064
2065 // packages/dataviews/build-module/components/dataviews-context/index.mjs
2066 var DataViewsContext = (0, import_element5.createContext)({
2067 view: { type: LAYOUT_TABLE },
2068 onChangeView: () => {
2069 },
2070 fields: [],
2071 data: [],
2072 paginationInfo: {
2073 totalItems: 0,
2074 totalPages: 0
2075 },
2076 selection: [],
2077 onChangeSelection: () => {
2078 },
2079 setOpenedFilter: () => {
2080 },
2081 openedFilter: null,
2082 getItemId: (item) => item.id,
2083 isItemClickable: () => true,
2084 renderItemLink: void 0,
2085 containerWidth: 0,
2086 containerRef: (0, import_element5.createRef)(),
2087 resizeObserverRef: () => {
2088 },
2089 defaultLayouts: { list: {}, grid: {}, table: {} },
2090 filters: [],
2091 isShowingFilter: false,
2092 setIsShowingFilter: () => {
2093 },
2094 hasInitiallyLoaded: false,
2095 config: {
2096 perPageSizes: []
2097 },
2098 intersectionObserver: null
2099 });
2100 DataViewsContext.displayName = "DataViewsContext";
2101 var dataviews_context_default = DataViewsContext;
2102
2103 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
2104 var import_i18n21 = __toESM(require_i18n(), 1);
2105
2106 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
2107 var import_i18n9 = __toESM(require_i18n(), 1);
2108 var import_components6 = __toESM(require_components(), 1);
2109 var import_element13 = __toESM(require_element(), 1);
2110 var import_keycodes = __toESM(require_keycodes(), 1);
2111
2112 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
2113 var import_components = __toESM(require_components(), 1);
2114 var import_i18n2 = __toESM(require_i18n(), 1);
2115 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
2116 function DataViewsSelectionCheckbox({
2117 selection,
2118 onChangeSelection,
2119 item,
2120 getItemId,
2121 titleField,
2122 disabled,
2123 ...extraProps
2124 }) {
2125 const id = getItemId(item);
2126 const isInSelectionArray = selection.includes(id);
2127 const checked = !disabled && isInSelectionArray;
2128 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
2129 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2130 import_components.CheckboxControl,
2131 {
2132 className: "dataviews-selection-checkbox",
2133 "aria-label": selectionLabel,
2134 "aria-disabled": disabled,
2135 checked,
2136 onChange: () => {
2137 if (disabled) {
2138 return;
2139 }
2140 onChangeSelection(
2141 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
2142 );
2143 },
2144 ...extraProps
2145 }
2146 );
2147 }
2148
2149 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
2150 var import_components2 = __toESM(require_components(), 1);
2151 var import_i18n3 = __toESM(require_i18n(), 1);
2152 var import_element6 = __toESM(require_element(), 1);
2153 var import_data4 = __toESM(require_data(), 1);
2154 var import_compose = __toESM(require_compose(), 1);
2155
2156 // packages/dataviews/build-module/lock-unlock.mjs
2157 var import_private_apis2 = __toESM(require_private_apis(), 1);
2158 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
2159 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
2160 "@wordpress/dataviews"
2161 );
2162
2163 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
2164 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
2165 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
2166 function ButtonTrigger({
2167 action,
2168 onClick,
2169 items,
2170 variant
2171 }) {
2172 const label = typeof action.label === "string" ? action.label : action.label(items);
2173 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2174 import_components2.Button,
2175 {
2176 disabled: !!action.disabled,
2177 accessibleWhenDisabled: true,
2178 size: "compact",
2179 variant,
2180 onClick,
2181 children: label
2182 }
2183 );
2184 }
2185 function MenuItemTrigger({
2186 action,
2187 onClick,
2188 items
2189 }) {
2190 const label = typeof action.label === "string" ? action.label : action.label(items);
2191 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Menu.ItemLabel, { children: label }) });
2192 }
2193 function ActionModal({
2194 action,
2195 items,
2196 closeModal
2197 }) {
2198 const label = typeof action.label === "string" ? action.label : action.label(items);
2199 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
2200 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2201 import_components2.Modal,
2202 {
2203 title: modalHeader || label,
2204 __experimentalHideHeader: !!action.hideModalHeader,
2205 onRequestClose: closeModal,
2206 focusOnMount: action.modalFocusOnMount ?? true,
2207 size: action.modalSize || "medium",
2208 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
2209 action.id
2210 )}`,
2211 children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(action.RenderModal, { items, closeModal })
2212 }
2213 );
2214 }
2215 function ActionsMenuGroup({
2216 actions,
2217 item,
2218 registry,
2219 setActiveModalAction
2220 }) {
2221 const { primaryActions, regularActions } = (0, import_element6.useMemo)(() => {
2222 return actions.reduce(
2223 (acc, action) => {
2224 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
2225 return acc;
2226 },
2227 {
2228 primaryActions: [],
2229 regularActions: []
2230 }
2231 );
2232 }, [actions]);
2233 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2234 MenuItemTrigger,
2235 {
2236 action,
2237 onClick: () => {
2238 if ("RenderModal" in action) {
2239 setActiveModalAction(action);
2240 return;
2241 }
2242 action.callback([item], { registry });
2243 },
2244 items: [item]
2245 },
2246 action.id
2247 ));
2248 return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Menu.Group, { children: [
2249 renderActionGroup(primaryActions),
2250 renderActionGroup(regularActions)
2251 ] });
2252 }
2253 function ItemActions({
2254 item,
2255 actions,
2256 isCompact
2257 }) {
2258 const registry = (0, import_data4.useRegistry)();
2259 const { primaryActions, eligibleActions } = (0, import_element6.useMemo)(() => {
2260 const _eligibleActions = actions.filter(
2261 (action) => !action.isEligible || action.isEligible(item)
2262 );
2263 const _primaryActions = _eligibleActions.filter(
2264 (action) => action.isPrimary
2265 );
2266 return {
2267 primaryActions: _primaryActions,
2268 eligibleActions: _eligibleActions
2269 };
2270 }, [actions, item]);
2271 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
2272 if (isCompact) {
2273 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2274 CompactItemActions,
2275 {
2276 item,
2277 actions: eligibleActions,
2278 isSmall: true,
2279 registry
2280 }
2281 );
2282 }
2283 return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2284 Stack,
2285 {
2286 direction: "row",
2287 justify: "flex-end",
2288 className: "dataviews-item-actions",
2289 style: {
2290 flexShrink: 0,
2291 width: "auto"
2292 },
2293 children: [
2294 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2295 PrimaryActions,
2296 {
2297 item,
2298 actions: primaryActions,
2299 registry
2300 }
2301 ),
2302 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
2303 // there if there are any actions at all.
2304 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2305 CompactItemActions,
2306 {
2307 item,
2308 actions: eligibleActions,
2309 registry
2310 }
2311 )
2312 ]
2313 }
2314 );
2315 }
2316 function CompactItemActions({
2317 item,
2318 actions,
2319 isSmall,
2320 registry
2321 }) {
2322 const [activeModalAction, setActiveModalAction] = (0, import_element6.useState)(
2323 null
2324 );
2325 return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2326 /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Menu, { placement: "bottom-end", children: [
2327 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2328 Menu.TriggerButton,
2329 {
2330 render: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2331 import_components2.Button,
2332 {
2333 size: isSmall ? "small" : "compact",
2334 icon: more_vertical_default,
2335 label: (0, import_i18n3.__)("Actions"),
2336 accessibleWhenDisabled: true,
2337 disabled: !actions.length,
2338 className: "dataviews-all-actions-button"
2339 }
2340 )
2341 }
2342 ),
2343 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2344 ActionsMenuGroup,
2345 {
2346 actions,
2347 item,
2348 registry,
2349 setActiveModalAction
2350 }
2351 ) })
2352 ] }),
2353 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2354 ActionModal,
2355 {
2356 action: activeModalAction,
2357 items: [item],
2358 closeModal: () => setActiveModalAction(null)
2359 }
2360 )
2361 ] });
2362 }
2363 function PrimaryActions({
2364 item,
2365 actions,
2366 registry,
2367 buttonVariant
2368 }) {
2369 const [activeModalAction, setActiveModalAction] = (0, import_element6.useState)(null);
2370 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
2371 if (isMobileViewport) {
2372 return null;
2373 }
2374 if (!Array.isArray(actions) || actions.length === 0) {
2375 return null;
2376 }
2377 return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2378 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2379 ButtonTrigger,
2380 {
2381 action,
2382 onClick: () => {
2383 if ("RenderModal" in action) {
2384 setActiveModalAction(action);
2385 return;
2386 }
2387 action.callback([item], { registry });
2388 },
2389 items: [item],
2390 variant: buttonVariant
2391 },
2392 action.id
2393 )),
2394 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2395 ActionModal,
2396 {
2397 action: activeModalAction,
2398 items: [item],
2399 closeModal: () => setActiveModalAction(null)
2400 }
2401 )
2402 ] });
2403 }
2404
2405 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
2406 var import_components3 = __toESM(require_components(), 1);
2407 var import_i18n5 = __toESM(require_i18n(), 1);
2408 var import_element7 = __toESM(require_element(), 1);
2409 var import_data5 = __toESM(require_data(), 1);
2410 var import_compose2 = __toESM(require_compose(), 1);
2411
2412 // packages/dataviews/build-module/utils/get-footer-message.mjs
2413 var import_i18n4 = __toESM(require_i18n(), 1);
2414 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
2415 if (selectionCount > 0) {
2416 return (0, import_i18n4.sprintf)(
2417 /* translators: %d: number of items. */
2418 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
2419 selectionCount
2420 );
2421 }
2422 if (onlyTotalCount || totalItems <= itemsCount) {
2423 return (0, import_i18n4.sprintf)(
2424 /* translators: %d: number of items. */
2425 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
2426 totalItems
2427 );
2428 }
2429 return (0, import_i18n4.sprintf)(
2430 /* translators: %1$d: number of items. %2$d: total number of items. */
2431 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
2432 itemsCount,
2433 totalItems
2434 );
2435 }
2436
2437 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
2438 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
2439 function ActionWithModal({
2440 action,
2441 items,
2442 ActionTriggerComponent
2443 }) {
2444 const [isModalOpen, setIsModalOpen] = (0, import_element7.useState)(false);
2445 const actionTriggerProps = {
2446 action,
2447 onClick: () => {
2448 setIsModalOpen(true);
2449 },
2450 items
2451 };
2452 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
2453 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
2454 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2455 ActionModal,
2456 {
2457 action,
2458 items,
2459 closeModal: () => setIsModalOpen(false)
2460 }
2461 )
2462 ] });
2463 }
2464 function useHasAPossibleBulkAction(actions, item) {
2465 return (0, import_element7.useMemo)(() => {
2466 return actions.some((action) => {
2467 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
2468 });
2469 }, [actions, item]);
2470 }
2471 function useSomeItemHasAPossibleBulkAction(actions, data) {
2472 return (0, import_element7.useMemo)(() => {
2473 return data.some((item) => {
2474 return actions.some((action) => {
2475 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
2476 });
2477 });
2478 }, [actions, data]);
2479 }
2480 function BulkSelectionCheckbox({
2481 selection,
2482 onChangeSelection,
2483 data,
2484 actions,
2485 getItemId,
2486 disableSelectAll = false
2487 }) {
2488 const selectableItems = (0, import_element7.useMemo)(() => {
2489 return data.filter((item) => {
2490 return actions.some(
2491 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
2492 );
2493 });
2494 }, [data, actions]);
2495 const selectedItems = data.filter(
2496 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
2497 );
2498 const hasSelection = selection.length > 0;
2499 const areAllSelected = selectedItems.length === selectableItems.length;
2500 if (disableSelectAll) {
2501 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2502 import_components3.CheckboxControl,
2503 {
2504 className: "dataviews-view-table-selection-checkbox",
2505 checked: hasSelection,
2506 disabled: !hasSelection,
2507 onChange: () => {
2508 onChangeSelection([]);
2509 },
2510 "aria-label": (0, import_i18n5.__)("Deselect all")
2511 }
2512 );
2513 }
2514 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2515 import_components3.CheckboxControl,
2516 {
2517 className: "dataviews-view-table-selection-checkbox",
2518 checked: areAllSelected,
2519 indeterminate: !areAllSelected && !!selectedItems.length,
2520 onChange: () => {
2521 if (areAllSelected) {
2522 onChangeSelection([]);
2523 } else {
2524 onChangeSelection(
2525 selectableItems.map((item) => getItemId(item))
2526 );
2527 }
2528 },
2529 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
2530 }
2531 );
2532 }
2533 function ActionTrigger({
2534 action,
2535 onClick,
2536 isBusy,
2537 items
2538 }) {
2539 const label = typeof action.label === "string" ? action.label : action.label(items);
2540 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
2541 if (isMobile) {
2542 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2543 import_components3.Button,
2544 {
2545 disabled: isBusy,
2546 accessibleWhenDisabled: true,
2547 label,
2548 icon: action.icon,
2549 size: "compact",
2550 onClick,
2551 isBusy
2552 }
2553 );
2554 }
2555 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2556 import_components3.Button,
2557 {
2558 disabled: isBusy,
2559 accessibleWhenDisabled: true,
2560 size: "compact",
2561 onClick,
2562 isBusy,
2563 children: label
2564 }
2565 );
2566 }
2567 var EMPTY_ARRAY2 = [];
2568 function ActionButton({
2569 action,
2570 selectedItems,
2571 actionInProgress,
2572 setActionInProgress
2573 }) {
2574 const registry = (0, import_data5.useRegistry)();
2575 const selectedEligibleItems = (0, import_element7.useMemo)(() => {
2576 return selectedItems.filter((item) => {
2577 return !action.isEligible || action.isEligible(item);
2578 });
2579 }, [action, selectedItems]);
2580 if ("RenderModal" in action) {
2581 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2582 ActionWithModal,
2583 {
2584 action,
2585 items: selectedEligibleItems,
2586 ActionTriggerComponent: ActionTrigger
2587 },
2588 action.id
2589 );
2590 }
2591 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2592 ActionTrigger,
2593 {
2594 action,
2595 onClick: async () => {
2596 setActionInProgress(action.id);
2597 await action.callback(selectedItems, {
2598 registry
2599 });
2600 setActionInProgress(null);
2601 },
2602 items: selectedEligibleItems,
2603 isBusy: actionInProgress === action.id
2604 },
2605 action.id
2606 );
2607 }
2608 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
2609 const message2 = getFooterMessage(
2610 selection.length,
2611 data.length,
2612 paginationInfo.totalItems,
2613 isInfiniteScroll
2614 );
2615 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
2616 Stack,
2617 {
2618 direction: "row",
2619 className: "dataviews-bulk-actions-footer__container",
2620 gap: "md",
2621 align: "center",
2622 children: [
2623 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2624 BulkSelectionCheckbox,
2625 {
2626 selection,
2627 onChangeSelection,
2628 data,
2629 actions,
2630 getItemId,
2631 disableSelectAll: isInfiniteScroll
2632 }
2633 ),
2634 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
2635 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
2636 Stack,
2637 {
2638 direction: "row",
2639 className: "dataviews-bulk-actions-footer__action-buttons",
2640 gap: "xs",
2641 children: [
2642 actionsToShow.map((action) => {
2643 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2644 ActionButton,
2645 {
2646 action,
2647 selectedItems,
2648 actionInProgress,
2649 setActionInProgress
2650 },
2651 action.id
2652 );
2653 }),
2654 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2655 import_components3.Button,
2656 {
2657 icon: close_small_default,
2658 showTooltip: true,
2659 tooltipPosition: "top",
2660 size: "compact",
2661 label: (0, import_i18n5.__)("Cancel"),
2662 disabled: !!actionInProgress,
2663 accessibleWhenDisabled: false,
2664 onClick: () => {
2665 onChangeSelection(EMPTY_ARRAY2);
2666 }
2667 }
2668 )
2669 ]
2670 }
2671 )
2672 ]
2673 }
2674 );
2675 }
2676 function FooterContent({
2677 selection,
2678 actions,
2679 onChangeSelection,
2680 data,
2681 getItemId,
2682 isInfiniteScroll,
2683 paginationInfo
2684 }) {
2685 const [actionInProgress, setActionInProgress] = (0, import_element7.useState)(
2686 null
2687 );
2688 const footerContentRef = (0, import_element7.useRef)(void 0);
2689 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
2690 const bulkActions = (0, import_element7.useMemo)(
2691 () => actions.filter((action) => action.supportsBulk),
2692 [actions]
2693 );
2694 const selectableItems = (0, import_element7.useMemo)(() => {
2695 return data.filter((item) => {
2696 return bulkActions.some(
2697 (action) => !action.isEligible || action.isEligible(item)
2698 );
2699 });
2700 }, [data, bulkActions]);
2701 const selectedItems = (0, import_element7.useMemo)(() => {
2702 return data.filter(
2703 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
2704 );
2705 }, [selection, data, getItemId, selectableItems]);
2706 const actionsToShow = (0, import_element7.useMemo)(
2707 () => actions.filter((action) => {
2708 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
2709 (item) => !action.isEligible || action.isEligible(item)
2710 );
2711 }),
2712 [actions, selectedItems, isMobile]
2713 );
2714 if (!actionInProgress) {
2715 if (footerContentRef.current) {
2716 footerContentRef.current = void 0;
2717 }
2718 return renderFooterContent(
2719 data,
2720 actions,
2721 getItemId,
2722 isInfiniteScroll,
2723 selection,
2724 actionsToShow,
2725 selectedItems,
2726 actionInProgress,
2727 setActionInProgress,
2728 onChangeSelection,
2729 paginationInfo
2730 );
2731 } else if (!footerContentRef.current) {
2732 footerContentRef.current = renderFooterContent(
2733 data,
2734 actions,
2735 getItemId,
2736 isInfiniteScroll,
2737 selection,
2738 actionsToShow,
2739 selectedItems,
2740 actionInProgress,
2741 setActionInProgress,
2742 onChangeSelection,
2743 paginationInfo
2744 );
2745 }
2746 return footerContentRef.current;
2747 }
2748 function BulkActionsFooter() {
2749 const {
2750 data,
2751 selection,
2752 actions = EMPTY_ARRAY2,
2753 onChangeSelection,
2754 getItemId,
2755 paginationInfo,
2756 view
2757 } = (0, import_element7.useContext)(dataviews_context_default);
2758 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2759 FooterContent,
2760 {
2761 selection,
2762 onChangeSelection,
2763 data,
2764 actions,
2765 getItemId,
2766 isInfiniteScroll: !!view.infiniteScrollEnabled,
2767 paginationInfo
2768 }
2769 );
2770 }
2771
2772 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
2773 var import_i18n6 = __toESM(require_i18n(), 1);
2774 var import_components4 = __toESM(require_components(), 1);
2775 var import_element8 = __toESM(require_element(), 1);
2776
2777 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
2778 function getHideableFields(view, fields) {
2779 const togglableFields = [
2780 view?.titleField,
2781 view?.mediaField,
2782 view?.descriptionField
2783 ].filter(Boolean);
2784 return fields.filter(
2785 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
2786 );
2787 }
2788
2789 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
2790 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
2791 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
2792 function WithMenuSeparators({ children }) {
2793 return import_element8.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_element8.Fragment, { children: [
2794 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Separator, {}),
2795 child
2796 ] }, i2));
2797 }
2798 var _HeaderMenu = (0, import_element8.forwardRef)(function HeaderMenu({
2799 fieldId,
2800 view,
2801 fields,
2802 onChangeView,
2803 onHide,
2804 setOpenedFilter,
2805 canMove = true,
2806 canInsertLeft = true,
2807 canInsertRight = true
2808 }, ref) {
2809 const visibleFieldIds = view.fields ?? [];
2810 const index = visibleFieldIds?.indexOf(fieldId);
2811 const isSorted = view.sort?.field === fieldId;
2812 let isHidable = false;
2813 let isSortable = false;
2814 let canAddFilter = false;
2815 let operators = [];
2816 const field = fields.find((f2) => f2.id === fieldId);
2817 const { setIsShowingFilter } = (0, import_element8.useContext)(dataviews_context_default);
2818 if (!field) {
2819 return null;
2820 }
2821 isHidable = field.enableHiding !== false;
2822 isSortable = field.enableSorting !== false;
2823 const header = field.header;
2824 operators = !!field.filterBy && field.filterBy?.operators || [];
2825 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
2826 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
2827 return header;
2828 }
2829 const hiddenFields = getHideableFields(view, fields).filter(
2830 (f2) => !visibleFieldIds.includes(f2.id)
2831 );
2832 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
2833 const isRtl = (0, import_i18n6.isRTL)();
2834 return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Menu2, { children: [
2835 /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2836 Menu2.TriggerButton,
2837 {
2838 render: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2839 import_components4.Button,
2840 {
2841 size: "compact",
2842 className: "dataviews-view-table-header-button",
2843 ref,
2844 variant: "tertiary"
2845 }
2846 ),
2847 children: [
2848 header,
2849 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
2850 ]
2851 }
2852 ),
2853 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(WithMenuSeparators, { children: [
2854 isSortable && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
2855 (direction) => {
2856 const isChecked = view.sort && isSorted && view.sort.direction === direction;
2857 const value = `${fieldId}-${direction}`;
2858 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2859 Menu2.RadioItem,
2860 {
2861 name: "view-table-sorting",
2862 value,
2863 checked: isChecked,
2864 onChange: () => {
2865 onChangeView({
2866 ...view,
2867 sort: {
2868 field: fieldId,
2869 direction
2870 },
2871 showLevels: false
2872 });
2873 },
2874 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
2875 },
2876 value
2877 );
2878 }
2879 ) }),
2880 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2881 Menu2.Item,
2882 {
2883 prefix: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components4.Icon, { icon: funnel_default }),
2884 onClick: () => {
2885 setOpenedFilter(fieldId);
2886 setIsShowingFilter(true);
2887 onChangeView({
2888 ...view,
2889 page: 1,
2890 filters: [
2891 ...view.filters || [],
2892 {
2893 field: fieldId,
2894 value: void 0,
2895 operator: operators[0]
2896 }
2897 ]
2898 });
2899 },
2900 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
2901 }
2902 ) }),
2903 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Menu2.Group, { children: [
2904 canMove && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2905 Menu2.Item,
2906 {
2907 prefix: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components4.Icon, { icon: arrow_left_default }),
2908 disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
2909 onClick: () => {
2910 const targetIndex = isRtl ? index + 1 : index - 1;
2911 const newFields = [
2912 ...visibleFieldIds
2913 ];
2914 newFields.splice(index, 1);
2915 newFields.splice(
2916 targetIndex,
2917 0,
2918 fieldId
2919 );
2920 onChangeView({
2921 ...view,
2922 fields: newFields
2923 });
2924 },
2925 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
2926 }
2927 ),
2928 canMove && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2929 Menu2.Item,
2930 {
2931 prefix: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components4.Icon, { icon: arrow_right_default }),
2932 disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
2933 onClick: () => {
2934 const targetIndex = isRtl ? index - 1 : index + 1;
2935 const newFields = [
2936 ...visibleFieldIds
2937 ];
2938 newFields.splice(index, 1);
2939 newFields.splice(
2940 targetIndex,
2941 0,
2942 fieldId
2943 );
2944 onChangeView({
2945 ...view,
2946 fields: newFields
2947 });
2948 },
2949 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
2950 }
2951 ),
2952 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Menu2, { children: [
2953 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
2954 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
2955 const insertIndex = isRtl ? index + 1 : index;
2956 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2957 Menu2.Item,
2958 {
2959 onClick: () => {
2960 onChangeView({
2961 ...view,
2962 fields: [
2963 ...visibleFieldIds.slice(
2964 0,
2965 insertIndex
2966 ),
2967 hiddenField.id,
2968 ...visibleFieldIds.slice(
2969 insertIndex
2970 )
2971 ]
2972 });
2973 },
2974 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
2975 },
2976 hiddenField.id
2977 );
2978 }) })
2979 ] }),
2980 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Menu2, { children: [
2981 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
2982 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
2983 const insertIndex = isRtl ? index : index + 1;
2984 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2985 Menu2.Item,
2986 {
2987 onClick: () => {
2988 onChangeView({
2989 ...view,
2990 fields: [
2991 ...visibleFieldIds.slice(
2992 0,
2993 insertIndex
2994 ),
2995 hiddenField.id,
2996 ...visibleFieldIds.slice(
2997 insertIndex
2998 )
2999 ]
3000 });
3001 },
3002 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
3003 },
3004 hiddenField.id
3005 );
3006 }) })
3007 ] }),
3008 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3009 Menu2.Item,
3010 {
3011 prefix: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components4.Icon, { icon: unseen_default }),
3012 onClick: () => {
3013 onHide(field);
3014 onChangeView({
3015 ...view,
3016 fields: visibleFieldIds.filter(
3017 (id) => id !== fieldId
3018 )
3019 });
3020 },
3021 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
3022 }
3023 )
3024 ] })
3025 ] }) })
3026 ] });
3027 });
3028 var ColumnHeaderMenu = _HeaderMenu;
3029 var column_header_menu_default = ColumnHeaderMenu;
3030
3031 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
3032 var import_element9 = __toESM(require_element(), 1);
3033 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
3034 function getClickableItemProps({
3035 item,
3036 isItemClickable,
3037 onClickItem,
3038 className
3039 }) {
3040 if (!isItemClickable(item) || !onClickItem) {
3041 return { className };
3042 }
3043 return {
3044 className: className ? `${className} ${className}--clickable` : void 0,
3045 role: "button",
3046 tabIndex: 0,
3047 onClick: (event) => {
3048 event.stopPropagation();
3049 onClickItem(item);
3050 },
3051 onKeyDown: (event) => {
3052 if (event.key === "Enter" || event.key === "" || event.key === " ") {
3053 event.stopPropagation();
3054 onClickItem(item);
3055 }
3056 }
3057 };
3058 }
3059 function ItemClickWrapper({
3060 item,
3061 isItemClickable,
3062 onClickItem,
3063 renderItemLink,
3064 className,
3065 children,
3066 ...extraProps
3067 }) {
3068 if (!isItemClickable(item)) {
3069 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className, ...extraProps, children });
3070 }
3071 if (renderItemLink) {
3072 const renderedElement = renderItemLink({
3073 item,
3074 className: `${className} ${className}--clickable`,
3075 ...extraProps,
3076 children
3077 });
3078 return (0, import_element9.cloneElement)(renderedElement, {
3079 onClick: (event) => {
3080 event.stopPropagation();
3081 if (renderedElement.props.onClick) {
3082 renderedElement.props.onClick(event);
3083 }
3084 },
3085 onKeyDown: (event) => {
3086 if (event.key === "Enter" || event.key === "" || event.key === " ") {
3087 event.stopPropagation();
3088 if (renderedElement.props.onKeyDown) {
3089 renderedElement.props.onKeyDown(event);
3090 }
3091 }
3092 }
3093 });
3094 }
3095 const clickProps = getClickableItemProps({
3096 item,
3097 isItemClickable,
3098 onClickItem,
3099 className
3100 });
3101 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { ...clickProps, ...extraProps, children });
3102 }
3103
3104 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
3105 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3106 function ColumnPrimary({
3107 item,
3108 level,
3109 titleField,
3110 mediaField,
3111 descriptionField,
3112 onClickItem,
3113 renderItemLink,
3114 isItemClickable
3115 }) {
3116 return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
3117 mediaField && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
3118 ItemClickWrapper,
3119 {
3120 item,
3121 isItemClickable,
3122 onClickItem,
3123 renderItemLink,
3124 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
3125 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
3126 children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
3127 mediaField.render,
3128 {
3129 item,
3130 field: mediaField,
3131 config: { sizes: "32px" }
3132 }
3133 )
3134 }
3135 ),
3136 /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
3137 Stack,
3138 {
3139 direction: "column",
3140 align: "flex-start",
3141 className: "dataviews-view-table__primary-column-content",
3142 children: [
3143 titleField && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
3144 ItemClickWrapper,
3145 {
3146 item,
3147 isItemClickable,
3148 onClickItem,
3149 renderItemLink,
3150 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
3151 children: [
3152 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "dataviews-view-table__level", children: [
3153 Array(level).fill("\u2014").join(" "),
3154 "\xA0"
3155 ] }),
3156 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(titleField.render, { item, field: titleField })
3157 ]
3158 }
3159 ),
3160 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
3161 descriptionField.render,
3162 {
3163 item,
3164 field: descriptionField
3165 }
3166 )
3167 ]
3168 }
3169 )
3170 ] });
3171 }
3172 var column_primary_default = ColumnPrimary;
3173
3174 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
3175 var import_element10 = __toESM(require_element(), 1);
3176 var import_i18n7 = __toESM(require_i18n(), 1);
3177 var isScrolledToEnd = (element) => {
3178 if ((0, import_i18n7.isRTL)()) {
3179 const scrollLeft = Math.abs(element.scrollLeft);
3180 return scrollLeft <= 1;
3181 }
3182 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
3183 };
3184 function useScrollState({
3185 scrollContainerRef,
3186 enabledHorizontal = false
3187 }) {
3188 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element10.useState)(false);
3189 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element10.useState)(false);
3190 const handleScroll = (0, import_element10.useCallback)(() => {
3191 const scrollContainer = scrollContainerRef.current;
3192 if (!scrollContainer) {
3193 return;
3194 }
3195 if (enabledHorizontal) {
3196 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
3197 }
3198 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
3199 }, [scrollContainerRef, enabledHorizontal]);
3200 (0, import_element10.useEffect)(() => {
3201 if (typeof window === "undefined" || !scrollContainerRef.current) {
3202 return () => {
3203 };
3204 }
3205 const scrollContainer = scrollContainerRef.current;
3206 handleScroll();
3207 scrollContainer.addEventListener("scroll", handleScroll);
3208 window.addEventListener("resize", handleScroll);
3209 return () => {
3210 scrollContainer.removeEventListener("scroll", handleScroll);
3211 window.removeEventListener("resize", handleScroll);
3212 };
3213 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
3214 return { isHorizontalScrollEnd, isVerticallyScrolled };
3215 }
3216
3217 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
3218 function getDataByGroup(data, groupByField) {
3219 return data.reduce((groups, item) => {
3220 const groupName = groupByField.getValue({ item });
3221 if (!groups.has(groupName)) {
3222 groups.set(groupName, []);
3223 }
3224 groups.get(groupName)?.push(item);
3225 return groups;
3226 }, /* @__PURE__ */ new Map());
3227 }
3228
3229 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
3230 var import_components5 = __toESM(require_components(), 1);
3231 var import_i18n8 = __toESM(require_i18n(), 1);
3232 var import_element11 = __toESM(require_element(), 1);
3233 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3234 function FieldItem({
3235 field,
3236 isVisible: isVisible2,
3237 onToggleVisibility
3238 }) {
3239 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
3240 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_components5.Icon, { icon: check_default }) }),
3241 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
3242 ] }) });
3243 }
3244 function isDefined(item) {
3245 return !!item;
3246 }
3247 function PropertiesSection({
3248 showLabel = true
3249 }) {
3250 const { view, fields, onChangeView } = (0, import_element11.useContext)(dataviews_context_default);
3251 const regularFields = getHideableFields(view, fields);
3252 if (!regularFields?.length) {
3253 return null;
3254 }
3255 const titleField = fields.find((f2) => f2.id === view.titleField);
3256 const previewField2 = fields.find((f2) => f2.id === view.mediaField);
3257 const descriptionField = fields.find(
3258 (f2) => f2.id === view.descriptionField
3259 );
3260 const lockedFields = [
3261 {
3262 field: titleField,
3263 isVisibleFlag: "showTitle"
3264 },
3265 {
3266 field: previewField2,
3267 isVisibleFlag: "showMedia"
3268 },
3269 {
3270 field: descriptionField,
3271 isVisibleFlag: "showDescription"
3272 }
3273 ].filter(({ field }) => isDefined(field));
3274 const visibleFieldIds = view.fields ?? [];
3275 const visibleRegularFieldsCount = regularFields.filter(
3276 (f2) => visibleFieldIds.includes(f2.id)
3277 ).length;
3278 const visibleLockedFields = lockedFields.filter(
3279 ({ isVisibleFlag }) => (
3280 // @ts-expect-error
3281 view[isVisibleFlag] ?? true
3282 )
3283 );
3284 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
3285 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
3286 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
3287 showLabel && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
3288 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3289 Stack,
3290 {
3291 direction: "column",
3292 className: "dataviews-view-config__properties",
3293 children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
3294 lockedFields.map(({ field, isVisibleFlag }) => {
3295 const isVisible2 = view[isVisibleFlag] ?? true;
3296 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
3297 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3298 FieldItem,
3299 {
3300 field: fieldToRender,
3301 isVisible: isVisible2,
3302 onToggleVisibility: () => {
3303 onChangeView({
3304 ...view,
3305 [isVisibleFlag]: !isVisible2
3306 });
3307 }
3308 },
3309 field.id
3310 );
3311 }),
3312 regularFields.map((field) => {
3313 const isVisible2 = visibleFieldIds.includes(field.id);
3314 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
3315 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3316 FieldItem,
3317 {
3318 field: fieldToRender,
3319 isVisible: isVisible2,
3320 onToggleVisibility: () => {
3321 onChangeView({
3322 ...view,
3323 fields: isVisible2 ? visibleFieldIds.filter(
3324 (fieldId) => fieldId !== field.id
3325 ) : [...visibleFieldIds, field.id]
3326 });
3327 }
3328 },
3329 field.id
3330 );
3331 })
3332 ] })
3333 }
3334 )
3335 ] });
3336 }
3337
3338 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
3339 var import_element12 = __toESM(require_element(), 1);
3340 function useDelayedLoading(isLoading, options = { delay: 400 }) {
3341 const [showLoader, setShowLoader] = (0, import_element12.useState)(false);
3342 (0, import_element12.useEffect)(() => {
3343 if (!isLoading) {
3344 return;
3345 }
3346 const timeout = setTimeout(() => {
3347 setShowLoader(true);
3348 }, options.delay);
3349 return () => {
3350 clearTimeout(timeout);
3351 setShowLoader(false);
3352 };
3353 }, [isLoading, options.delay]);
3354 return showLoader;
3355 }
3356
3357 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
3358 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3359 function getEffectiveAlign(explicitAlign, fieldType) {
3360 if (explicitAlign) {
3361 return explicitAlign;
3362 }
3363 if (fieldType === "integer" || fieldType === "number") {
3364 return "end";
3365 }
3366 return void 0;
3367 }
3368 function TableColumnField({
3369 item,
3370 fields,
3371 column,
3372 align
3373 }) {
3374 const field = fields.find((f2) => f2.id === column);
3375 if (!field) {
3376 return null;
3377 }
3378 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
3379 "dataviews-view-table__cell-align-end": align === "end",
3380 "dataviews-view-table__cell-align-center": align === "center"
3381 });
3382 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(field.render, { item, field }) });
3383 }
3384 function TableRow({
3385 hasBulkActions,
3386 item,
3387 level,
3388 actions,
3389 fields,
3390 id,
3391 view,
3392 titleField,
3393 mediaField,
3394 descriptionField,
3395 selection,
3396 getItemId,
3397 isItemClickable,
3398 onClickItem,
3399 renderItemLink,
3400 onChangeSelection,
3401 isActionsColumnSticky,
3402 posinset
3403 }) {
3404 const { paginationInfo } = (0, import_element13.useContext)(dataviews_context_default);
3405 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
3406 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
3407 const {
3408 showTitle = true,
3409 showMedia = true,
3410 showDescription = true,
3411 infiniteScrollEnabled
3412 } = view;
3413 const isTouchDeviceRef = (0, import_element13.useRef)(false);
3414 const columns = view.fields ?? [];
3415 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
3416 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3417 "tr",
3418 {
3419 className: clsx_default("dataviews-view-table__row", {
3420 "is-selected": hasPossibleBulkAction && isSelected2,
3421 "has-bulk-actions": hasPossibleBulkAction
3422 }),
3423 onTouchStart: () => {
3424 isTouchDeviceRef.current = true;
3425 },
3426 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
3427 "aria-posinset": posinset,
3428 role: infiniteScrollEnabled ? "article" : void 0,
3429 onMouseDown: (event) => {
3430 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
3431 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
3432 event?.preventDefault();
3433 }
3434 },
3435 onClick: (event) => {
3436 if (!hasPossibleBulkAction) {
3437 return;
3438 }
3439 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
3440 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
3441 onChangeSelection(
3442 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
3443 );
3444 }
3445 },
3446 children: [
3447 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3448 DataViewsSelectionCheckbox,
3449 {
3450 item,
3451 selection,
3452 onChangeSelection,
3453 getItemId,
3454 titleField,
3455 disabled: !hasPossibleBulkAction
3456 }
3457 ) }) }),
3458 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3459 column_primary_default,
3460 {
3461 item,
3462 level,
3463 titleField: showTitle ? titleField : void 0,
3464 mediaField: showMedia ? mediaField : void 0,
3465 descriptionField: showDescription ? descriptionField : void 0,
3466 isItemClickable,
3467 onClickItem,
3468 renderItemLink
3469 }
3470 ) }),
3471 columns.map((column) => {
3472 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
3473 const field = fields.find((f2) => f2.id === column);
3474 const effectiveAlign = getEffectiveAlign(align, field?.type);
3475 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3476 "td",
3477 {
3478 style: {
3479 width,
3480 maxWidth,
3481 minWidth
3482 },
3483 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3484 TableColumnField,
3485 {
3486 fields,
3487 item,
3488 column,
3489 align: effectiveAlign
3490 }
3491 )
3492 },
3493 column
3494 );
3495 }),
3496 !!actions?.length && // Disable reason: we are not making the element interactive,
3497 // but preventing any click events from bubbling up to the
3498 // table row. This allows us to add a click handler to the row
3499 // itself (to toggle row selection) without erroneously
3500 // intercepting click events from ItemActions.
3501 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3502 "td",
3503 {
3504 className: clsx_default("dataviews-view-table__actions-column", {
3505 "dataviews-view-table__actions-column--sticky": true,
3506 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
3507 }),
3508 onClick: (e2) => e2.stopPropagation(),
3509 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ItemActions, { item, actions })
3510 }
3511 )
3512 ]
3513 }
3514 );
3515 }
3516 function ViewTable({
3517 actions,
3518 data,
3519 fields,
3520 getItemId,
3521 getItemLevel,
3522 isLoading = false,
3523 onChangeView,
3524 onChangeSelection,
3525 selection,
3526 setOpenedFilter,
3527 onClickItem,
3528 isItemClickable,
3529 renderItemLink,
3530 view,
3531 className,
3532 empty
3533 }) {
3534 const { containerRef } = (0, import_element13.useContext)(dataviews_context_default);
3535 const isDelayedLoading = useDelayedLoading(isLoading);
3536 const headerMenuRefs = (0, import_element13.useRef)(/* @__PURE__ */ new Map());
3537 const headerMenuToFocusRef = (0, import_element13.useRef)(void 0);
3538 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element13.useState)();
3539 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element13.useState)(null);
3540 (0, import_element13.useEffect)(() => {
3541 if (headerMenuToFocusRef.current) {
3542 headerMenuToFocusRef.current.focus();
3543 headerMenuToFocusRef.current = void 0;
3544 }
3545 });
3546 const tableNoticeId = (0, import_element13.useId)();
3547 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
3548 scrollContainerRef: containerRef,
3549 enabledHorizontal: !!actions?.length
3550 });
3551 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
3552 if (nextHeaderMenuToFocus) {
3553 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
3554 setNextHeaderMenuToFocus(void 0);
3555 return;
3556 }
3557 const onHide = (field) => {
3558 const hidden = headerMenuRefs.current.get(field.id);
3559 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
3560 setNextHeaderMenuToFocus(fallback?.node);
3561 };
3562 const handleHeaderContextMenu = (event) => {
3563 event.preventDefault();
3564 event.stopPropagation();
3565 const virtualAnchor = {
3566 getBoundingClientRect: () => ({
3567 x: event.clientX,
3568 y: event.clientY,
3569 top: event.clientY,
3570 left: event.clientX,
3571 right: event.clientX,
3572 bottom: event.clientY,
3573 width: 0,
3574 height: 0,
3575 toJSON: () => ({})
3576 })
3577 };
3578 window.requestAnimationFrame(() => {
3579 setContextMenuAnchor(virtualAnchor);
3580 });
3581 };
3582 const hasData = !!data?.length;
3583 const titleField = fields.find((field) => field.id === view.titleField);
3584 const mediaField = fields.find((field) => field.id === view.mediaField);
3585 const descriptionField = fields.find(
3586 (field) => field.id === view.descriptionField
3587 );
3588 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
3589 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
3590 const { showTitle = true, showMedia = true, showDescription = true } = view;
3591 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
3592 const columns = view.fields ?? [];
3593 const headerMenuRef = (column, index) => (node) => {
3594 if (node) {
3595 headerMenuRefs.current.set(column, {
3596 node,
3597 fallback: columns[index > 0 ? index - 1 : 1]
3598 });
3599 } else {
3600 headerMenuRefs.current.delete(column);
3601 }
3602 };
3603 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
3604 const isRtl = (0, import_i18n9.isRTL)();
3605 if (!hasData) {
3606 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3607 "div",
3608 {
3609 className: clsx_default("dataviews-no-results", {
3610 "is-refreshing": isDelayedLoading
3611 }),
3612 id: tableNoticeId,
3613 children: empty
3614 }
3615 );
3616 }
3617 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
3618 /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3619 "table",
3620 {
3621 className: clsx_default("dataviews-view-table", className, {
3622 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
3623 view.layout.density
3624 ),
3625 "has-bulk-actions": hasBulkActions,
3626 "is-refreshing": !isInfiniteScroll && isDelayedLoading
3627 }),
3628 "aria-busy": isLoading,
3629 "aria-describedby": tableNoticeId,
3630 role: isInfiniteScroll ? "feed" : void 0,
3631 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
3632 children: [
3633 /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("colgroup", { children: [
3634 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
3635 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
3636 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3637 "col",
3638 {
3639 className: clsx_default(
3640 `dataviews-view-table__col-${column}`,
3641 {
3642 "dataviews-view-table__col-expand": !hasPrimaryColumn && index === columns.length - 1
3643 }
3644 )
3645 },
3646 `col-${column}`
3647 )),
3648 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("col", { className: "dataviews-view-table__col-actions" })
3649 ] }),
3650 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3651 import_components6.Popover,
3652 {
3653 anchor: contextMenuAnchor,
3654 onClose: () => setContextMenuAnchor(null),
3655 placement: "bottom-start",
3656 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(PropertiesSection, { showLabel: false })
3657 }
3658 ),
3659 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3660 "thead",
3661 {
3662 className: clsx_default({
3663 "dataviews-view-table__thead--stuck": isVerticallyScrolled
3664 }),
3665 onContextMenu: handleHeaderContextMenu,
3666 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("tr", { className: "dataviews-view-table__row", children: [
3667 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3668 "th",
3669 {
3670 className: "dataviews-view-table__checkbox-column",
3671 scope: "col",
3672 onContextMenu: handleHeaderContextMenu,
3673 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3674 BulkSelectionCheckbox,
3675 {
3676 selection,
3677 onChangeSelection,
3678 data,
3679 actions,
3680 getItemId
3681 }
3682 )
3683 }
3684 ),
3685 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3686 column_header_menu_default,
3687 {
3688 ref: headerMenuRef(
3689 titleField.id,
3690 0
3691 ),
3692 fieldId: titleField.id,
3693 view,
3694 fields,
3695 onChangeView,
3696 onHide,
3697 setOpenedFilter,
3698 canMove: false,
3699 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
3700 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
3701 }
3702 ) }),
3703 columns.map((column, index) => {
3704 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
3705 const field = fields.find(
3706 (f2) => f2.id === column
3707 );
3708 const effectiveAlign = getEffectiveAlign(
3709 align,
3710 field?.type
3711 );
3712 const canInsertOrMove = view.layout?.enableMoving ?? true;
3713 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3714 "th",
3715 {
3716 style: {
3717 width,
3718 maxWidth,
3719 minWidth,
3720 textAlign: effectiveAlign
3721 },
3722 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
3723 scope: "col",
3724 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3725 column_header_menu_default,
3726 {
3727 ref: headerMenuRef(column, index),
3728 fieldId: column,
3729 view,
3730 fields,
3731 onChangeView,
3732 onHide,
3733 setOpenedFilter,
3734 canMove: canInsertOrMove,
3735 canInsertLeft: canInsertOrMove,
3736 canInsertRight: canInsertOrMove
3737 }
3738 )
3739 },
3740 column
3741 );
3742 }),
3743 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3744 "th",
3745 {
3746 className: clsx_default(
3747 "dataviews-view-table__actions-column",
3748 {
3749 "dataviews-view-table__actions-column--sticky": true,
3750 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
3751 }
3752 ),
3753 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
3754 }
3755 )
3756 ] })
3757 }
3758 ),
3759 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
3760 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("tbody", { children: [
3761 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3762 "td",
3763 {
3764 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
3765 className: "dataviews-view-table__group-header-cell",
3766 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
3767 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
3768 (0, import_i18n9.__)("%1$s: %2$s"),
3769 groupField.label,
3770 groupName
3771 )
3772 }
3773 ) }),
3774 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3775 TableRow,
3776 {
3777 item,
3778 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
3779 hasBulkActions,
3780 actions,
3781 fields,
3782 id: getItemId(item) || index.toString(),
3783 view,
3784 titleField,
3785 mediaField,
3786 descriptionField,
3787 selection,
3788 getItemId,
3789 onChangeSelection,
3790 onClickItem,
3791 renderItemLink,
3792 isItemClickable,
3793 isActionsColumnSticky: !isHorizontalScrollEnd
3794 },
3795 getItemId(item)
3796 ))
3797 ] }, `group-${groupName}`)
3798 ) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3799 TableRow,
3800 {
3801 item,
3802 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
3803 hasBulkActions,
3804 actions,
3805 fields,
3806 id: getItemId(item) || index.toString(),
3807 view,
3808 titleField,
3809 mediaField,
3810 descriptionField,
3811 selection,
3812 getItemId,
3813 onChangeSelection,
3814 onClickItem,
3815 renderItemLink,
3816 isItemClickable,
3817 isActionsColumnSticky: !isHorizontalScrollEnd,
3818 posinset: isInfiniteScroll ? index + 1 : void 0
3819 },
3820 getItemId(item)
3821 )) })
3822 ]
3823 }
3824 ),
3825 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components6.Spinner, {}) }) })
3826 ] });
3827 }
3828 var table_default = ViewTable;
3829
3830 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
3831 var import_components9 = __toESM(require_components(), 1);
3832 var import_i18n12 = __toESM(require_i18n(), 1);
3833
3834 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
3835 var import_components8 = __toESM(require_components(), 1);
3836 var import_i18n11 = __toESM(require_i18n(), 1);
3837 var import_compose3 = __toESM(require_compose(), 1);
3838 var import_keycodes2 = __toESM(require_keycodes(), 1);
3839 var import_element17 = __toESM(require_element(), 1);
3840
3841 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
3842 var import_components7 = __toESM(require_components(), 1);
3843 var import_i18n10 = __toESM(require_i18n(), 1);
3844 var import_element14 = __toESM(require_element(), 1);
3845 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3846 var imageSizes = [
3847 {
3848 value: 120,
3849 breakpoint: 1
3850 },
3851 {
3852 value: 170,
3853 breakpoint: 1
3854 },
3855 {
3856 value: 230,
3857 breakpoint: 1
3858 },
3859 {
3860 value: 290,
3861 breakpoint: 1112
3862 // at minimum image width, 4 images display at this container size
3863 },
3864 {
3865 value: 350,
3866 breakpoint: 1636
3867 // at minimum image width, 6 images display at this container size
3868 },
3869 {
3870 value: 430,
3871 breakpoint: 588
3872 // at minimum image width, 2 images display at this container size
3873 }
3874 ];
3875 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
3876 function useGridColumns() {
3877 const context = (0, import_element14.useContext)(dataviews_context_default);
3878 const view = context.view;
3879 return (0, import_element14.useMemo)(() => {
3880 const containerWidth = context.containerWidth;
3881 const gap = 32;
3882 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
3883 const columns = Math.floor(
3884 (containerWidth + gap) / (previewSize + gap)
3885 );
3886 return Math.max(1, columns);
3887 }, [context.containerWidth, view.layout?.previewSize]);
3888 }
3889
3890 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
3891 var import_element15 = __toESM(require_element(), 1);
3892 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3893 var GridItems = (0, import_element15.forwardRef)(({ className, previewSize, ...props }, ref) => {
3894 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3895 "div",
3896 {
3897 ref,
3898 className: clsx_default("dataviews-view-grid-items", className),
3899 style: {
3900 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
3901 },
3902 ...props
3903 }
3904 );
3905 });
3906
3907 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
3908 var import_element16 = __toESM(require_element(), 1);
3909 function useIntersectionObserver(elementRef, posinset) {
3910 const { intersectionObserver } = (0, import_element16.useContext)(dataviews_context_default);
3911 (0, import_element16.useEffect)(() => {
3912 const element = elementRef.current;
3913 if (!element || posinset === void 0 || !intersectionObserver) {
3914 return;
3915 }
3916 intersectionObserver.observe(element);
3917 return () => {
3918 intersectionObserver.unobserve(element);
3919 };
3920 }, [elementRef, intersectionObserver, posinset]);
3921 }
3922 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
3923 const hasData = !!data?.length;
3924 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
3925 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
3926 }
3927
3928 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
3929 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3930 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
3931 function chunk(array, size) {
3932 const chunks = [];
3933 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) {
3934 chunks.push(array.slice(i2, i2 + size));
3935 }
3936 return chunks;
3937 }
3938 var GridItem = (0, import_element17.forwardRef)(
3939 function GridItem2({
3940 view,
3941 selection,
3942 onChangeSelection,
3943 onClickItem,
3944 isItemClickable,
3945 renderItemLink,
3946 getItemId,
3947 item,
3948 actions,
3949 mediaField,
3950 titleField,
3951 descriptionField,
3952 regularFields,
3953 badgeFields,
3954 hasBulkActions,
3955 config,
3956 posinset,
3957 setsize,
3958 ...props
3959 }, forwardedRef) {
3960 const {
3961 showTitle = true,
3962 showMedia = true,
3963 showDescription = true
3964 } = view;
3965 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
3966 const id = getItemId(item);
3967 const elementRef = (0, import_element17.useRef)(null);
3968 const setRefs = (0, import_element17.useCallback)(
3969 (node) => {
3970 elementRef.current = node;
3971 if (typeof forwardedRef === "function") {
3972 forwardedRef(node);
3973 } else if (forwardedRef) {
3974 forwardedRef.current = node;
3975 }
3976 },
3977 [forwardedRef]
3978 );
3979 useIntersectionObserver(elementRef, posinset);
3980 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
3981 const isSelected2 = selection.includes(id);
3982 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
3983 const rendersMediaField = showMedia && mediaField?.render;
3984 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3985 mediaField.render,
3986 {
3987 item,
3988 field: mediaField,
3989 config
3990 }
3991 ) : mediaPlaceholder;
3992 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(titleField.render, { item, field: titleField }) : null;
3993 let mediaA11yProps;
3994 let titleA11yProps;
3995 if (isItemClickable(item) && onClickItem) {
3996 if (renderedTitleField) {
3997 mediaA11yProps = {
3998 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
3999 };
4000 titleA11yProps = {
4001 id: `dataviews-view-grid__title-field-${instanceId}`
4002 };
4003 } else {
4004 mediaA11yProps = {
4005 "aria-label": (0, import_i18n11.__)("Navigate to item")
4006 };
4007 }
4008 }
4009 return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
4010 Stack,
4011 {
4012 direction: "column",
4013 ...props,
4014 ref: setRefs,
4015 "aria-setsize": setsize,
4016 "aria-posinset": posinset,
4017 className: clsx_default(
4018 props.className,
4019 "dataviews-view-grid__row__gridcell",
4020 "dataviews-view-grid__card",
4021 {
4022 "is-selected": hasBulkAction && isSelected2
4023 }
4024 ),
4025 onClickCapture: (event) => {
4026 props.onClickCapture?.(event);
4027 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
4028 event.stopPropagation();
4029 event.preventDefault();
4030 if (!hasBulkAction) {
4031 return;
4032 }
4033 onChangeSelection(
4034 isSelected2 ? selection.filter(
4035 (itemId) => id !== itemId
4036 ) : [...selection, id]
4037 );
4038 }
4039 },
4040 children: [
4041 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4042 ItemClickWrapper,
4043 {
4044 item,
4045 isItemClickable,
4046 onClickItem,
4047 renderItemLink,
4048 className: clsx_default("dataviews-view-grid__media", {
4049 "dataviews-view-grid__media--placeholder": !rendersMediaField
4050 }),
4051 ...mediaA11yProps,
4052 children: renderedMediaField
4053 }
4054 ),
4055 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4056 DataViewsSelectionCheckbox,
4057 {
4058 item,
4059 selection,
4060 onChangeSelection,
4061 getItemId,
4062 titleField,
4063 disabled: !hasBulkAction
4064 }
4065 ),
4066 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4067 ItemActions,
4068 {
4069 item,
4070 actions,
4071 isCompact: true
4072 }
4073 ) }),
4074 showTitle && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4075 ItemClickWrapper,
4076 {
4077 item,
4078 isItemClickable,
4079 onClickItem,
4080 renderItemLink,
4081 className: "dataviews-view-grid__title-field dataviews-title-field",
4082 ...titleA11yProps,
4083 title: titleField?.getValueFormatted({
4084 item,
4085 field: titleField
4086 }) || void 0,
4087 children: renderedTitleField
4088 }
4089 ) }),
4090 /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Stack, { direction: "column", gap: "xs", children: [
4091 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4092 descriptionField.render,
4093 {
4094 item,
4095 field: descriptionField
4096 }
4097 ),
4098 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4099 Stack,
4100 {
4101 direction: "row",
4102 className: "dataviews-view-grid__badge-fields",
4103 gap: "sm",
4104 wrap: "wrap",
4105 align: "top",
4106 justify: "flex-start",
4107 children: badgeFields.map((field) => {
4108 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4109 WCBadge,
4110 {
4111 className: "dataviews-view-grid__field-value",
4112 children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4113 field.render,
4114 {
4115 item,
4116 field
4117 }
4118 )
4119 },
4120 field.id
4121 );
4122 })
4123 }
4124 ),
4125 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4126 Stack,
4127 {
4128 direction: "column",
4129 className: "dataviews-view-grid__fields",
4130 gap: "xs",
4131 children: regularFields.map((field) => {
4132 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4133 import_components8.Flex,
4134 {
4135 className: "dataviews-view-grid__field",
4136 gap: 1,
4137 justify: "flex-start",
4138 expanded: true,
4139 style: { height: "auto" },
4140 direction: "row",
4141 children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
4142 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components8.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }),
4143 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4144 import_components8.FlexItem,
4145 {
4146 className: "dataviews-view-grid__field-value",
4147 style: { maxHeight: "none" },
4148 children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4149 field.render,
4150 {
4151 item,
4152 field
4153 }
4154 )
4155 }
4156 )
4157 ] })
4158 },
4159 field.id
4160 );
4161 })
4162 }
4163 )
4164 ] })
4165 ]
4166 }
4167 );
4168 }
4169 );
4170 function CompositeGrid({
4171 data,
4172 isInfiniteScroll,
4173 className,
4174 inert,
4175 isLoading,
4176 view,
4177 fields,
4178 selection,
4179 onChangeSelection,
4180 onClickItem,
4181 isItemClickable,
4182 renderItemLink,
4183 getItemId,
4184 actions
4185 }) {
4186 const { paginationInfo, resizeObserverRef } = (0, import_element17.useContext)(dataviews_context_default);
4187 const gridColumns = useGridColumns();
4188 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
4189 const titleField = fields.find(
4190 (field) => field.id === view?.titleField
4191 );
4192 const mediaField = fields.find(
4193 (field) => field.id === view?.mediaField
4194 );
4195 const descriptionField = fields.find(
4196 (field) => field.id === view?.descriptionField
4197 );
4198 const otherFields = view.fields ?? [];
4199 const { regularFields, badgeFields } = otherFields.reduce(
4200 (accumulator, fieldId) => {
4201 const field = fields.find((f2) => f2.id === fieldId);
4202 if (!field) {
4203 return accumulator;
4204 }
4205 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
4206 accumulator[key].push(field);
4207 return accumulator;
4208 },
4209 { regularFields: [], badgeFields: [] }
4210 );
4211 const size = "900px";
4212 const totalRows = Math.ceil(data.length / gridColumns);
4213 const placeholdersNeeded = usePlaceholdersNeeded(
4214 data,
4215 isInfiniteScroll,
4216 gridColumns
4217 );
4218 return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, {
4219 // Render infinite scroll layout (no rows, feed semantics)
4220 children: [
4221 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
4222 import_components8.Composite,
4223 {
4224 render: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4225 GridItems,
4226 {
4227 className: clsx_default(
4228 "dataviews-view-grid-infinite-scroll",
4229 className,
4230 {
4231 [`has-${view.layout?.density}-density`]: view.layout?.density && [
4232 "compact",
4233 "comfortable"
4234 ].includes(view.layout.density)
4235 }
4236 ),
4237 previewSize: view.layout?.previewSize,
4238 "aria-busy": isLoading,
4239 ref: resizeObserverRef
4240 }
4241 ),
4242 role: "feed",
4243 focusWrap: true,
4244 inert,
4245 children: [
4246 Array.from({ length: placeholdersNeeded }).map(
4247 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4248 import_components8.Composite.Item,
4249 {
4250 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4251 Stack,
4252 {
4253 ...props,
4254 direction: "column",
4255 role: "article",
4256 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
4257 }
4258 ),
4259 "aria-hidden": true,
4260 tabIndex: -1
4261 },
4262 `placeholder-${index}`
4263 )
4264 ),
4265 data.map((item) => {
4266 const itemId = getItemId(item);
4267 const stablePosition = item.position;
4268 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4269 import_components8.Composite.Item,
4270 {
4271 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4272 GridItem,
4273 {
4274 ...props,
4275 id: itemId,
4276 role: "article",
4277 view,
4278 selection,
4279 onChangeSelection,
4280 onClickItem,
4281 isItemClickable,
4282 renderItemLink,
4283 getItemId,
4284 item,
4285 actions,
4286 mediaField,
4287 titleField,
4288 descriptionField,
4289 regularFields,
4290 badgeFields,
4291 hasBulkActions,
4292 posinset: stablePosition,
4293 setsize: paginationInfo.totalItems,
4294 config: {
4295 sizes: size
4296 }
4297 }
4298 )
4299 },
4300 itemId
4301 );
4302 })
4303 ]
4304 }
4305 ),
4306 // Render standard grid layout (with rows, grid semantics)
4307 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4308 import_components8.Composite,
4309 {
4310 role: "grid",
4311 className: clsx_default("dataviews-view-grid", className, {
4312 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
4313 view.layout.density
4314 )
4315 }),
4316 focusWrap: true,
4317 "aria-busy": isLoading,
4318 "aria-rowcount": totalRows,
4319 ref: resizeObserverRef,
4320 inert,
4321 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4322 import_components8.Composite.Row,
4323 {
4324 render: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4325 "div",
4326 {
4327 role: "row",
4328 "aria-rowindex": i2 + 1,
4329 "aria-label": (0, import_i18n11.sprintf)(
4330 /* translators: %d: The row number in the grid */
4331 (0, import_i18n11.__)("Row %d"),
4332 i2 + 1
4333 ),
4334 className: "dataviews-view-grid__row",
4335 style: {
4336 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
4337 }
4338 }
4339 ),
4340 children: row.map((item) => {
4341 const itemId = getItemId(item);
4342 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4343 import_components8.Composite.Item,
4344 {
4345 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4346 GridItem,
4347 {
4348 ...props,
4349 id: itemId,
4350 role: "gridcell",
4351 view,
4352 selection,
4353 onChangeSelection,
4354 onClickItem,
4355 isItemClickable,
4356 renderItemLink,
4357 getItemId,
4358 item,
4359 actions,
4360 mediaField,
4361 titleField,
4362 descriptionField,
4363 regularFields,
4364 badgeFields,
4365 hasBulkActions,
4366 config: {
4367 sizes: size
4368 }
4369 }
4370 )
4371 },
4372 itemId
4373 );
4374 })
4375 },
4376 i2
4377 ))
4378 }
4379 )
4380 ]
4381 });
4382 }
4383
4384 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
4385 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
4386 function ViewGrid({
4387 actions,
4388 data,
4389 fields,
4390 getItemId,
4391 isLoading,
4392 onChangeSelection,
4393 onClickItem,
4394 isItemClickable,
4395 renderItemLink,
4396 selection,
4397 view,
4398 className,
4399 empty
4400 }) {
4401 const isDelayedLoading = useDelayedLoading(!!isLoading);
4402 const hasData = !!data?.length;
4403 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
4404 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
4405 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4406 if (!hasData) {
4407 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4408 "div",
4409 {
4410 className: clsx_default("dataviews-no-results", {
4411 "is-refreshing": isDelayedLoading
4412 }),
4413 children: empty
4414 }
4415 );
4416 }
4417 const gridProps = {
4418 className: clsx_default(className, {
4419 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4420 }),
4421 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
4422 isLoading,
4423 view,
4424 fields,
4425 selection,
4426 onChangeSelection,
4427 onClickItem,
4428 isItemClickable,
4429 renderItemLink,
4430 getItemId,
4431 actions
4432 };
4433 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, {
4434 // Render multiple groups.
4435 children: [
4436 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
4437 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
4438 Stack,
4439 {
4440 direction: "column",
4441 gap: "sm",
4442 children: [
4443 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
4444 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
4445 (0, import_i18n12.__)("%1$s: %2$s"),
4446 groupField.label,
4447 groupName
4448 ) }),
4449 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4450 CompositeGrid,
4451 {
4452 ...gridProps,
4453 data: groupItems,
4454 isInfiniteScroll: false
4455 }
4456 )
4457 ]
4458 },
4459 groupName
4460 )
4461 ) }),
4462 // Render a single grid with all data.
4463 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4464 CompositeGrid,
4465 {
4466 ...gridProps,
4467 data,
4468 isInfiniteScroll: !!isInfiniteScroll
4469 }
4470 ),
4471 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_components9.Spinner, {}) })
4472 ]
4473 });
4474 }
4475 var grid_default = ViewGrid;
4476
4477 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
4478 var import_compose4 = __toESM(require_compose(), 1);
4479 var import_components10 = __toESM(require_components(), 1);
4480 var import_element18 = __toESM(require_element(), 1);
4481 var import_i18n13 = __toESM(require_i18n(), 1);
4482 var import_data6 = __toESM(require_data(), 1);
4483 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
4484 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
4485 function generateItemWrapperCompositeId(idPrefix) {
4486 return `${idPrefix}-item-wrapper`;
4487 }
4488 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
4489 return `${idPrefix}-primary-action-${primaryActionId}`;
4490 }
4491 function generateDropdownTriggerCompositeId(idPrefix) {
4492 return `${idPrefix}-dropdown`;
4493 }
4494 function PrimaryActionGridCell({
4495 idPrefix,
4496 primaryAction,
4497 item
4498 }) {
4499 const registry = (0, import_data6.useRegistry)();
4500 const [isModalOpen, setIsModalOpen] = (0, import_element18.useState)(false);
4501 const compositeItemId = generatePrimaryActionCompositeId(
4502 idPrefix,
4503 primaryAction.id
4504 );
4505 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
4506 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4507 import_components10.Composite.Item,
4508 {
4509 id: compositeItemId,
4510 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4511 import_components10.Button,
4512 {
4513 disabled: !!primaryAction.disabled,
4514 accessibleWhenDisabled: true,
4515 text: label,
4516 size: "small",
4517 onClick: () => setIsModalOpen(true)
4518 }
4519 ),
4520 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4521 ActionModal,
4522 {
4523 action: primaryAction,
4524 items: [item],
4525 closeModal: () => setIsModalOpen(false)
4526 }
4527 )
4528 }
4529 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4530 import_components10.Composite.Item,
4531 {
4532 id: compositeItemId,
4533 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4534 import_components10.Button,
4535 {
4536 disabled: !!primaryAction.disabled,
4537 accessibleWhenDisabled: true,
4538 size: "small",
4539 onClick: () => {
4540 primaryAction.callback([item], { registry });
4541 },
4542 children: label
4543 }
4544 )
4545 }
4546 ) }, primaryAction.id);
4547 }
4548 function ListItem({
4549 view,
4550 actions,
4551 idPrefix,
4552 isSelected: isSelected2,
4553 item,
4554 titleField,
4555 mediaField,
4556 descriptionField,
4557 onSelect,
4558 otherFields,
4559 onDropdownTriggerKeyDown,
4560 posinset
4561 }) {
4562 const {
4563 showTitle = true,
4564 showMedia = true,
4565 showDescription = true,
4566 infiniteScrollEnabled
4567 } = view;
4568 const itemRef = (0, import_element18.useRef)(null);
4569 const labelId = `${idPrefix}-label`;
4570 const descriptionId = `${idPrefix}-description`;
4571 const registry = (0, import_data6.useRegistry)();
4572 const [isHovered, setIsHovered] = (0, import_element18.useState)(false);
4573 const [activeModalAction, setActiveModalAction] = (0, import_element18.useState)(
4574 null
4575 );
4576 const handleHover = ({ type }) => {
4577 const isHover = type === "mouseenter";
4578 setIsHovered(isHover);
4579 };
4580 const { paginationInfo } = (0, import_element18.useContext)(dataviews_context_default);
4581 (0, import_element18.useEffect)(() => {
4582 if (isSelected2) {
4583 itemRef.current?.scrollIntoView({
4584 behavior: "auto",
4585 block: "nearest",
4586 inline: "nearest"
4587 });
4588 }
4589 }, [isSelected2]);
4590 const { primaryAction, eligibleActions } = (0, import_element18.useMemo)(() => {
4591 const _eligibleActions = actions.filter(
4592 (action) => !action.isEligible || action.isEligible(item)
4593 );
4594 const _primaryActions = _eligibleActions.filter(
4595 (action) => action.isPrimary
4596 );
4597 return {
4598 primaryAction: _primaryActions[0],
4599 eligibleActions: _eligibleActions
4600 };
4601 }, [actions, item]);
4602 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
4603 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4604 mediaField.render,
4605 {
4606 item,
4607 field: mediaField,
4608 config: { sizes: "52px" }
4609 }
4610 ) }) : null;
4611 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(titleField.render, { item, field: titleField }) : null;
4612 const renderDescription = showDescription && descriptionField?.render;
4613 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
4614 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4615 Stack,
4616 {
4617 direction: "row",
4618 gap: "md",
4619 className: "dataviews-view-list__item-actions",
4620 children: [
4621 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4622 PrimaryActionGridCell,
4623 {
4624 idPrefix,
4625 primaryAction,
4626 item
4627 }
4628 ),
4629 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { role: "gridcell", children: [
4630 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Menu3, { placement: "bottom-end", children: [
4631 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4632 Menu3.TriggerButton,
4633 {
4634 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4635 import_components10.Composite.Item,
4636 {
4637 id: generateDropdownTriggerCompositeId(
4638 idPrefix
4639 ),
4640 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4641 import_components10.Button,
4642 {
4643 size: "small",
4644 icon: more_vertical_default,
4645 label: (0, import_i18n13.__)("Actions"),
4646 accessibleWhenDisabled: true,
4647 disabled: !actions.length,
4648 onKeyDown: onDropdownTriggerKeyDown
4649 }
4650 )
4651 }
4652 )
4653 }
4654 ),
4655 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4656 ActionsMenuGroup,
4657 {
4658 actions: eligibleActions,
4659 item,
4660 registry,
4661 setActiveModalAction
4662 }
4663 ) })
4664 ] }),
4665 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4666 ActionModal,
4667 {
4668 action: activeModalAction,
4669 items: [item],
4670 closeModal: () => setActiveModalAction(null)
4671 }
4672 )
4673 ] })
4674 ]
4675 }
4676 );
4677 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4678 import_components10.Composite.Row,
4679 {
4680 ref: itemRef,
4681 render: (
4682 /* aria-posinset breaks Composite.Row if passed to it directly. */
4683 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4684 "div",
4685 {
4686 "aria-posinset": posinset,
4687 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
4688 }
4689 )
4690 ),
4691 role: infiniteScrollEnabled ? "article" : "row",
4692 className: clsx_default({
4693 "is-selected": isSelected2,
4694 "is-hovered": isHovered
4695 }),
4696 onMouseEnter: handleHover,
4697 onMouseLeave: handleHover,
4698 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4699 Stack,
4700 {
4701 direction: "row",
4702 className: "dataviews-view-list__item-wrapper",
4703 children: [
4704 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4705 import_components10.Composite.Item,
4706 {
4707 id: generateItemWrapperCompositeId(idPrefix),
4708 "aria-pressed": isSelected2,
4709 "aria-labelledby": labelId,
4710 "aria-describedby": descriptionId,
4711 className: "dataviews-view-list__item",
4712 onClick: () => onSelect(item)
4713 }
4714 ) }),
4715 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4716 Stack,
4717 {
4718 direction: "row",
4719 gap: "md",
4720 justify: "start",
4721 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
4722 style: { flex: 1, minWidth: 0 },
4723 children: [
4724 renderedMediaField,
4725 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4726 Stack,
4727 {
4728 direction: "column",
4729 gap: "xs",
4730 className: "dataviews-view-list__field-wrapper",
4731 children: [
4732 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Stack, { direction: "row", align: "center", children: [
4733 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4734 "div",
4735 {
4736 className: "dataviews-title-field dataviews-view-list__title-field",
4737 id: labelId,
4738 children: renderedTitleField
4739 }
4740 ),
4741 usedActions
4742 ] }),
4743 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4744 descriptionField.render,
4745 {
4746 item,
4747 field: descriptionField
4748 }
4749 ) }),
4750 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4751 "div",
4752 {
4753 className: "dataviews-view-list__fields",
4754 id: descriptionId,
4755 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4756 "div",
4757 {
4758 className: "dataviews-view-list__field",
4759 children: [
4760 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4761 VisuallyHidden,
4762 {
4763 className: "dataviews-view-list__field-label",
4764 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", {}),
4765 children: field.label
4766 }
4767 ),
4768 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4769 field.render,
4770 {
4771 item,
4772 field
4773 }
4774 ) })
4775 ]
4776 },
4777 field.id
4778 ))
4779 }
4780 )
4781 ]
4782 }
4783 )
4784 ]
4785 }
4786 )
4787 ]
4788 }
4789 )
4790 }
4791 );
4792 }
4793 function isDefined2(item) {
4794 return !!item;
4795 }
4796 function ViewList(props) {
4797 const {
4798 actions,
4799 data,
4800 fields,
4801 getItemId,
4802 isLoading,
4803 onChangeSelection,
4804 selection,
4805 view,
4806 className,
4807 empty
4808 } = props;
4809 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
4810 const isDelayedLoading = useDelayedLoading(!!isLoading);
4811 const selectedItem = data?.findLast(
4812 (item) => selection.includes(getItemId(item))
4813 );
4814 const titleField = fields.find((field) => field.id === view.titleField);
4815 const mediaField = fields.find((field) => field.id === view.mediaField);
4816 const descriptionField = fields.find(
4817 (field) => field.id === view.descriptionField
4818 );
4819 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
4820 const onSelect = (item) => onChangeSelection([getItemId(item)]);
4821 const generateCompositeItemIdPrefix = (0, import_element18.useCallback)(
4822 (item) => `${baseId}-${getItemId(item)}`,
4823 [baseId, getItemId]
4824 );
4825 const isActiveCompositeItem = (0, import_element18.useCallback)(
4826 (item, idToCheck) => {
4827 return idToCheck.startsWith(
4828 generateCompositeItemIdPrefix(item)
4829 );
4830 },
4831 [generateCompositeItemIdPrefix]
4832 );
4833 const [activeCompositeId, setActiveCompositeId] = (0, import_element18.useState)(void 0);
4834 const compositeRef = (0, import_element18.useRef)(null);
4835 (0, import_element18.useEffect)(() => {
4836 if (selectedItem) {
4837 setActiveCompositeId(
4838 generateItemWrapperCompositeId(
4839 generateCompositeItemIdPrefix(selectedItem)
4840 )
4841 );
4842 }
4843 }, [selectedItem, generateCompositeItemIdPrefix]);
4844 const activeItemIndex = data.findIndex(
4845 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
4846 );
4847 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
4848 const isActiveIdInList = activeItemIndex !== -1;
4849 const selectCompositeItem = (0, import_element18.useCallback)(
4850 (targetIndex, generateCompositeId) => {
4851 const clampedIndex = Math.min(
4852 data.length - 1,
4853 Math.max(0, targetIndex)
4854 );
4855 if (!data[clampedIndex]) {
4856 return;
4857 }
4858 const itemIdPrefix = generateCompositeItemIdPrefix(
4859 data[clampedIndex]
4860 );
4861 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
4862 setActiveCompositeId(targetCompositeItemId);
4863 if (compositeRef.current?.contains(
4864 compositeRef.current.ownerDocument.activeElement
4865 )) {
4866 document.getElementById(targetCompositeItemId)?.focus();
4867 }
4868 },
4869 [data, generateCompositeItemIdPrefix]
4870 );
4871 (0, import_element18.useEffect)(() => {
4872 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
4873 if (!isActiveIdInList && wasActiveIdInList) {
4874 selectCompositeItem(
4875 previousActiveItemIndex,
4876 generateItemWrapperCompositeId
4877 );
4878 }
4879 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
4880 const onDropdownTriggerKeyDown = (0, import_element18.useCallback)(
4881 (event) => {
4882 if (event.key === "ArrowDown") {
4883 event.preventDefault();
4884 selectCompositeItem(
4885 activeItemIndex + 1,
4886 generateDropdownTriggerCompositeId
4887 );
4888 }
4889 if (event.key === "ArrowUp") {
4890 event.preventDefault();
4891 selectCompositeItem(
4892 activeItemIndex - 1,
4893 generateDropdownTriggerCompositeId
4894 );
4895 }
4896 },
4897 [selectCompositeItem, activeItemIndex]
4898 );
4899 const hasData = !!data?.length;
4900 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
4901 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
4902 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4903 if (!hasData) {
4904 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4905 "div",
4906 {
4907 className: clsx_default("dataviews-no-results", {
4908 "is-refreshing": isDelayedLoading
4909 }),
4910 children: empty
4911 }
4912 );
4913 }
4914 if (hasData && groupField && dataByGroup) {
4915 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4916 import_components10.Composite,
4917 {
4918 ref: compositeRef,
4919 id: `${baseId}`,
4920 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", {}),
4921 className: "dataviews-view-list__group",
4922 role: "grid",
4923 activeId: activeCompositeId,
4924 setActiveId: setActiveCompositeId,
4925 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4926 Stack,
4927 {
4928 direction: "column",
4929 gap: "lg",
4930 className: clsx_default("dataviews-view-list", className),
4931 children: Array.from(dataByGroup.entries()).map(
4932 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4933 Stack,
4934 {
4935 direction: "column",
4936 gap: "sm",
4937 children: [
4938 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
4939 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
4940 (0, import_i18n13.__)("%1$s: %2$s"),
4941 groupField.label,
4942 groupName
4943 ) }),
4944 groupItems.map((item) => {
4945 const id = generateCompositeItemIdPrefix(item);
4946 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4947 ListItem,
4948 {
4949 view,
4950 idPrefix: id,
4951 actions,
4952 item,
4953 isSelected: item === selectedItem,
4954 onSelect,
4955 mediaField,
4956 titleField,
4957 descriptionField,
4958 otherFields,
4959 onDropdownTriggerKeyDown
4960 },
4961 id
4962 );
4963 })
4964 ]
4965 },
4966 groupName
4967 )
4968 )
4969 }
4970 )
4971 }
4972 );
4973 }
4974 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
4975 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4976 import_components10.Composite,
4977 {
4978 ref: compositeRef,
4979 id: baseId,
4980 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", {}),
4981 className: clsx_default("dataviews-view-list", className, {
4982 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
4983 view.layout.density
4984 ),
4985 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4986 }),
4987 role: view.infiniteScrollEnabled ? "feed" : "grid",
4988 activeId: activeCompositeId,
4989 setActiveId: setActiveCompositeId,
4990 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
4991 children: data.map((item, index) => {
4992 const id = generateCompositeItemIdPrefix(item);
4993 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4994 ListItem,
4995 {
4996 view,
4997 idPrefix: id,
4998 actions,
4999 item,
5000 isSelected: item === selectedItem,
5001 onSelect,
5002 mediaField,
5003 titleField,
5004 descriptionField,
5005 otherFields,
5006 onDropdownTriggerKeyDown,
5007 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
5008 },
5009 id
5010 );
5011 })
5012 }
5013 ),
5014 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components10.Spinner, {}) })
5015 ] });
5016 }
5017
5018 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
5019 var import_components11 = __toESM(require_components(), 1);
5020
5021 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
5022 var import_i18n14 = __toESM(require_i18n(), 1);
5023 var import_element19 = __toESM(require_element(), 1);
5024 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
5025 function ActivityGroup({
5026 groupName,
5027 groupData,
5028 groupField,
5029 showLabel = true,
5030 children
5031 }) {
5032 const groupHeader = showLabel ? (0, import_element19.createInterpolateElement)(
5033 // translators: %s: The label of the field e.g. "Status".
5034 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
5035 {
5036 groupName: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
5037 groupField.render,
5038 {
5039 item: groupData[0],
5040 field: groupField
5041 }
5042 )
5043 }
5044 ) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(groupField.render, { item: groupData[0], field: groupField });
5045 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
5046 Stack,
5047 {
5048 direction: "column",
5049 className: "dataviews-view-activity__group",
5050 children: [
5051 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
5052 children
5053 ]
5054 },
5055 groupName
5056 );
5057 }
5058
5059 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
5060 var import_element20 = __toESM(require_element(), 1);
5061 var import_data7 = __toESM(require_data(), 1);
5062 var import_compose5 = __toESM(require_compose(), 1);
5063 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
5064 function ActivityItem(props) {
5065 const {
5066 view,
5067 actions,
5068 item,
5069 titleField,
5070 mediaField,
5071 descriptionField,
5072 otherFields,
5073 posinset,
5074 onClickItem,
5075 renderItemLink,
5076 isItemClickable
5077 } = props;
5078 const {
5079 showTitle = true,
5080 showMedia = true,
5081 showDescription = true,
5082 infiniteScrollEnabled
5083 } = view;
5084 const itemRef = (0, import_element20.useRef)(null);
5085 const registry = (0, import_data7.useRegistry)();
5086 const { paginationInfo } = (0, import_element20.useContext)(dataviews_context_default);
5087 const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
5088 const _eligibleActions = actions.filter(
5089 (action) => !action.isEligible || action.isEligible(item)
5090 );
5091 const _primaryActions = _eligibleActions.filter(
5092 (action) => action.isPrimary
5093 );
5094 return {
5095 primaryActions: _primaryActions,
5096 eligibleActions: _eligibleActions
5097 };
5098 }, [actions, item]);
5099 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
5100 const density = view.layout?.density ?? "balanced";
5101 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5102 mediaField.render,
5103 {
5104 item,
5105 field: mediaField,
5106 config: {
5107 sizes: density === "comfortable" ? "32px" : "24px"
5108 }
5109 }
5110 ) : null;
5111 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5112 "span",
5113 {
5114 className: "dataviews-view-activity__item-bullet",
5115 "aria-hidden": "true"
5116 }
5117 ) });
5118 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(titleField.render, { item, field: titleField }) : null;
5119 const verticalGap = (0, import_element20.useMemo)(() => {
5120 switch (density) {
5121 case "comfortable":
5122 return "md";
5123 default:
5124 return "sm";
5125 }
5126 }, [density]);
5127 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5128 "div",
5129 {
5130 ref: itemRef,
5131 role: infiniteScrollEnabled ? "article" : void 0,
5132 "aria-posinset": posinset,
5133 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
5134 className: clsx_default(
5135 "dataviews-view-activity__item",
5136 density === "compact" && "is-compact",
5137 density === "balanced" && "is-balanced",
5138 density === "comfortable" && "is-comfortable"
5139 ),
5140 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
5141 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5142 Stack,
5143 {
5144 direction: "column",
5145 gap: "xs",
5146 align: "center",
5147 className: "dataviews-view-activity__item-type",
5148 children: renderedMediaField
5149 }
5150 ),
5151 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
5152 Stack,
5153 {
5154 direction: "column",
5155 gap: verticalGap,
5156 align: "flex-start",
5157 className: "dataviews-view-activity__item-content",
5158 children: [
5159 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5160 ItemClickWrapper,
5161 {
5162 item,
5163 isItemClickable,
5164 onClickItem,
5165 renderItemLink,
5166 className: "dataviews-view-activity__item-title",
5167 children: renderedTitleField
5168 }
5169 ),
5170 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5171 descriptionField.render,
5172 {
5173 item,
5174 field: descriptionField
5175 }
5176 ) }),
5177 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
5178 "div",
5179 {
5180 className: "dataviews-view-activity__item-field",
5181 children: [
5182 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5183 VisuallyHidden,
5184 {
5185 className: "dataviews-view-activity__item-field-label",
5186 render: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", {}),
5187 children: field.label
5188 }
5189 ),
5190 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5191 field.render,
5192 {
5193 item,
5194 field
5195 }
5196 ) })
5197 ]
5198 },
5199 field.id
5200 )) }),
5201 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5202 PrimaryActions,
5203 {
5204 item,
5205 actions: primaryActions,
5206 registry,
5207 buttonVariant: "secondary"
5208 }
5209 )
5210 ]
5211 }
5212 ),
5213 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
5214 // there if there are any actions at all.
5215 isMobileViewport && // At the same time, only show the menu if there are actions to show.
5216 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5217 ItemActions,
5218 {
5219 item,
5220 actions: eligibleActions,
5221 isCompact: true
5222 }
5223 ) })
5224 ] })
5225 }
5226 );
5227 }
5228 var activity_item_default = ActivityItem;
5229
5230 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
5231 var import_react5 = __toESM(require_react(), 1);
5232 function isDefined3(item) {
5233 return !!item;
5234 }
5235 function ActivityItems(props) {
5236 const { data, fields, getItemId, view } = props;
5237 const titleField = fields.find((field) => field.id === view.titleField);
5238 const mediaField = fields.find((field) => field.id === view.mediaField);
5239 const descriptionField = fields.find(
5240 (field) => field.id === view.descriptionField
5241 );
5242 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
5243 return data.map((item, index) => {
5244 return /* @__PURE__ */ (0, import_react5.createElement)(
5245 activity_item_default,
5246 {
5247 ...props,
5248 key: getItemId(item),
5249 item,
5250 mediaField,
5251 titleField,
5252 descriptionField,
5253 otherFields,
5254 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
5255 }
5256 );
5257 });
5258 }
5259
5260 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
5261 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
5262 function ViewActivity(props) {
5263 const { empty, data, fields, isLoading, view, className } = props;
5264 const isDelayedLoading = useDelayedLoading(!!isLoading);
5265 const hasData = !!data?.length;
5266 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
5267 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
5268 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5269 if (!hasData) {
5270 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5271 "div",
5272 {
5273 className: clsx_default("dataviews-no-results", {
5274 "is-refreshing": isDelayedLoading
5275 }),
5276 children: empty
5277 }
5278 );
5279 }
5280 const isInert = !isInfiniteScroll && !!isLoading;
5281 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
5282 "is-refreshing": !isInfiniteScroll && isDelayedLoading
5283 });
5284 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
5285 if (hasData && groupField && dataByGroup) {
5286 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5287 Stack,
5288 {
5289 direction: "column",
5290 gap: "sm",
5291 className: wrapperClassName,
5292 inert: isInert ? "true" : void 0,
5293 children: groupedEntries.map(
5294 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5295 ActivityGroup,
5296 {
5297 groupName,
5298 groupData,
5299 groupField,
5300 showLabel: view.groupBy?.showLabel !== false,
5301 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5302 ActivityItems,
5303 {
5304 ...props,
5305 data: groupData
5306 }
5307 )
5308 },
5309 groupName
5310 )
5311 )
5312 }
5313 );
5314 }
5315 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
5316 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5317 "div",
5318 {
5319 className: wrapperClassName,
5320 role: view.infiniteScrollEnabled ? "feed" : void 0,
5321 inert: isInert ? "true" : void 0,
5322 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ActivityItems, { ...props })
5323 }
5324 ),
5325 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components11.Spinner, {}) })
5326 ] });
5327 }
5328
5329 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
5330 var import_components14 = __toESM(require_components(), 1);
5331 var import_i18n17 = __toESM(require_i18n(), 1);
5332 var import_compose6 = __toESM(require_compose(), 1);
5333 var import_element23 = __toESM(require_element(), 1);
5334
5335 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
5336 var import_components13 = __toESM(require_components(), 1);
5337 var import_data8 = __toESM(require_data(), 1);
5338 var import_element22 = __toESM(require_element(), 1);
5339 var import_i18n16 = __toESM(require_i18n(), 1);
5340
5341 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
5342 var import_components12 = __toESM(require_components(), 1);
5343 var import_element21 = __toESM(require_element(), 1);
5344 var import_i18n15 = __toESM(require_i18n(), 1);
5345 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
5346 function DataViewsPagination() {
5347 const {
5348 view,
5349 onChangeView,
5350 paginationInfo: { totalItems = 0, totalPages }
5351 } = (0, import_element21.useContext)(dataviews_context_default);
5352 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
5353 return null;
5354 }
5355 const currentPage = view.page ?? 1;
5356 const pageSelectOptions = Array.from(Array(totalPages)).map(
5357 (_, i2) => {
5358 const page = i2 + 1;
5359 return {
5360 value: page.toString(),
5361 label: page.toString(),
5362 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
5363 // translators: 1: current page number. 2: total number of pages.
5364 (0, import_i18n15.__)("Page %1$d of %2$d"),
5365 currentPage,
5366 totalPages
5367 ) : page.toString()
5368 };
5369 }
5370 );
5371 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
5372 Stack,
5373 {
5374 direction: "row",
5375 className: "dataviews-pagination",
5376 justify: "end",
5377 align: "center",
5378 gap: "xl",
5379 children: [
5380 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
5381 Stack,
5382 {
5383 direction: "row",
5384 justify: "flex-start",
5385 align: "center",
5386 gap: "xs",
5387 className: "dataviews-pagination__page-select",
5388 children: (0, import_element21.createInterpolateElement)(
5389 (0, import_i18n15.sprintf)(
5390 // translators: 1: Current page number, 2: Total number of pages.
5391 (0, import_i18n15._x)(
5392 "<div>Page</div>%1$s<div>of %2$d</div>",
5393 "paging"
5394 ),
5395 "<CurrentPage />",
5396 totalPages
5397 ),
5398 {
5399 div: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { "aria-hidden": true }),
5400 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
5401 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
5402 import_components12.SelectControl,
5403 {
5404 "aria-label": (0, import_i18n15.__)("Current page"),
5405 value: currentPage.toString(),
5406 options: pageSelectOptions,
5407 onChange: (newValue) => {
5408 onChangeView({
5409 ...view,
5410 page: +newValue
5411 });
5412 },
5413 size: "small",
5414 variant: "minimal"
5415 }
5416 )
5417 }
5418 )
5419 }
5420 ),
5421 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
5422 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
5423 import_components12.Button,
5424 {
5425 onClick: () => onChangeView({
5426 ...view,
5427 page: currentPage - 1
5428 }),
5429 disabled: currentPage === 1,
5430 accessibleWhenDisabled: true,
5431 label: (0, import_i18n15.__)("Previous page"),
5432 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
5433 showTooltip: true,
5434 size: "compact",
5435 tooltipPosition: "top"
5436 }
5437 ),
5438 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
5439 import_components12.Button,
5440 {
5441 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
5442 disabled: currentPage >= totalPages,
5443 accessibleWhenDisabled: true,
5444 label: (0, import_i18n15.__)("Next page"),
5445 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
5446 showTooltip: true,
5447 size: "compact",
5448 tooltipPosition: "top"
5449 }
5450 )
5451 ] })
5452 ]
5453 }
5454 );
5455 }
5456 var dataviews_pagination_default = (0, import_element21.memo)(DataViewsPagination);
5457
5458 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
5459 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
5460 function useIsMultiselectPicker(actions) {
5461 return (0, import_element22.useMemo)(() => {
5462 return actions?.every((action) => action.supportsBulk);
5463 }, [actions]);
5464 }
5465
5466 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
5467 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
5468 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
5469 function GridItem3({
5470 view,
5471 multiselect,
5472 selection,
5473 onChangeSelection,
5474 getItemId,
5475 item,
5476 mediaField,
5477 titleField,
5478 descriptionField,
5479 regularFields,
5480 badgeFields,
5481 config,
5482 posinset,
5483 setsize
5484 }) {
5485 const { showTitle = true, showMedia = true, showDescription = true } = view;
5486 const id = getItemId(item);
5487 const elementRef = (0, import_element23.useRef)(null);
5488 const isSelected2 = selection.includes(id);
5489 useIntersectionObserver(elementRef, posinset);
5490 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5491 mediaField.render,
5492 {
5493 item,
5494 field: mediaField,
5495 config
5496 }
5497 ) : null;
5498 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(titleField.render, { item, field: titleField }) : null;
5499 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
5500 import_components14.Composite.Item,
5501 {
5502 ref: elementRef,
5503 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
5504 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Stack, { direction: "column", children, ...props }),
5505 role: "option",
5506 "aria-posinset": posinset,
5507 "aria-setsize": setsize,
5508 className: clsx_default("dataviews-view-picker-grid__card", {
5509 "is-selected": isSelected2
5510 }),
5511 "aria-selected": isSelected2,
5512 onClick: () => {
5513 if (isSelected2) {
5514 onChangeSelection(
5515 selection.filter((itemId) => id !== itemId)
5516 );
5517 } else {
5518 const newSelection = multiselect ? [...selection, id] : [id];
5519 onChangeSelection(newSelection);
5520 }
5521 },
5522 children: [
5523 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
5524 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5525 DataViewsSelectionCheckbox,
5526 {
5527 item,
5528 selection,
5529 onChangeSelection,
5530 getItemId,
5531 titleField,
5532 disabled: false,
5533 "aria-hidden": true,
5534 tabIndex: -1
5535 }
5536 ),
5537 showTitle && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5538 Stack,
5539 {
5540 direction: "row",
5541 justify: "space-between",
5542 className: "dataviews-view-picker-grid__title-actions",
5543 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
5544 }
5545 ),
5546 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Stack, { direction: "column", gap: "xs", children: [
5547 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5548 descriptionField.render,
5549 {
5550 item,
5551 field: descriptionField
5552 }
5553 ),
5554 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5555 Stack,
5556 {
5557 direction: "row",
5558 className: "dataviews-view-picker-grid__badge-fields",
5559 gap: "sm",
5560 wrap: "wrap",
5561 align: "top",
5562 justify: "flex-start",
5563 children: badgeFields.map((field) => {
5564 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5565 WCBadge2,
5566 {
5567 className: "dataviews-view-picker-grid__field-value",
5568 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5569 field.render,
5570 {
5571 item,
5572 field
5573 }
5574 )
5575 },
5576 field.id
5577 );
5578 })
5579 }
5580 ),
5581 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5582 Stack,
5583 {
5584 direction: "column",
5585 className: "dataviews-view-picker-grid__fields",
5586 gap: "xs",
5587 children: regularFields.map((field) => {
5588 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5589 import_components14.Flex,
5590 {
5591 className: "dataviews-view-picker-grid__field",
5592 gap: 1,
5593 justify: "flex-start",
5594 expanded: true,
5595 style: { height: "auto" },
5596 direction: "row",
5597 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
5598 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
5599 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5600 import_components14.FlexItem,
5601 {
5602 className: "dataviews-view-picker-grid__field-value",
5603 style: { maxHeight: "none" },
5604 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5605 field.render,
5606 {
5607 item,
5608 field
5609 }
5610 )
5611 }
5612 )
5613 ] })
5614 },
5615 field.id
5616 );
5617 })
5618 }
5619 )
5620 ] })
5621 ]
5622 },
5623 id
5624 );
5625 }
5626 function GridGroup({
5627 groupName,
5628 groupField,
5629 showLabel = true,
5630 children
5631 }) {
5632 const headerId = (0, import_compose6.useInstanceId)(
5633 GridGroup,
5634 "dataviews-view-picker-grid-group__header"
5635 );
5636 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
5637 Stack,
5638 {
5639 direction: "column",
5640 gap: "sm",
5641 role: "group",
5642 "aria-labelledby": headerId,
5643 children: [
5644 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5645 "h3",
5646 {
5647 className: "dataviews-view-picker-grid-group__header",
5648 id: headerId,
5649 children: showLabel ? (0, import_i18n17.sprintf)(
5650 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5651 (0, import_i18n17.__)("%1$s: %2$s"),
5652 groupField.label,
5653 groupName
5654 ) : groupName
5655 }
5656 ),
5657 children
5658 ]
5659 },
5660 groupName
5661 );
5662 }
5663 function ViewPickerGrid({
5664 actions,
5665 data,
5666 fields,
5667 getItemId,
5668 isLoading,
5669 onChangeSelection,
5670 selection,
5671 view,
5672 className,
5673 empty
5674 }) {
5675 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element23.useContext)(dataviews_context_default);
5676 const titleField = fields.find(
5677 (field) => field.id === view?.titleField
5678 );
5679 const mediaField = fields.find(
5680 (field) => field.id === view?.mediaField
5681 );
5682 const descriptionField = fields.find(
5683 (field) => field.id === view?.descriptionField
5684 );
5685 const otherFields = view.fields ?? [];
5686 const { regularFields, badgeFields } = otherFields.reduce(
5687 (accumulator, fieldId) => {
5688 const field = fields.find((f2) => f2.id === fieldId);
5689 if (!field) {
5690 return accumulator;
5691 }
5692 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
5693 accumulator[key].push(field);
5694 return accumulator;
5695 },
5696 { regularFields: [], badgeFields: [] }
5697 );
5698 const hasData = !!data?.length;
5699 const usedPreviewSize = view.layout?.previewSize;
5700 const isMultiselect = useIsMultiselectPicker(actions);
5701 const size = "900px";
5702 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
5703 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5704 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
5705 const currentPage = view?.page ?? 1;
5706 const perPage = view?.perPage ?? 0;
5707 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
5708 const gridColumns = useGridColumns();
5709 const placeholdersNeeded = usePlaceholdersNeeded(
5710 data,
5711 isInfiniteScroll,
5712 gridColumns
5713 );
5714 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, {
5715 // Render multiple groups.
5716 children: [
5717 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5718 import_components14.Composite,
5719 {
5720 virtualFocus: true,
5721 orientation: "horizontal",
5722 role: "listbox",
5723 "aria-multiselectable": isMultiselect,
5724 className: clsx_default(
5725 "dataviews-view-picker-grid",
5726 className,
5727 {
5728 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5729 view.layout.density
5730 )
5731 }
5732 ),
5733 "aria-label": itemListLabel,
5734 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5735 Stack,
5736 {
5737 direction: "column",
5738 gap: "lg",
5739 children,
5740 ...props
5741 }
5742 ),
5743 children: Array.from(dataByGroup.entries()).map(
5744 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5745 GridGroup,
5746 {
5747 groupName,
5748 groupField,
5749 showLabel: view.groupBy?.showLabel !== false,
5750 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5751 GridItems,
5752 {
5753 previewSize: usedPreviewSize,
5754 style: {
5755 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
5756 },
5757 "aria-busy": isLoading,
5758 ref: resizeObserverRef,
5759 children: groupItems.map((item) => {
5760 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
5761 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5762 GridItem3,
5763 {
5764 view,
5765 multiselect: isMultiselect,
5766 selection,
5767 onChangeSelection,
5768 getItemId,
5769 item,
5770 mediaField,
5771 titleField,
5772 descriptionField,
5773 regularFields,
5774 badgeFields,
5775 config: {
5776 sizes: size
5777 },
5778 posinset: posInSet,
5779 setsize: setSize
5780 },
5781 getItemId(item)
5782 );
5783 })
5784 }
5785 )
5786 },
5787 groupName
5788 )
5789 )
5790 }
5791 ),
5792 // Render a single grid with all data.
5793 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
5794 import_components14.Composite,
5795 {
5796 render: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5797 GridItems,
5798 {
5799 className: clsx_default(
5800 "dataviews-view-picker-grid",
5801 className,
5802 {
5803 [`has-${view.layout?.density}-density`]: view.layout?.density && [
5804 "compact",
5805 "comfortable"
5806 ].includes(view.layout.density)
5807 }
5808 ),
5809 previewSize: usedPreviewSize,
5810 "aria-busy": isLoading,
5811 ref: resizeObserverRef
5812 }
5813 ),
5814 virtualFocus: true,
5815 orientation: "horizontal",
5816 role: "listbox",
5817 "aria-multiselectable": isMultiselect,
5818 "aria-label": itemListLabel,
5819 children: [
5820 Array.from({ length: placeholdersNeeded }).map(
5821 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5822 import_components14.Composite.Item,
5823 {
5824 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5825 Stack,
5826 {
5827 direction: "column",
5828 children,
5829 ...props
5830 }
5831 ),
5832 role: "option",
5833 "aria-hidden": true,
5834 tabIndex: -1,
5835 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
5836 },
5837 `placeholder-${index}`
5838 )
5839 ),
5840 data.map((item) => {
5841 const posinset = item.position;
5842 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5843 GridItem3,
5844 {
5845 view,
5846 multiselect: isMultiselect,
5847 selection,
5848 onChangeSelection,
5849 getItemId,
5850 item,
5851 mediaField,
5852 titleField,
5853 descriptionField,
5854 regularFields,
5855 badgeFields,
5856 config: {
5857 sizes: size
5858 },
5859 posinset,
5860 setsize: setSize
5861 },
5862 getItemId(item)
5863 );
5864 })
5865 ]
5866 }
5867 ),
5868 // Render empty state.
5869 !hasData && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5870 "div",
5871 {
5872 className: clsx_default({
5873 "dataviews-loading": isLoading,
5874 "dataviews-no-results": !isLoading
5875 }),
5876 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components14.Spinner, {}) }) : empty
5877 }
5878 ),
5879 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components14.Spinner, {}) })
5880 ]
5881 });
5882 }
5883 var picker_grid_default = ViewPickerGrid;
5884
5885 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
5886 var import_i18n18 = __toESM(require_i18n(), 1);
5887 var import_components15 = __toESM(require_components(), 1);
5888 var import_element24 = __toESM(require_element(), 1);
5889 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
5890 function TableColumnField2({
5891 item,
5892 fields,
5893 column,
5894 align
5895 }) {
5896 const field = fields.find((f2) => f2.id === column);
5897 if (!field) {
5898 return null;
5899 }
5900 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
5901 "dataviews-view-table__cell-align-end": align === "end",
5902 "dataviews-view-table__cell-align-center": align === "center"
5903 });
5904 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(field.render, { item, field }) });
5905 }
5906 function TableRow2({
5907 item,
5908 fields,
5909 id,
5910 view,
5911 titleField,
5912 mediaField,
5913 descriptionField,
5914 selection,
5915 getItemId,
5916 onChangeSelection,
5917 multiselect,
5918 posinset
5919 }) {
5920 const { paginationInfo } = (0, import_element24.useContext)(dataviews_context_default);
5921 const isSelected2 = selection.includes(id);
5922 const [isHovered, setIsHovered] = (0, import_element24.useState)(false);
5923 const elementRef = (0, import_element24.useRef)(null);
5924 useIntersectionObserver(elementRef, posinset);
5925 const {
5926 showTitle = true,
5927 showMedia = true,
5928 showDescription = true,
5929 infiniteScrollEnabled
5930 } = view;
5931 const handleMouseEnter = () => {
5932 setIsHovered(true);
5933 };
5934 const handleMouseLeave = () => {
5935 setIsHovered(false);
5936 };
5937 const columns = view.fields ?? [];
5938 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
5939 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
5940 import_components15.Composite.Item,
5941 {
5942 ref: elementRef,
5943 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5944 "tr",
5945 {
5946 className: clsx_default("dataviews-view-table__row", {
5947 "is-selected": isSelected2,
5948 "is-hovered": isHovered
5949 }),
5950 onMouseEnter: handleMouseEnter,
5951 onMouseLeave: handleMouseLeave,
5952 children,
5953 ...props
5954 }
5955 ),
5956 "aria-selected": isSelected2,
5957 "aria-setsize": paginationInfo.totalItems || void 0,
5958 "aria-posinset": posinset,
5959 role: infiniteScrollEnabled ? "article" : "option",
5960 onClick: () => {
5961 if (isSelected2) {
5962 onChangeSelection(
5963 selection.filter((itemId) => id !== itemId)
5964 );
5965 } else {
5966 const newSelection = multiselect ? [...selection, id] : [id];
5967 onChangeSelection(newSelection);
5968 }
5969 },
5970 children: [
5971 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5972 "td",
5973 {
5974 className: "dataviews-view-table__checkbox-column",
5975 role: "presentation",
5976 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5977 DataViewsSelectionCheckbox,
5978 {
5979 item,
5980 selection,
5981 onChangeSelection,
5982 getItemId,
5983 titleField,
5984 disabled: false,
5985 "aria-hidden": true,
5986 tabIndex: -1
5987 }
5988 ) })
5989 }
5990 ),
5991 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5992 "td",
5993 {
5994 role: "presentation",
5995 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5996 column_primary_default,
5997 {
5998 item,
5999 titleField: showTitle ? titleField : void 0,
6000 mediaField: showMedia ? mediaField : void 0,
6001 descriptionField: showDescription ? descriptionField : void 0,
6002 isItemClickable: () => false
6003 }
6004 )
6005 }
6006 ),
6007 columns.map((column) => {
6008 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
6009 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6010 "td",
6011 {
6012 style: {
6013 width,
6014 maxWidth,
6015 minWidth
6016 },
6017 role: "presentation",
6018 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6019 TableColumnField2,
6020 {
6021 fields,
6022 item,
6023 column,
6024 align
6025 }
6026 )
6027 },
6028 column
6029 );
6030 })
6031 ]
6032 },
6033 id
6034 );
6035 }
6036 function ViewPickerTable({
6037 actions,
6038 data,
6039 fields,
6040 getItemId,
6041 isLoading = false,
6042 onChangeView,
6043 onChangeSelection,
6044 selection,
6045 setOpenedFilter,
6046 view,
6047 className,
6048 empty
6049 }) {
6050 const headerMenuRefs = (0, import_element24.useRef)(/* @__PURE__ */ new Map());
6051 const headerMenuToFocusRef = (0, import_element24.useRef)(void 0);
6052 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element24.useState)();
6053 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
6054 (0, import_element24.useEffect)(() => {
6055 if (headerMenuToFocusRef.current) {
6056 headerMenuToFocusRef.current.focus();
6057 headerMenuToFocusRef.current = void 0;
6058 }
6059 });
6060 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
6061 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
6062 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
6063 const tableNoticeId = (0, import_element24.useId)();
6064 if (nextHeaderMenuToFocus) {
6065 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
6066 setNextHeaderMenuToFocus(void 0);
6067 return;
6068 }
6069 const onHide = (field) => {
6070 const hidden = headerMenuRefs.current.get(field.id);
6071 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
6072 setNextHeaderMenuToFocus(fallback?.node);
6073 };
6074 const hasData = !!data?.length;
6075 const titleField = fields.find((field) => field.id === view.titleField);
6076 const mediaField = fields.find((field) => field.id === view.mediaField);
6077 const descriptionField = fields.find(
6078 (field) => field.id === view.descriptionField
6079 );
6080 const { showTitle = true, showMedia = true, showDescription = true } = view;
6081 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
6082 const columns = view.fields ?? [];
6083 const headerMenuRef = (column, index) => (node) => {
6084 if (node) {
6085 headerMenuRefs.current.set(column, {
6086 node,
6087 fallback: columns[index > 0 ? index - 1 : 1]
6088 });
6089 } else {
6090 headerMenuRefs.current.delete(column);
6091 }
6092 };
6093 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
6094 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
6095 "table",
6096 {
6097 className: clsx_default(
6098 "dataviews-view-table",
6099 "dataviews-view-picker-table",
6100 className,
6101 {
6102 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
6103 view.layout.density
6104 )
6105 }
6106 ),
6107 "aria-busy": isLoading,
6108 "aria-describedby": tableNoticeId,
6109 role: isInfiniteScroll ? "feed" : "listbox",
6110 children: [
6111 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
6112 "tr",
6113 {
6114 className: "dataviews-view-table__row",
6115 role: "presentation",
6116 children: [
6117 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6118 BulkSelectionCheckbox,
6119 {
6120 selection,
6121 onChangeSelection,
6122 data,
6123 actions,
6124 getItemId,
6125 disableSelectAll: isInfiniteScroll
6126 }
6127 ) }),
6128 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6129 column_header_menu_default,
6130 {
6131 ref: headerMenuRef(
6132 titleField.id,
6133 0
6134 ),
6135 fieldId: titleField.id,
6136 view,
6137 fields,
6138 onChangeView,
6139 onHide,
6140 setOpenedFilter,
6141 canMove: false
6142 }
6143 ) }),
6144 columns.map((column, index) => {
6145 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
6146 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6147 "th",
6148 {
6149 style: {
6150 width,
6151 maxWidth,
6152 minWidth,
6153 textAlign: align
6154 },
6155 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
6156 scope: "col",
6157 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6158 column_header_menu_default,
6159 {
6160 ref: headerMenuRef(column, index),
6161 fieldId: column,
6162 view,
6163 fields,
6164 onChangeView,
6165 onHide,
6166 setOpenedFilter,
6167 canMove: view.layout?.enableMoving ?? true
6168 }
6169 )
6170 },
6171 column
6172 );
6173 })
6174 ]
6175 }
6176 ) }),
6177 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
6178 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
6179 import_components15.Composite,
6180 {
6181 virtualFocus: true,
6182 orientation: "vertical",
6183 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("tbody", { role: "group" }),
6184 children: [
6185 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6186 "tr",
6187 {
6188 className: "dataviews-view-table__group-header-row",
6189 role: "presentation",
6190 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6191 "td",
6192 {
6193 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
6194 className: "dataviews-view-table__group-header-cell",
6195 role: "presentation",
6196 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
6197 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
6198 (0, import_i18n18.__)("%1$s: %2$s"),
6199 groupField.label,
6200 groupName
6201 )
6202 }
6203 )
6204 }
6205 ),
6206 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6207 TableRow2,
6208 {
6209 item,
6210 fields,
6211 id: getItemId(item) || index.toString(),
6212 view,
6213 titleField,
6214 mediaField,
6215 descriptionField,
6216 selection,
6217 getItemId,
6218 onChangeSelection,
6219 multiselect: isMultiselect
6220 },
6221 getItemId(item)
6222 ))
6223 ]
6224 },
6225 `group-${groupName}`
6226 )
6227 ) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6228 import_components15.Composite,
6229 {
6230 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("tbody", { role: "presentation" }),
6231 virtualFocus: true,
6232 orientation: "vertical",
6233 children: hasData && data.map((item, index) => {
6234 const itemId = getItemId(item);
6235 const posinset = item.position;
6236 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6237 TableRow2,
6238 {
6239 item,
6240 fields,
6241 id: itemId || index.toString(),
6242 view,
6243 titleField,
6244 mediaField,
6245 descriptionField,
6246 selection,
6247 getItemId,
6248 onChangeSelection,
6249 multiselect: isMultiselect,
6250 posinset
6251 },
6252 itemId
6253 );
6254 })
6255 }
6256 )
6257 ]
6258 }
6259 ),
6260 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
6261 "div",
6262 {
6263 className: clsx_default({
6264 "dataviews-loading": isLoading,
6265 "dataviews-no-results": !hasData && !isLoading
6266 }),
6267 id: tableNoticeId,
6268 children: [
6269 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components15.Spinner, {}) }) : empty),
6270 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components15.Spinner, {}) })
6271 ]
6272 }
6273 )
6274 ] });
6275 }
6276 var picker_table_default = ViewPickerTable;
6277
6278 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
6279 var import_components16 = __toESM(require_components(), 1);
6280 var import_i18n19 = __toESM(require_i18n(), 1);
6281 var import_element25 = __toESM(require_element(), 1);
6282 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
6283 function DensityPicker() {
6284 const context = (0, import_element25.useContext)(dataviews_context_default);
6285 const view = context.view;
6286 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
6287 import_components16.__experimentalToggleGroupControl,
6288 {
6289 size: "__unstable-large",
6290 label: (0, import_i18n19.__)("Density"),
6291 value: view.layout?.density || "balanced",
6292 onChange: (value) => {
6293 context.onChangeView({
6294 ...view,
6295 layout: {
6296 ...view.layout,
6297 density: value
6298 }
6299 });
6300 },
6301 isBlock: true,
6302 children: [
6303 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6304 import_components16.__experimentalToggleGroupControlOption,
6305 {
6306 value: "comfortable",
6307 label: (0, import_i18n19._x)(
6308 "Comfortable",
6309 "Density option for DataView layout"
6310 )
6311 },
6312 "comfortable"
6313 ),
6314 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6315 import_components16.__experimentalToggleGroupControlOption,
6316 {
6317 value: "balanced",
6318 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout")
6319 },
6320 "balanced"
6321 ),
6322 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6323 import_components16.__experimentalToggleGroupControlOption,
6324 {
6325 value: "compact",
6326 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout")
6327 },
6328 "compact"
6329 )
6330 ]
6331 }
6332 );
6333 }
6334
6335 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
6336 var import_components17 = __toESM(require_components(), 1);
6337 var import_i18n20 = __toESM(require_i18n(), 1);
6338 var import_element26 = __toESM(require_element(), 1);
6339 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
6340 var imageSizes2 = [
6341 {
6342 value: 120,
6343 breakpoint: 1
6344 },
6345 {
6346 value: 170,
6347 breakpoint: 1
6348 },
6349 {
6350 value: 230,
6351 breakpoint: 1
6352 },
6353 {
6354 value: 290,
6355 breakpoint: 1112
6356 // at minimum image width, 4 images display at this container size
6357 },
6358 {
6359 value: 350,
6360 breakpoint: 1636
6361 // at minimum image width, 6 images display at this container size
6362 },
6363 {
6364 value: 430,
6365 breakpoint: 588
6366 // at minimum image width, 2 images display at this container size
6367 }
6368 ];
6369 function PreviewSizePicker() {
6370 const context = (0, import_element26.useContext)(dataviews_context_default);
6371 const view = context.view;
6372 const breakValues = imageSizes2.filter((size) => {
6373 return context.containerWidth >= size.breakpoint;
6374 });
6375 const layoutPreviewSize = view.layout?.previewSize ?? 230;
6376 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
6377 const marks = breakValues.map((size, index) => {
6378 return {
6379 value: index
6380 };
6381 });
6382 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
6383 import_components17.RangeControl,
6384 {
6385 __next40pxDefaultSize: true,
6386 showTooltip: false,
6387 label: (0, import_i18n20.__)("Preview size"),
6388 value: previewSizeToUse,
6389 min: 0,
6390 max: breakValues.length - 1,
6391 withInputField: false,
6392 onChange: (value = 0) => {
6393 context.onChangeView({
6394 ...view,
6395 layout: {
6396 ...view.layout,
6397 previewSize: breakValues[value].value
6398 }
6399 });
6400 },
6401 step: 1,
6402 marks
6403 }
6404 );
6405 }
6406
6407 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
6408 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
6409 function GridConfigOptions() {
6410 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
6411 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DensityPicker, {}),
6412 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PreviewSizePicker, {})
6413 ] });
6414 }
6415
6416 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
6417 var VIEW_LAYOUTS = [
6418 {
6419 type: LAYOUT_TABLE,
6420 label: (0, import_i18n21.__)("Table"),
6421 component: table_default,
6422 icon: block_table_default,
6423 viewConfigOptions: DensityPicker
6424 },
6425 {
6426 type: LAYOUT_GRID,
6427 label: (0, import_i18n21.__)("Grid"),
6428 component: grid_default,
6429 icon: category_default,
6430 viewConfigOptions: GridConfigOptions
6431 },
6432 {
6433 type: LAYOUT_LIST,
6434 label: (0, import_i18n21.__)("List"),
6435 component: ViewList,
6436 icon: (0, import_i18n21.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
6437 viewConfigOptions: DensityPicker
6438 },
6439 {
6440 type: LAYOUT_ACTIVITY,
6441 label: (0, import_i18n21.__)("Activity"),
6442 component: ViewActivity,
6443 icon: scheduled_default,
6444 viewConfigOptions: DensityPicker
6445 },
6446 {
6447 type: LAYOUT_PICKER_GRID,
6448 label: (0, import_i18n21.__)("Grid"),
6449 component: picker_grid_default,
6450 icon: category_default,
6451 viewConfigOptions: GridConfigOptions,
6452 isPicker: true
6453 },
6454 {
6455 type: LAYOUT_PICKER_TABLE,
6456 label: (0, import_i18n21.__)("Table"),
6457 component: picker_table_default,
6458 icon: block_table_default,
6459 viewConfigOptions: DensityPicker,
6460 isPicker: true
6461 }
6462 ];
6463
6464 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
6465 var import_element34 = __toESM(require_element(), 1);
6466
6467 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
6468 var import_components20 = __toESM(require_components(), 1);
6469 var import_i18n24 = __toESM(require_i18n(), 1);
6470 var import_element31 = __toESM(require_element(), 1);
6471
6472 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
6473 function noop(..._) {
6474 }
6475 function applyState(argument, currentValue) {
6476 if (isUpdater(argument)) {
6477 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
6478 return argument(value);
6479 }
6480 return argument;
6481 }
6482 function isUpdater(argument) {
6483 return typeof argument === "function";
6484 }
6485 function isLazyValue(value) {
6486 return typeof value === "function";
6487 }
6488 function hasOwnProperty(object, prop) {
6489 if (typeof Object.hasOwn === "function") {
6490 return Object.hasOwn(object, prop);
6491 }
6492 return Object.prototype.hasOwnProperty.call(object, prop);
6493 }
6494 function chain(...fns) {
6495 return (...args) => {
6496 for (const fn of fns) {
6497 if (typeof fn === "function") {
6498 fn(...args);
6499 }
6500 }
6501 };
6502 }
6503 function normalizeString(str) {
6504 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
6505 }
6506 function omit2(object, keys) {
6507 const result = { ...object };
6508 for (const key of keys) {
6509 if (hasOwnProperty(result, key)) {
6510 delete result[key];
6511 }
6512 }
6513 return result;
6514 }
6515 function pick(object, paths) {
6516 const result = {};
6517 for (const key of paths) {
6518 if (hasOwnProperty(object, key)) {
6519 result[key] = object[key];
6520 }
6521 }
6522 return result;
6523 }
6524 function identity(value) {
6525 return value;
6526 }
6527 function invariant(condition, message2) {
6528 if (condition) return;
6529 if (typeof message2 !== "string") throw new Error("Invariant failed");
6530 throw new Error(message2);
6531 }
6532 function getKeys(obj) {
6533 return Object.keys(obj);
6534 }
6535 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
6536 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
6537 if (result == null) return false;
6538 return !result;
6539 }
6540 function disabledFromProps(props) {
6541 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
6542 }
6543 function removeUndefinedValues(obj) {
6544 const result = {};
6545 for (const key in obj) {
6546 if (obj[key] !== void 0) {
6547 result[key] = obj[key];
6548 }
6549 }
6550 return result;
6551 }
6552 function defaultValue(...values) {
6553 for (const value of values) {
6554 if (value !== void 0) return value;
6555 }
6556 return void 0;
6557 }
6558
6559 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
6560 var import_react6 = __toESM(require_react(), 1);
6561 function setRef(ref, value) {
6562 if (typeof ref === "function") {
6563 ref(value);
6564 } else if (ref) {
6565 ref.current = value;
6566 }
6567 }
6568 function isValidElementWithRef(element) {
6569 if (!element) return false;
6570 if (!(0, import_react6.isValidElement)(element)) return false;
6571 if ("ref" in element.props) return true;
6572 if ("ref" in element) return true;
6573 return false;
6574 }
6575 function getRefProperty(element) {
6576 if (!isValidElementWithRef(element)) return null;
6577 const props = { ...element.props };
6578 return props.ref || element.ref;
6579 }
6580 function mergeProps2(base, overrides) {
6581 const props = { ...base };
6582 for (const key in overrides) {
6583 if (!hasOwnProperty(overrides, key)) continue;
6584 if (key === "className") {
6585 const prop = "className";
6586 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
6587 continue;
6588 }
6589 if (key === "style") {
6590 const prop = "style";
6591 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
6592 continue;
6593 }
6594 const overrideValue = overrides[key];
6595 if (typeof overrideValue === "function" && key.startsWith("on")) {
6596 const baseValue = base[key];
6597 if (typeof baseValue === "function") {
6598 props[key] = (...args) => {
6599 overrideValue(...args);
6600 baseValue(...args);
6601 };
6602 continue;
6603 }
6604 }
6605 props[key] = overrideValue;
6606 }
6607 return props;
6608 }
6609
6610 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
6611 var canUseDOM = checkIsBrowser();
6612 function checkIsBrowser() {
6613 var _a;
6614 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
6615 }
6616 function getDocument(node) {
6617 if (!node) return document;
6618 if ("self" in node) return node.document;
6619 return node.ownerDocument || document;
6620 }
6621 function getActiveElement(node, activeDescendant = false) {
6622 var _a;
6623 const { activeElement } = getDocument(node);
6624 if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
6625 return null;
6626 }
6627 if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
6628 return getActiveElement(
6629 activeElement.contentDocument.body,
6630 activeDescendant
6631 );
6632 }
6633 if (activeDescendant) {
6634 const id = activeElement.getAttribute("aria-activedescendant");
6635 if (id) {
6636 const element = getDocument(activeElement).getElementById(id);
6637 if (element) {
6638 return element;
6639 }
6640 }
6641 }
6642 return activeElement;
6643 }
6644 function contains(parent, child) {
6645 return parent === child || parent.contains(child);
6646 }
6647 function isFrame(element) {
6648 return element.tagName === "IFRAME";
6649 }
6650 function isButton(element) {
6651 const tagName = element.tagName.toLowerCase();
6652 if (tagName === "button") return true;
6653 if (tagName === "input" && element.type) {
6654 return buttonInputTypes.indexOf(element.type) !== -1;
6655 }
6656 return false;
6657 }
6658 var buttonInputTypes = [
6659 "button",
6660 "color",
6661 "file",
6662 "image",
6663 "reset",
6664 "submit"
6665 ];
6666 function isVisible(element) {
6667 if (typeof element.checkVisibility === "function") {
6668 return element.checkVisibility();
6669 }
6670 const htmlElement = element;
6671 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
6672 }
6673 function isTextField(element) {
6674 try {
6675 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
6676 const isTextArea = element.tagName === "TEXTAREA";
6677 return isTextInput || isTextArea || false;
6678 } catch (_error) {
6679 return false;
6680 }
6681 }
6682 function isTextbox(element) {
6683 return element.isContentEditable || isTextField(element);
6684 }
6685 function getTextboxValue(element) {
6686 if (isTextField(element)) {
6687 return element.value;
6688 }
6689 if (element.isContentEditable) {
6690 const range = getDocument(element).createRange();
6691 range.selectNodeContents(element);
6692 return range.toString();
6693 }
6694 return "";
6695 }
6696 function getTextboxSelection(element) {
6697 let start = 0;
6698 let end = 0;
6699 if (isTextField(element)) {
6700 start = element.selectionStart || 0;
6701 end = element.selectionEnd || 0;
6702 } else if (element.isContentEditable) {
6703 const selection = getDocument(element).getSelection();
6704 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
6705 const range = selection.getRangeAt(0);
6706 const nextRange = range.cloneRange();
6707 nextRange.selectNodeContents(element);
6708 nextRange.setEnd(range.startContainer, range.startOffset);
6709 start = nextRange.toString().length;
6710 nextRange.setEnd(range.endContainer, range.endOffset);
6711 end = nextRange.toString().length;
6712 }
6713 }
6714 return { start, end };
6715 }
6716 function getPopupRole(element, fallback) {
6717 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
6718 const role = element == null ? void 0 : element.getAttribute("role");
6719 if (role && allowedPopupRoles.indexOf(role) !== -1) {
6720 return role;
6721 }
6722 return fallback;
6723 }
6724 function getScrollingElement(element) {
6725 if (!element) return null;
6726 const isScrollableOverflow = (overflow) => {
6727 if (overflow === "auto") return true;
6728 if (overflow === "scroll") return true;
6729 return false;
6730 };
6731 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
6732 const { overflowY } = getComputedStyle(element);
6733 if (isScrollableOverflow(overflowY)) return element;
6734 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
6735 const { overflowX } = getComputedStyle(element);
6736 if (isScrollableOverflow(overflowX)) return element;
6737 }
6738 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
6739 }
6740 function setSelectionRange(element, ...args) {
6741 if (/text|search|password|tel|url/i.test(element.type)) {
6742 element.setSelectionRange(...args);
6743 }
6744 }
6745 function sortBasedOnDOMPosition(items, getElement) {
6746 const pairs = items.map((item, index) => [index, item]);
6747 let isOrderDifferent = false;
6748 pairs.sort(([indexA, a2], [indexB, b2]) => {
6749 const elementA = getElement(a2);
6750 const elementB = getElement(b2);
6751 if (elementA === elementB) return 0;
6752 if (!elementA || !elementB) return 0;
6753 if (isElementPreceding(elementA, elementB)) {
6754 if (indexA > indexB) {
6755 isOrderDifferent = true;
6756 }
6757 return -1;
6758 }
6759 if (indexA < indexB) {
6760 isOrderDifferent = true;
6761 }
6762 return 1;
6763 });
6764 if (isOrderDifferent) {
6765 return pairs.map(([_, item]) => item);
6766 }
6767 return items;
6768 }
6769 function isElementPreceding(a2, b2) {
6770 return Boolean(
6771 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
6772 );
6773 }
6774
6775 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
6776 function isTouchDevice() {
6777 return canUseDOM && !!navigator.maxTouchPoints;
6778 }
6779 function isApple() {
6780 if (!canUseDOM) return false;
6781 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
6782 }
6783 function isSafari() {
6784 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
6785 }
6786 function isFirefox() {
6787 return canUseDOM && /firefox\//i.test(navigator.userAgent);
6788 }
6789
6790 // node_modules/@ariakit/core/esm/utils/events.js
6791 function isPortalEvent(event) {
6792 return Boolean(
6793 event.currentTarget && !contains(event.currentTarget, event.target)
6794 );
6795 }
6796 function isSelfTarget(event) {
6797 return event.target === event.currentTarget;
6798 }
6799 function isOpeningInNewTab(event) {
6800 const element = event.currentTarget;
6801 if (!element) return false;
6802 const isAppleDevice = isApple();
6803 if (isAppleDevice && !event.metaKey) return false;
6804 if (!isAppleDevice && !event.ctrlKey) return false;
6805 const tagName = element.tagName.toLowerCase();
6806 if (tagName === "a") return true;
6807 if (tagName === "button" && element.type === "submit") return true;
6808 if (tagName === "input" && element.type === "submit") return true;
6809 return false;
6810 }
6811 function isDownloading(event) {
6812 const element = event.currentTarget;
6813 if (!element) return false;
6814 const tagName = element.tagName.toLowerCase();
6815 if (!event.altKey) return false;
6816 if (tagName === "a") return true;
6817 if (tagName === "button" && element.type === "submit") return true;
6818 if (tagName === "input" && element.type === "submit") return true;
6819 return false;
6820 }
6821 function fireBlurEvent(element, eventInit) {
6822 const event = new FocusEvent("blur", eventInit);
6823 const defaultAllowed = element.dispatchEvent(event);
6824 const bubbleInit = { ...eventInit, bubbles: true };
6825 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
6826 return defaultAllowed;
6827 }
6828 function fireKeyboardEvent(element, type, eventInit) {
6829 const event = new KeyboardEvent(type, eventInit);
6830 return element.dispatchEvent(event);
6831 }
6832 function fireClickEvent(element, eventInit) {
6833 const event = new MouseEvent("click", eventInit);
6834 return element.dispatchEvent(event);
6835 }
6836 function isFocusEventOutside(event, container) {
6837 const containerElement = container || event.currentTarget;
6838 const relatedTarget = event.relatedTarget;
6839 return !relatedTarget || !contains(containerElement, relatedTarget);
6840 }
6841 function queueBeforeEvent(element, type, callback, timeout) {
6842 const createTimer = (callback2) => {
6843 if (timeout) {
6844 const timerId2 = setTimeout(callback2, timeout);
6845 return () => clearTimeout(timerId2);
6846 }
6847 const timerId = requestAnimationFrame(callback2);
6848 return () => cancelAnimationFrame(timerId);
6849 };
6850 const cancelTimer = createTimer(() => {
6851 element.removeEventListener(type, callSync, true);
6852 callback();
6853 });
6854 const callSync = () => {
6855 cancelTimer();
6856 callback();
6857 };
6858 element.addEventListener(type, callSync, { once: true, capture: true });
6859 return cancelTimer;
6860 }
6861 function addGlobalEventListener(type, listener, options, scope = window) {
6862 const children = [];
6863 try {
6864 scope.document.addEventListener(type, listener, options);
6865 for (const frame of Array.from(scope.frames)) {
6866 children.push(addGlobalEventListener(type, listener, options, frame));
6867 }
6868 } catch (e2) {
6869 }
6870 const removeEventListener = () => {
6871 try {
6872 scope.document.removeEventListener(type, listener, options);
6873 } catch (e2) {
6874 }
6875 for (const remove of children) {
6876 remove();
6877 }
6878 };
6879 return removeEventListener;
6880 }
6881
6882 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
6883 var React6 = __toESM(require_react(), 1);
6884 var import_react7 = __toESM(require_react(), 1);
6885 var _React = { ...React6 };
6886 var useReactId = _React.useId;
6887 var useReactDeferredValue = _React.useDeferredValue;
6888 var useReactInsertionEffect = _React.useInsertionEffect;
6889 var useSafeLayoutEffect = canUseDOM ? import_react7.useLayoutEffect : import_react7.useEffect;
6890 function useInitialValue(value) {
6891 const [initialValue] = (0, import_react7.useState)(value);
6892 return initialValue;
6893 }
6894 function useLiveRef(value) {
6895 const ref = (0, import_react7.useRef)(value);
6896 useSafeLayoutEffect(() => {
6897 ref.current = value;
6898 });
6899 return ref;
6900 }
6901 function useEvent(callback) {
6902 const ref = (0, import_react7.useRef)(() => {
6903 throw new Error("Cannot call an event handler while rendering.");
6904 });
6905 if (useReactInsertionEffect) {
6906 useReactInsertionEffect(() => {
6907 ref.current = callback;
6908 });
6909 } else {
6910 ref.current = callback;
6911 }
6912 return (0, import_react7.useCallback)((...args) => {
6913 var _a;
6914 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
6915 }, []);
6916 }
6917 function useTransactionState(callback) {
6918 const [state, setState] = (0, import_react7.useState)(null);
6919 useSafeLayoutEffect(() => {
6920 if (state == null) return;
6921 if (!callback) return;
6922 let prevState = null;
6923 callback((prev) => {
6924 prevState = prev;
6925 return state;
6926 });
6927 return () => {
6928 callback(prevState);
6929 };
6930 }, [state, callback]);
6931 return [state, setState];
6932 }
6933 function useMergeRefs(...refs) {
6934 return (0, import_react7.useMemo)(() => {
6935 if (!refs.some(Boolean)) return;
6936 return (value) => {
6937 for (const ref of refs) {
6938 setRef(ref, value);
6939 }
6940 };
6941 }, refs);
6942 }
6943 function useId3(defaultId) {
6944 if (useReactId) {
6945 const reactId = useReactId();
6946 if (defaultId) return defaultId;
6947 return reactId;
6948 }
6949 const [id, setId] = (0, import_react7.useState)(defaultId);
6950 useSafeLayoutEffect(() => {
6951 if (defaultId || id) return;
6952 const random = Math.random().toString(36).slice(2, 8);
6953 setId(`id-${random}`);
6954 }, [defaultId, id]);
6955 return defaultId || id;
6956 }
6957 function useTagName(refOrElement, type) {
6958 const stringOrUndefined = (type2) => {
6959 if (typeof type2 !== "string") return;
6960 return type2;
6961 };
6962 const [tagName, setTagName] = (0, import_react7.useState)(() => stringOrUndefined(type));
6963 useSafeLayoutEffect(() => {
6964 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
6965 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
6966 }, [refOrElement, type]);
6967 return tagName;
6968 }
6969 function useAttribute(refOrElement, attributeName, defaultValue2) {
6970 const initialValue = useInitialValue(defaultValue2);
6971 const [attribute, setAttribute] = (0, import_react7.useState)(initialValue);
6972 (0, import_react7.useEffect)(() => {
6973 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
6974 if (!element) return;
6975 const callback = () => {
6976 const value = element.getAttribute(attributeName);
6977 setAttribute(value == null ? initialValue : value);
6978 };
6979 const observer = new MutationObserver(callback);
6980 observer.observe(element, { attributeFilter: [attributeName] });
6981 callback();
6982 return () => observer.disconnect();
6983 }, [refOrElement, attributeName, initialValue]);
6984 return attribute;
6985 }
6986 function useUpdateEffect(effect, deps) {
6987 const mounted = (0, import_react7.useRef)(false);
6988 (0, import_react7.useEffect)(() => {
6989 if (mounted.current) {
6990 return effect();
6991 }
6992 mounted.current = true;
6993 }, deps);
6994 (0, import_react7.useEffect)(
6995 () => () => {
6996 mounted.current = false;
6997 },
6998 []
6999 );
7000 }
7001 function useUpdateLayoutEffect(effect, deps) {
7002 const mounted = (0, import_react7.useRef)(false);
7003 useSafeLayoutEffect(() => {
7004 if (mounted.current) {
7005 return effect();
7006 }
7007 mounted.current = true;
7008 }, deps);
7009 useSafeLayoutEffect(
7010 () => () => {
7011 mounted.current = false;
7012 },
7013 []
7014 );
7015 }
7016 function useForceUpdate() {
7017 return (0, import_react7.useReducer)(() => [], []);
7018 }
7019 function useBooleanEvent(booleanOrCallback) {
7020 return useEvent(
7021 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
7022 );
7023 }
7024 function useWrapElement(props, callback, deps = []) {
7025 const wrapElement = (0, import_react7.useCallback)(
7026 (element) => {
7027 if (props.wrapElement) {
7028 element = props.wrapElement(element);
7029 }
7030 return callback(element);
7031 },
7032 [...deps, props.wrapElement]
7033 );
7034 return { ...props, wrapElement };
7035 }
7036 function useMetadataProps(props, key, value) {
7037 const parent = props.onLoadedMetadataCapture;
7038 const onLoadedMetadataCapture = (0, import_react7.useMemo)(() => {
7039 return Object.assign(() => {
7040 }, { ...parent, [key]: value });
7041 }, [parent, key, value]);
7042 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
7043 }
7044 var hasInstalledGlobalEventListeners = false;
7045 function useIsMouseMoving() {
7046 (0, import_react7.useEffect)(() => {
7047 if (hasInstalledGlobalEventListeners) return;
7048 addGlobalEventListener("mousemove", setMouseMoving, true);
7049 addGlobalEventListener("mousedown", resetMouseMoving, true);
7050 addGlobalEventListener("mouseup", resetMouseMoving, true);
7051 addGlobalEventListener("keydown", resetMouseMoving, true);
7052 addGlobalEventListener("scroll", resetMouseMoving, true);
7053 hasInstalledGlobalEventListeners = true;
7054 }, []);
7055 const isMouseMoving = useEvent(() => mouseMoving);
7056 return isMouseMoving;
7057 }
7058 var mouseMoving = false;
7059 var previousScreenX = 0;
7060 var previousScreenY = 0;
7061 function hasMouseMovement(event) {
7062 const movementX = event.movementX || event.screenX - previousScreenX;
7063 const movementY = event.movementY || event.screenY - previousScreenY;
7064 previousScreenX = event.screenX;
7065 previousScreenY = event.screenY;
7066 return movementX || movementY || false;
7067 }
7068 function setMouseMoving(event) {
7069 if (!hasMouseMovement(event)) return;
7070 mouseMoving = true;
7071 }
7072 function resetMouseMoving() {
7073 mouseMoving = false;
7074 }
7075
7076 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
7077 var React7 = __toESM(require_react(), 1);
7078 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
7079 function forwardRef22(render4) {
7080 const Role = React7.forwardRef(
7081 // @ts-ignore Incompatible with React 19 types. Ignore for now.
7082 (props, ref) => render4({ ...props, ref })
7083 );
7084 Role.displayName = render4.displayName || render4.name;
7085 return Role;
7086 }
7087 function memo22(Component, propsAreEqual) {
7088 return React7.memo(Component, propsAreEqual);
7089 }
7090 function createElement3(Type, props) {
7091 const { wrapElement, render: render4, ...rest } = props;
7092 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
7093 let element;
7094 if (React7.isValidElement(render4)) {
7095 const renderProps = {
7096 // @ts-ignore Incompatible with React 19 types. Ignore for now.
7097 ...render4.props,
7098 ref: mergedRef
7099 };
7100 element = React7.cloneElement(render4, mergeProps2(rest, renderProps));
7101 } else if (render4) {
7102 element = render4(rest);
7103 } else {
7104 element = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Type, { ...rest });
7105 }
7106 if (wrapElement) {
7107 return wrapElement(element);
7108 }
7109 return element;
7110 }
7111 function createHook(useProps) {
7112 const useRole = (props = {}) => {
7113 return useProps(props);
7114 };
7115 useRole.displayName = useProps.name;
7116 return useRole;
7117 }
7118 function createStoreContext(providers = [], scopedProviders = []) {
7119 const context = React7.createContext(void 0);
7120 const scopedContext = React7.createContext(void 0);
7121 const useContext29 = () => React7.useContext(context);
7122 const useScopedContext = (onlyScoped = false) => {
7123 const scoped = React7.useContext(scopedContext);
7124 const store = useContext29();
7125 if (onlyScoped) return scoped;
7126 return scoped || store;
7127 };
7128 const useProviderContext = () => {
7129 const scoped = React7.useContext(scopedContext);
7130 const store = useContext29();
7131 if (scoped && scoped === store) return;
7132 return store;
7133 };
7134 const ContextProvider = (props) => {
7135 return providers.reduceRight(
7136 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Provider, { ...props, children }),
7137 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(context.Provider, { ...props })
7138 );
7139 };
7140 const ScopedContextProvider = (props) => {
7141 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
7142 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Provider, { ...props, children }),
7143 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(scopedContext.Provider, { ...props })
7144 ) });
7145 };
7146 return {
7147 context,
7148 scopedContext,
7149 useContext: useContext29,
7150 useScopedContext,
7151 useProviderContext,
7152 ContextProvider,
7153 ScopedContextProvider
7154 };
7155 }
7156
7157 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
7158 var ctx = createStoreContext();
7159 var useCollectionContext = ctx.useContext;
7160 var useCollectionScopedContext = ctx.useScopedContext;
7161 var useCollectionProviderContext = ctx.useProviderContext;
7162 var CollectionContextProvider = ctx.ContextProvider;
7163 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
7164
7165 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
7166 var import_react8 = __toESM(require_react(), 1);
7167 var ctx2 = createStoreContext(
7168 [CollectionContextProvider],
7169 [CollectionScopedContextProvider]
7170 );
7171 var useCompositeContext = ctx2.useContext;
7172 var useCompositeScopedContext = ctx2.useScopedContext;
7173 var useCompositeProviderContext = ctx2.useProviderContext;
7174 var CompositeContextProvider = ctx2.ContextProvider;
7175 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
7176 var CompositeItemContext = (0, import_react8.createContext)(
7177 void 0
7178 );
7179 var CompositeRowContext = (0, import_react8.createContext)(
7180 void 0
7181 );
7182
7183 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
7184 function findFirstEnabledItem(items, excludeId) {
7185 return items.find((item) => {
7186 if (excludeId) {
7187 return !item.disabled && item.id !== excludeId;
7188 }
7189 return !item.disabled;
7190 });
7191 }
7192 function getEnabledItem(store, id) {
7193 if (!id) return null;
7194 return store.item(id) || null;
7195 }
7196 function groupItemsByRows(items) {
7197 const rows = [];
7198 for (const item of items) {
7199 const row = rows.find((currentRow) => {
7200 var _a;
7201 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
7202 });
7203 if (row) {
7204 row.push(item);
7205 } else {
7206 rows.push([item]);
7207 }
7208 }
7209 return rows;
7210 }
7211 function selectTextField(element, collapseToEnd = false) {
7212 if (isTextField(element)) {
7213 element.setSelectionRange(
7214 collapseToEnd ? element.value.length : 0,
7215 element.value.length
7216 );
7217 } else if (element.isContentEditable) {
7218 const selection = getDocument(element).getSelection();
7219 selection == null ? void 0 : selection.selectAllChildren(element);
7220 if (collapseToEnd) {
7221 selection == null ? void 0 : selection.collapseToEnd();
7222 }
7223 }
7224 }
7225 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
7226 function focusSilently(element) {
7227 element[FOCUS_SILENTLY] = true;
7228 element.focus({ preventScroll: true });
7229 }
7230 function silentlyFocused(element) {
7231 const isSilentlyFocused = element[FOCUS_SILENTLY];
7232 delete element[FOCUS_SILENTLY];
7233 return isSilentlyFocused;
7234 }
7235 function isItem(store, element, exclude) {
7236 if (!element) return false;
7237 if (element === exclude) return false;
7238 const item = store.item(element.id);
7239 if (!item) return false;
7240 if (exclude && item.element === exclude) return false;
7241 return true;
7242 }
7243
7244 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
7245 var import_react9 = __toESM(require_react(), 1);
7246 var TagName = "div";
7247 var useCollectionItem = createHook(
7248 function useCollectionItem2({
7249 store,
7250 shouldRegisterItem = true,
7251 getItem = identity,
7252 // @ts-expect-error This prop may come from a collection renderer.
7253 element,
7254 ...props
7255 }) {
7256 const context = useCollectionContext();
7257 store = store || context;
7258 const id = useId3(props.id);
7259 const ref = (0, import_react9.useRef)(element);
7260 (0, import_react9.useEffect)(() => {
7261 const element2 = ref.current;
7262 if (!id) return;
7263 if (!element2) return;
7264 if (!shouldRegisterItem) return;
7265 const item = getItem({ id, element: element2 });
7266 return store == null ? void 0 : store.renderItem(item);
7267 }, [id, shouldRegisterItem, getItem, store]);
7268 props = {
7269 ...props,
7270 ref: useMergeRefs(ref, props.ref)
7271 };
7272 return removeUndefinedValues(props);
7273 }
7274 );
7275 var CollectionItem = forwardRef22(function CollectionItem2(props) {
7276 const htmlProps = useCollectionItem(props);
7277 return createElement3(TagName, htmlProps);
7278 });
7279
7280 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
7281 var import_react10 = __toESM(require_react(), 1);
7282 var FocusableContext = (0, import_react10.createContext)(true);
7283
7284 // node_modules/@ariakit/core/esm/utils/focus.js
7285 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'])";
7286 function isFocusable(element) {
7287 if (!element.matches(selector)) return false;
7288 if (!isVisible(element)) return false;
7289 if (element.closest("[inert]")) return false;
7290 return true;
7291 }
7292 function getClosestFocusable(element) {
7293 while (element && !isFocusable(element)) {
7294 element = element.closest(selector);
7295 }
7296 return element || null;
7297 }
7298 function hasFocus(element) {
7299 const activeElement = getActiveElement(element);
7300 if (!activeElement) return false;
7301 if (activeElement === element) return true;
7302 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
7303 if (!activeDescendant) return false;
7304 return activeDescendant === element.id;
7305 }
7306 function hasFocusWithin(element) {
7307 const activeElement = getActiveElement(element);
7308 if (!activeElement) return false;
7309 if (contains(element, activeElement)) return true;
7310 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
7311 if (!activeDescendant) return false;
7312 if (!("id" in element)) return false;
7313 if (activeDescendant === element.id) return true;
7314 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
7315 }
7316 function focusIfNeeded(element) {
7317 if (!hasFocusWithin(element) && isFocusable(element)) {
7318 element.focus();
7319 }
7320 }
7321 function focusIntoView(element, options) {
7322 if (!("scrollIntoView" in element)) {
7323 element.focus();
7324 } else {
7325 element.focus({ preventScroll: true });
7326 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
7327 }
7328 }
7329
7330 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
7331 var import_react11 = __toESM(require_react(), 1);
7332 var TagName2 = "div";
7333 var isSafariBrowser = isSafari();
7334 var alwaysFocusVisibleInputTypes = [
7335 "text",
7336 "search",
7337 "url",
7338 "tel",
7339 "email",
7340 "password",
7341 "number",
7342 "date",
7343 "month",
7344 "week",
7345 "time",
7346 "datetime",
7347 "datetime-local"
7348 ];
7349 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
7350 function markSafariFocusAncestor(element, value) {
7351 if (!element) return;
7352 element[safariFocusAncestorSymbol] = value;
7353 }
7354 function isAlwaysFocusVisible(element) {
7355 const { tagName, readOnly, type } = element;
7356 if (tagName === "TEXTAREA" && !readOnly) return true;
7357 if (tagName === "SELECT" && !readOnly) return true;
7358 if (tagName === "INPUT" && !readOnly) {
7359 return alwaysFocusVisibleInputTypes.includes(type);
7360 }
7361 if (element.isContentEditable) return true;
7362 const role = element.getAttribute("role");
7363 if (role === "combobox" && element.dataset.name) {
7364 return true;
7365 }
7366 return false;
7367 }
7368 function getLabels(element) {
7369 if ("labels" in element) {
7370 return element.labels;
7371 }
7372 return null;
7373 }
7374 function isNativeCheckboxOrRadio(element) {
7375 const tagName = element.tagName.toLowerCase();
7376 if (tagName === "input" && element.type) {
7377 return element.type === "radio" || element.type === "checkbox";
7378 }
7379 return false;
7380 }
7381 function isNativeTabbable(tagName) {
7382 if (!tagName) return true;
7383 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
7384 }
7385 function supportsDisabledAttribute(tagName) {
7386 if (!tagName) return true;
7387 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
7388 }
7389 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
7390 if (!focusable) {
7391 return tabIndexProp;
7392 }
7393 if (trulyDisabled) {
7394 if (nativeTabbable && !supportsDisabled) {
7395 return -1;
7396 }
7397 return;
7398 }
7399 if (nativeTabbable) {
7400 return tabIndexProp;
7401 }
7402 return tabIndexProp || 0;
7403 }
7404 function useDisableEvent(onEvent, disabled) {
7405 return useEvent((event) => {
7406 onEvent == null ? void 0 : onEvent(event);
7407 if (event.defaultPrevented) return;
7408 if (disabled) {
7409 event.stopPropagation();
7410 event.preventDefault();
7411 }
7412 });
7413 }
7414 var hasInstalledGlobalEventListeners2 = false;
7415 var isKeyboardModality = true;
7416 function onGlobalMouseDown(event) {
7417 const target = event.target;
7418 if (target && "hasAttribute" in target) {
7419 if (!target.hasAttribute("data-focus-visible")) {
7420 isKeyboardModality = false;
7421 }
7422 }
7423 }
7424 function onGlobalKeyDown(event) {
7425 if (event.metaKey) return;
7426 if (event.ctrlKey) return;
7427 if (event.altKey) return;
7428 isKeyboardModality = true;
7429 }
7430 var useFocusable = createHook(
7431 function useFocusable2({
7432 focusable = true,
7433 accessibleWhenDisabled,
7434 autoFocus,
7435 onFocusVisible,
7436 ...props
7437 }) {
7438 const ref = (0, import_react11.useRef)(null);
7439 (0, import_react11.useEffect)(() => {
7440 if (!focusable) return;
7441 if (hasInstalledGlobalEventListeners2) return;
7442 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
7443 addGlobalEventListener("keydown", onGlobalKeyDown, true);
7444 hasInstalledGlobalEventListeners2 = true;
7445 }, [focusable]);
7446 if (isSafariBrowser) {
7447 (0, import_react11.useEffect)(() => {
7448 if (!focusable) return;
7449 const element = ref.current;
7450 if (!element) return;
7451 if (!isNativeCheckboxOrRadio(element)) return;
7452 const labels = getLabels(element);
7453 if (!labels) return;
7454 const onMouseUp = () => queueMicrotask(() => element.focus());
7455 for (const label of labels) {
7456 label.addEventListener("mouseup", onMouseUp);
7457 }
7458 return () => {
7459 for (const label of labels) {
7460 label.removeEventListener("mouseup", onMouseUp);
7461 }
7462 };
7463 }, [focusable]);
7464 }
7465 const disabled = focusable && disabledFromProps(props);
7466 const trulyDisabled = !!disabled && !accessibleWhenDisabled;
7467 const [focusVisible, setFocusVisible] = (0, import_react11.useState)(false);
7468 (0, import_react11.useEffect)(() => {
7469 if (!focusable) return;
7470 if (trulyDisabled && focusVisible) {
7471 setFocusVisible(false);
7472 }
7473 }, [focusable, trulyDisabled, focusVisible]);
7474 (0, import_react11.useEffect)(() => {
7475 if (!focusable) return;
7476 if (!focusVisible) return;
7477 const element = ref.current;
7478 if (!element) return;
7479 if (typeof IntersectionObserver === "undefined") return;
7480 const observer = new IntersectionObserver(() => {
7481 if (!isFocusable(element)) {
7482 setFocusVisible(false);
7483 }
7484 });
7485 observer.observe(element);
7486 return () => observer.disconnect();
7487 }, [focusable, focusVisible]);
7488 const onKeyPressCapture = useDisableEvent(
7489 props.onKeyPressCapture,
7490 disabled
7491 );
7492 const onMouseDownCapture = useDisableEvent(
7493 props.onMouseDownCapture,
7494 disabled
7495 );
7496 const onClickCapture = useDisableEvent(props.onClickCapture, disabled);
7497 const onMouseDownProp = props.onMouseDown;
7498 const onMouseDown = useEvent((event) => {
7499 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
7500 if (event.defaultPrevented) return;
7501 if (!focusable) return;
7502 const element = event.currentTarget;
7503 if (!isSafariBrowser) return;
7504 if (isPortalEvent(event)) return;
7505 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
7506 let receivedFocus = false;
7507 const onFocus = () => {
7508 receivedFocus = true;
7509 };
7510 const options = { capture: true, once: true };
7511 element.addEventListener("focusin", onFocus, options);
7512 const focusableContainer = getClosestFocusable(element.parentElement);
7513 markSafariFocusAncestor(focusableContainer, true);
7514 queueBeforeEvent(element, "mouseup", () => {
7515 element.removeEventListener("focusin", onFocus, true);
7516 markSafariFocusAncestor(focusableContainer, false);
7517 if (receivedFocus) return;
7518 focusIfNeeded(element);
7519 });
7520 });
7521 const handleFocusVisible = (event, currentTarget) => {
7522 if (currentTarget) {
7523 event.currentTarget = currentTarget;
7524 }
7525 if (!focusable) return;
7526 const element = event.currentTarget;
7527 if (!element) return;
7528 if (!hasFocus(element)) return;
7529 onFocusVisible == null ? void 0 : onFocusVisible(event);
7530 if (event.defaultPrevented) return;
7531 element.dataset.focusVisible = "true";
7532 setFocusVisible(true);
7533 };
7534 const onKeyDownCaptureProp = props.onKeyDownCapture;
7535 const onKeyDownCapture = useEvent((event) => {
7536 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
7537 if (event.defaultPrevented) return;
7538 if (!focusable) return;
7539 if (focusVisible) return;
7540 if (event.metaKey) return;
7541 if (event.altKey) return;
7542 if (event.ctrlKey) return;
7543 if (!isSelfTarget(event)) return;
7544 const element = event.currentTarget;
7545 const applyFocusVisible = () => handleFocusVisible(event, element);
7546 queueBeforeEvent(element, "focusout", applyFocusVisible);
7547 });
7548 const onFocusCaptureProp = props.onFocusCapture;
7549 const onFocusCapture = useEvent((event) => {
7550 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
7551 if (event.defaultPrevented) return;
7552 if (!focusable) return;
7553 if (!isSelfTarget(event)) {
7554 setFocusVisible(false);
7555 return;
7556 }
7557 const element = event.currentTarget;
7558 const applyFocusVisible = () => handleFocusVisible(event, element);
7559 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
7560 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
7561 } else {
7562 setFocusVisible(false);
7563 }
7564 });
7565 const onBlurProp = props.onBlur;
7566 const onBlur = useEvent((event) => {
7567 onBlurProp == null ? void 0 : onBlurProp(event);
7568 if (!focusable) return;
7569 if (!isFocusEventOutside(event)) return;
7570 event.currentTarget.removeAttribute("data-focus-visible");
7571 setFocusVisible(false);
7572 });
7573 const autoFocusOnShow = (0, import_react11.useContext)(FocusableContext);
7574 const autoFocusRef = useEvent((element) => {
7575 if (!focusable) return;
7576 if (!autoFocus) return;
7577 if (!element) return;
7578 if (!autoFocusOnShow) return;
7579 queueMicrotask(() => {
7580 if (hasFocus(element)) return;
7581 if (!isFocusable(element)) return;
7582 element.focus();
7583 });
7584 });
7585 const tagName = useTagName(ref);
7586 const nativeTabbable = focusable && isNativeTabbable(tagName);
7587 const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
7588 const styleProp = props.style;
7589 const style = (0, import_react11.useMemo)(() => {
7590 if (trulyDisabled) {
7591 return { pointerEvents: "none", ...styleProp };
7592 }
7593 return styleProp;
7594 }, [trulyDisabled, styleProp]);
7595 props = {
7596 "data-focus-visible": focusable && focusVisible || void 0,
7597 "data-autofocus": autoFocus || void 0,
7598 "aria-disabled": disabled || void 0,
7599 ...props,
7600 ref: useMergeRefs(ref, autoFocusRef, props.ref),
7601 style,
7602 tabIndex: getTabIndex(
7603 focusable,
7604 trulyDisabled,
7605 nativeTabbable,
7606 supportsDisabled,
7607 props.tabIndex
7608 ),
7609 disabled: supportsDisabled && trulyDisabled ? true : void 0,
7610 // TODO: Test Focusable contentEditable.
7611 contentEditable: disabled ? void 0 : props.contentEditable,
7612 onKeyPressCapture,
7613 onClickCapture,
7614 onMouseDownCapture,
7615 onMouseDown,
7616 onKeyDownCapture,
7617 onFocusCapture,
7618 onBlur
7619 };
7620 return removeUndefinedValues(props);
7621 }
7622 );
7623 var Focusable = forwardRef22(function Focusable2(props) {
7624 const htmlProps = useFocusable(props);
7625 return createElement3(TagName2, htmlProps);
7626 });
7627
7628 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
7629 var import_react12 = __toESM(require_react(), 1);
7630 var TagName3 = "button";
7631 function isNativeClick(event) {
7632 if (!event.isTrusted) return false;
7633 const element = event.currentTarget;
7634 if (event.key === "Enter") {
7635 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
7636 }
7637 if (event.key === " ") {
7638 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
7639 }
7640 return false;
7641 }
7642 var symbol = /* @__PURE__ */ Symbol("command");
7643 var useCommand = createHook(
7644 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
7645 const ref = (0, import_react12.useRef)(null);
7646 const [isNativeButton, setIsNativeButton] = (0, import_react12.useState)(false);
7647 (0, import_react12.useEffect)(() => {
7648 if (!ref.current) return;
7649 setIsNativeButton(isButton(ref.current));
7650 }, []);
7651 const [active, setActive] = (0, import_react12.useState)(false);
7652 const activeRef = (0, import_react12.useRef)(false);
7653 const disabled = disabledFromProps(props);
7654 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
7655 const onKeyDownProp = props.onKeyDown;
7656 const onKeyDown = useEvent((event) => {
7657 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
7658 const element = event.currentTarget;
7659 if (event.defaultPrevented) return;
7660 if (isDuplicate) return;
7661 if (disabled) return;
7662 if (!isSelfTarget(event)) return;
7663 if (isTextField(element)) return;
7664 if (element.isContentEditable) return;
7665 const isEnter = clickOnEnter && event.key === "Enter";
7666 const isSpace = clickOnSpace && event.key === " ";
7667 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
7668 const shouldPreventSpace = event.key === " " && !clickOnSpace;
7669 if (shouldPreventEnter || shouldPreventSpace) {
7670 event.preventDefault();
7671 return;
7672 }
7673 if (isEnter || isSpace) {
7674 const nativeClick = isNativeClick(event);
7675 if (isEnter) {
7676 if (!nativeClick) {
7677 event.preventDefault();
7678 const { view, ...eventInit } = event;
7679 const click = () => fireClickEvent(element, eventInit);
7680 if (isFirefox()) {
7681 queueBeforeEvent(element, "keyup", click);
7682 } else {
7683 queueMicrotask(click);
7684 }
7685 }
7686 } else if (isSpace) {
7687 activeRef.current = true;
7688 if (!nativeClick) {
7689 event.preventDefault();
7690 setActive(true);
7691 }
7692 }
7693 }
7694 });
7695 const onKeyUpProp = props.onKeyUp;
7696 const onKeyUp = useEvent((event) => {
7697 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
7698 if (event.defaultPrevented) return;
7699 if (isDuplicate) return;
7700 if (disabled) return;
7701 if (event.metaKey) return;
7702 const isSpace = clickOnSpace && event.key === " ";
7703 if (activeRef.current && isSpace) {
7704 activeRef.current = false;
7705 if (!isNativeClick(event)) {
7706 event.preventDefault();
7707 setActive(false);
7708 const element = event.currentTarget;
7709 const { view, ...eventInit } = event;
7710 queueMicrotask(() => fireClickEvent(element, eventInit));
7711 }
7712 }
7713 });
7714 props = {
7715 "data-active": active || void 0,
7716 type: isNativeButton ? "button" : void 0,
7717 ...metadataProps,
7718 ...props,
7719 ref: useMergeRefs(ref, props.ref),
7720 onKeyDown,
7721 onKeyUp
7722 };
7723 props = useFocusable(props);
7724 return props;
7725 }
7726 );
7727 var Command = forwardRef22(function Command2(props) {
7728 const htmlProps = useCommand(props);
7729 return createElement3(TagName3, htmlProps);
7730 });
7731
7732 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
7733 function getInternal(store, key) {
7734 const internals = store.__unstableInternals;
7735 invariant(internals, "Invalid store");
7736 return internals[key];
7737 }
7738 function createStore(initialState, ...stores) {
7739 let state = initialState;
7740 let prevStateBatch = state;
7741 let lastUpdate = /* @__PURE__ */ Symbol();
7742 let destroy = noop;
7743 const instances = /* @__PURE__ */ new Set();
7744 const updatedKeys = /* @__PURE__ */ new Set();
7745 const setups = /* @__PURE__ */ new Set();
7746 const listeners = /* @__PURE__ */ new Set();
7747 const batchListeners = /* @__PURE__ */ new Set();
7748 const disposables = /* @__PURE__ */ new WeakMap();
7749 const listenerKeys = /* @__PURE__ */ new WeakMap();
7750 const storeSetup = (callback) => {
7751 setups.add(callback);
7752 return () => setups.delete(callback);
7753 };
7754 const storeInit = () => {
7755 const initialized = instances.size;
7756 const instance = /* @__PURE__ */ Symbol();
7757 instances.add(instance);
7758 const maybeDestroy = () => {
7759 instances.delete(instance);
7760 if (instances.size) return;
7761 destroy();
7762 };
7763 if (initialized) return maybeDestroy;
7764 const desyncs = getKeys(state).map(
7765 (key) => chain(
7766 ...stores.map((store) => {
7767 var _a;
7768 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
7769 if (!storeState) return;
7770 if (!hasOwnProperty(storeState, key)) return;
7771 return sync(store, [key], (state2) => {
7772 setState(
7773 key,
7774 state2[key],
7775 // @ts-expect-error - Not public API. This is just to prevent
7776 // infinite loops.
7777 true
7778 );
7779 });
7780 })
7781 )
7782 );
7783 const teardowns = [];
7784 for (const setup2 of setups) {
7785 teardowns.push(setup2());
7786 }
7787 const cleanups = stores.map(init);
7788 destroy = chain(...desyncs, ...teardowns, ...cleanups);
7789 return maybeDestroy;
7790 };
7791 const sub = (keys, listener, set2 = listeners) => {
7792 set2.add(listener);
7793 listenerKeys.set(listener, keys);
7794 return () => {
7795 var _a;
7796 (_a = disposables.get(listener)) == null ? void 0 : _a();
7797 disposables.delete(listener);
7798 listenerKeys.delete(listener);
7799 set2.delete(listener);
7800 };
7801 };
7802 const storeSubscribe = (keys, listener) => sub(keys, listener);
7803 const storeSync = (keys, listener) => {
7804 disposables.set(listener, listener(state, state));
7805 return sub(keys, listener);
7806 };
7807 const storeBatch = (keys, listener) => {
7808 disposables.set(listener, listener(state, prevStateBatch));
7809 return sub(keys, listener, batchListeners);
7810 };
7811 const storePick = (keys) => createStore(pick(state, keys), finalStore);
7812 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore);
7813 const getState = () => state;
7814 const setState = (key, value, fromStores = false) => {
7815 var _a;
7816 if (!hasOwnProperty(state, key)) return;
7817 const nextValue = applyState(value, state[key]);
7818 if (nextValue === state[key]) return;
7819 if (!fromStores) {
7820 for (const store of stores) {
7821 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
7822 }
7823 }
7824 const prevState = state;
7825 state = { ...state, [key]: nextValue };
7826 const thisUpdate = /* @__PURE__ */ Symbol();
7827 lastUpdate = thisUpdate;
7828 updatedKeys.add(key);
7829 const run = (listener, prev, uKeys) => {
7830 var _a2;
7831 const keys = listenerKeys.get(listener);
7832 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
7833 if (!keys || keys.some(updated)) {
7834 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
7835 disposables.set(listener, listener(state, prev));
7836 }
7837 };
7838 for (const listener of listeners) {
7839 run(listener, prevState);
7840 }
7841 queueMicrotask(() => {
7842 if (lastUpdate !== thisUpdate) return;
7843 const snapshot = state;
7844 for (const listener of batchListeners) {
7845 run(listener, prevStateBatch, updatedKeys);
7846 }
7847 prevStateBatch = snapshot;
7848 updatedKeys.clear();
7849 });
7850 };
7851 const finalStore = {
7852 getState,
7853 setState,
7854 __unstableInternals: {
7855 setup: storeSetup,
7856 init: storeInit,
7857 subscribe: storeSubscribe,
7858 sync: storeSync,
7859 batch: storeBatch,
7860 pick: storePick,
7861 omit: storeOmit
7862 }
7863 };
7864 return finalStore;
7865 }
7866 function setup(store, ...args) {
7867 if (!store) return;
7868 return getInternal(store, "setup")(...args);
7869 }
7870 function init(store, ...args) {
7871 if (!store) return;
7872 return getInternal(store, "init")(...args);
7873 }
7874 function subscribe(store, ...args) {
7875 if (!store) return;
7876 return getInternal(store, "subscribe")(...args);
7877 }
7878 function sync(store, ...args) {
7879 if (!store) return;
7880 return getInternal(store, "sync")(...args);
7881 }
7882 function batch(store, ...args) {
7883 if (!store) return;
7884 return getInternal(store, "batch")(...args);
7885 }
7886 function omit22(store, ...args) {
7887 if (!store) return;
7888 return getInternal(store, "omit")(...args);
7889 }
7890 function pick2(store, ...args) {
7891 if (!store) return;
7892 return getInternal(store, "pick")(...args);
7893 }
7894 function mergeStore(...stores) {
7895 var _a;
7896 const initialState = {};
7897 for (const store2 of stores) {
7898 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
7899 if (nextState) {
7900 Object.assign(initialState, nextState);
7901 }
7902 }
7903 const store = createStore(initialState, ...stores);
7904 return Object.assign({}, ...stores, store);
7905 }
7906 function throwOnConflictingProps(props, store) {
7907 if (false) return;
7908 if (!store) return;
7909 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
7910 var _a;
7911 const stateKey = key.replace("default", "");
7912 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
7913 });
7914 if (!defaultKeys.length) return;
7915 const storeState = store.getState();
7916 const conflictingProps = defaultKeys.filter(
7917 (key) => hasOwnProperty(storeState, key)
7918 );
7919 if (!conflictingProps.length) return;
7920 throw new Error(
7921 `Passing a store prop in conjunction with a default state is not supported.
7922
7923 const store = useSelectStore();
7924 <SelectProvider store={store} defaultValue="Apple" />
7925 ^ ^
7926
7927 Instead, pass the default state to the topmost store:
7928
7929 const store = useSelectStore({ defaultValue: "Apple" });
7930 <SelectProvider store={store} />
7931
7932 See https://github.com/ariakit/ariakit/pull/2745 for more details.
7933
7934 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
7935 `
7936 );
7937 }
7938
7939 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
7940 var React8 = __toESM(require_react(), 1);
7941 var import_shim = __toESM(require_shim(), 1);
7942 var { useSyncExternalStore } = import_shim.default;
7943 var noopSubscribe = () => () => {
7944 };
7945 function useStoreState(store, keyOrSelector = identity) {
7946 const storeSubscribe = React8.useCallback(
7947 (callback) => {
7948 if (!store) return noopSubscribe();
7949 return subscribe(store, null, callback);
7950 },
7951 [store]
7952 );
7953 const getSnapshot = () => {
7954 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
7955 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
7956 const state = store == null ? void 0 : store.getState();
7957 if (selector2) return selector2(state);
7958 if (!state) return;
7959 if (!key) return;
7960 if (!hasOwnProperty(state, key)) return;
7961 return state[key];
7962 };
7963 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
7964 }
7965 function useStoreStateObject(store, object) {
7966 const objRef = React8.useRef(
7967 {}
7968 );
7969 const storeSubscribe = React8.useCallback(
7970 (callback) => {
7971 if (!store) return noopSubscribe();
7972 return subscribe(store, null, callback);
7973 },
7974 [store]
7975 );
7976 const getSnapshot = () => {
7977 const state = store == null ? void 0 : store.getState();
7978 let updated = false;
7979 const obj = objRef.current;
7980 for (const prop in object) {
7981 const keyOrSelector = object[prop];
7982 if (typeof keyOrSelector === "function") {
7983 const value = keyOrSelector(state);
7984 if (value !== obj[prop]) {
7985 obj[prop] = value;
7986 updated = true;
7987 }
7988 }
7989 if (typeof keyOrSelector === "string") {
7990 if (!state) continue;
7991 if (!hasOwnProperty(state, keyOrSelector)) continue;
7992 const value = state[keyOrSelector];
7993 if (value !== obj[prop]) {
7994 obj[prop] = value;
7995 updated = true;
7996 }
7997 }
7998 }
7999 if (updated) {
8000 objRef.current = { ...obj };
8001 }
8002 return objRef.current;
8003 };
8004 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
8005 }
8006 function useStoreProps(store, props, key, setKey) {
8007 const value = hasOwnProperty(props, key) ? props[key] : void 0;
8008 const setValue = setKey ? props[setKey] : void 0;
8009 const propsRef = useLiveRef({ value, setValue });
8010 useSafeLayoutEffect(() => {
8011 return sync(store, [key], (state, prev) => {
8012 const { value: value2, setValue: setValue2 } = propsRef.current;
8013 if (!setValue2) return;
8014 if (state[key] === prev[key]) return;
8015 if (state[key] === value2) return;
8016 setValue2(state[key]);
8017 });
8018 }, [store, key]);
8019 useSafeLayoutEffect(() => {
8020 if (value === void 0) return;
8021 store.setState(key, value);
8022 return batch(store, [key], () => {
8023 if (value === void 0) return;
8024 store.setState(key, value);
8025 });
8026 });
8027 }
8028 function useStore(createStore2, props) {
8029 const [store, setStore] = React8.useState(() => createStore2(props));
8030 useSafeLayoutEffect(() => init(store), [store]);
8031 const useState25 = React8.useCallback(
8032 (keyOrSelector) => useStoreState(store, keyOrSelector),
8033 [store]
8034 );
8035 const memoizedStore = React8.useMemo(
8036 () => ({ ...store, useState: useState25 }),
8037 [store, useState25]
8038 );
8039 const updateStore = useEvent(() => {
8040 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
8041 });
8042 return [memoizedStore, updateStore];
8043 }
8044
8045 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
8046 var import_react13 = __toESM(require_react(), 1);
8047 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
8048 var TagName4 = "button";
8049 function isEditableElement(element) {
8050 if (isTextbox(element)) return true;
8051 return element.tagName === "INPUT" && !isButton(element);
8052 }
8053 function getNextPageOffset(scrollingElement, pageUp = false) {
8054 const height = scrollingElement.clientHeight;
8055 const { top } = scrollingElement.getBoundingClientRect();
8056 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
8057 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
8058 if (scrollingElement.tagName === "HTML") {
8059 return pageOffset + scrollingElement.scrollTop;
8060 }
8061 return pageOffset;
8062 }
8063 function getItemOffset(itemElement, pageUp = false) {
8064 const { top } = itemElement.getBoundingClientRect();
8065 if (pageUp) {
8066 return top + itemElement.clientHeight;
8067 }
8068 return top;
8069 }
8070 function findNextPageItemId(element, store, next, pageUp = false) {
8071 var _a;
8072 if (!store) return;
8073 if (!next) return;
8074 const { renderedItems } = store.getState();
8075 const scrollingElement = getScrollingElement(element);
8076 if (!scrollingElement) return;
8077 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
8078 let id;
8079 let prevDifference;
8080 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
8081 const previousId = id;
8082 id = next(i2);
8083 if (!id) break;
8084 if (id === previousId) continue;
8085 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
8086 if (!itemElement) continue;
8087 const itemOffset = getItemOffset(itemElement, pageUp);
8088 const difference = itemOffset - nextPageOffset;
8089 const absDifference = Math.abs(difference);
8090 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
8091 if (prevDifference !== void 0 && prevDifference < absDifference) {
8092 id = previousId;
8093 }
8094 break;
8095 }
8096 prevDifference = absDifference;
8097 }
8098 return id;
8099 }
8100 function targetIsAnotherItem(event, store) {
8101 if (isSelfTarget(event)) return false;
8102 return isItem(store, event.target);
8103 }
8104 var useCompositeItem = createHook(
8105 function useCompositeItem2({
8106 store,
8107 rowId: rowIdProp,
8108 preventScrollOnKeyDown = false,
8109 moveOnKeyPress = true,
8110 tabbable = false,
8111 getItem: getItemProp,
8112 "aria-setsize": ariaSetSizeProp,
8113 "aria-posinset": ariaPosInSetProp,
8114 ...props
8115 }) {
8116 const context = useCompositeContext();
8117 store = store || context;
8118 const id = useId3(props.id);
8119 const ref = (0, import_react13.useRef)(null);
8120 const row = (0, import_react13.useContext)(CompositeRowContext);
8121 const disabled = disabledFromProps(props);
8122 const trulyDisabled = disabled && !props.accessibleWhenDisabled;
8123 const {
8124 rowId,
8125 baseElement,
8126 isActiveItem,
8127 ariaSetSize,
8128 ariaPosInSet,
8129 isTabbable
8130 } = useStoreStateObject(store, {
8131 rowId(state) {
8132 if (rowIdProp) return rowIdProp;
8133 if (!state) return;
8134 if (!(row == null ? void 0 : row.baseElement)) return;
8135 if (row.baseElement !== state.baseElement) return;
8136 return row.id;
8137 },
8138 baseElement(state) {
8139 return (state == null ? void 0 : state.baseElement) || void 0;
8140 },
8141 isActiveItem(state) {
8142 return !!state && state.activeId === id;
8143 },
8144 ariaSetSize(state) {
8145 if (ariaSetSizeProp != null) return ariaSetSizeProp;
8146 if (!state) return;
8147 if (!(row == null ? void 0 : row.ariaSetSize)) return;
8148 if (row.baseElement !== state.baseElement) return;
8149 return row.ariaSetSize;
8150 },
8151 ariaPosInSet(state) {
8152 if (ariaPosInSetProp != null) return ariaPosInSetProp;
8153 if (!state) return;
8154 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
8155 if (row.baseElement !== state.baseElement) return;
8156 const itemsInRow = state.renderedItems.filter(
8157 (item) => item.rowId === rowId
8158 );
8159 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
8160 },
8161 isTabbable(state) {
8162 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
8163 if (state.virtualFocus) return false;
8164 if (tabbable) return true;
8165 if (state.activeId === null) return false;
8166 const item = store == null ? void 0 : store.item(state.activeId);
8167 if (item == null ? void 0 : item.disabled) return true;
8168 if (!(item == null ? void 0 : item.element)) return true;
8169 return state.activeId === id;
8170 }
8171 });
8172 const getItem = (0, import_react13.useCallback)(
8173 (item) => {
8174 var _a;
8175 const nextItem = {
8176 ...item,
8177 id: id || item.id,
8178 rowId,
8179 disabled: !!trulyDisabled,
8180 children: (_a = item.element) == null ? void 0 : _a.textContent
8181 };
8182 if (getItemProp) {
8183 return getItemProp(nextItem);
8184 }
8185 return nextItem;
8186 },
8187 [id, rowId, trulyDisabled, getItemProp]
8188 );
8189 const onFocusProp = props.onFocus;
8190 const hasFocusedComposite = (0, import_react13.useRef)(false);
8191 const onFocus = useEvent((event) => {
8192 onFocusProp == null ? void 0 : onFocusProp(event);
8193 if (event.defaultPrevented) return;
8194 if (isPortalEvent(event)) return;
8195 if (!id) return;
8196 if (!store) return;
8197 if (targetIsAnotherItem(event, store)) return;
8198 const { virtualFocus, baseElement: baseElement2 } = store.getState();
8199 store.setActiveId(id);
8200 if (isTextbox(event.currentTarget)) {
8201 selectTextField(event.currentTarget);
8202 }
8203 if (!virtualFocus) return;
8204 if (!isSelfTarget(event)) return;
8205 if (isEditableElement(event.currentTarget)) return;
8206 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
8207 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
8208 event.currentTarget.scrollIntoView({
8209 block: "nearest",
8210 inline: "nearest"
8211 });
8212 }
8213 hasFocusedComposite.current = true;
8214 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
8215 if (fromComposite) {
8216 focusSilently(baseElement2);
8217 } else {
8218 baseElement2.focus();
8219 }
8220 });
8221 const onBlurCaptureProp = props.onBlurCapture;
8222 const onBlurCapture = useEvent((event) => {
8223 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
8224 if (event.defaultPrevented) return;
8225 const state = store == null ? void 0 : store.getState();
8226 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
8227 hasFocusedComposite.current = false;
8228 event.preventDefault();
8229 event.stopPropagation();
8230 }
8231 });
8232 const onKeyDownProp = props.onKeyDown;
8233 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
8234 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
8235 const onKeyDown = useEvent((event) => {
8236 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
8237 if (event.defaultPrevented) return;
8238 if (!isSelfTarget(event)) return;
8239 if (!store) return;
8240 const { currentTarget } = event;
8241 const state = store.getState();
8242 const item = store.item(id);
8243 const isGrid2 = !!(item == null ? void 0 : item.rowId);
8244 const isVertical = state.orientation !== "horizontal";
8245 const isHorizontal = state.orientation !== "vertical";
8246 const canHomeEnd = () => {
8247 if (isGrid2) return true;
8248 if (isHorizontal) return true;
8249 if (!state.baseElement) return true;
8250 if (!isTextField(state.baseElement)) return true;
8251 return false;
8252 };
8253 const keyMap = {
8254 ArrowUp: (isGrid2 || isVertical) && store.up,
8255 ArrowRight: (isGrid2 || isHorizontal) && store.next,
8256 ArrowDown: (isGrid2 || isVertical) && store.down,
8257 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
8258 Home: () => {
8259 if (!canHomeEnd()) return;
8260 if (!isGrid2 || event.ctrlKey) {
8261 return store == null ? void 0 : store.first();
8262 }
8263 return store == null ? void 0 : store.previous(-1);
8264 },
8265 End: () => {
8266 if (!canHomeEnd()) return;
8267 if (!isGrid2 || event.ctrlKey) {
8268 return store == null ? void 0 : store.last();
8269 }
8270 return store == null ? void 0 : store.next(-1);
8271 },
8272 PageUp: () => {
8273 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
8274 },
8275 PageDown: () => {
8276 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
8277 }
8278 };
8279 const action = keyMap[event.key];
8280 if (action) {
8281 if (isTextbox(currentTarget)) {
8282 const selection = getTextboxSelection(currentTarget);
8283 const isLeft = isHorizontal && event.key === "ArrowLeft";
8284 const isRight = isHorizontal && event.key === "ArrowRight";
8285 const isUp = isVertical && event.key === "ArrowUp";
8286 const isDown = isVertical && event.key === "ArrowDown";
8287 if (isRight || isDown) {
8288 const { length: valueLength } = getTextboxValue(currentTarget);
8289 if (selection.end !== valueLength) return;
8290 } else if ((isLeft || isUp) && selection.start !== 0) return;
8291 }
8292 const nextId = action();
8293 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
8294 if (!moveOnKeyPressProp(event)) return;
8295 event.preventDefault();
8296 store.move(nextId);
8297 }
8298 }
8299 });
8300 const providerValue = (0, import_react13.useMemo)(
8301 () => ({ id, baseElement }),
8302 [id, baseElement]
8303 );
8304 props = useWrapElement(
8305 props,
8306 (element) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
8307 [providerValue]
8308 );
8309 props = {
8310 id,
8311 "data-active-item": isActiveItem || void 0,
8312 ...props,
8313 ref: useMergeRefs(ref, props.ref),
8314 tabIndex: isTabbable ? props.tabIndex : -1,
8315 onFocus,
8316 onBlurCapture,
8317 onKeyDown
8318 };
8319 props = useCommand(props);
8320 props = useCollectionItem({
8321 store,
8322 ...props,
8323 getItem,
8324 shouldRegisterItem: id ? props.shouldRegisterItem : false
8325 });
8326 return removeUndefinedValues({
8327 ...props,
8328 "aria-setsize": ariaSetSize,
8329 "aria-posinset": ariaPosInSet
8330 });
8331 }
8332 );
8333 var CompositeItem = memo22(
8334 forwardRef22(function CompositeItem2(props) {
8335 const htmlProps = useCompositeItem(props);
8336 return createElement3(TagName4, htmlProps);
8337 })
8338 );
8339
8340 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
8341 function toArray(arg) {
8342 if (Array.isArray(arg)) {
8343 return arg;
8344 }
8345 return typeof arg !== "undefined" ? [arg] : [];
8346 }
8347 function flatten2DArray(array) {
8348 const flattened = [];
8349 for (const row of array) {
8350 flattened.push(...row);
8351 }
8352 return flattened;
8353 }
8354 function reverseArray(array) {
8355 return array.slice().reverse();
8356 }
8357
8358 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
8359 var import_react14 = __toESM(require_react(), 1);
8360 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
8361 var TagName5 = "div";
8362 function isGrid(items) {
8363 return items.some((item) => !!item.rowId);
8364 }
8365 function isPrintableKey(event) {
8366 const target = event.target;
8367 if (target && !isTextField(target)) return false;
8368 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
8369 }
8370 function isModifierKey(event) {
8371 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
8372 }
8373 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
8374 return useEvent((event) => {
8375 var _a;
8376 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
8377 if (event.defaultPrevented) return;
8378 if (event.isPropagationStopped()) return;
8379 if (!isSelfTarget(event)) return;
8380 if (isModifierKey(event)) return;
8381 if (isPrintableKey(event)) return;
8382 const state = store.getState();
8383 const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
8384 if (!activeElement) return;
8385 const { view, ...eventInit } = event;
8386 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
8387 if (activeElement !== previousElement) {
8388 activeElement.focus();
8389 }
8390 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
8391 event.preventDefault();
8392 }
8393 if (event.currentTarget.contains(activeElement)) {
8394 event.stopPropagation();
8395 }
8396 });
8397 }
8398 function findFirstEnabledItemInTheLastRow(items) {
8399 return findFirstEnabledItem(
8400 flatten2DArray(reverseArray(groupItemsByRows(items)))
8401 );
8402 }
8403 function useScheduleFocus(store) {
8404 const [scheduled, setScheduled] = (0, import_react14.useState)(false);
8405 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
8406 const activeItem = store.useState(
8407 (state) => getEnabledItem(store, state.activeId)
8408 );
8409 (0, import_react14.useEffect)(() => {
8410 const activeElement = activeItem == null ? void 0 : activeItem.element;
8411 if (!scheduled) return;
8412 if (!activeElement) return;
8413 setScheduled(false);
8414 activeElement.focus({ preventScroll: true });
8415 }, [activeItem, scheduled]);
8416 return schedule;
8417 }
8418 var useComposite = createHook(
8419 function useComposite2({
8420 store,
8421 composite = true,
8422 focusOnMove = composite,
8423 moveOnKeyPress = true,
8424 ...props
8425 }) {
8426 const context = useCompositeProviderContext();
8427 store = store || context;
8428 invariant(
8429 store,
8430 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
8431 );
8432 const ref = (0, import_react14.useRef)(null);
8433 const previousElementRef = (0, import_react14.useRef)(null);
8434 const scheduleFocus = useScheduleFocus(store);
8435 const moves = store.useState("moves");
8436 const [, setBaseElement] = useTransactionState(
8437 composite ? store.setBaseElement : null
8438 );
8439 (0, import_react14.useEffect)(() => {
8440 var _a;
8441 if (!store) return;
8442 if (!moves) return;
8443 if (!composite) return;
8444 if (!focusOnMove) return;
8445 const { activeId: activeId2 } = store.getState();
8446 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
8447 if (!itemElement) return;
8448 focusIntoView(itemElement);
8449 }, [store, moves, composite, focusOnMove]);
8450 useSafeLayoutEffect(() => {
8451 if (!store) return;
8452 if (!moves) return;
8453 if (!composite) return;
8454 const { baseElement, activeId: activeId2 } = store.getState();
8455 const isSelfAcive = activeId2 === null;
8456 if (!isSelfAcive) return;
8457 if (!baseElement) return;
8458 const previousElement = previousElementRef.current;
8459 previousElementRef.current = null;
8460 if (previousElement) {
8461 fireBlurEvent(previousElement, { relatedTarget: baseElement });
8462 }
8463 if (!hasFocus(baseElement)) {
8464 baseElement.focus();
8465 }
8466 }, [store, moves, composite]);
8467 const activeId = store.useState("activeId");
8468 const virtualFocus = store.useState("virtualFocus");
8469 useSafeLayoutEffect(() => {
8470 var _a;
8471 if (!store) return;
8472 if (!composite) return;
8473 if (!virtualFocus) return;
8474 const previousElement = previousElementRef.current;
8475 previousElementRef.current = null;
8476 if (!previousElement) return;
8477 const activeElement = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
8478 const relatedTarget = activeElement || getActiveElement(previousElement);
8479 if (relatedTarget === previousElement) return;
8480 fireBlurEvent(previousElement, { relatedTarget });
8481 }, [store, activeId, virtualFocus, composite]);
8482 const onKeyDownCapture = useKeyboardEventProxy(
8483 store,
8484 props.onKeyDownCapture,
8485 previousElementRef
8486 );
8487 const onKeyUpCapture = useKeyboardEventProxy(
8488 store,
8489 props.onKeyUpCapture,
8490 previousElementRef
8491 );
8492 const onFocusCaptureProp = props.onFocusCapture;
8493 const onFocusCapture = useEvent((event) => {
8494 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
8495 if (event.defaultPrevented) return;
8496 if (!store) return;
8497 const { virtualFocus: virtualFocus2 } = store.getState();
8498 if (!virtualFocus2) return;
8499 const previousActiveElement = event.relatedTarget;
8500 const isSilentlyFocused = silentlyFocused(event.currentTarget);
8501 if (isSelfTarget(event) && isSilentlyFocused) {
8502 event.stopPropagation();
8503 previousElementRef.current = previousActiveElement;
8504 }
8505 });
8506 const onFocusProp = props.onFocus;
8507 const onFocus = useEvent((event) => {
8508 onFocusProp == null ? void 0 : onFocusProp(event);
8509 if (event.defaultPrevented) return;
8510 if (!composite) return;
8511 if (!store) return;
8512 const { relatedTarget } = event;
8513 const { virtualFocus: virtualFocus2 } = store.getState();
8514 if (virtualFocus2) {
8515 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
8516 queueMicrotask(scheduleFocus);
8517 }
8518 } else if (isSelfTarget(event)) {
8519 store.setActiveId(null);
8520 }
8521 });
8522 const onBlurCaptureProp = props.onBlurCapture;
8523 const onBlurCapture = useEvent((event) => {
8524 var _a;
8525 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
8526 if (event.defaultPrevented) return;
8527 if (!store) return;
8528 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
8529 if (!virtualFocus2) return;
8530 const activeElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
8531 const nextActiveElement = event.relatedTarget;
8532 const nextActiveElementIsItem = isItem(store, nextActiveElement);
8533 const previousElement = previousElementRef.current;
8534 previousElementRef.current = null;
8535 if (isSelfTarget(event) && nextActiveElementIsItem) {
8536 if (nextActiveElement === activeElement) {
8537 if (previousElement && previousElement !== nextActiveElement) {
8538 fireBlurEvent(previousElement, event);
8539 }
8540 } else if (activeElement) {
8541 fireBlurEvent(activeElement, event);
8542 } else if (previousElement) {
8543 fireBlurEvent(previousElement, event);
8544 }
8545 event.stopPropagation();
8546 } else {
8547 const targetIsItem = isItem(store, event.target);
8548 if (!targetIsItem && activeElement) {
8549 fireBlurEvent(activeElement, event);
8550 }
8551 }
8552 });
8553 const onKeyDownProp = props.onKeyDown;
8554 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
8555 const onKeyDown = useEvent((event) => {
8556 var _a;
8557 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
8558 if (event.nativeEvent.isComposing) return;
8559 if (event.defaultPrevented) return;
8560 if (!store) return;
8561 if (!isSelfTarget(event)) return;
8562 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
8563 const activeItem = getEnabledItem(store, activeId2);
8564 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
8565 const isVertical = orientation !== "horizontal";
8566 const isHorizontal = orientation !== "vertical";
8567 const grid = isGrid(renderedItems);
8568 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
8569 if (isHorizontalKey && isTextField(event.currentTarget)) return;
8570 const up = () => {
8571 if (grid) {
8572 const item = findFirstEnabledItemInTheLastRow(renderedItems);
8573 return item == null ? void 0 : item.id;
8574 }
8575 return store == null ? void 0 : store.last();
8576 };
8577 const keyMap = {
8578 ArrowUp: (grid || isVertical) && up,
8579 ArrowRight: (grid || isHorizontal) && store.first,
8580 ArrowDown: (grid || isVertical) && store.first,
8581 ArrowLeft: (grid || isHorizontal) && store.last,
8582 Home: store.first,
8583 End: store.last,
8584 PageUp: store.first,
8585 PageDown: store.last
8586 };
8587 const action = keyMap[event.key];
8588 if (action) {
8589 const id = action();
8590 if (id !== void 0) {
8591 if (!moveOnKeyPressProp(event)) return;
8592 event.preventDefault();
8593 store.move(id);
8594 }
8595 }
8596 });
8597 props = useWrapElement(
8598 props,
8599 (element) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(CompositeContextProvider, { value: store, children: element }),
8600 [store]
8601 );
8602 const activeDescendant = store.useState((state) => {
8603 var _a;
8604 if (!store) return;
8605 if (!composite) return;
8606 if (!state.virtualFocus) return;
8607 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
8608 });
8609 props = {
8610 "aria-activedescendant": activeDescendant,
8611 ...props,
8612 ref: useMergeRefs(ref, setBaseElement, props.ref),
8613 onKeyDownCapture,
8614 onKeyUpCapture,
8615 onFocusCapture,
8616 onFocus,
8617 onBlurCapture,
8618 onKeyDown
8619 };
8620 const focusable = store.useState(
8621 (state) => composite && (state.virtualFocus || state.activeId === null)
8622 );
8623 props = useFocusable({ focusable, ...props });
8624 return props;
8625 }
8626 );
8627 var Composite5 = forwardRef22(function Composite22(props) {
8628 const htmlProps = useComposite(props);
8629 return createElement3(TagName5, htmlProps);
8630 });
8631
8632 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
8633 var ctx3 = createStoreContext();
8634 var useDisclosureContext = ctx3.useContext;
8635 var useDisclosureScopedContext = ctx3.useScopedContext;
8636 var useDisclosureProviderContext = ctx3.useProviderContext;
8637 var DisclosureContextProvider = ctx3.ContextProvider;
8638 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
8639
8640 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
8641 var import_react15 = __toESM(require_react(), 1);
8642 var ctx4 = createStoreContext(
8643 [DisclosureContextProvider],
8644 [DisclosureScopedContextProvider]
8645 );
8646 var useDialogContext = ctx4.useContext;
8647 var useDialogScopedContext = ctx4.useScopedContext;
8648 var useDialogProviderContext = ctx4.useProviderContext;
8649 var DialogContextProvider = ctx4.ContextProvider;
8650 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
8651 var DialogHeadingContext = (0, import_react15.createContext)(void 0);
8652 var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
8653
8654 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
8655 var import_react16 = __toESM(require_react(), 1);
8656 var import_react_dom = __toESM(require_react_dom(), 1);
8657 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
8658 var TagName6 = "div";
8659 function afterTimeout(timeoutMs, cb) {
8660 const timeoutId = setTimeout(cb, timeoutMs);
8661 return () => clearTimeout(timeoutId);
8662 }
8663 function afterPaint2(cb) {
8664 let raf = requestAnimationFrame(() => {
8665 raf = requestAnimationFrame(cb);
8666 });
8667 return () => cancelAnimationFrame(raf);
8668 }
8669 function parseCSSTime(...times) {
8670 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
8671 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
8672 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
8673 if (currentTime > longestTime) return currentTime;
8674 return longestTime;
8675 }, 0);
8676 }
8677 function isHidden(mounted, hidden, alwaysVisible) {
8678 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
8679 }
8680 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
8681 const context = useDisclosureProviderContext();
8682 store = store || context;
8683 invariant(
8684 store,
8685 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
8686 );
8687 const ref = (0, import_react16.useRef)(null);
8688 const id = useId3(props.id);
8689 const [transition, setTransition] = (0, import_react16.useState)(null);
8690 const open = store.useState("open");
8691 const mounted = store.useState("mounted");
8692 const animated = store.useState("animated");
8693 const contentElement = store.useState("contentElement");
8694 const otherElement = useStoreState(store.disclosure, "contentElement");
8695 useSafeLayoutEffect(() => {
8696 if (!ref.current) return;
8697 store == null ? void 0 : store.setContentElement(ref.current);
8698 }, [store]);
8699 useSafeLayoutEffect(() => {
8700 let previousAnimated;
8701 store == null ? void 0 : store.setState("animated", (animated2) => {
8702 previousAnimated = animated2;
8703 return true;
8704 });
8705 return () => {
8706 if (previousAnimated === void 0) return;
8707 store == null ? void 0 : store.setState("animated", previousAnimated);
8708 };
8709 }, [store]);
8710 useSafeLayoutEffect(() => {
8711 if (!animated) return;
8712 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
8713 setTransition(null);
8714 return;
8715 }
8716 return afterPaint2(() => {
8717 setTransition(open ? "enter" : mounted ? "leave" : null);
8718 });
8719 }, [animated, contentElement, open, mounted]);
8720 useSafeLayoutEffect(() => {
8721 if (!store) return;
8722 if (!animated) return;
8723 if (!transition) return;
8724 if (!contentElement) return;
8725 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
8726 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation);
8727 if (transition === "leave" && open) return;
8728 if (transition === "enter" && !open) return;
8729 if (typeof animated === "number") {
8730 const timeout2 = animated;
8731 return afterTimeout(timeout2, stopAnimationSync);
8732 }
8733 const {
8734 transitionDuration,
8735 animationDuration,
8736 transitionDelay,
8737 animationDelay
8738 } = getComputedStyle(contentElement);
8739 const {
8740 transitionDuration: transitionDuration2 = "0",
8741 animationDuration: animationDuration2 = "0",
8742 transitionDelay: transitionDelay2 = "0",
8743 animationDelay: animationDelay2 = "0"
8744 } = otherElement ? getComputedStyle(otherElement) : {};
8745 const delay = parseCSSTime(
8746 transitionDelay,
8747 animationDelay,
8748 transitionDelay2,
8749 animationDelay2
8750 );
8751 const duration = parseCSSTime(
8752 transitionDuration,
8753 animationDuration,
8754 transitionDuration2,
8755 animationDuration2
8756 );
8757 const timeout = delay + duration;
8758 if (!timeout) {
8759 if (transition === "enter") {
8760 store.setState("animated", false);
8761 }
8762 stopAnimation();
8763 return;
8764 }
8765 const frameRate = 1e3 / 60;
8766 const maxTimeout = Math.max(timeout - frameRate, 0);
8767 return afterTimeout(maxTimeout, stopAnimationSync);
8768 }, [store, animated, contentElement, otherElement, open, transition]);
8769 props = useWrapElement(
8770 props,
8771 (element) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(DialogScopedContextProvider, { value: store, children: element }),
8772 [store]
8773 );
8774 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
8775 const styleProp = props.style;
8776 const style = (0, import_react16.useMemo)(() => {
8777 if (hidden) {
8778 return { ...styleProp, display: "none" };
8779 }
8780 return styleProp;
8781 }, [hidden, styleProp]);
8782 props = {
8783 id,
8784 "data-open": open || void 0,
8785 "data-enter": transition === "enter" || void 0,
8786 "data-leave": transition === "leave" || void 0,
8787 hidden,
8788 ...props,
8789 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
8790 style
8791 };
8792 return removeUndefinedValues(props);
8793 });
8794 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
8795 const htmlProps = useDisclosureContent(props);
8796 return createElement3(TagName6, htmlProps);
8797 });
8798 var DisclosureContent = forwardRef22(function DisclosureContent2({
8799 unmountOnHide,
8800 ...props
8801 }) {
8802 const context = useDisclosureProviderContext();
8803 const store = props.store || context;
8804 const mounted = useStoreState(
8805 store,
8806 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
8807 );
8808 if (mounted === false) return null;
8809 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(DisclosureContentImpl, { ...props });
8810 });
8811
8812 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
8813 function createDisclosureStore(props = {}) {
8814 const store = mergeStore(
8815 props.store,
8816 omit22(props.disclosure, ["contentElement", "disclosureElement"])
8817 );
8818 throwOnConflictingProps(props, store);
8819 const syncState = store == null ? void 0 : store.getState();
8820 const open = defaultValue(
8821 props.open,
8822 syncState == null ? void 0 : syncState.open,
8823 props.defaultOpen,
8824 false
8825 );
8826 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
8827 const initialState = {
8828 open,
8829 animated,
8830 animating: !!animated && open,
8831 mounted: open,
8832 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
8833 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
8834 };
8835 const disclosure = createStore(initialState, store);
8836 setup(
8837 disclosure,
8838 () => sync(disclosure, ["animated", "animating"], (state) => {
8839 if (state.animated) return;
8840 disclosure.setState("animating", false);
8841 })
8842 );
8843 setup(
8844 disclosure,
8845 () => subscribe(disclosure, ["open"], () => {
8846 if (!disclosure.getState().animated) return;
8847 disclosure.setState("animating", true);
8848 })
8849 );
8850 setup(
8851 disclosure,
8852 () => sync(disclosure, ["open", "animating"], (state) => {
8853 disclosure.setState("mounted", state.open || state.animating);
8854 })
8855 );
8856 return {
8857 ...disclosure,
8858 disclosure: props.disclosure,
8859 setOpen: (value) => disclosure.setState("open", value),
8860 show: () => disclosure.setState("open", true),
8861 hide: () => disclosure.setState("open", false),
8862 toggle: () => disclosure.setState("open", (open2) => !open2),
8863 stopAnimation: () => disclosure.setState("animating", false),
8864 setContentElement: (value) => disclosure.setState("contentElement", value),
8865 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
8866 };
8867 }
8868
8869 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
8870 function useDisclosureStoreProps(store, update2, props) {
8871 useUpdateEffect(update2, [props.store, props.disclosure]);
8872 useStoreProps(store, props, "open", "setOpen");
8873 useStoreProps(store, props, "mounted", "setMounted");
8874 useStoreProps(store, props, "animated");
8875 return Object.assign(store, { disclosure: props.disclosure });
8876 }
8877
8878 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
8879 var ctx5 = createStoreContext(
8880 [DialogContextProvider],
8881 [DialogScopedContextProvider]
8882 );
8883 var usePopoverContext = ctx5.useContext;
8884 var usePopoverScopedContext = ctx5.useScopedContext;
8885 var usePopoverProviderContext = ctx5.useProviderContext;
8886 var PopoverContextProvider = ctx5.ContextProvider;
8887 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
8888
8889 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
8890 function getCommonParent(items) {
8891 var _a;
8892 const firstItem = items.find((item) => !!item.element);
8893 const lastItem = [...items].reverse().find((item) => !!item.element);
8894 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
8895 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
8896 const parent = parentElement;
8897 if (lastItem && parent.contains(lastItem.element)) {
8898 return parentElement;
8899 }
8900 parentElement = parentElement.parentElement;
8901 }
8902 return getDocument(parentElement).body;
8903 }
8904 function getPrivateStore(store) {
8905 return store == null ? void 0 : store.__unstablePrivateStore;
8906 }
8907 function createCollectionStore(props = {}) {
8908 var _a;
8909 throwOnConflictingProps(props, props.store);
8910 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
8911 const items = defaultValue(
8912 props.items,
8913 syncState == null ? void 0 : syncState.items,
8914 props.defaultItems,
8915 []
8916 );
8917 const itemsMap = new Map(items.map((item) => [item.id, item]));
8918 const initialState = {
8919 items,
8920 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
8921 };
8922 const syncPrivateStore = getPrivateStore(props.store);
8923 const privateStore = createStore(
8924 { items, renderedItems: initialState.renderedItems },
8925 syncPrivateStore
8926 );
8927 const collection = createStore(initialState, props.store);
8928 const sortItems = (renderedItems) => {
8929 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
8930 privateStore.setState("renderedItems", sortedItems);
8931 collection.setState("renderedItems", sortedItems);
8932 };
8933 setup(collection, () => init(privateStore));
8934 setup(privateStore, () => {
8935 return batch(privateStore, ["items"], (state) => {
8936 collection.setState("items", state.items);
8937 });
8938 });
8939 setup(privateStore, () => {
8940 return batch(privateStore, ["renderedItems"], (state) => {
8941 let firstRun = true;
8942 let raf = requestAnimationFrame(() => {
8943 const { renderedItems } = collection.getState();
8944 if (state.renderedItems === renderedItems) return;
8945 sortItems(state.renderedItems);
8946 });
8947 if (typeof IntersectionObserver !== "function") {
8948 return () => cancelAnimationFrame(raf);
8949 }
8950 const ioCallback = () => {
8951 if (firstRun) {
8952 firstRun = false;
8953 return;
8954 }
8955 cancelAnimationFrame(raf);
8956 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
8957 };
8958 const root = getCommonParent(state.renderedItems);
8959 const observer = new IntersectionObserver(ioCallback, { root });
8960 for (const item of state.renderedItems) {
8961 if (!item.element) continue;
8962 observer.observe(item.element);
8963 }
8964 return () => {
8965 cancelAnimationFrame(raf);
8966 observer.disconnect();
8967 };
8968 });
8969 });
8970 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
8971 let prevItem;
8972 setItems((items2) => {
8973 const index = items2.findIndex(({ id }) => id === item.id);
8974 const nextItems = items2.slice();
8975 if (index !== -1) {
8976 prevItem = items2[index];
8977 const nextItem = { ...prevItem, ...item };
8978 nextItems[index] = nextItem;
8979 itemsMap.set(item.id, nextItem);
8980 } else {
8981 nextItems.push(item);
8982 itemsMap.set(item.id, item);
8983 }
8984 return nextItems;
8985 });
8986 const unmergeItem = () => {
8987 setItems((items2) => {
8988 if (!prevItem) {
8989 if (canDeleteFromMap) {
8990 itemsMap.delete(item.id);
8991 }
8992 return items2.filter(({ id }) => id !== item.id);
8993 }
8994 const index = items2.findIndex(({ id }) => id === item.id);
8995 if (index === -1) return items2;
8996 const nextItems = items2.slice();
8997 nextItems[index] = prevItem;
8998 itemsMap.set(item.id, prevItem);
8999 return nextItems;
9000 });
9001 };
9002 return unmergeItem;
9003 };
9004 const registerItem = (item) => mergeItem(
9005 item,
9006 (getItems) => privateStore.setState("items", getItems),
9007 true
9008 );
9009 return {
9010 ...collection,
9011 registerItem,
9012 renderItem: (item) => chain(
9013 registerItem(item),
9014 mergeItem(
9015 item,
9016 (getItems) => privateStore.setState("renderedItems", getItems)
9017 )
9018 ),
9019 item: (id) => {
9020 if (!id) return null;
9021 let item = itemsMap.get(id);
9022 if (!item) {
9023 const { items: items2 } = privateStore.getState();
9024 item = items2.find((item2) => item2.id === id);
9025 if (item) {
9026 itemsMap.set(id, item);
9027 }
9028 }
9029 return item || null;
9030 },
9031 // @ts-expect-error Internal
9032 __unstablePrivateStore: privateStore
9033 };
9034 }
9035
9036 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
9037 function useCollectionStoreProps(store, update2, props) {
9038 useUpdateEffect(update2, [props.store]);
9039 useStoreProps(store, props, "items", "setItems");
9040 return store;
9041 }
9042
9043 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
9044 var NULL_ITEM = { id: null };
9045 function findFirstEnabledItem2(items, excludeId) {
9046 return items.find((item) => {
9047 if (excludeId) {
9048 return !item.disabled && item.id !== excludeId;
9049 }
9050 return !item.disabled;
9051 });
9052 }
9053 function getEnabledItems(items, excludeId) {
9054 return items.filter((item) => {
9055 if (excludeId) {
9056 return !item.disabled && item.id !== excludeId;
9057 }
9058 return !item.disabled;
9059 });
9060 }
9061 function getItemsInRow(items, rowId) {
9062 return items.filter((item) => item.rowId === rowId);
9063 }
9064 function flipItems(items, activeId, shouldInsertNullItem = false) {
9065 const index = items.findIndex((item) => item.id === activeId);
9066 return [
9067 ...items.slice(index + 1),
9068 ...shouldInsertNullItem ? [NULL_ITEM] : [],
9069 ...items.slice(0, index)
9070 ];
9071 }
9072 function groupItemsByRows2(items) {
9073 const rows = [];
9074 for (const item of items) {
9075 const row = rows.find((currentRow) => {
9076 var _a;
9077 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
9078 });
9079 if (row) {
9080 row.push(item);
9081 } else {
9082 rows.push([item]);
9083 }
9084 }
9085 return rows;
9086 }
9087 function getMaxRowLength(array) {
9088 let maxLength = 0;
9089 for (const { length } of array) {
9090 if (length > maxLength) {
9091 maxLength = length;
9092 }
9093 }
9094 return maxLength;
9095 }
9096 function createEmptyItem(rowId) {
9097 return {
9098 id: "__EMPTY_ITEM__",
9099 disabled: true,
9100 rowId
9101 };
9102 }
9103 function normalizeRows(rows, activeId, focusShift) {
9104 const maxLength = getMaxRowLength(rows);
9105 for (const row of rows) {
9106 for (let i2 = 0; i2 < maxLength; i2 += 1) {
9107 const item = row[i2];
9108 if (!item || focusShift && item.disabled) {
9109 const isFirst = i2 === 0;
9110 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
9111 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
9112 }
9113 }
9114 }
9115 return rows;
9116 }
9117 function verticalizeItems(items) {
9118 const rows = groupItemsByRows2(items);
9119 const maxLength = getMaxRowLength(rows);
9120 const verticalized = [];
9121 for (let i2 = 0; i2 < maxLength; i2 += 1) {
9122 for (const row of rows) {
9123 const item = row[i2];
9124 if (item) {
9125 verticalized.push({
9126 ...item,
9127 // If there's no rowId, it means that it's not a grid composite, but
9128 // a single row instead. So, instead of verticalizing it, that is,
9129 // assigning a different rowId based on the column index, we keep it
9130 // undefined so they will be part of the same row. This is useful
9131 // when using up/down on one-dimensional composites.
9132 rowId: item.rowId ? `${i2}` : void 0
9133 });
9134 }
9135 }
9136 }
9137 return verticalized;
9138 }
9139 function createCompositeStore(props = {}) {
9140 var _a;
9141 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
9142 const collection = createCollectionStore(props);
9143 const activeId = defaultValue(
9144 props.activeId,
9145 syncState == null ? void 0 : syncState.activeId,
9146 props.defaultActiveId
9147 );
9148 const initialState = {
9149 ...collection.getState(),
9150 id: defaultValue(
9151 props.id,
9152 syncState == null ? void 0 : syncState.id,
9153 `id-${Math.random().toString(36).slice(2, 8)}`
9154 ),
9155 activeId,
9156 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
9157 includesBaseElement: defaultValue(
9158 props.includesBaseElement,
9159 syncState == null ? void 0 : syncState.includesBaseElement,
9160 activeId === null
9161 ),
9162 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
9163 orientation: defaultValue(
9164 props.orientation,
9165 syncState == null ? void 0 : syncState.orientation,
9166 "both"
9167 ),
9168 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
9169 virtualFocus: defaultValue(
9170 props.virtualFocus,
9171 syncState == null ? void 0 : syncState.virtualFocus,
9172 false
9173 ),
9174 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
9175 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
9176 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
9177 };
9178 const composite = createStore(initialState, collection, props.store);
9179 setup(
9180 composite,
9181 () => sync(composite, ["renderedItems", "activeId"], (state) => {
9182 composite.setState("activeId", (activeId2) => {
9183 var _a2;
9184 if (activeId2 !== void 0) return activeId2;
9185 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
9186 });
9187 })
9188 );
9189 const getNextId = (direction = "next", options = {}) => {
9190 var _a2, _b;
9191 const defaultState = composite.getState();
9192 const {
9193 skip = 0,
9194 activeId: activeId2 = defaultState.activeId,
9195 focusShift = defaultState.focusShift,
9196 focusLoop = defaultState.focusLoop,
9197 focusWrap = defaultState.focusWrap,
9198 includesBaseElement = defaultState.includesBaseElement,
9199 renderedItems = defaultState.renderedItems,
9200 rtl = defaultState.rtl
9201 } = options;
9202 const isVerticalDirection = direction === "up" || direction === "down";
9203 const isNextDirection = direction === "next" || direction === "down";
9204 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
9205 const canShift = focusShift && !skip;
9206 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
9207 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
9208 );
9209 items = canReverse ? reverseArray(items) : items;
9210 items = isVerticalDirection ? verticalizeItems(items) : items;
9211 if (activeId2 == null) {
9212 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
9213 }
9214 const activeItem = items.find((item) => item.id === activeId2);
9215 if (!activeItem) {
9216 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
9217 }
9218 const isGrid2 = items.some((item) => item.rowId);
9219 const activeIndex = items.indexOf(activeItem);
9220 const nextItems = items.slice(activeIndex + 1);
9221 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
9222 if (skip) {
9223 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
9224 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
9225 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
9226 return nextItem2 == null ? void 0 : nextItem2.id;
9227 }
9228 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
9229 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
9230 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
9231 if (canLoop) {
9232 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
9233 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
9234 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
9235 return nextItem2 == null ? void 0 : nextItem2.id;
9236 }
9237 if (canWrap) {
9238 const nextItem2 = findFirstEnabledItem2(
9239 // We can use nextItems, which contains all the next items, including
9240 // items from other rows, to wrap between rows. However, if there is a
9241 // null item (the composite container), we'll only use the next items in
9242 // the row. So moving next from the last item will focus on the
9243 // composite container. On grid composites, horizontal navigation never
9244 // focuses on the composite container, only vertical.
9245 hasNullItem ? nextItemsInRow : nextItems,
9246 activeId2
9247 );
9248 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
9249 return nextId;
9250 }
9251 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
9252 if (!nextItem && hasNullItem) {
9253 return null;
9254 }
9255 return nextItem == null ? void 0 : nextItem.id;
9256 };
9257 return {
9258 ...collection,
9259 ...composite,
9260 setBaseElement: (element) => composite.setState("baseElement", element),
9261 setActiveId: (id) => composite.setState("activeId", id),
9262 move: (id) => {
9263 if (id === void 0) return;
9264 composite.setState("activeId", id);
9265 composite.setState("moves", (moves) => moves + 1);
9266 },
9267 first: () => {
9268 var _a2;
9269 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
9270 },
9271 last: () => {
9272 var _a2;
9273 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
9274 },
9275 next: (options) => {
9276 if (options !== void 0 && typeof options === "number") {
9277 options = { skip: options };
9278 }
9279 return getNextId("next", options);
9280 },
9281 previous: (options) => {
9282 if (options !== void 0 && typeof options === "number") {
9283 options = { skip: options };
9284 }
9285 return getNextId("previous", options);
9286 },
9287 down: (options) => {
9288 if (options !== void 0 && typeof options === "number") {
9289 options = { skip: options };
9290 }
9291 return getNextId("down", options);
9292 },
9293 up: (options) => {
9294 if (options !== void 0 && typeof options === "number") {
9295 options = { skip: options };
9296 }
9297 return getNextId("up", options);
9298 }
9299 };
9300 }
9301
9302 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
9303 function useCompositeStoreOptions(props) {
9304 const id = useId3(props.id);
9305 return { id, ...props };
9306 }
9307 function useCompositeStoreProps(store, update2, props) {
9308 store = useCollectionStoreProps(store, update2, props);
9309 useStoreProps(store, props, "activeId", "setActiveId");
9310 useStoreProps(store, props, "includesBaseElement");
9311 useStoreProps(store, props, "virtualFocus");
9312 useStoreProps(store, props, "orientation");
9313 useStoreProps(store, props, "rtl");
9314 useStoreProps(store, props, "focusLoop");
9315 useStoreProps(store, props, "focusWrap");
9316 useStoreProps(store, props, "focusShift");
9317 return store;
9318 }
9319
9320 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
9321 var import_react17 = __toESM(require_react(), 1);
9322 var ComboboxListRoleContext = (0, import_react17.createContext)(
9323 void 0
9324 );
9325 var ctx6 = createStoreContext(
9326 [PopoverContextProvider, CompositeContextProvider],
9327 [PopoverScopedContextProvider, CompositeScopedContextProvider]
9328 );
9329 var useComboboxContext = ctx6.useContext;
9330 var useComboboxScopedContext = ctx6.useScopedContext;
9331 var useComboboxProviderContext = ctx6.useProviderContext;
9332 var ComboboxContextProvider = ctx6.ContextProvider;
9333 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
9334 var ComboboxItemValueContext = (0, import_react17.createContext)(
9335 void 0
9336 );
9337 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
9338
9339 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
9340 function createDialogStore(props = {}) {
9341 return createDisclosureStore(props);
9342 }
9343
9344 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
9345 function useDialogStoreProps(store, update2, props) {
9346 return useDisclosureStoreProps(store, update2, props);
9347 }
9348
9349 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
9350 function createPopoverStore({
9351 popover: otherPopover,
9352 ...props
9353 } = {}) {
9354 const store = mergeStore(
9355 props.store,
9356 omit22(otherPopover, [
9357 "arrowElement",
9358 "anchorElement",
9359 "contentElement",
9360 "popoverElement",
9361 "disclosureElement"
9362 ])
9363 );
9364 throwOnConflictingProps(props, store);
9365 const syncState = store == null ? void 0 : store.getState();
9366 const dialog = createDialogStore({ ...props, store });
9367 const placement = defaultValue(
9368 props.placement,
9369 syncState == null ? void 0 : syncState.placement,
9370 "bottom"
9371 );
9372 const initialState = {
9373 ...dialog.getState(),
9374 placement,
9375 currentPlacement: placement,
9376 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
9377 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
9378 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
9379 rendered: /* @__PURE__ */ Symbol("rendered")
9380 };
9381 const popover = createStore(initialState, dialog, store);
9382 return {
9383 ...dialog,
9384 ...popover,
9385 setAnchorElement: (element) => popover.setState("anchorElement", element),
9386 setPopoverElement: (element) => popover.setState("popoverElement", element),
9387 setArrowElement: (element) => popover.setState("arrowElement", element),
9388 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
9389 };
9390 }
9391
9392 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
9393 function usePopoverStoreProps(store, update2, props) {
9394 useUpdateEffect(update2, [props.popover]);
9395 useStoreProps(store, props, "placement");
9396 return useDialogStoreProps(store, update2, props);
9397 }
9398
9399 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
9400 var TagName7 = "div";
9401 var usePopoverAnchor = createHook(
9402 function usePopoverAnchor2({ store, ...props }) {
9403 const context = usePopoverProviderContext();
9404 store = store || context;
9405 props = {
9406 ...props,
9407 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
9408 };
9409 return props;
9410 }
9411 );
9412 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
9413 const htmlProps = usePopoverAnchor(props);
9414 return createElement3(TagName7, htmlProps);
9415 });
9416
9417 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
9418 var import_react18 = __toESM(require_react(), 1);
9419 var TagName8 = "div";
9420 function getMouseDestination(event) {
9421 const relatedTarget = event.relatedTarget;
9422 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
9423 return relatedTarget;
9424 }
9425 return null;
9426 }
9427 function hoveringInside(event) {
9428 const nextElement = getMouseDestination(event);
9429 if (!nextElement) return false;
9430 return contains(event.currentTarget, nextElement);
9431 }
9432 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
9433 function movingToAnotherItem(event) {
9434 let dest = getMouseDestination(event);
9435 if (!dest) return false;
9436 do {
9437 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
9438 dest = dest.parentElement;
9439 } while (dest);
9440 return false;
9441 }
9442 var useCompositeHover = createHook(
9443 function useCompositeHover2({
9444 store,
9445 focusOnHover = true,
9446 blurOnHoverEnd = !!focusOnHover,
9447 ...props
9448 }) {
9449 const context = useCompositeContext();
9450 store = store || context;
9451 invariant(
9452 store,
9453 "CompositeHover must be wrapped in a Composite component."
9454 );
9455 const isMouseMoving = useIsMouseMoving();
9456 const onMouseMoveProp = props.onMouseMove;
9457 const focusOnHoverProp = useBooleanEvent(focusOnHover);
9458 const onMouseMove = useEvent((event) => {
9459 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
9460 if (event.defaultPrevented) return;
9461 if (!isMouseMoving()) return;
9462 if (!focusOnHoverProp(event)) return;
9463 if (!hasFocusWithin(event.currentTarget)) {
9464 const baseElement = store == null ? void 0 : store.getState().baseElement;
9465 if (baseElement && !hasFocus(baseElement)) {
9466 baseElement.focus();
9467 }
9468 }
9469 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
9470 });
9471 const onMouseLeaveProp = props.onMouseLeave;
9472 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
9473 const onMouseLeave = useEvent((event) => {
9474 var _a;
9475 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
9476 if (event.defaultPrevented) return;
9477 if (!isMouseMoving()) return;
9478 if (hoveringInside(event)) return;
9479 if (movingToAnotherItem(event)) return;
9480 if (!focusOnHoverProp(event)) return;
9481 if (!blurOnHoverEndProp(event)) return;
9482 store == null ? void 0 : store.setActiveId(null);
9483 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
9484 });
9485 const ref = (0, import_react18.useCallback)((element) => {
9486 if (!element) return;
9487 element[symbol2] = true;
9488 }, []);
9489 props = {
9490 ...props,
9491 ref: useMergeRefs(ref, props.ref),
9492 onMouseMove,
9493 onMouseLeave
9494 };
9495 return removeUndefinedValues(props);
9496 }
9497 );
9498 var CompositeHover = memo22(
9499 forwardRef22(function CompositeHover2(props) {
9500 const htmlProps = useCompositeHover(props);
9501 return createElement3(TagName8, htmlProps);
9502 })
9503 );
9504
9505 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
9506 var import_react19 = __toESM(require_react(), 1);
9507 var TagName9 = "input";
9508 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
9509 if (!autoSelect) return false;
9510 const firstItem = items.find((item) => !item.disabled && item.value);
9511 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
9512 }
9513 function hasCompletionString(value, activeValue) {
9514 if (!activeValue) return false;
9515 if (value == null) return false;
9516 value = normalizeString(value);
9517 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
9518 }
9519 function isInputEvent(event) {
9520 return event.type === "input";
9521 }
9522 function isAriaAutoCompleteValue(value) {
9523 return value === "inline" || value === "list" || value === "both" || value === "none";
9524 }
9525 function getDefaultAutoSelectId(items) {
9526 const item = items.find((item2) => {
9527 var _a;
9528 if (item2.disabled) return false;
9529 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
9530 });
9531 return item == null ? void 0 : item.id;
9532 }
9533 var useCombobox = createHook(
9534 function useCombobox2({
9535 store,
9536 focusable = true,
9537 autoSelect: autoSelectProp = false,
9538 getAutoSelectId,
9539 setValueOnChange,
9540 showMinLength = 0,
9541 showOnChange,
9542 showOnMouseDown,
9543 showOnClick = showOnMouseDown,
9544 showOnKeyDown,
9545 showOnKeyPress = showOnKeyDown,
9546 blurActiveItemOnClick,
9547 setValueOnClick = true,
9548 moveOnKeyPress = true,
9549 autoComplete = "list",
9550 ...props
9551 }) {
9552 const context = useComboboxProviderContext();
9553 store = store || context;
9554 invariant(
9555 store,
9556 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
9557 );
9558 const ref = (0, import_react19.useRef)(null);
9559 const [valueUpdated, forceValueUpdate] = useForceUpdate();
9560 const canAutoSelectRef = (0, import_react19.useRef)(false);
9561 const composingRef = (0, import_react19.useRef)(false);
9562 const autoSelect = store.useState(
9563 (state) => state.virtualFocus && autoSelectProp
9564 );
9565 const inline = autoComplete === "inline" || autoComplete === "both";
9566 const [canInline, setCanInline] = (0, import_react19.useState)(inline);
9567 useUpdateLayoutEffect(() => {
9568 if (!inline) return;
9569 setCanInline(true);
9570 }, [inline]);
9571 const storeValue = store.useState("value");
9572 const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
9573 (0, import_react19.useEffect)(() => {
9574 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
9575 prevSelectedValueRef.current = prev.selectedValue;
9576 });
9577 }, []);
9578 const inlineActiveValue = store.useState((state) => {
9579 var _a;
9580 if (!inline) return;
9581 if (!canInline) return;
9582 if (state.activeValue && Array.isArray(state.selectedValue)) {
9583 if (state.selectedValue.includes(state.activeValue)) return;
9584 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
9585 }
9586 return state.activeValue;
9587 });
9588 const items = store.useState("renderedItems");
9589 const open = store.useState("open");
9590 const contentElement = store.useState("contentElement");
9591 const value = (0, import_react19.useMemo)(() => {
9592 if (!inline) return storeValue;
9593 if (!canInline) return storeValue;
9594 const firstItemAutoSelected = isFirstItemAutoSelected(
9595 items,
9596 inlineActiveValue,
9597 autoSelect
9598 );
9599 if (firstItemAutoSelected) {
9600 if (hasCompletionString(storeValue, inlineActiveValue)) {
9601 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
9602 return storeValue + slice;
9603 }
9604 return storeValue;
9605 }
9606 return inlineActiveValue || storeValue;
9607 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
9608 (0, import_react19.useEffect)(() => {
9609 const element = ref.current;
9610 if (!element) return;
9611 const onCompositeItemMove = () => setCanInline(true);
9612 element.addEventListener("combobox-item-move", onCompositeItemMove);
9613 return () => {
9614 element.removeEventListener("combobox-item-move", onCompositeItemMove);
9615 };
9616 }, []);
9617 (0, import_react19.useEffect)(() => {
9618 if (!inline) return;
9619 if (!canInline) return;
9620 if (!inlineActiveValue) return;
9621 const firstItemAutoSelected = isFirstItemAutoSelected(
9622 items,
9623 inlineActiveValue,
9624 autoSelect
9625 );
9626 if (!firstItemAutoSelected) return;
9627 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
9628 let cleanup = noop;
9629 queueMicrotask(() => {
9630 const element = ref.current;
9631 if (!element) return;
9632 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
9633 const nextStart = storeValue.length;
9634 const nextEnd = inlineActiveValue.length;
9635 setSelectionRange(element, nextStart, nextEnd);
9636 cleanup = () => {
9637 if (!hasFocus(element)) return;
9638 const { start, end } = getTextboxSelection(element);
9639 if (start !== nextStart) return;
9640 if (end !== nextEnd) return;
9641 setSelectionRange(element, prevStart, prevEnd);
9642 };
9643 });
9644 return () => cleanup();
9645 }, [
9646 valueUpdated,
9647 inline,
9648 canInline,
9649 inlineActiveValue,
9650 items,
9651 autoSelect,
9652 storeValue
9653 ]);
9654 const scrollingElementRef = (0, import_react19.useRef)(null);
9655 const getAutoSelectIdProp = useEvent(getAutoSelectId);
9656 const autoSelectIdRef = (0, import_react19.useRef)(null);
9657 (0, import_react19.useEffect)(() => {
9658 if (!open) return;
9659 if (!contentElement) return;
9660 const scrollingElement = getScrollingElement(contentElement);
9661 if (!scrollingElement) return;
9662 scrollingElementRef.current = scrollingElement;
9663 const onUserScroll = () => {
9664 canAutoSelectRef.current = false;
9665 };
9666 const onScroll = () => {
9667 if (!store) return;
9668 if (!canAutoSelectRef.current) return;
9669 const { activeId } = store.getState();
9670 if (activeId === null) return;
9671 if (activeId === autoSelectIdRef.current) return;
9672 canAutoSelectRef.current = false;
9673 };
9674 const options = { passive: true, capture: true };
9675 scrollingElement.addEventListener("wheel", onUserScroll, options);
9676 scrollingElement.addEventListener("touchmove", onUserScroll, options);
9677 scrollingElement.addEventListener("scroll", onScroll, options);
9678 return () => {
9679 scrollingElement.removeEventListener("wheel", onUserScroll, true);
9680 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
9681 scrollingElement.removeEventListener("scroll", onScroll, true);
9682 };
9683 }, [open, contentElement, store]);
9684 useSafeLayoutEffect(() => {
9685 if (!storeValue) return;
9686 if (composingRef.current) return;
9687 canAutoSelectRef.current = true;
9688 }, [storeValue]);
9689 useSafeLayoutEffect(() => {
9690 if (autoSelect !== "always" && open) return;
9691 canAutoSelectRef.current = open;
9692 }, [autoSelect, open]);
9693 const resetValueOnSelect = store.useState("resetValueOnSelect");
9694 useUpdateEffect(() => {
9695 var _a, _b;
9696 const canAutoSelect = canAutoSelectRef.current;
9697 if (!store) return;
9698 if (!open) return;
9699 if (!canAutoSelect && !resetValueOnSelect) return;
9700 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
9701 if (baseElement && !hasFocus(baseElement)) return;
9702 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
9703 const observer = new MutationObserver(forceValueUpdate);
9704 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
9705 return () => observer.disconnect();
9706 }
9707 if (autoSelect && canAutoSelect) {
9708 const userAutoSelectId = getAutoSelectIdProp(items);
9709 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
9710 autoSelectIdRef.current = autoSelectId;
9711 store.move(autoSelectId != null ? autoSelectId : null);
9712 } else {
9713 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
9714 if (element && "scrollIntoView" in element) {
9715 element.scrollIntoView({ block: "nearest", inline: "nearest" });
9716 }
9717 }
9718 return;
9719 }, [
9720 store,
9721 open,
9722 valueUpdated,
9723 storeValue,
9724 autoSelect,
9725 resetValueOnSelect,
9726 getAutoSelectIdProp,
9727 items
9728 ]);
9729 (0, import_react19.useEffect)(() => {
9730 if (!inline) return;
9731 const combobox = ref.current;
9732 if (!combobox) return;
9733 const elements = [combobox, contentElement].filter(
9734 (value2) => !!value2
9735 );
9736 const onBlur2 = (event) => {
9737 if (elements.every((el) => isFocusEventOutside(event, el))) {
9738 store == null ? void 0 : store.setValue(value);
9739 }
9740 };
9741 for (const element of elements) {
9742 element.addEventListener("focusout", onBlur2);
9743 }
9744 return () => {
9745 for (const element of elements) {
9746 element.removeEventListener("focusout", onBlur2);
9747 }
9748 };
9749 }, [inline, contentElement, store, value]);
9750 const canShow = (event) => {
9751 const currentTarget = event.currentTarget;
9752 return currentTarget.value.length >= showMinLength;
9753 };
9754 const onChangeProp = props.onChange;
9755 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
9756 const setValueOnChangeProp = useBooleanEvent(
9757 // If the combobox is combined with tags, the value will be set by the tag
9758 // input component.
9759 setValueOnChange != null ? setValueOnChange : !store.tag
9760 );
9761 const onChange = useEvent((event) => {
9762 onChangeProp == null ? void 0 : onChangeProp(event);
9763 if (event.defaultPrevented) return;
9764 if (!store) return;
9765 const currentTarget = event.currentTarget;
9766 const { value: value2, selectionStart, selectionEnd } = currentTarget;
9767 const nativeEvent = event.nativeEvent;
9768 canAutoSelectRef.current = true;
9769 if (isInputEvent(nativeEvent)) {
9770 if (nativeEvent.isComposing) {
9771 canAutoSelectRef.current = false;
9772 composingRef.current = true;
9773 }
9774 if (inline) {
9775 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
9776 const caretAtEnd = selectionStart === value2.length;
9777 setCanInline(textInserted && caretAtEnd);
9778 }
9779 }
9780 if (setValueOnChangeProp(event)) {
9781 const isSameValue = value2 === store.getState().value;
9782 store.setValue(value2);
9783 queueMicrotask(() => {
9784 setSelectionRange(currentTarget, selectionStart, selectionEnd);
9785 });
9786 if (inline && autoSelect && isSameValue) {
9787 forceValueUpdate();
9788 }
9789 }
9790 if (showOnChangeProp(event)) {
9791 store.show();
9792 }
9793 if (!autoSelect || !canAutoSelectRef.current) {
9794 store.setActiveId(null);
9795 }
9796 });
9797 const onCompositionEndProp = props.onCompositionEnd;
9798 const onCompositionEnd = useEvent((event) => {
9799 canAutoSelectRef.current = true;
9800 composingRef.current = false;
9801 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
9802 if (event.defaultPrevented) return;
9803 if (!autoSelect) return;
9804 forceValueUpdate();
9805 });
9806 const onMouseDownProp = props.onMouseDown;
9807 const blurActiveItemOnClickProp = useBooleanEvent(
9808 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
9809 );
9810 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
9811 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
9812 const onMouseDown = useEvent((event) => {
9813 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
9814 if (event.defaultPrevented) return;
9815 if (event.button) return;
9816 if (event.ctrlKey) return;
9817 if (!store) return;
9818 if (blurActiveItemOnClickProp(event)) {
9819 store.setActiveId(null);
9820 }
9821 if (setValueOnClickProp(event)) {
9822 store.setValue(value);
9823 }
9824 if (showOnClickProp(event)) {
9825 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
9826 }
9827 });
9828 const onKeyDownProp = props.onKeyDown;
9829 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
9830 const onKeyDown = useEvent((event) => {
9831 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9832 if (!event.repeat) {
9833 canAutoSelectRef.current = false;
9834 }
9835 if (event.defaultPrevented) return;
9836 if (event.ctrlKey) return;
9837 if (event.altKey) return;
9838 if (event.shiftKey) return;
9839 if (event.metaKey) return;
9840 if (!store) return;
9841 const { open: open2 } = store.getState();
9842 if (open2) return;
9843 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
9844 if (showOnKeyPressProp(event)) {
9845 event.preventDefault();
9846 store.show();
9847 }
9848 }
9849 });
9850 const onBlurProp = props.onBlur;
9851 const onBlur = useEvent((event) => {
9852 canAutoSelectRef.current = false;
9853 onBlurProp == null ? void 0 : onBlurProp(event);
9854 if (event.defaultPrevented) return;
9855 });
9856 const id = useId3(props.id);
9857 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
9858 const isActiveItem = store.useState((state) => state.activeId === null);
9859 props = {
9860 id,
9861 role: "combobox",
9862 "aria-autocomplete": ariaAutoComplete,
9863 "aria-haspopup": getPopupRole(contentElement, "listbox"),
9864 "aria-expanded": open,
9865 "aria-controls": contentElement == null ? void 0 : contentElement.id,
9866 "data-active-item": isActiveItem || void 0,
9867 value,
9868 ...props,
9869 ref: useMergeRefs(ref, props.ref),
9870 onChange,
9871 onCompositionEnd,
9872 onMouseDown,
9873 onKeyDown,
9874 onBlur
9875 };
9876 props = useComposite({
9877 store,
9878 focusable,
9879 ...props,
9880 // Enable inline autocomplete when the user moves from the combobox input
9881 // to an item.
9882 moveOnKeyPress: (event) => {
9883 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
9884 if (inline) setCanInline(true);
9885 return true;
9886 }
9887 });
9888 props = usePopoverAnchor({ store, ...props });
9889 return { autoComplete: "off", ...props };
9890 }
9891 );
9892 var Combobox = forwardRef22(function Combobox2(props) {
9893 const htmlProps = useCombobox(props);
9894 return createElement3(TagName9, htmlProps);
9895 });
9896
9897 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
9898 var import_react20 = __toESM(require_react(), 1);
9899 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
9900 var TagName10 = "div";
9901 function isSelected(storeValue, itemValue) {
9902 if (itemValue == null) return;
9903 if (storeValue == null) return false;
9904 if (Array.isArray(storeValue)) {
9905 return storeValue.includes(itemValue);
9906 }
9907 return storeValue === itemValue;
9908 }
9909 function getItemRole(popupRole) {
9910 var _a;
9911 const itemRoleByPopupRole = {
9912 menu: "menuitem",
9913 listbox: "option",
9914 tree: "treeitem"
9915 };
9916 const key = popupRole;
9917 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
9918 }
9919 var useComboboxItem = createHook(
9920 function useComboboxItem2({
9921 store,
9922 value,
9923 hideOnClick,
9924 setValueOnClick,
9925 selectValueOnClick = true,
9926 resetValueOnSelect,
9927 focusOnHover = false,
9928 moveOnKeyPress = true,
9929 getItem: getItemProp,
9930 ...props
9931 }) {
9932 var _a;
9933 const context = useComboboxScopedContext();
9934 store = store || context;
9935 invariant(
9936 store,
9937 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
9938 );
9939 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
9940 resetValueOnSelectState: "resetValueOnSelect",
9941 multiSelectable(state) {
9942 return Array.isArray(state.selectedValue);
9943 },
9944 selected(state) {
9945 return isSelected(state.selectedValue, value);
9946 }
9947 });
9948 const getItem = (0, import_react20.useCallback)(
9949 (item) => {
9950 const nextItem = { ...item, value };
9951 if (getItemProp) {
9952 return getItemProp(nextItem);
9953 }
9954 return nextItem;
9955 },
9956 [value, getItemProp]
9957 );
9958 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
9959 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
9960 const onClickProp = props.onClick;
9961 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
9962 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
9963 const resetValueOnSelectProp = useBooleanEvent(
9964 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
9965 );
9966 const hideOnClickProp = useBooleanEvent(hideOnClick);
9967 const onClick = useEvent((event) => {
9968 onClickProp == null ? void 0 : onClickProp(event);
9969 if (event.defaultPrevented) return;
9970 if (isDownloading(event)) return;
9971 if (isOpeningInNewTab(event)) return;
9972 if (value != null) {
9973 if (selectValueOnClickProp(event)) {
9974 if (resetValueOnSelectProp(event)) {
9975 store == null ? void 0 : store.resetValue();
9976 }
9977 store == null ? void 0 : store.setSelectedValue((prevValue) => {
9978 if (!Array.isArray(prevValue)) return value;
9979 if (prevValue.includes(value)) {
9980 return prevValue.filter((v2) => v2 !== value);
9981 }
9982 return [...prevValue, value];
9983 });
9984 }
9985 if (setValueOnClickProp(event)) {
9986 store == null ? void 0 : store.setValue(value);
9987 }
9988 }
9989 if (hideOnClickProp(event)) {
9990 store == null ? void 0 : store.hide();
9991 }
9992 });
9993 const onKeyDownProp = props.onKeyDown;
9994 const onKeyDown = useEvent((event) => {
9995 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9996 if (event.defaultPrevented) return;
9997 const baseElement = store == null ? void 0 : store.getState().baseElement;
9998 if (!baseElement) return;
9999 if (hasFocus(baseElement)) return;
10000 const printable = event.key.length === 1;
10001 if (printable || event.key === "Backspace" || event.key === "Delete") {
10002 queueMicrotask(() => baseElement.focus());
10003 if (isTextField(baseElement)) {
10004 store == null ? void 0 : store.setValue(baseElement.value);
10005 }
10006 }
10007 });
10008 if (multiSelectable && selected != null) {
10009 props = {
10010 "aria-selected": selected,
10011 ...props
10012 };
10013 }
10014 props = useWrapElement(
10015 props,
10016 (element) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
10017 [value, selected]
10018 );
10019 const popupRole = (0, import_react20.useContext)(ComboboxListRoleContext);
10020 props = {
10021 role: getItemRole(popupRole),
10022 children: value,
10023 ...props,
10024 onClick,
10025 onKeyDown
10026 };
10027 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
10028 props = useCompositeItem({
10029 store,
10030 ...props,
10031 getItem,
10032 // Dispatch a custom event on the combobox input when moving to an item
10033 // with the keyboard so the Combobox component can enable inline
10034 // autocompletion.
10035 moveOnKeyPress: (event) => {
10036 if (!moveOnKeyPressProp(event)) return false;
10037 const moveEvent = new Event("combobox-item-move");
10038 const baseElement = store == null ? void 0 : store.getState().baseElement;
10039 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
10040 return true;
10041 }
10042 });
10043 props = useCompositeHover({ store, focusOnHover, ...props });
10044 return props;
10045 }
10046 );
10047 var ComboboxItem = memo22(
10048 forwardRef22(function ComboboxItem2(props) {
10049 const htmlProps = useComboboxItem(props);
10050 return createElement3(TagName10, htmlProps);
10051 })
10052 );
10053
10054 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
10055 var import_react21 = __toESM(require_react(), 1);
10056 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
10057 var TagName11 = "span";
10058 function normalizeValue(value) {
10059 return normalizeString(value).toLowerCase();
10060 }
10061 function getOffsets(string, values) {
10062 const offsets = [];
10063 for (const value of values) {
10064 let pos = 0;
10065 const length = value.length;
10066 while (string.indexOf(value, pos) !== -1) {
10067 const index = string.indexOf(value, pos);
10068 if (index !== -1) {
10069 offsets.push([index, length]);
10070 }
10071 pos = index + 1;
10072 }
10073 }
10074 return offsets;
10075 }
10076 function filterOverlappingOffsets(offsets) {
10077 return offsets.filter(([offset, length], i2, arr) => {
10078 return !arr.some(
10079 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length
10080 );
10081 });
10082 }
10083 function sortOffsets(offsets) {
10084 return offsets.sort(([a2], [b2]) => a2 - b2);
10085 }
10086 function splitValue(itemValue, userValue) {
10087 if (!itemValue) return itemValue;
10088 if (!userValue) return itemValue;
10089 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
10090 const parts = [];
10091 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
10092 "span",
10093 {
10094 "data-autocomplete-value": autocomplete ? "" : void 0,
10095 "data-user-value": autocomplete ? void 0 : "",
10096 children: value
10097 },
10098 parts.length
10099 );
10100 const offsets = sortOffsets(
10101 filterOverlappingOffsets(
10102 // Convert userValues into a set to avoid duplicates
10103 getOffsets(normalizeValue(itemValue), new Set(userValues))
10104 )
10105 );
10106 if (!offsets.length) {
10107 parts.push(span(itemValue, true));
10108 return parts;
10109 }
10110 const [firstOffset] = offsets[0];
10111 const values = [
10112 itemValue.slice(0, firstOffset),
10113 ...offsets.flatMap(([offset, length], i2) => {
10114 var _a;
10115 const value = itemValue.slice(offset, offset + length);
10116 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
10117 const nextValue = itemValue.slice(offset + length, nextOffset);
10118 return [value, nextValue];
10119 })
10120 ];
10121 values.forEach((value, i2) => {
10122 if (!value) return;
10123 parts.push(span(value, i2 % 2 === 0));
10124 });
10125 return parts;
10126 }
10127 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
10128 const context = useComboboxScopedContext();
10129 store = store || context;
10130 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
10131 const itemValue = value != null ? value : itemContext;
10132 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
10133 const children = (0, import_react21.useMemo)(() => {
10134 if (!itemValue) return;
10135 if (!inputValue) return itemValue;
10136 return splitValue(itemValue, inputValue);
10137 }, [itemValue, inputValue]);
10138 props = {
10139 children,
10140 ...props
10141 };
10142 return removeUndefinedValues(props);
10143 });
10144 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
10145 const htmlProps = useComboboxItemValue(props);
10146 return createElement3(TagName11, htmlProps);
10147 });
10148
10149 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
10150 var TagName12 = "label";
10151 var useComboboxLabel = createHook(
10152 function useComboboxLabel2({ store, ...props }) {
10153 const context = useComboboxProviderContext();
10154 store = store || context;
10155 invariant(
10156 store,
10157 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
10158 );
10159 const comboboxId = store.useState((state) => {
10160 var _a;
10161 return (_a = state.baseElement) == null ? void 0 : _a.id;
10162 });
10163 props = {
10164 htmlFor: comboboxId,
10165 ...props
10166 };
10167 return removeUndefinedValues(props);
10168 }
10169 );
10170 var ComboboxLabel = memo22(
10171 forwardRef22(function ComboboxLabel2(props) {
10172 const htmlProps = useComboboxLabel(props);
10173 return createElement3(TagName12, htmlProps);
10174 })
10175 );
10176
10177 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
10178 var import_react22 = __toESM(require_react(), 1);
10179 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
10180 var TagName13 = "div";
10181 var useComboboxList = createHook(
10182 function useComboboxList2({ store, alwaysVisible, ...props }) {
10183 const scopedContext = useComboboxScopedContext(true);
10184 const context = useComboboxContext();
10185 store = store || context;
10186 const scopedContextSameStore = !!store && store === scopedContext;
10187 invariant(
10188 store,
10189 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
10190 );
10191 const ref = (0, import_react22.useRef)(null);
10192 const id = useId3(props.id);
10193 const mounted = store.useState("mounted");
10194 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
10195 const style = hidden ? { ...props.style, display: "none" } : props.style;
10196 const multiSelectable = store.useState(
10197 (state) => Array.isArray(state.selectedValue)
10198 );
10199 const role = useAttribute(ref, "role", props.role);
10200 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
10201 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
10202 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
10203 const contentElement = store.useState("contentElement");
10204 useSafeLayoutEffect(() => {
10205 if (!mounted) return;
10206 const element = ref.current;
10207 if (!element) return;
10208 if (contentElement !== element) return;
10209 const callback = () => {
10210 setHasListboxInside(!!element.querySelector("[role='listbox']"));
10211 };
10212 const observer = new MutationObserver(callback);
10213 observer.observe(element, {
10214 subtree: true,
10215 childList: true,
10216 attributeFilter: ["role"]
10217 });
10218 callback();
10219 return () => observer.disconnect();
10220 }, [mounted, contentElement]);
10221 if (!hasListboxInside) {
10222 props = {
10223 role: "listbox",
10224 "aria-multiselectable": ariaMultiSelectable,
10225 ...props
10226 };
10227 }
10228 props = useWrapElement(
10229 props,
10230 (element) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
10231 [store, role]
10232 );
10233 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
10234 props = {
10235 id,
10236 hidden,
10237 ...props,
10238 ref: useMergeRefs(setContentElement, ref, props.ref),
10239 style
10240 };
10241 return removeUndefinedValues(props);
10242 }
10243 );
10244 var ComboboxList = forwardRef22(function ComboboxList2(props) {
10245 const htmlProps = useComboboxList(props);
10246 return createElement3(TagName13, htmlProps);
10247 });
10248
10249 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
10250 var import_react23 = __toESM(require_react(), 1);
10251 var TagValueContext = (0, import_react23.createContext)(null);
10252 var TagRemoveIdContext = (0, import_react23.createContext)(
10253 null
10254 );
10255 var ctx7 = createStoreContext(
10256 [CompositeContextProvider],
10257 [CompositeScopedContextProvider]
10258 );
10259 var useTagContext = ctx7.useContext;
10260 var useTagScopedContext = ctx7.useScopedContext;
10261 var useTagProviderContext = ctx7.useProviderContext;
10262 var TagContextProvider = ctx7.ContextProvider;
10263 var TagScopedContextProvider = ctx7.ScopedContextProvider;
10264
10265 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
10266 var isTouchSafari = isSafari() && isTouchDevice();
10267 function createComboboxStore({
10268 tag,
10269 ...props
10270 } = {}) {
10271 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
10272 throwOnConflictingProps(props, store);
10273 const tagState = tag == null ? void 0 : tag.getState();
10274 const syncState = store == null ? void 0 : store.getState();
10275 const activeId = defaultValue(
10276 props.activeId,
10277 syncState == null ? void 0 : syncState.activeId,
10278 props.defaultActiveId,
10279 null
10280 );
10281 const composite = createCompositeStore({
10282 ...props,
10283 activeId,
10284 includesBaseElement: defaultValue(
10285 props.includesBaseElement,
10286 syncState == null ? void 0 : syncState.includesBaseElement,
10287 true
10288 ),
10289 orientation: defaultValue(
10290 props.orientation,
10291 syncState == null ? void 0 : syncState.orientation,
10292 "vertical"
10293 ),
10294 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
10295 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
10296 virtualFocus: defaultValue(
10297 props.virtualFocus,
10298 syncState == null ? void 0 : syncState.virtualFocus,
10299 true
10300 )
10301 });
10302 const popover = createPopoverStore({
10303 ...props,
10304 placement: defaultValue(
10305 props.placement,
10306 syncState == null ? void 0 : syncState.placement,
10307 "bottom-start"
10308 )
10309 });
10310 const value = defaultValue(
10311 props.value,
10312 syncState == null ? void 0 : syncState.value,
10313 props.defaultValue,
10314 ""
10315 );
10316 const selectedValue = defaultValue(
10317 props.selectedValue,
10318 syncState == null ? void 0 : syncState.selectedValue,
10319 tagState == null ? void 0 : tagState.values,
10320 props.defaultSelectedValue,
10321 ""
10322 );
10323 const multiSelectable = Array.isArray(selectedValue);
10324 const initialState = {
10325 ...composite.getState(),
10326 ...popover.getState(),
10327 value,
10328 selectedValue,
10329 resetValueOnSelect: defaultValue(
10330 props.resetValueOnSelect,
10331 syncState == null ? void 0 : syncState.resetValueOnSelect,
10332 multiSelectable
10333 ),
10334 resetValueOnHide: defaultValue(
10335 props.resetValueOnHide,
10336 syncState == null ? void 0 : syncState.resetValueOnHide,
10337 multiSelectable && !tag
10338 ),
10339 activeValue: syncState == null ? void 0 : syncState.activeValue
10340 };
10341 const combobox = createStore(initialState, composite, popover, store);
10342 if (isTouchSafari) {
10343 setup(
10344 combobox,
10345 () => sync(combobox, ["virtualFocus"], () => {
10346 combobox.setState("virtualFocus", false);
10347 })
10348 );
10349 }
10350 setup(combobox, () => {
10351 if (!tag) return;
10352 return chain(
10353 sync(combobox, ["selectedValue"], (state) => {
10354 if (!Array.isArray(state.selectedValue)) return;
10355 tag.setValues(state.selectedValue);
10356 }),
10357 sync(tag, ["values"], (state) => {
10358 combobox.setState("selectedValue", state.values);
10359 })
10360 );
10361 });
10362 setup(
10363 combobox,
10364 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
10365 if (!state.resetValueOnHide) return;
10366 if (state.mounted) return;
10367 combobox.setState("value", value);
10368 })
10369 );
10370 setup(
10371 combobox,
10372 () => sync(combobox, ["open"], (state) => {
10373 if (state.open) return;
10374 combobox.setState("activeId", activeId);
10375 combobox.setState("moves", 0);
10376 })
10377 );
10378 setup(
10379 combobox,
10380 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
10381 if (state.moves === prevState.moves) {
10382 combobox.setState("activeValue", void 0);
10383 }
10384 })
10385 );
10386 setup(
10387 combobox,
10388 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
10389 if (state.moves === prev.moves) return;
10390 const { activeId: activeId2 } = combobox.getState();
10391 const activeItem = composite.item(activeId2);
10392 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
10393 })
10394 );
10395 return {
10396 ...popover,
10397 ...composite,
10398 ...combobox,
10399 tag,
10400 setValue: (value2) => combobox.setState("value", value2),
10401 resetValue: () => combobox.setState("value", initialState.value),
10402 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
10403 };
10404 }
10405
10406 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
10407 function useComboboxStoreOptions(props) {
10408 const tag = useTagContext();
10409 props = {
10410 ...props,
10411 tag: props.tag !== void 0 ? props.tag : tag
10412 };
10413 return useCompositeStoreOptions(props);
10414 }
10415 function useComboboxStoreProps(store, update2, props) {
10416 useUpdateEffect(update2, [props.tag]);
10417 useStoreProps(store, props, "value", "setValue");
10418 useStoreProps(store, props, "selectedValue", "setSelectedValue");
10419 useStoreProps(store, props, "resetValueOnHide");
10420 useStoreProps(store, props, "resetValueOnSelect");
10421 return Object.assign(
10422 useCompositeStoreProps(
10423 usePopoverStoreProps(store, update2, props),
10424 update2,
10425 props
10426 ),
10427 { tag: props.tag }
10428 );
10429 }
10430 function useComboboxStore(props = {}) {
10431 props = useComboboxStoreOptions(props);
10432 const [store, update2] = useStore(createComboboxStore, props);
10433 return useComboboxStoreProps(store, update2, props);
10434 }
10435
10436 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
10437 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
10438 function ComboboxProvider(props = {}) {
10439 const store = useComboboxStore(props);
10440 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ComboboxContextProvider, { value: store, children: props.children });
10441 }
10442
10443 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
10444 var import_remove_accents = __toESM(require_remove_accents(), 1);
10445 var import_compose7 = __toESM(require_compose(), 1);
10446 var import_i18n22 = __toESM(require_i18n(), 1);
10447 var import_element28 = __toESM(require_element(), 1);
10448 var import_components18 = __toESM(require_components(), 1);
10449
10450 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
10451 var EMPTY_ARRAY3 = [];
10452 var getCurrentValue = (filterDefinition, currentFilter) => {
10453 if (filterDefinition.singleSelection) {
10454 return currentFilter?.value;
10455 }
10456 if (Array.isArray(currentFilter?.value)) {
10457 return currentFilter.value;
10458 }
10459 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
10460 return [currentFilter.value];
10461 }
10462 return EMPTY_ARRAY3;
10463 };
10464
10465 // packages/dataviews/build-module/hooks/use-elements.mjs
10466 var import_element27 = __toESM(require_element(), 1);
10467 var EMPTY_ARRAY4 = [];
10468 function useElements({
10469 elements,
10470 getElements
10471 }) {
10472 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
10473 const [records, setRecords] = (0, import_element27.useState)(staticElements);
10474 const [isLoading, setIsLoading] = (0, import_element27.useState)(false);
10475 (0, import_element27.useEffect)(() => {
10476 if (!getElements) {
10477 setRecords(staticElements);
10478 return;
10479 }
10480 let cancelled = false;
10481 setIsLoading(true);
10482 getElements().then((fetchedElements) => {
10483 if (!cancelled) {
10484 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
10485 setRecords(dynamicElements);
10486 }
10487 }).catch(() => {
10488 if (!cancelled) {
10489 setRecords(staticElements);
10490 }
10491 }).finally(() => {
10492 if (!cancelled) {
10493 setIsLoading(false);
10494 }
10495 });
10496 return () => {
10497 cancelled = true;
10498 };
10499 }, [getElements, staticElements]);
10500 return {
10501 elements: records,
10502 isLoading
10503 };
10504 }
10505
10506 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
10507 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
10508 function normalizeSearchInput(input = "") {
10509 return (0, import_remove_accents.default)(input.trim().toLowerCase());
10510 }
10511 var getNewValue = (filterDefinition, currentFilter, value) => {
10512 if (filterDefinition.singleSelection) {
10513 return value;
10514 }
10515 if (Array.isArray(currentFilter?.value)) {
10516 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
10517 }
10518 return [value];
10519 };
10520 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
10521 return `${prefix}-${filterElementValue}`;
10522 }
10523 var MultiSelectionOption = ({ selected }) => {
10524 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10525 "span",
10526 {
10527 className: clsx_default(
10528 "dataviews-filters__search-widget-listitem-multi-selection",
10529 { "is-selected": selected }
10530 ),
10531 children: selected && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components18.Icon, { icon: check_default })
10532 }
10533 );
10534 };
10535 var SingleSelectionOption = ({ selected }) => {
10536 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10537 "span",
10538 {
10539 className: clsx_default(
10540 "dataviews-filters__search-widget-listitem-single-selection",
10541 { "is-selected": selected }
10542 )
10543 }
10544 );
10545 };
10546 function ListBox({ view, filter, onChangeView }) {
10547 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
10548 const [activeCompositeId, setActiveCompositeId] = (0, import_element28.useState)(
10549 // When there are one or less operators, the first item is set as active
10550 // (by setting the initial `activeId` to `undefined`).
10551 // With 2 or more operators, the focus is moved on the operators control
10552 // (by setting the initial `activeId` to `null`), meaning that there won't
10553 // be an active item initially. Focus is then managed via the
10554 // `onFocusVisible` callback.
10555 filter.operators?.length === 1 ? void 0 : null
10556 );
10557 const currentFilter = view.filters?.find(
10558 (f2) => f2.field === filter.field
10559 );
10560 const currentValue = getCurrentValue(filter, currentFilter);
10561 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10562 import_components18.Composite,
10563 {
10564 virtualFocus: true,
10565 focusLoop: true,
10566 activeId: activeCompositeId,
10567 setActiveId: setActiveCompositeId,
10568 role: "listbox",
10569 className: "dataviews-filters__search-widget-listbox",
10570 "aria-label": (0, import_i18n22.sprintf)(
10571 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
10572 (0, import_i18n22.__)("List of: %1$s"),
10573 filter.name
10574 ),
10575 onFocusVisible: () => {
10576 if (!activeCompositeId && filter.elements.length) {
10577 setActiveCompositeId(
10578 generateFilterElementCompositeItemId(
10579 baseId,
10580 filter.elements[0].value
10581 )
10582 );
10583 }
10584 },
10585 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components18.Composite.Typeahead, {}),
10586 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10587 import_components18.Composite.Hover,
10588 {
10589 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10590 import_components18.Composite.Item,
10591 {
10592 id: generateFilterElementCompositeItemId(
10593 baseId,
10594 element.value
10595 ),
10596 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10597 "div",
10598 {
10599 "aria-label": element.label,
10600 role: "option",
10601 className: "dataviews-filters__search-widget-listitem"
10602 }
10603 ),
10604 onClick: () => {
10605 const newFilters = currentFilter ? [
10606 ...(view.filters ?? []).map(
10607 (_filter) => {
10608 if (_filter.field === filter.field) {
10609 return {
10610 ..._filter,
10611 operator: currentFilter.operator || filter.operators[0],
10612 value: getNewValue(
10613 filter,
10614 currentFilter,
10615 element.value
10616 )
10617 };
10618 }
10619 return _filter;
10620 }
10621 )
10622 ] : [
10623 ...view.filters ?? [],
10624 {
10625 field: filter.field,
10626 operator: filter.operators[0],
10627 value: getNewValue(
10628 filter,
10629 currentFilter,
10630 element.value
10631 )
10632 }
10633 ];
10634 onChangeView({
10635 ...view,
10636 page: 1,
10637 filters: newFilters
10638 });
10639 }
10640 }
10641 ),
10642 children: [
10643 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10644 SingleSelectionOption,
10645 {
10646 selected: currentValue === element.value
10647 }
10648 ),
10649 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10650 MultiSelectionOption,
10651 {
10652 selected: currentValue.includes(element.value)
10653 }
10654 ),
10655 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10656 "span",
10657 {
10658 className: "dataviews-filters__search-widget-listitem-value",
10659 title: element.label,
10660 children: element.label
10661 }
10662 )
10663 ]
10664 },
10665 element.value
10666 ))
10667 }
10668 );
10669 }
10670 function ComboboxList22({ view, filter, onChangeView }) {
10671 const [searchValue, setSearchValue] = (0, import_element28.useState)("");
10672 const deferredSearchValue = (0, import_element28.useDeferredValue)(searchValue);
10673 const currentFilter = view.filters?.find(
10674 (_filter) => _filter.field === filter.field
10675 );
10676 const currentValue = getCurrentValue(filter, currentFilter);
10677 const matches = (0, import_element28.useMemo)(() => {
10678 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
10679 return filter.elements.filter(
10680 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
10681 );
10682 }, [filter.elements, deferredSearchValue]);
10683 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10684 ComboboxProvider,
10685 {
10686 selectedValue: currentValue,
10687 setSelectedValue: (value) => {
10688 const newFilters = currentFilter ? [
10689 ...(view.filters ?? []).map((_filter) => {
10690 if (_filter.field === filter.field) {
10691 return {
10692 ..._filter,
10693 operator: currentFilter.operator || filter.operators[0],
10694 value
10695 };
10696 }
10697 return _filter;
10698 })
10699 ] : [
10700 ...view.filters ?? [],
10701 {
10702 field: filter.field,
10703 operator: filter.operators[0],
10704 value
10705 }
10706 ];
10707 onChangeView({
10708 ...view,
10709 page: 1,
10710 filters: newFilters
10711 });
10712 },
10713 setValue: setSearchValue,
10714 children: [
10715 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
10716 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ComboboxLabel, {}), children: (0, import_i18n22.__)("Search items") }),
10717 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10718 Combobox,
10719 {
10720 autoSelect: "always",
10721 placeholder: (0, import_i18n22.__)("Search"),
10722 className: "dataviews-filters__search-widget-filter-combobox__input"
10723 }
10724 ),
10725 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components18.Icon, { icon: search_default }) })
10726 ] }),
10727 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10728 ComboboxList,
10729 {
10730 className: "dataviews-filters__search-widget-filter-combobox-list",
10731 alwaysVisible: true,
10732 children: [
10733 matches.map((element) => {
10734 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10735 ComboboxItem,
10736 {
10737 resetValueOnSelect: false,
10738 value: element.value,
10739 className: "dataviews-filters__search-widget-listitem",
10740 hideOnClick: false,
10741 setValueOnClick: false,
10742 focusOnHover: true,
10743 children: [
10744 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10745 SingleSelectionOption,
10746 {
10747 selected: currentValue === element.value
10748 }
10749 ),
10750 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10751 MultiSelectionOption,
10752 {
10753 selected: currentValue.includes(
10754 element.value
10755 )
10756 }
10757 ),
10758 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10759 "span",
10760 {
10761 className: "dataviews-filters__search-widget-listitem-value",
10762 title: element.label,
10763 children: [
10764 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10765 ComboboxItemValue,
10766 {
10767 className: "dataviews-filters__search-widget-filter-combobox-item-value",
10768 value: element.label
10769 }
10770 ),
10771 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
10772 ]
10773 }
10774 )
10775 ]
10776 },
10777 element.value
10778 );
10779 }),
10780 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { children: (0, import_i18n22.__)("No results found") })
10781 ]
10782 }
10783 )
10784 ]
10785 }
10786 );
10787 }
10788 function SearchWidget(props) {
10789 const { elements, isLoading } = useElements({
10790 elements: props.filter.elements,
10791 getElements: props.filter.getElements
10792 });
10793 if (isLoading) {
10794 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components18.Spinner, {}) });
10795 }
10796 if (elements.length === 0) {
10797 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n22.__)("No elements found") });
10798 }
10799 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
10800 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
10801 }
10802
10803 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
10804 var import_es6 = __toESM(require_es6(), 1);
10805 var import_compose8 = __toESM(require_compose(), 1);
10806 var import_element29 = __toESM(require_element(), 1);
10807 var import_components19 = __toESM(require_components(), 1);
10808 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
10809 function InputWidget({
10810 filter,
10811 view,
10812 onChangeView,
10813 fields
10814 }) {
10815 const currentFilter = view.filters?.find(
10816 (f2) => f2.field === filter.field
10817 );
10818 const currentValue = getCurrentValue(filter, currentFilter);
10819 const field = (0, import_element29.useMemo)(() => {
10820 const currentField = fields.find((f2) => f2.id === filter.field);
10821 if (currentField) {
10822 return {
10823 ...currentField,
10824 // Deactivate validation for filters.
10825 isValid: {},
10826 // Filter controls are always enabled.
10827 isDisabled: () => false,
10828 // Filter controls are always visible.
10829 isVisible: () => true,
10830 // Configure getValue/setValue as if Item was a plain object.
10831 getValue: ({ item }) => item[currentField.id],
10832 setValue: ({ value }) => ({
10833 [currentField.id]: value
10834 })
10835 };
10836 }
10837 return currentField;
10838 }, [fields, filter.field]);
10839 const data = (0, import_element29.useMemo)(() => {
10840 return (view.filters ?? []).reduce(
10841 (acc, activeFilter) => {
10842 acc[activeFilter.field] = activeFilter.value;
10843 return acc;
10844 },
10845 {}
10846 );
10847 }, [view.filters]);
10848 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
10849 if (!field || !currentFilter) {
10850 return;
10851 }
10852 const nextValue = field.getValue({ item: updatedData });
10853 if ((0, import_es6.default)(nextValue, currentValue)) {
10854 return;
10855 }
10856 onChangeView({
10857 ...view,
10858 filters: (view.filters ?? []).map(
10859 (_filter) => _filter.field === filter.field ? {
10860 ..._filter,
10861 operator: currentFilter.operator || filter.operators[0],
10862 // Consider empty strings as undefined:
10863 //
10864 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
10865 // - empty string as value means "search empty string": returns only the records that have an empty string as value
10866 //
10867 // In practice, this means the filter will not be able to find an empty string as the value.
10868 value: nextValue === "" ? void 0 : nextValue
10869 } : _filter
10870 )
10871 });
10872 });
10873 if (!field || !field.Edit || !currentFilter) {
10874 return null;
10875 }
10876 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
10877 import_components19.Flex,
10878 {
10879 className: "dataviews-filters__user-input-widget",
10880 gap: 2.5,
10881 direction: "column",
10882 children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
10883 field.Edit,
10884 {
10885 hideLabelFromVision: true,
10886 data,
10887 field,
10888 operator: currentFilter.operator,
10889 onChange: handleChange
10890 }
10891 )
10892 }
10893 );
10894 }
10895
10896 // packages/dataviews/node_modules/date-fns/constants.js
10897 var daysInYear = 365.2425;
10898 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
10899 var minTime = -maxTime;
10900 var millisecondsInWeek = 6048e5;
10901 var millisecondsInDay = 864e5;
10902 var secondsInHour = 3600;
10903 var secondsInDay = secondsInHour * 24;
10904 var secondsInWeek = secondsInDay * 7;
10905 var secondsInYear = secondsInDay * daysInYear;
10906 var secondsInMonth = secondsInYear / 12;
10907 var secondsInQuarter = secondsInMonth * 3;
10908 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
10909
10910 // packages/dataviews/node_modules/date-fns/constructFrom.js
10911 function constructFrom(date, value) {
10912 if (typeof date === "function") return date(value);
10913 if (date && typeof date === "object" && constructFromSymbol in date)
10914 return date[constructFromSymbol](value);
10915 if (date instanceof Date) return new date.constructor(value);
10916 return new Date(value);
10917 }
10918
10919 // packages/dataviews/node_modules/date-fns/toDate.js
10920 function toDate(argument, context) {
10921 return constructFrom(context || argument, argument);
10922 }
10923
10924 // packages/dataviews/node_modules/date-fns/addDays.js
10925 function addDays(date, amount, options) {
10926 const _date = toDate(date, options?.in);
10927 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
10928 if (!amount) return _date;
10929 _date.setDate(_date.getDate() + amount);
10930 return _date;
10931 }
10932
10933 // packages/dataviews/node_modules/date-fns/addMonths.js
10934 function addMonths(date, amount, options) {
10935 const _date = toDate(date, options?.in);
10936 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
10937 if (!amount) {
10938 return _date;
10939 }
10940 const dayOfMonth = _date.getDate();
10941 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
10942 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
10943 const daysInMonth = endOfDesiredMonth.getDate();
10944 if (dayOfMonth >= daysInMonth) {
10945 return endOfDesiredMonth;
10946 } else {
10947 _date.setFullYear(
10948 endOfDesiredMonth.getFullYear(),
10949 endOfDesiredMonth.getMonth(),
10950 dayOfMonth
10951 );
10952 return _date;
10953 }
10954 }
10955
10956 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
10957 var defaultOptions = {};
10958 function getDefaultOptions() {
10959 return defaultOptions;
10960 }
10961
10962 // packages/dataviews/node_modules/date-fns/startOfWeek.js
10963 function startOfWeek(date, options) {
10964 const defaultOptions2 = getDefaultOptions();
10965 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
10966 const _date = toDate(date, options?.in);
10967 const day = _date.getDay();
10968 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
10969 _date.setDate(_date.getDate() - diff);
10970 _date.setHours(0, 0, 0, 0);
10971 return _date;
10972 }
10973
10974 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
10975 function startOfISOWeek(date, options) {
10976 return startOfWeek(date, { ...options, weekStartsOn: 1 });
10977 }
10978
10979 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
10980 function getISOWeekYear(date, options) {
10981 const _date = toDate(date, options?.in);
10982 const year = _date.getFullYear();
10983 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
10984 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
10985 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
10986 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
10987 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
10988 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
10989 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
10990 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
10991 if (_date.getTime() >= startOfNextYear.getTime()) {
10992 return year + 1;
10993 } else if (_date.getTime() >= startOfThisYear.getTime()) {
10994 return year;
10995 } else {
10996 return year - 1;
10997 }
10998 }
10999
11000 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
11001 function getTimezoneOffsetInMilliseconds(date) {
11002 const _date = toDate(date);
11003 const utcDate = new Date(
11004 Date.UTC(
11005 _date.getFullYear(),
11006 _date.getMonth(),
11007 _date.getDate(),
11008 _date.getHours(),
11009 _date.getMinutes(),
11010 _date.getSeconds(),
11011 _date.getMilliseconds()
11012 )
11013 );
11014 utcDate.setUTCFullYear(_date.getFullYear());
11015 return +date - +utcDate;
11016 }
11017
11018 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
11019 function normalizeDates(context, ...dates) {
11020 const normalize = constructFrom.bind(
11021 null,
11022 context || dates.find((date) => typeof date === "object")
11023 );
11024 return dates.map(normalize);
11025 }
11026
11027 // packages/dataviews/node_modules/date-fns/startOfDay.js
11028 function startOfDay(date, options) {
11029 const _date = toDate(date, options?.in);
11030 _date.setHours(0, 0, 0, 0);
11031 return _date;
11032 }
11033
11034 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
11035 function differenceInCalendarDays(laterDate, earlierDate, options) {
11036 const [laterDate_, earlierDate_] = normalizeDates(
11037 options?.in,
11038 laterDate,
11039 earlierDate
11040 );
11041 const laterStartOfDay = startOfDay(laterDate_);
11042 const earlierStartOfDay = startOfDay(earlierDate_);
11043 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
11044 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
11045 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
11046 }
11047
11048 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
11049 function startOfISOWeekYear(date, options) {
11050 const year = getISOWeekYear(date, options);
11051 const fourthOfJanuary = constructFrom(options?.in || date, 0);
11052 fourthOfJanuary.setFullYear(year, 0, 4);
11053 fourthOfJanuary.setHours(0, 0, 0, 0);
11054 return startOfISOWeek(fourthOfJanuary);
11055 }
11056
11057 // packages/dataviews/node_modules/date-fns/addWeeks.js
11058 function addWeeks(date, amount, options) {
11059 return addDays(date, amount * 7, options);
11060 }
11061
11062 // packages/dataviews/node_modules/date-fns/addYears.js
11063 function addYears(date, amount, options) {
11064 return addMonths(date, amount * 12, options);
11065 }
11066
11067 // packages/dataviews/node_modules/date-fns/isDate.js
11068 function isDate(value) {
11069 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
11070 }
11071
11072 // packages/dataviews/node_modules/date-fns/isValid.js
11073 function isValid(date) {
11074 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
11075 }
11076
11077 // packages/dataviews/node_modules/date-fns/startOfMonth.js
11078 function startOfMonth(date, options) {
11079 const _date = toDate(date, options?.in);
11080 _date.setDate(1);
11081 _date.setHours(0, 0, 0, 0);
11082 return _date;
11083 }
11084
11085 // packages/dataviews/node_modules/date-fns/startOfYear.js
11086 function startOfYear(date, options) {
11087 const date_ = toDate(date, options?.in);
11088 date_.setFullYear(date_.getFullYear(), 0, 1);
11089 date_.setHours(0, 0, 0, 0);
11090 return date_;
11091 }
11092
11093 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
11094 var formatDistanceLocale = {
11095 lessThanXSeconds: {
11096 one: "less than a second",
11097 other: "less than {{count}} seconds"
11098 },
11099 xSeconds: {
11100 one: "1 second",
11101 other: "{{count}} seconds"
11102 },
11103 halfAMinute: "half a minute",
11104 lessThanXMinutes: {
11105 one: "less than a minute",
11106 other: "less than {{count}} minutes"
11107 },
11108 xMinutes: {
11109 one: "1 minute",
11110 other: "{{count}} minutes"
11111 },
11112 aboutXHours: {
11113 one: "about 1 hour",
11114 other: "about {{count}} hours"
11115 },
11116 xHours: {
11117 one: "1 hour",
11118 other: "{{count}} hours"
11119 },
11120 xDays: {
11121 one: "1 day",
11122 other: "{{count}} days"
11123 },
11124 aboutXWeeks: {
11125 one: "about 1 week",
11126 other: "about {{count}} weeks"
11127 },
11128 xWeeks: {
11129 one: "1 week",
11130 other: "{{count}} weeks"
11131 },
11132 aboutXMonths: {
11133 one: "about 1 month",
11134 other: "about {{count}} months"
11135 },
11136 xMonths: {
11137 one: "1 month",
11138 other: "{{count}} months"
11139 },
11140 aboutXYears: {
11141 one: "about 1 year",
11142 other: "about {{count}} years"
11143 },
11144 xYears: {
11145 one: "1 year",
11146 other: "{{count}} years"
11147 },
11148 overXYears: {
11149 one: "over 1 year",
11150 other: "over {{count}} years"
11151 },
11152 almostXYears: {
11153 one: "almost 1 year",
11154 other: "almost {{count}} years"
11155 }
11156 };
11157 var formatDistance = (token, count, options) => {
11158 let result;
11159 const tokenValue = formatDistanceLocale[token];
11160 if (typeof tokenValue === "string") {
11161 result = tokenValue;
11162 } else if (count === 1) {
11163 result = tokenValue.one;
11164 } else {
11165 result = tokenValue.other.replace("{{count}}", count.toString());
11166 }
11167 if (options?.addSuffix) {
11168 if (options.comparison && options.comparison > 0) {
11169 return "in " + result;
11170 } else {
11171 return result + " ago";
11172 }
11173 }
11174 return result;
11175 };
11176
11177 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
11178 function buildFormatLongFn(args) {
11179 return (options = {}) => {
11180 const width = options.width ? String(options.width) : args.defaultWidth;
11181 const format6 = args.formats[width] || args.formats[args.defaultWidth];
11182 return format6;
11183 };
11184 }
11185
11186 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
11187 var dateFormats = {
11188 full: "EEEE, MMMM do, y",
11189 long: "MMMM do, y",
11190 medium: "MMM d, y",
11191 short: "MM/dd/yyyy"
11192 };
11193 var timeFormats = {
11194 full: "h:mm:ss a zzzz",
11195 long: "h:mm:ss a z",
11196 medium: "h:mm:ss a",
11197 short: "h:mm a"
11198 };
11199 var dateTimeFormats = {
11200 full: "{{date}} 'at' {{time}}",
11201 long: "{{date}} 'at' {{time}}",
11202 medium: "{{date}}, {{time}}",
11203 short: "{{date}}, {{time}}"
11204 };
11205 var formatLong = {
11206 date: buildFormatLongFn({
11207 formats: dateFormats,
11208 defaultWidth: "full"
11209 }),
11210 time: buildFormatLongFn({
11211 formats: timeFormats,
11212 defaultWidth: "full"
11213 }),
11214 dateTime: buildFormatLongFn({
11215 formats: dateTimeFormats,
11216 defaultWidth: "full"
11217 })
11218 };
11219
11220 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
11221 var formatRelativeLocale = {
11222 lastWeek: "'last' eeee 'at' p",
11223 yesterday: "'yesterday at' p",
11224 today: "'today at' p",
11225 tomorrow: "'tomorrow at' p",
11226 nextWeek: "eeee 'at' p",
11227 other: "P"
11228 };
11229 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
11230
11231 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
11232 function buildLocalizeFn(args) {
11233 return (value, options) => {
11234 const context = options?.context ? String(options.context) : "standalone";
11235 let valuesArray;
11236 if (context === "formatting" && args.formattingValues) {
11237 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
11238 const width = options?.width ? String(options.width) : defaultWidth;
11239 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
11240 } else {
11241 const defaultWidth = args.defaultWidth;
11242 const width = options?.width ? String(options.width) : args.defaultWidth;
11243 valuesArray = args.values[width] || args.values[defaultWidth];
11244 }
11245 const index = args.argumentCallback ? args.argumentCallback(value) : value;
11246 return valuesArray[index];
11247 };
11248 }
11249
11250 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
11251 var eraValues = {
11252 narrow: ["B", "A"],
11253 abbreviated: ["BC", "AD"],
11254 wide: ["Before Christ", "Anno Domini"]
11255 };
11256 var quarterValues = {
11257 narrow: ["1", "2", "3", "4"],
11258 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
11259 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
11260 };
11261 var monthValues = {
11262 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
11263 abbreviated: [
11264 "Jan",
11265 "Feb",
11266 "Mar",
11267 "Apr",
11268 "May",
11269 "Jun",
11270 "Jul",
11271 "Aug",
11272 "Sep",
11273 "Oct",
11274 "Nov",
11275 "Dec"
11276 ],
11277 wide: [
11278 "January",
11279 "February",
11280 "March",
11281 "April",
11282 "May",
11283 "June",
11284 "July",
11285 "August",
11286 "September",
11287 "October",
11288 "November",
11289 "December"
11290 ]
11291 };
11292 var dayValues = {
11293 narrow: ["S", "M", "T", "W", "T", "F", "S"],
11294 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
11295 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
11296 wide: [
11297 "Sunday",
11298 "Monday",
11299 "Tuesday",
11300 "Wednesday",
11301 "Thursday",
11302 "Friday",
11303 "Saturday"
11304 ]
11305 };
11306 var dayPeriodValues = {
11307 narrow: {
11308 am: "a",
11309 pm: "p",
11310 midnight: "mi",
11311 noon: "n",
11312 morning: "morning",
11313 afternoon: "afternoon",
11314 evening: "evening",
11315 night: "night"
11316 },
11317 abbreviated: {
11318 am: "AM",
11319 pm: "PM",
11320 midnight: "midnight",
11321 noon: "noon",
11322 morning: "morning",
11323 afternoon: "afternoon",
11324 evening: "evening",
11325 night: "night"
11326 },
11327 wide: {
11328 am: "a.m.",
11329 pm: "p.m.",
11330 midnight: "midnight",
11331 noon: "noon",
11332 morning: "morning",
11333 afternoon: "afternoon",
11334 evening: "evening",
11335 night: "night"
11336 }
11337 };
11338 var formattingDayPeriodValues = {
11339 narrow: {
11340 am: "a",
11341 pm: "p",
11342 midnight: "mi",
11343 noon: "n",
11344 morning: "in the morning",
11345 afternoon: "in the afternoon",
11346 evening: "in the evening",
11347 night: "at night"
11348 },
11349 abbreviated: {
11350 am: "AM",
11351 pm: "PM",
11352 midnight: "midnight",
11353 noon: "noon",
11354 morning: "in the morning",
11355 afternoon: "in the afternoon",
11356 evening: "in the evening",
11357 night: "at night"
11358 },
11359 wide: {
11360 am: "a.m.",
11361 pm: "p.m.",
11362 midnight: "midnight",
11363 noon: "noon",
11364 morning: "in the morning",
11365 afternoon: "in the afternoon",
11366 evening: "in the evening",
11367 night: "at night"
11368 }
11369 };
11370 var ordinalNumber = (dirtyNumber, _options) => {
11371 const number = Number(dirtyNumber);
11372 const rem100 = number % 100;
11373 if (rem100 > 20 || rem100 < 10) {
11374 switch (rem100 % 10) {
11375 case 1:
11376 return number + "st";
11377 case 2:
11378 return number + "nd";
11379 case 3:
11380 return number + "rd";
11381 }
11382 }
11383 return number + "th";
11384 };
11385 var localize = {
11386 ordinalNumber,
11387 era: buildLocalizeFn({
11388 values: eraValues,
11389 defaultWidth: "wide"
11390 }),
11391 quarter: buildLocalizeFn({
11392 values: quarterValues,
11393 defaultWidth: "wide",
11394 argumentCallback: (quarter) => quarter - 1
11395 }),
11396 month: buildLocalizeFn({
11397 values: monthValues,
11398 defaultWidth: "wide"
11399 }),
11400 day: buildLocalizeFn({
11401 values: dayValues,
11402 defaultWidth: "wide"
11403 }),
11404 dayPeriod: buildLocalizeFn({
11405 values: dayPeriodValues,
11406 defaultWidth: "wide",
11407 formattingValues: formattingDayPeriodValues,
11408 defaultFormattingWidth: "wide"
11409 })
11410 };
11411
11412 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
11413 function buildMatchFn(args) {
11414 return (string, options = {}) => {
11415 const width = options.width;
11416 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
11417 const matchResult = string.match(matchPattern);
11418 if (!matchResult) {
11419 return null;
11420 }
11421 const matchedString = matchResult[0];
11422 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
11423 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
11424 // [TODO] -- I challenge you to fix the type
11425 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
11426 );
11427 let value;
11428 value = args.valueCallback ? args.valueCallback(key) : key;
11429 value = options.valueCallback ? (
11430 // [TODO] -- I challenge you to fix the type
11431 options.valueCallback(value)
11432 ) : value;
11433 const rest = string.slice(matchedString.length);
11434 return { value, rest };
11435 };
11436 }
11437 function findKey(object, predicate) {
11438 for (const key in object) {
11439 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
11440 return key;
11441 }
11442 }
11443 return void 0;
11444 }
11445 function findIndex(array, predicate) {
11446 for (let key = 0; key < array.length; key++) {
11447 if (predicate(array[key])) {
11448 return key;
11449 }
11450 }
11451 return void 0;
11452 }
11453
11454 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
11455 function buildMatchPatternFn(args) {
11456 return (string, options = {}) => {
11457 const matchResult = string.match(args.matchPattern);
11458 if (!matchResult) return null;
11459 const matchedString = matchResult[0];
11460 const parseResult = string.match(args.parsePattern);
11461 if (!parseResult) return null;
11462 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
11463 value = options.valueCallback ? options.valueCallback(value) : value;
11464 const rest = string.slice(matchedString.length);
11465 return { value, rest };
11466 };
11467 }
11468
11469 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
11470 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
11471 var parseOrdinalNumberPattern = /\d+/i;
11472 var matchEraPatterns = {
11473 narrow: /^(b|a)/i,
11474 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
11475 wide: /^(before christ|before common era|anno domini|common era)/i
11476 };
11477 var parseEraPatterns = {
11478 any: [/^b/i, /^(a|c)/i]
11479 };
11480 var matchQuarterPatterns = {
11481 narrow: /^[1234]/i,
11482 abbreviated: /^q[1234]/i,
11483 wide: /^[1234](th|st|nd|rd)? quarter/i
11484 };
11485 var parseQuarterPatterns = {
11486 any: [/1/i, /2/i, /3/i, /4/i]
11487 };
11488 var matchMonthPatterns = {
11489 narrow: /^[jfmasond]/i,
11490 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
11491 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
11492 };
11493 var parseMonthPatterns = {
11494 narrow: [
11495 /^j/i,
11496 /^f/i,
11497 /^m/i,
11498 /^a/i,
11499 /^m/i,
11500 /^j/i,
11501 /^j/i,
11502 /^a/i,
11503 /^s/i,
11504 /^o/i,
11505 /^n/i,
11506 /^d/i
11507 ],
11508 any: [
11509 /^ja/i,
11510 /^f/i,
11511 /^mar/i,
11512 /^ap/i,
11513 /^may/i,
11514 /^jun/i,
11515 /^jul/i,
11516 /^au/i,
11517 /^s/i,
11518 /^o/i,
11519 /^n/i,
11520 /^d/i
11521 ]
11522 };
11523 var matchDayPatterns = {
11524 narrow: /^[smtwf]/i,
11525 short: /^(su|mo|tu|we|th|fr|sa)/i,
11526 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
11527 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
11528 };
11529 var parseDayPatterns = {
11530 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
11531 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
11532 };
11533 var matchDayPeriodPatterns = {
11534 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
11535 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
11536 };
11537 var parseDayPeriodPatterns = {
11538 any: {
11539 am: /^a/i,
11540 pm: /^p/i,
11541 midnight: /^mi/i,
11542 noon: /^no/i,
11543 morning: /morning/i,
11544 afternoon: /afternoon/i,
11545 evening: /evening/i,
11546 night: /night/i
11547 }
11548 };
11549 var match = {
11550 ordinalNumber: buildMatchPatternFn({
11551 matchPattern: matchOrdinalNumberPattern,
11552 parsePattern: parseOrdinalNumberPattern,
11553 valueCallback: (value) => parseInt(value, 10)
11554 }),
11555 era: buildMatchFn({
11556 matchPatterns: matchEraPatterns,
11557 defaultMatchWidth: "wide",
11558 parsePatterns: parseEraPatterns,
11559 defaultParseWidth: "any"
11560 }),
11561 quarter: buildMatchFn({
11562 matchPatterns: matchQuarterPatterns,
11563 defaultMatchWidth: "wide",
11564 parsePatterns: parseQuarterPatterns,
11565 defaultParseWidth: "any",
11566 valueCallback: (index) => index + 1
11567 }),
11568 month: buildMatchFn({
11569 matchPatterns: matchMonthPatterns,
11570 defaultMatchWidth: "wide",
11571 parsePatterns: parseMonthPatterns,
11572 defaultParseWidth: "any"
11573 }),
11574 day: buildMatchFn({
11575 matchPatterns: matchDayPatterns,
11576 defaultMatchWidth: "wide",
11577 parsePatterns: parseDayPatterns,
11578 defaultParseWidth: "any"
11579 }),
11580 dayPeriod: buildMatchFn({
11581 matchPatterns: matchDayPeriodPatterns,
11582 defaultMatchWidth: "any",
11583 parsePatterns: parseDayPeriodPatterns,
11584 defaultParseWidth: "any"
11585 })
11586 };
11587
11588 // packages/dataviews/node_modules/date-fns/locale/en-US.js
11589 var enUS = {
11590 code: "en-US",
11591 formatDistance,
11592 formatLong,
11593 formatRelative,
11594 localize,
11595 match,
11596 options: {
11597 weekStartsOn: 0,
11598 firstWeekContainsDate: 1
11599 }
11600 };
11601
11602 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
11603 function getDayOfYear(date, options) {
11604 const _date = toDate(date, options?.in);
11605 const diff = differenceInCalendarDays(_date, startOfYear(_date));
11606 const dayOfYear = diff + 1;
11607 return dayOfYear;
11608 }
11609
11610 // packages/dataviews/node_modules/date-fns/getISOWeek.js
11611 function getISOWeek(date, options) {
11612 const _date = toDate(date, options?.in);
11613 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
11614 return Math.round(diff / millisecondsInWeek) + 1;
11615 }
11616
11617 // packages/dataviews/node_modules/date-fns/getWeekYear.js
11618 function getWeekYear(date, options) {
11619 const _date = toDate(date, options?.in);
11620 const year = _date.getFullYear();
11621 const defaultOptions2 = getDefaultOptions();
11622 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
11623 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
11624 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
11625 firstWeekOfNextYear.setHours(0, 0, 0, 0);
11626 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
11627 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
11628 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
11629 firstWeekOfThisYear.setHours(0, 0, 0, 0);
11630 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
11631 if (+_date >= +startOfNextYear) {
11632 return year + 1;
11633 } else if (+_date >= +startOfThisYear) {
11634 return year;
11635 } else {
11636 return year - 1;
11637 }
11638 }
11639
11640 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
11641 function startOfWeekYear(date, options) {
11642 const defaultOptions2 = getDefaultOptions();
11643 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
11644 const year = getWeekYear(date, options);
11645 const firstWeek = constructFrom(options?.in || date, 0);
11646 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
11647 firstWeek.setHours(0, 0, 0, 0);
11648 const _date = startOfWeek(firstWeek, options);
11649 return _date;
11650 }
11651
11652 // packages/dataviews/node_modules/date-fns/getWeek.js
11653 function getWeek(date, options) {
11654 const _date = toDate(date, options?.in);
11655 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
11656 return Math.round(diff / millisecondsInWeek) + 1;
11657 }
11658
11659 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
11660 function addLeadingZeros(number, targetLength) {
11661 const sign = number < 0 ? "-" : "";
11662 const output = Math.abs(number).toString().padStart(targetLength, "0");
11663 return sign + output;
11664 }
11665
11666 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
11667 var lightFormatters = {
11668 // Year
11669 y(date, token) {
11670 const signedYear = date.getFullYear();
11671 const year = signedYear > 0 ? signedYear : 1 - signedYear;
11672 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
11673 },
11674 // Month
11675 M(date, token) {
11676 const month = date.getMonth();
11677 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
11678 },
11679 // Day of the month
11680 d(date, token) {
11681 return addLeadingZeros(date.getDate(), token.length);
11682 },
11683 // AM or PM
11684 a(date, token) {
11685 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
11686 switch (token) {
11687 case "a":
11688 case "aa":
11689 return dayPeriodEnumValue.toUpperCase();
11690 case "aaa":
11691 return dayPeriodEnumValue;
11692 case "aaaaa":
11693 return dayPeriodEnumValue[0];
11694 case "aaaa":
11695 default:
11696 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
11697 }
11698 },
11699 // Hour [1-12]
11700 h(date, token) {
11701 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
11702 },
11703 // Hour [0-23]
11704 H(date, token) {
11705 return addLeadingZeros(date.getHours(), token.length);
11706 },
11707 // Minute
11708 m(date, token) {
11709 return addLeadingZeros(date.getMinutes(), token.length);
11710 },
11711 // Second
11712 s(date, token) {
11713 return addLeadingZeros(date.getSeconds(), token.length);
11714 },
11715 // Fraction of second
11716 S(date, token) {
11717 const numberOfDigits = token.length;
11718 const milliseconds = date.getMilliseconds();
11719 const fractionalSeconds = Math.trunc(
11720 milliseconds * Math.pow(10, numberOfDigits - 3)
11721 );
11722 return addLeadingZeros(fractionalSeconds, token.length);
11723 }
11724 };
11725
11726 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
11727 var dayPeriodEnum = {
11728 am: "am",
11729 pm: "pm",
11730 midnight: "midnight",
11731 noon: "noon",
11732 morning: "morning",
11733 afternoon: "afternoon",
11734 evening: "evening",
11735 night: "night"
11736 };
11737 var formatters = {
11738 // Era
11739 G: function(date, token, localize2) {
11740 const era = date.getFullYear() > 0 ? 1 : 0;
11741 switch (token) {
11742 // AD, BC
11743 case "G":
11744 case "GG":
11745 case "GGG":
11746 return localize2.era(era, { width: "abbreviated" });
11747 // A, B
11748 case "GGGGG":
11749 return localize2.era(era, { width: "narrow" });
11750 // Anno Domini, Before Christ
11751 case "GGGG":
11752 default:
11753 return localize2.era(era, { width: "wide" });
11754 }
11755 },
11756 // Year
11757 y: function(date, token, localize2) {
11758 if (token === "yo") {
11759 const signedYear = date.getFullYear();
11760 const year = signedYear > 0 ? signedYear : 1 - signedYear;
11761 return localize2.ordinalNumber(year, { unit: "year" });
11762 }
11763 return lightFormatters.y(date, token);
11764 },
11765 // Local week-numbering year
11766 Y: function(date, token, localize2, options) {
11767 const signedWeekYear = getWeekYear(date, options);
11768 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
11769 if (token === "YY") {
11770 const twoDigitYear = weekYear % 100;
11771 return addLeadingZeros(twoDigitYear, 2);
11772 }
11773 if (token === "Yo") {
11774 return localize2.ordinalNumber(weekYear, { unit: "year" });
11775 }
11776 return addLeadingZeros(weekYear, token.length);
11777 },
11778 // ISO week-numbering year
11779 R: function(date, token) {
11780 const isoWeekYear = getISOWeekYear(date);
11781 return addLeadingZeros(isoWeekYear, token.length);
11782 },
11783 // Extended year. This is a single number designating the year of this calendar system.
11784 // The main difference between `y` and `u` localizers are B.C. years:
11785 // | Year | `y` | `u` |
11786 // |------|-----|-----|
11787 // | AC 1 | 1 | 1 |
11788 // | BC 1 | 1 | 0 |
11789 // | BC 2 | 2 | -1 |
11790 // Also `yy` always returns the last two digits of a year,
11791 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
11792 u: function(date, token) {
11793 const year = date.getFullYear();
11794 return addLeadingZeros(year, token.length);
11795 },
11796 // Quarter
11797 Q: function(date, token, localize2) {
11798 const quarter = Math.ceil((date.getMonth() + 1) / 3);
11799 switch (token) {
11800 // 1, 2, 3, 4
11801 case "Q":
11802 return String(quarter);
11803 // 01, 02, 03, 04
11804 case "QQ":
11805 return addLeadingZeros(quarter, 2);
11806 // 1st, 2nd, 3rd, 4th
11807 case "Qo":
11808 return localize2.ordinalNumber(quarter, { unit: "quarter" });
11809 // Q1, Q2, Q3, Q4
11810 case "QQQ":
11811 return localize2.quarter(quarter, {
11812 width: "abbreviated",
11813 context: "formatting"
11814 });
11815 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
11816 case "QQQQQ":
11817 return localize2.quarter(quarter, {
11818 width: "narrow",
11819 context: "formatting"
11820 });
11821 // 1st quarter, 2nd quarter, ...
11822 case "QQQQ":
11823 default:
11824 return localize2.quarter(quarter, {
11825 width: "wide",
11826 context: "formatting"
11827 });
11828 }
11829 },
11830 // Stand-alone quarter
11831 q: function(date, token, localize2) {
11832 const quarter = Math.ceil((date.getMonth() + 1) / 3);
11833 switch (token) {
11834 // 1, 2, 3, 4
11835 case "q":
11836 return String(quarter);
11837 // 01, 02, 03, 04
11838 case "qq":
11839 return addLeadingZeros(quarter, 2);
11840 // 1st, 2nd, 3rd, 4th
11841 case "qo":
11842 return localize2.ordinalNumber(quarter, { unit: "quarter" });
11843 // Q1, Q2, Q3, Q4
11844 case "qqq":
11845 return localize2.quarter(quarter, {
11846 width: "abbreviated",
11847 context: "standalone"
11848 });
11849 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
11850 case "qqqqq":
11851 return localize2.quarter(quarter, {
11852 width: "narrow",
11853 context: "standalone"
11854 });
11855 // 1st quarter, 2nd quarter, ...
11856 case "qqqq":
11857 default:
11858 return localize2.quarter(quarter, {
11859 width: "wide",
11860 context: "standalone"
11861 });
11862 }
11863 },
11864 // Month
11865 M: function(date, token, localize2) {
11866 const month = date.getMonth();
11867 switch (token) {
11868 case "M":
11869 case "MM":
11870 return lightFormatters.M(date, token);
11871 // 1st, 2nd, ..., 12th
11872 case "Mo":
11873 return localize2.ordinalNumber(month + 1, { unit: "month" });
11874 // Jan, Feb, ..., Dec
11875 case "MMM":
11876 return localize2.month(month, {
11877 width: "abbreviated",
11878 context: "formatting"
11879 });
11880 // J, F, ..., D
11881 case "MMMMM":
11882 return localize2.month(month, {
11883 width: "narrow",
11884 context: "formatting"
11885 });
11886 // January, February, ..., December
11887 case "MMMM":
11888 default:
11889 return localize2.month(month, { width: "wide", context: "formatting" });
11890 }
11891 },
11892 // Stand-alone month
11893 L: function(date, token, localize2) {
11894 const month = date.getMonth();
11895 switch (token) {
11896 // 1, 2, ..., 12
11897 case "L":
11898 return String(month + 1);
11899 // 01, 02, ..., 12
11900 case "LL":
11901 return addLeadingZeros(month + 1, 2);
11902 // 1st, 2nd, ..., 12th
11903 case "Lo":
11904 return localize2.ordinalNumber(month + 1, { unit: "month" });
11905 // Jan, Feb, ..., Dec
11906 case "LLL":
11907 return localize2.month(month, {
11908 width: "abbreviated",
11909 context: "standalone"
11910 });
11911 // J, F, ..., D
11912 case "LLLLL":
11913 return localize2.month(month, {
11914 width: "narrow",
11915 context: "standalone"
11916 });
11917 // January, February, ..., December
11918 case "LLLL":
11919 default:
11920 return localize2.month(month, { width: "wide", context: "standalone" });
11921 }
11922 },
11923 // Local week of year
11924 w: function(date, token, localize2, options) {
11925 const week = getWeek(date, options);
11926 if (token === "wo") {
11927 return localize2.ordinalNumber(week, { unit: "week" });
11928 }
11929 return addLeadingZeros(week, token.length);
11930 },
11931 // ISO week of year
11932 I: function(date, token, localize2) {
11933 const isoWeek = getISOWeek(date);
11934 if (token === "Io") {
11935 return localize2.ordinalNumber(isoWeek, { unit: "week" });
11936 }
11937 return addLeadingZeros(isoWeek, token.length);
11938 },
11939 // Day of the month
11940 d: function(date, token, localize2) {
11941 if (token === "do") {
11942 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
11943 }
11944 return lightFormatters.d(date, token);
11945 },
11946 // Day of year
11947 D: function(date, token, localize2) {
11948 const dayOfYear = getDayOfYear(date);
11949 if (token === "Do") {
11950 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
11951 }
11952 return addLeadingZeros(dayOfYear, token.length);
11953 },
11954 // Day of week
11955 E: function(date, token, localize2) {
11956 const dayOfWeek = date.getDay();
11957 switch (token) {
11958 // Tue
11959 case "E":
11960 case "EE":
11961 case "EEE":
11962 return localize2.day(dayOfWeek, {
11963 width: "abbreviated",
11964 context: "formatting"
11965 });
11966 // T
11967 case "EEEEE":
11968 return localize2.day(dayOfWeek, {
11969 width: "narrow",
11970 context: "formatting"
11971 });
11972 // Tu
11973 case "EEEEEE":
11974 return localize2.day(dayOfWeek, {
11975 width: "short",
11976 context: "formatting"
11977 });
11978 // Tuesday
11979 case "EEEE":
11980 default:
11981 return localize2.day(dayOfWeek, {
11982 width: "wide",
11983 context: "formatting"
11984 });
11985 }
11986 },
11987 // Local day of week
11988 e: function(date, token, localize2, options) {
11989 const dayOfWeek = date.getDay();
11990 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
11991 switch (token) {
11992 // Numerical value (Nth day of week with current locale or weekStartsOn)
11993 case "e":
11994 return String(localDayOfWeek);
11995 // Padded numerical value
11996 case "ee":
11997 return addLeadingZeros(localDayOfWeek, 2);
11998 // 1st, 2nd, ..., 7th
11999 case "eo":
12000 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
12001 case "eee":
12002 return localize2.day(dayOfWeek, {
12003 width: "abbreviated",
12004 context: "formatting"
12005 });
12006 // T
12007 case "eeeee":
12008 return localize2.day(dayOfWeek, {
12009 width: "narrow",
12010 context: "formatting"
12011 });
12012 // Tu
12013 case "eeeeee":
12014 return localize2.day(dayOfWeek, {
12015 width: "short",
12016 context: "formatting"
12017 });
12018 // Tuesday
12019 case "eeee":
12020 default:
12021 return localize2.day(dayOfWeek, {
12022 width: "wide",
12023 context: "formatting"
12024 });
12025 }
12026 },
12027 // Stand-alone local day of week
12028 c: function(date, token, localize2, options) {
12029 const dayOfWeek = date.getDay();
12030 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
12031 switch (token) {
12032 // Numerical value (same as in `e`)
12033 case "c":
12034 return String(localDayOfWeek);
12035 // Padded numerical value
12036 case "cc":
12037 return addLeadingZeros(localDayOfWeek, token.length);
12038 // 1st, 2nd, ..., 7th
12039 case "co":
12040 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
12041 case "ccc":
12042 return localize2.day(dayOfWeek, {
12043 width: "abbreviated",
12044 context: "standalone"
12045 });
12046 // T
12047 case "ccccc":
12048 return localize2.day(dayOfWeek, {
12049 width: "narrow",
12050 context: "standalone"
12051 });
12052 // Tu
12053 case "cccccc":
12054 return localize2.day(dayOfWeek, {
12055 width: "short",
12056 context: "standalone"
12057 });
12058 // Tuesday
12059 case "cccc":
12060 default:
12061 return localize2.day(dayOfWeek, {
12062 width: "wide",
12063 context: "standalone"
12064 });
12065 }
12066 },
12067 // ISO day of week
12068 i: function(date, token, localize2) {
12069 const dayOfWeek = date.getDay();
12070 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
12071 switch (token) {
12072 // 2
12073 case "i":
12074 return String(isoDayOfWeek);
12075 // 02
12076 case "ii":
12077 return addLeadingZeros(isoDayOfWeek, token.length);
12078 // 2nd
12079 case "io":
12080 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
12081 // Tue
12082 case "iii":
12083 return localize2.day(dayOfWeek, {
12084 width: "abbreviated",
12085 context: "formatting"
12086 });
12087 // T
12088 case "iiiii":
12089 return localize2.day(dayOfWeek, {
12090 width: "narrow",
12091 context: "formatting"
12092 });
12093 // Tu
12094 case "iiiiii":
12095 return localize2.day(dayOfWeek, {
12096 width: "short",
12097 context: "formatting"
12098 });
12099 // Tuesday
12100 case "iiii":
12101 default:
12102 return localize2.day(dayOfWeek, {
12103 width: "wide",
12104 context: "formatting"
12105 });
12106 }
12107 },
12108 // AM or PM
12109 a: function(date, token, localize2) {
12110 const hours = date.getHours();
12111 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
12112 switch (token) {
12113 case "a":
12114 case "aa":
12115 return localize2.dayPeriod(dayPeriodEnumValue, {
12116 width: "abbreviated",
12117 context: "formatting"
12118 });
12119 case "aaa":
12120 return localize2.dayPeriod(dayPeriodEnumValue, {
12121 width: "abbreviated",
12122 context: "formatting"
12123 }).toLowerCase();
12124 case "aaaaa":
12125 return localize2.dayPeriod(dayPeriodEnumValue, {
12126 width: "narrow",
12127 context: "formatting"
12128 });
12129 case "aaaa":
12130 default:
12131 return localize2.dayPeriod(dayPeriodEnumValue, {
12132 width: "wide",
12133 context: "formatting"
12134 });
12135 }
12136 },
12137 // AM, PM, midnight, noon
12138 b: function(date, token, localize2) {
12139 const hours = date.getHours();
12140 let dayPeriodEnumValue;
12141 if (hours === 12) {
12142 dayPeriodEnumValue = dayPeriodEnum.noon;
12143 } else if (hours === 0) {
12144 dayPeriodEnumValue = dayPeriodEnum.midnight;
12145 } else {
12146 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
12147 }
12148 switch (token) {
12149 case "b":
12150 case "bb":
12151 return localize2.dayPeriod(dayPeriodEnumValue, {
12152 width: "abbreviated",
12153 context: "formatting"
12154 });
12155 case "bbb":
12156 return localize2.dayPeriod(dayPeriodEnumValue, {
12157 width: "abbreviated",
12158 context: "formatting"
12159 }).toLowerCase();
12160 case "bbbbb":
12161 return localize2.dayPeriod(dayPeriodEnumValue, {
12162 width: "narrow",
12163 context: "formatting"
12164 });
12165 case "bbbb":
12166 default:
12167 return localize2.dayPeriod(dayPeriodEnumValue, {
12168 width: "wide",
12169 context: "formatting"
12170 });
12171 }
12172 },
12173 // in the morning, in the afternoon, in the evening, at night
12174 B: function(date, token, localize2) {
12175 const hours = date.getHours();
12176 let dayPeriodEnumValue;
12177 if (hours >= 17) {
12178 dayPeriodEnumValue = dayPeriodEnum.evening;
12179 } else if (hours >= 12) {
12180 dayPeriodEnumValue = dayPeriodEnum.afternoon;
12181 } else if (hours >= 4) {
12182 dayPeriodEnumValue = dayPeriodEnum.morning;
12183 } else {
12184 dayPeriodEnumValue = dayPeriodEnum.night;
12185 }
12186 switch (token) {
12187 case "B":
12188 case "BB":
12189 case "BBB":
12190 return localize2.dayPeriod(dayPeriodEnumValue, {
12191 width: "abbreviated",
12192 context: "formatting"
12193 });
12194 case "BBBBB":
12195 return localize2.dayPeriod(dayPeriodEnumValue, {
12196 width: "narrow",
12197 context: "formatting"
12198 });
12199 case "BBBB":
12200 default:
12201 return localize2.dayPeriod(dayPeriodEnumValue, {
12202 width: "wide",
12203 context: "formatting"
12204 });
12205 }
12206 },
12207 // Hour [1-12]
12208 h: function(date, token, localize2) {
12209 if (token === "ho") {
12210 let hours = date.getHours() % 12;
12211 if (hours === 0) hours = 12;
12212 return localize2.ordinalNumber(hours, { unit: "hour" });
12213 }
12214 return lightFormatters.h(date, token);
12215 },
12216 // Hour [0-23]
12217 H: function(date, token, localize2) {
12218 if (token === "Ho") {
12219 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
12220 }
12221 return lightFormatters.H(date, token);
12222 },
12223 // Hour [0-11]
12224 K: function(date, token, localize2) {
12225 const hours = date.getHours() % 12;
12226 if (token === "Ko") {
12227 return localize2.ordinalNumber(hours, { unit: "hour" });
12228 }
12229 return addLeadingZeros(hours, token.length);
12230 },
12231 // Hour [1-24]
12232 k: function(date, token, localize2) {
12233 let hours = date.getHours();
12234 if (hours === 0) hours = 24;
12235 if (token === "ko") {
12236 return localize2.ordinalNumber(hours, { unit: "hour" });
12237 }
12238 return addLeadingZeros(hours, token.length);
12239 },
12240 // Minute
12241 m: function(date, token, localize2) {
12242 if (token === "mo") {
12243 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
12244 }
12245 return lightFormatters.m(date, token);
12246 },
12247 // Second
12248 s: function(date, token, localize2) {
12249 if (token === "so") {
12250 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
12251 }
12252 return lightFormatters.s(date, token);
12253 },
12254 // Fraction of second
12255 S: function(date, token) {
12256 return lightFormatters.S(date, token);
12257 },
12258 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
12259 X: function(date, token, _localize) {
12260 const timezoneOffset = date.getTimezoneOffset();
12261 if (timezoneOffset === 0) {
12262 return "Z";
12263 }
12264 switch (token) {
12265 // Hours and optional minutes
12266 case "X":
12267 return formatTimezoneWithOptionalMinutes(timezoneOffset);
12268 // Hours, minutes and optional seconds without `:` delimiter
12269 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12270 // so this token always has the same output as `XX`
12271 case "XXXX":
12272 case "XX":
12273 return formatTimezone(timezoneOffset);
12274 // Hours, minutes and optional seconds with `:` delimiter
12275 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12276 // so this token always has the same output as `XXX`
12277 case "XXXXX":
12278 case "XXX":
12279 // Hours and minutes with `:` delimiter
12280 default:
12281 return formatTimezone(timezoneOffset, ":");
12282 }
12283 },
12284 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
12285 x: function(date, token, _localize) {
12286 const timezoneOffset = date.getTimezoneOffset();
12287 switch (token) {
12288 // Hours and optional minutes
12289 case "x":
12290 return formatTimezoneWithOptionalMinutes(timezoneOffset);
12291 // Hours, minutes and optional seconds without `:` delimiter
12292 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12293 // so this token always has the same output as `xx`
12294 case "xxxx":
12295 case "xx":
12296 return formatTimezone(timezoneOffset);
12297 // Hours, minutes and optional seconds with `:` delimiter
12298 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12299 // so this token always has the same output as `xxx`
12300 case "xxxxx":
12301 case "xxx":
12302 // Hours and minutes with `:` delimiter
12303 default:
12304 return formatTimezone(timezoneOffset, ":");
12305 }
12306 },
12307 // Timezone (GMT)
12308 O: function(date, token, _localize) {
12309 const timezoneOffset = date.getTimezoneOffset();
12310 switch (token) {
12311 // Short
12312 case "O":
12313 case "OO":
12314 case "OOO":
12315 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
12316 // Long
12317 case "OOOO":
12318 default:
12319 return "GMT" + formatTimezone(timezoneOffset, ":");
12320 }
12321 },
12322 // Timezone (specific non-location)
12323 z: function(date, token, _localize) {
12324 const timezoneOffset = date.getTimezoneOffset();
12325 switch (token) {
12326 // Short
12327 case "z":
12328 case "zz":
12329 case "zzz":
12330 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
12331 // Long
12332 case "zzzz":
12333 default:
12334 return "GMT" + formatTimezone(timezoneOffset, ":");
12335 }
12336 },
12337 // Seconds timestamp
12338 t: function(date, token, _localize) {
12339 const timestamp = Math.trunc(+date / 1e3);
12340 return addLeadingZeros(timestamp, token.length);
12341 },
12342 // Milliseconds timestamp
12343 T: function(date, token, _localize) {
12344 return addLeadingZeros(+date, token.length);
12345 }
12346 };
12347 function formatTimezoneShort(offset, delimiter = "") {
12348 const sign = offset > 0 ? "-" : "+";
12349 const absOffset = Math.abs(offset);
12350 const hours = Math.trunc(absOffset / 60);
12351 const minutes = absOffset % 60;
12352 if (minutes === 0) {
12353 return sign + String(hours);
12354 }
12355 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
12356 }
12357 function formatTimezoneWithOptionalMinutes(offset, delimiter) {
12358 if (offset % 60 === 0) {
12359 const sign = offset > 0 ? "-" : "+";
12360 return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
12361 }
12362 return formatTimezone(offset, delimiter);
12363 }
12364 function formatTimezone(offset, delimiter = "") {
12365 const sign = offset > 0 ? "-" : "+";
12366 const absOffset = Math.abs(offset);
12367 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
12368 const minutes = addLeadingZeros(absOffset % 60, 2);
12369 return sign + hours + delimiter + minutes;
12370 }
12371
12372 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
12373 var dateLongFormatter = (pattern, formatLong2) => {
12374 switch (pattern) {
12375 case "P":
12376 return formatLong2.date({ width: "short" });
12377 case "PP":
12378 return formatLong2.date({ width: "medium" });
12379 case "PPP":
12380 return formatLong2.date({ width: "long" });
12381 case "PPPP":
12382 default:
12383 return formatLong2.date({ width: "full" });
12384 }
12385 };
12386 var timeLongFormatter = (pattern, formatLong2) => {
12387 switch (pattern) {
12388 case "p":
12389 return formatLong2.time({ width: "short" });
12390 case "pp":
12391 return formatLong2.time({ width: "medium" });
12392 case "ppp":
12393 return formatLong2.time({ width: "long" });
12394 case "pppp":
12395 default:
12396 return formatLong2.time({ width: "full" });
12397 }
12398 };
12399 var dateTimeLongFormatter = (pattern, formatLong2) => {
12400 const matchResult = pattern.match(/(P+)(p+)?/) || [];
12401 const datePattern = matchResult[1];
12402 const timePattern = matchResult[2];
12403 if (!timePattern) {
12404 return dateLongFormatter(pattern, formatLong2);
12405 }
12406 let dateTimeFormat;
12407 switch (datePattern) {
12408 case "P":
12409 dateTimeFormat = formatLong2.dateTime({ width: "short" });
12410 break;
12411 case "PP":
12412 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
12413 break;
12414 case "PPP":
12415 dateTimeFormat = formatLong2.dateTime({ width: "long" });
12416 break;
12417 case "PPPP":
12418 default:
12419 dateTimeFormat = formatLong2.dateTime({ width: "full" });
12420 break;
12421 }
12422 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
12423 };
12424 var longFormatters = {
12425 p: timeLongFormatter,
12426 P: dateTimeLongFormatter
12427 };
12428
12429 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
12430 var dayOfYearTokenRE = /^D+$/;
12431 var weekYearTokenRE = /^Y+$/;
12432 var throwTokens = ["D", "DD", "YY", "YYYY"];
12433 function isProtectedDayOfYearToken(token) {
12434 return dayOfYearTokenRE.test(token);
12435 }
12436 function isProtectedWeekYearToken(token) {
12437 return weekYearTokenRE.test(token);
12438 }
12439 function warnOrThrowProtectedError(token, format6, input) {
12440 const _message = message(token, format6, input);
12441 console.warn(_message);
12442 if (throwTokens.includes(token)) throw new RangeError(_message);
12443 }
12444 function message(token, format6, input) {
12445 const subject = token[0] === "Y" ? "years" : "days of the month";
12446 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`;
12447 }
12448
12449 // packages/dataviews/node_modules/date-fns/format.js
12450 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
12451 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
12452 var escapedStringRegExp = /^'([^]*?)'?$/;
12453 var doubleQuoteRegExp = /''/g;
12454 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
12455 function format(date, formatStr, options) {
12456 const defaultOptions2 = getDefaultOptions();
12457 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
12458 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
12459 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
12460 const originalDate = toDate(date, options?.in);
12461 if (!isValid(originalDate)) {
12462 throw new RangeError("Invalid time value");
12463 }
12464 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
12465 const firstCharacter = substring[0];
12466 if (firstCharacter === "p" || firstCharacter === "P") {
12467 const longFormatter = longFormatters[firstCharacter];
12468 return longFormatter(substring, locale.formatLong);
12469 }
12470 return substring;
12471 }).join("").match(formattingTokensRegExp).map((substring) => {
12472 if (substring === "''") {
12473 return { isToken: false, value: "'" };
12474 }
12475 const firstCharacter = substring[0];
12476 if (firstCharacter === "'") {
12477 return { isToken: false, value: cleanEscapedString(substring) };
12478 }
12479 if (formatters[firstCharacter]) {
12480 return { isToken: true, value: substring };
12481 }
12482 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
12483 throw new RangeError(
12484 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
12485 );
12486 }
12487 return { isToken: false, value: substring };
12488 });
12489 if (locale.localize.preprocessor) {
12490 parts = locale.localize.preprocessor(originalDate, parts);
12491 }
12492 const formatterOptions = {
12493 firstWeekContainsDate,
12494 weekStartsOn,
12495 locale
12496 };
12497 return parts.map((part) => {
12498 if (!part.isToken) return part.value;
12499 const token = part.value;
12500 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
12501 warnOrThrowProtectedError(token, formatStr, String(date));
12502 }
12503 const formatter = formatters[token[0]];
12504 return formatter(originalDate, token, locale.localize, formatterOptions);
12505 }).join("");
12506 }
12507 function cleanEscapedString(input) {
12508 const matched = input.match(escapedStringRegExp);
12509 if (!matched) {
12510 return input;
12511 }
12512 return matched[1].replace(doubleQuoteRegExp, "'");
12513 }
12514
12515 // packages/dataviews/node_modules/date-fns/subDays.js
12516 function subDays(date, amount, options) {
12517 return addDays(date, -amount, options);
12518 }
12519
12520 // packages/dataviews/node_modules/date-fns/subMonths.js
12521 function subMonths(date, amount, options) {
12522 return addMonths(date, -amount, options);
12523 }
12524
12525 // packages/dataviews/node_modules/date-fns/subWeeks.js
12526 function subWeeks(date, amount, options) {
12527 return addWeeks(date, -amount, options);
12528 }
12529
12530 // packages/dataviews/node_modules/date-fns/subYears.js
12531 function subYears(date, amount, options) {
12532 return addYears(date, -amount, options);
12533 }
12534
12535 // packages/dataviews/build-module/utils/operators.mjs
12536 var import_i18n23 = __toESM(require_i18n(), 1);
12537 var import_element30 = __toESM(require_element(), 1);
12538 var import_date = __toESM(require_date(), 1);
12539 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12540 var filterTextWrappers = {
12541 Name: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
12542 Value: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
12543 };
12544 function getRelativeDate(value, unit) {
12545 switch (unit) {
12546 case "days":
12547 return subDays(/* @__PURE__ */ new Date(), value);
12548 case "weeks":
12549 return subWeeks(/* @__PURE__ */ new Date(), value);
12550 case "months":
12551 return subMonths(/* @__PURE__ */ new Date(), value);
12552 case "years":
12553 return subYears(/* @__PURE__ */ new Date(), value);
12554 default:
12555 return /* @__PURE__ */ new Date();
12556 }
12557 }
12558 var isNoneOperatorDefinition = {
12559 /* translators: DataViews operator name */
12560 label: (0, import_i18n23.__)("Is none of"),
12561 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12562 (0, import_i18n23.sprintf)(
12563 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
12564 (0, import_i18n23.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
12565 filter.name,
12566 activeElements.map((element) => element.label).join(", ")
12567 ),
12568 filterTextWrappers
12569 ),
12570 filter: ((item, field, filterValue) => {
12571 if (!filterValue?.length) {
12572 return true;
12573 }
12574 const fieldValue = field.getValue({ item });
12575 if (Array.isArray(fieldValue)) {
12576 return !filterValue.some(
12577 (fv) => fieldValue.includes(fv)
12578 );
12579 } else if (typeof fieldValue === "string") {
12580 return !filterValue.includes(fieldValue);
12581 }
12582 return false;
12583 }),
12584 selection: "multi"
12585 };
12586 var OPERATORS = [
12587 {
12588 name: OPERATOR_IS_ANY,
12589 /* translators: DataViews operator name */
12590 label: (0, import_i18n23.__)("Includes"),
12591 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12592 (0, import_i18n23.sprintf)(
12593 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
12594 (0, import_i18n23.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
12595 filter.name,
12596 activeElements.map((element) => element.label).join(", ")
12597 ),
12598 filterTextWrappers
12599 ),
12600 filter(item, field, filterValue) {
12601 if (!filterValue?.length) {
12602 return true;
12603 }
12604 const fieldValue = field.getValue({ item });
12605 if (Array.isArray(fieldValue)) {
12606 return filterValue.some(
12607 (fv) => fieldValue.includes(fv)
12608 );
12609 } else if (typeof fieldValue === "string") {
12610 return filterValue.includes(fieldValue);
12611 }
12612 return false;
12613 },
12614 selection: "multi"
12615 },
12616 {
12617 name: OPERATOR_IS_NONE,
12618 ...isNoneOperatorDefinition
12619 },
12620 {
12621 name: OPERATOR_IS_ALL,
12622 /* translators: DataViews operator name */
12623 label: (0, import_i18n23.__)("Includes all"),
12624 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12625 (0, import_i18n23.sprintf)(
12626 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
12627 (0, import_i18n23.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
12628 filter.name,
12629 activeElements.map((element) => element.label).join(", ")
12630 ),
12631 filterTextWrappers
12632 ),
12633 filter(item, field, filterValue) {
12634 if (!filterValue?.length) {
12635 return true;
12636 }
12637 return filterValue.every((value) => {
12638 return field.getValue({ item })?.includes(value);
12639 });
12640 },
12641 selection: "multi"
12642 },
12643 {
12644 name: OPERATOR_IS_NOT_ALL,
12645 ...isNoneOperatorDefinition
12646 },
12647 {
12648 name: OPERATOR_BETWEEN,
12649 /* translators: DataViews operator name */
12650 label: (0, import_i18n23.__)("Between (inc)"),
12651 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12652 (0, import_i18n23.sprintf)(
12653 /* 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". */
12654 (0, import_i18n23.__)(
12655 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
12656 ),
12657 filter.name,
12658 activeElements[0].label[0],
12659 activeElements[0].label[1]
12660 ),
12661 filterTextWrappers
12662 ),
12663 filter(item, field, filterValue) {
12664 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
12665 return true;
12666 }
12667 const fieldValue = field.getValue({ item });
12668 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
12669 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
12670 }
12671 return false;
12672 },
12673 selection: "custom"
12674 },
12675 {
12676 name: OPERATOR_IN_THE_PAST,
12677 /* translators: DataViews operator name */
12678 label: (0, import_i18n23.__)("In the past"),
12679 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12680 (0, import_i18n23.sprintf)(
12681 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
12682 (0, import_i18n23.__)(
12683 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
12684 ),
12685 filter.name,
12686 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
12687 ),
12688 filterTextWrappers
12689 ),
12690 filter(item, field, filterValue) {
12691 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
12692 return true;
12693 }
12694 const targetDate = getRelativeDate(
12695 filterValue.value,
12696 filterValue.unit
12697 );
12698 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
12699 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
12700 },
12701 selection: "custom"
12702 },
12703 {
12704 name: OPERATOR_OVER,
12705 /* translators: DataViews operator name */
12706 label: (0, import_i18n23.__)("Over"),
12707 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12708 (0, import_i18n23.sprintf)(
12709 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
12710 (0, import_i18n23.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
12711 filter.name,
12712 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
12713 ),
12714 filterTextWrappers
12715 ),
12716 filter(item, field, filterValue) {
12717 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
12718 return true;
12719 }
12720 const targetDate = getRelativeDate(
12721 filterValue.value,
12722 filterValue.unit
12723 );
12724 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
12725 return fieldValue < targetDate;
12726 },
12727 selection: "custom"
12728 },
12729 {
12730 name: OPERATOR_IS,
12731 /* translators: DataViews operator name */
12732 label: (0, import_i18n23.__)("Is"),
12733 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12734 (0, import_i18n23.sprintf)(
12735 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
12736 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
12737 filter.name,
12738 activeElements[0].label
12739 ),
12740 filterTextWrappers
12741 ),
12742 filter(item, field, filterValue) {
12743 return filterValue === field.getValue({ item }) || filterValue === void 0;
12744 },
12745 selection: "single"
12746 },
12747 {
12748 name: OPERATOR_IS_NOT,
12749 /* translators: DataViews operator name */
12750 label: (0, import_i18n23.__)("Is not"),
12751 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12752 (0, import_i18n23.sprintf)(
12753 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
12754 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
12755 filter.name,
12756 activeElements[0].label
12757 ),
12758 filterTextWrappers
12759 ),
12760 filter(item, field, filterValue) {
12761 return filterValue !== field.getValue({ item });
12762 },
12763 selection: "single"
12764 },
12765 {
12766 name: OPERATOR_LESS_THAN,
12767 /* translators: DataViews operator name */
12768 label: (0, import_i18n23.__)("Less than"),
12769 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12770 (0, import_i18n23.sprintf)(
12771 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
12772 (0, import_i18n23.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
12773 filter.name,
12774 activeElements[0].label
12775 ),
12776 filterTextWrappers
12777 ),
12778 filter(item, field, filterValue) {
12779 if (filterValue === void 0) {
12780 return true;
12781 }
12782 const fieldValue = field.getValue({ item });
12783 return fieldValue < filterValue;
12784 },
12785 selection: "single"
12786 },
12787 {
12788 name: OPERATOR_GREATER_THAN,
12789 /* translators: DataViews operator name */
12790 label: (0, import_i18n23.__)("Greater than"),
12791 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12792 (0, import_i18n23.sprintf)(
12793 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
12794 (0, import_i18n23.__)(
12795 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
12796 ),
12797 filter.name,
12798 activeElements[0].label
12799 ),
12800 filterTextWrappers
12801 ),
12802 filter(item, field, filterValue) {
12803 if (filterValue === void 0) {
12804 return true;
12805 }
12806 const fieldValue = field.getValue({ item });
12807 return fieldValue > filterValue;
12808 },
12809 selection: "single"
12810 },
12811 {
12812 name: OPERATOR_LESS_THAN_OR_EQUAL,
12813 /* translators: DataViews operator name */
12814 label: (0, import_i18n23.__)("Less than or equal"),
12815 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12816 (0, import_i18n23.sprintf)(
12817 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
12818 (0, import_i18n23.__)(
12819 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
12820 ),
12821 filter.name,
12822 activeElements[0].label
12823 ),
12824 filterTextWrappers
12825 ),
12826 filter(item, field, filterValue) {
12827 if (filterValue === void 0) {
12828 return true;
12829 }
12830 const fieldValue = field.getValue({ item });
12831 return fieldValue <= filterValue;
12832 },
12833 selection: "single"
12834 },
12835 {
12836 name: OPERATOR_GREATER_THAN_OR_EQUAL,
12837 /* translators: DataViews operator name */
12838 label: (0, import_i18n23.__)("Greater than or equal"),
12839 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12840 (0, import_i18n23.sprintf)(
12841 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
12842 (0, import_i18n23.__)(
12843 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
12844 ),
12845 filter.name,
12846 activeElements[0].label
12847 ),
12848 filterTextWrappers
12849 ),
12850 filter(item, field, filterValue) {
12851 if (filterValue === void 0) {
12852 return true;
12853 }
12854 const fieldValue = field.getValue({ item });
12855 return fieldValue >= filterValue;
12856 },
12857 selection: "single"
12858 },
12859 {
12860 name: OPERATOR_BEFORE,
12861 /* translators: DataViews operator name */
12862 label: (0, import_i18n23.__)("Before"),
12863 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12864 (0, import_i18n23.sprintf)(
12865 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
12866 (0, import_i18n23.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
12867 filter.name,
12868 activeElements[0].label
12869 ),
12870 filterTextWrappers
12871 ),
12872 filter(item, field, filterValue) {
12873 if (filterValue === void 0) {
12874 return true;
12875 }
12876 const filterDate = (0, import_date.getDate)(filterValue);
12877 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12878 return fieldDate < filterDate;
12879 },
12880 selection: "single"
12881 },
12882 {
12883 name: OPERATOR_AFTER,
12884 /* translators: DataViews operator name */
12885 label: (0, import_i18n23.__)("After"),
12886 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12887 (0, import_i18n23.sprintf)(
12888 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
12889 (0, import_i18n23.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
12890 filter.name,
12891 activeElements[0].label
12892 ),
12893 filterTextWrappers
12894 ),
12895 filter(item, field, filterValue) {
12896 if (filterValue === void 0) {
12897 return true;
12898 }
12899 const filterDate = (0, import_date.getDate)(filterValue);
12900 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12901 return fieldDate > filterDate;
12902 },
12903 selection: "single"
12904 },
12905 {
12906 name: OPERATOR_BEFORE_INC,
12907 /* translators: DataViews operator name */
12908 label: (0, import_i18n23.__)("Before (inc)"),
12909 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12910 (0, import_i18n23.sprintf)(
12911 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
12912 (0, import_i18n23.__)(
12913 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
12914 ),
12915 filter.name,
12916 activeElements[0].label
12917 ),
12918 filterTextWrappers
12919 ),
12920 filter(item, field, filterValue) {
12921 if (filterValue === void 0) {
12922 return true;
12923 }
12924 const filterDate = (0, import_date.getDate)(filterValue);
12925 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12926 return fieldDate <= filterDate;
12927 },
12928 selection: "single"
12929 },
12930 {
12931 name: OPERATOR_AFTER_INC,
12932 /* translators: DataViews operator name */
12933 label: (0, import_i18n23.__)("After (inc)"),
12934 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12935 (0, import_i18n23.sprintf)(
12936 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
12937 (0, import_i18n23.__)(
12938 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
12939 ),
12940 filter.name,
12941 activeElements[0].label
12942 ),
12943 filterTextWrappers
12944 ),
12945 filter(item, field, filterValue) {
12946 if (filterValue === void 0) {
12947 return true;
12948 }
12949 const filterDate = (0, import_date.getDate)(filterValue);
12950 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12951 return fieldDate >= filterDate;
12952 },
12953 selection: "single"
12954 },
12955 {
12956 name: OPERATOR_CONTAINS,
12957 /* translators: DataViews operator name */
12958 label: (0, import_i18n23.__)("Contains"),
12959 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12960 (0, import_i18n23.sprintf)(
12961 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
12962 (0, import_i18n23.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
12963 filter.name,
12964 activeElements[0].label
12965 ),
12966 filterTextWrappers
12967 ),
12968 filter(item, field, filterValue) {
12969 if (filterValue === void 0) {
12970 return true;
12971 }
12972 const fieldValue = field.getValue({ item });
12973 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
12974 },
12975 selection: "single"
12976 },
12977 {
12978 name: OPERATOR_NOT_CONTAINS,
12979 /* translators: DataViews operator name */
12980 label: (0, import_i18n23.__)("Doesn't contain"),
12981 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12982 (0, import_i18n23.sprintf)(
12983 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
12984 (0, import_i18n23.__)(
12985 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
12986 ),
12987 filter.name,
12988 activeElements[0].label
12989 ),
12990 filterTextWrappers
12991 ),
12992 filter(item, field, filterValue) {
12993 if (filterValue === void 0) {
12994 return true;
12995 }
12996 const fieldValue = field.getValue({ item });
12997 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
12998 },
12999 selection: "single"
13000 },
13001 {
13002 name: OPERATOR_STARTS_WITH,
13003 /* translators: DataViews operator name */
13004 label: (0, import_i18n23.__)("Starts with"),
13005 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
13006 (0, import_i18n23.sprintf)(
13007 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
13008 (0, import_i18n23.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
13009 filter.name,
13010 activeElements[0].label
13011 ),
13012 filterTextWrappers
13013 ),
13014 filter(item, field, filterValue) {
13015 if (filterValue === void 0) {
13016 return true;
13017 }
13018 const fieldValue = field.getValue({ item });
13019 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
13020 },
13021 selection: "single"
13022 },
13023 {
13024 name: OPERATOR_ON,
13025 /* translators: DataViews operator name */
13026 label: (0, import_i18n23.__)("On"),
13027 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
13028 (0, import_i18n23.sprintf)(
13029 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
13030 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
13031 filter.name,
13032 activeElements[0].label
13033 ),
13034 filterTextWrappers
13035 ),
13036 filter(item, field, filterValue) {
13037 if (filterValue === void 0) {
13038 return true;
13039 }
13040 const filterDate = (0, import_date.getDate)(filterValue);
13041 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
13042 return filterDate.getTime() === fieldDate.getTime();
13043 },
13044 selection: "single"
13045 },
13046 {
13047 name: OPERATOR_NOT_ON,
13048 /* translators: DataViews operator name */
13049 label: (0, import_i18n23.__)("Not on"),
13050 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
13051 (0, import_i18n23.sprintf)(
13052 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
13053 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
13054 filter.name,
13055 activeElements[0].label
13056 ),
13057 filterTextWrappers
13058 ),
13059 filter(item, field, filterValue) {
13060 if (filterValue === void 0) {
13061 return true;
13062 }
13063 const filterDate = (0, import_date.getDate)(filterValue);
13064 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
13065 return filterDate.getTime() !== fieldDate.getTime();
13066 },
13067 selection: "single"
13068 }
13069 ];
13070 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
13071 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
13072 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
13073 (op) => op.name === name
13074 );
13075 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
13076
13077 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
13078 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13079 var ENTER = "Enter";
13080 var SPACE = " ";
13081 var FilterText = ({
13082 activeElements,
13083 filterInView,
13084 filter
13085 }) => {
13086 if (activeElements === void 0 || activeElements.length === 0) {
13087 return filter.name;
13088 }
13089 const operator = getOperatorByName(filterInView?.operator);
13090 if (operator !== void 0) {
13091 return operator.filterText(filter, activeElements);
13092 }
13093 return (0, import_i18n24.sprintf)(
13094 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
13095 (0, import_i18n24.__)("Unknown status for %1$s"),
13096 filter.name
13097 );
13098 };
13099 function OperatorSelector({
13100 filter,
13101 view,
13102 onChangeView
13103 }) {
13104 const operatorOptions = filter.operators?.map((operator) => ({
13105 value: operator,
13106 label: getOperatorByName(operator)?.label || operator
13107 }));
13108 const currentFilter = view.filters?.find(
13109 (_filter) => _filter.field === filter.field
13110 );
13111 const value = currentFilter?.operator || filter.operators[0];
13112 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13113 Stack,
13114 {
13115 direction: "row",
13116 gap: "sm",
13117 justify: "flex-start",
13118 className: "dataviews-filters__summary-operators-container",
13119 align: "center",
13120 children: [
13121 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
13122 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13123 import_components20.SelectControl,
13124 {
13125 className: "dataviews-filters__summary-operators-filter-select",
13126 label: (0, import_i18n24.__)("Conditions"),
13127 value,
13128 options: operatorOptions,
13129 onChange: (newValue) => {
13130 const newOperator = newValue;
13131 const currentOperator = currentFilter?.operator;
13132 const newFilters = currentFilter ? [
13133 ...(view.filters ?? []).map(
13134 (_filter) => {
13135 if (_filter.field === filter.field) {
13136 const currentOpSelectionModel = getOperatorByName(
13137 currentOperator
13138 )?.selection;
13139 const newOpSelectionModel = getOperatorByName(
13140 newOperator
13141 )?.selection;
13142 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
13143 currentOpSelectionModel,
13144 newOpSelectionModel
13145 ].includes("custom");
13146 return {
13147 ..._filter,
13148 value: shouldResetValue ? void 0 : _filter.value,
13149 operator: newOperator
13150 };
13151 }
13152 return _filter;
13153 }
13154 )
13155 ] : [
13156 ...view.filters ?? [],
13157 {
13158 field: filter.field,
13159 operator: newOperator,
13160 value: void 0
13161 }
13162 ];
13163 onChangeView({
13164 ...view,
13165 page: 1,
13166 filters: newFilters
13167 });
13168 },
13169 size: "small",
13170 variant: "minimal",
13171 hideLabelFromVision: true
13172 }
13173 )
13174 ]
13175 }
13176 );
13177 }
13178 function Filter({
13179 addFilterRef,
13180 openedFilter,
13181 fields,
13182 ...commonProps
13183 }) {
13184 const toggleRef = (0, import_element31.useRef)(null);
13185 const { filter, view, onChangeView } = commonProps;
13186 const filterInView = view.filters?.find(
13187 (f2) => f2.field === filter.field
13188 );
13189 let activeElements = [];
13190 const field = (0, import_element31.useMemo)(() => {
13191 const currentField = fields.find((f2) => f2.id === filter.field);
13192 if (currentField) {
13193 return {
13194 ...currentField,
13195 // Configure getValue as if Item was a plain object.
13196 // See related input-widget.tsx
13197 getValue: ({ item }) => item[currentField.id]
13198 };
13199 }
13200 return currentField;
13201 }, [fields, filter.field]);
13202 const { elements } = useElements({
13203 elements: filter.elements,
13204 getElements: filter.getElements
13205 });
13206 if (elements.length > 0) {
13207 activeElements = elements.filter((element) => {
13208 if (filter.singleSelection) {
13209 return element.value === filterInView?.value;
13210 }
13211 return filterInView?.value?.includes(element.value);
13212 });
13213 } else if (Array.isArray(filterInView?.value)) {
13214 const label = filterInView.value.map((v2) => {
13215 const formattedValue = field?.getValueFormatted({
13216 item: { [field.id]: v2 },
13217 field
13218 });
13219 return formattedValue || String(v2);
13220 });
13221 activeElements = [
13222 {
13223 value: filterInView.value,
13224 // @ts-ignore
13225 label
13226 }
13227 ];
13228 } else if (typeof filterInView?.value === "object") {
13229 activeElements = [
13230 { value: filterInView.value, label: filterInView.value }
13231 ];
13232 } else if (filterInView?.value !== void 0) {
13233 const label = field !== void 0 ? field.getValueFormatted({
13234 item: { [field.id]: filterInView.value },
13235 field
13236 }) : String(filterInView.value);
13237 activeElements = [
13238 {
13239 value: filterInView.value,
13240 label
13241 }
13242 ];
13243 }
13244 const isPrimary = filter.isPrimary;
13245 const isLocked = filterInView?.isLocked;
13246 const hasValues = !isLocked && filterInView?.value !== void 0;
13247 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
13248 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13249 import_components20.Dropdown,
13250 {
13251 defaultOpen: openedFilter === filter.field,
13252 contentClassName: "dataviews-filters__summary-popover",
13253 popoverProps: { placement: "bottom-start", role: "dialog" },
13254 onClose: () => {
13255 toggleRef.current?.focus();
13256 },
13257 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
13258 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13259 import_components20.Tooltip,
13260 {
13261 text: (0, import_i18n24.sprintf)(
13262 /* translators: 1: Filter name. */
13263 (0, import_i18n24.__)("Filter by: %1$s"),
13264 filter.name.toLowerCase()
13265 ),
13266 placement: "top",
13267 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13268 "div",
13269 {
13270 className: clsx_default(
13271 "dataviews-filters__summary-chip",
13272 {
13273 "has-reset": canResetOrRemove,
13274 "has-values": hasValues,
13275 "is-not-clickable": isLocked
13276 }
13277 ),
13278 role: "button",
13279 tabIndex: isLocked ? -1 : 0,
13280 onClick: () => {
13281 if (!isLocked) {
13282 onToggle();
13283 }
13284 },
13285 onKeyDown: (event) => {
13286 if (!isLocked && [ENTER, SPACE].includes(event.key)) {
13287 onToggle();
13288 event.preventDefault();
13289 }
13290 },
13291 "aria-disabled": isLocked,
13292 "aria-pressed": isOpen,
13293 "aria-expanded": isOpen,
13294 ref: toggleRef,
13295 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13296 FilterText,
13297 {
13298 activeElements,
13299 filterInView,
13300 filter
13301 }
13302 )
13303 }
13304 )
13305 }
13306 ),
13307 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13308 import_components20.Tooltip,
13309 {
13310 text: isPrimary ? (0, import_i18n24.__)("Reset") : (0, import_i18n24.__)("Remove"),
13311 placement: "top",
13312 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13313 "button",
13314 {
13315 className: clsx_default(
13316 "dataviews-filters__summary-chip-remove",
13317 { "has-values": hasValues }
13318 ),
13319 onClick: () => {
13320 onChangeView({
13321 ...view,
13322 page: 1,
13323 filters: view.filters?.filter(
13324 (_filter) => _filter.field !== filter.field
13325 )
13326 });
13327 if (!isPrimary) {
13328 addFilterRef.current?.focus();
13329 } else {
13330 toggleRef.current?.focus();
13331 }
13332 },
13333 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components20.Icon, { icon: close_small_default })
13334 }
13335 )
13336 }
13337 )
13338 ] }),
13339 renderContent: () => {
13340 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
13341 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(OperatorSelector, { ...commonProps }),
13342 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13343 SearchWidget,
13344 {
13345 ...commonProps,
13346 filter: {
13347 ...commonProps.filter,
13348 elements
13349 }
13350 }
13351 ) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(InputWidget, { ...commonProps, fields })
13352 ] });
13353 }
13354 }
13355 );
13356 }
13357
13358 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
13359 var import_components21 = __toESM(require_components(), 1);
13360 var import_i18n25 = __toESM(require_i18n(), 1);
13361 var import_element32 = __toESM(require_element(), 1);
13362 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13363 var { Menu: Menu4 } = unlock2(import_components21.privateApis);
13364 function AddFilterMenu({
13365 filters,
13366 view,
13367 onChangeView,
13368 setOpenedFilter,
13369 triggerProps
13370 }) {
13371 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
13372 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Menu4, { children: [
13373 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu4.TriggerButton, { ...triggerProps }),
13374 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
13375 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13376 Menu4.Item,
13377 {
13378 onClick: () => {
13379 setOpenedFilter(filter.field);
13380 onChangeView({
13381 ...view,
13382 page: 1,
13383 filters: [
13384 ...view.filters || [],
13385 {
13386 field: filter.field,
13387 value: void 0,
13388 operator: filter.operators[0]
13389 }
13390 ]
13391 });
13392 },
13393 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu4.ItemLabel, { children: filter.name })
13394 },
13395 filter.field
13396 );
13397 }) })
13398 ] });
13399 }
13400 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
13401 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
13402 return null;
13403 }
13404 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
13405 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13406 AddFilterMenu,
13407 {
13408 triggerProps: {
13409 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13410 import_components21.Button,
13411 {
13412 accessibleWhenDisabled: true,
13413 size: "compact",
13414 className: "dataviews-filters-button",
13415 variant: "tertiary",
13416 disabled: !inactiveFilters.length,
13417 ref
13418 }
13419 ),
13420 children: (0, import_i18n25.__)("Add filter")
13421 },
13422 ...{ filters, view, onChangeView, setOpenedFilter }
13423 }
13424 );
13425 }
13426 var add_filter_default = (0, import_element32.forwardRef)(AddFilter);
13427
13428 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
13429 var import_components22 = __toESM(require_components(), 1);
13430 var import_i18n26 = __toESM(require_i18n(), 1);
13431 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13432 function ResetFilter({
13433 filters,
13434 view,
13435 onChangeView
13436 }) {
13437 const isPrimary = (field) => filters.some(
13438 (_filter) => _filter.field === field && _filter.isPrimary
13439 );
13440 const isDisabled = !view.search && !view.filters?.some(
13441 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
13442 );
13443 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13444 import_components22.Button,
13445 {
13446 disabled: isDisabled,
13447 accessibleWhenDisabled: true,
13448 size: "compact",
13449 variant: "tertiary",
13450 className: "dataviews-filters__reset-button",
13451 onClick: () => {
13452 onChangeView({
13453 ...view,
13454 page: 1,
13455 search: "",
13456 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
13457 });
13458 },
13459 children: (0, import_i18n26.__)("Reset")
13460 }
13461 );
13462 }
13463
13464 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
13465 var import_element33 = __toESM(require_element(), 1);
13466 function useFilters(fields, view) {
13467 return (0, import_element33.useMemo)(() => {
13468 const filters = [];
13469 fields.forEach((field) => {
13470 if (field.filterBy === false || !field.hasElements && !field.Edit) {
13471 return;
13472 }
13473 const operators = field.filterBy.operators;
13474 const isPrimary = !!field.filterBy?.isPrimary;
13475 const isLocked = view.filters?.some(
13476 (f2) => f2.field === field.id && !!f2.isLocked
13477 ) ?? false;
13478 filters.push({
13479 field: field.id,
13480 name: field.label,
13481 elements: field.elements,
13482 getElements: field.getElements,
13483 hasElements: field.hasElements,
13484 singleSelection: operators.some(
13485 (op) => isSingleSelectionOperator(op)
13486 ),
13487 operators,
13488 isVisible: isLocked || isPrimary || !!view.filters?.some(
13489 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
13490 ),
13491 isPrimary,
13492 isLocked
13493 });
13494 });
13495 filters.sort((a2, b2) => {
13496 if (a2.isLocked && !b2.isLocked) {
13497 return -1;
13498 }
13499 if (!a2.isLocked && b2.isLocked) {
13500 return 1;
13501 }
13502 if (a2.isPrimary && !b2.isPrimary) {
13503 return -1;
13504 }
13505 if (!a2.isPrimary && b2.isPrimary) {
13506 return 1;
13507 }
13508 return a2.name.localeCompare(b2.name);
13509 });
13510 return filters;
13511 }, [fields, view]);
13512 }
13513 var use_filters_default = useFilters;
13514
13515 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
13516 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13517 function Filters({ className }) {
13518 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element34.useContext)(dataviews_context_default);
13519 const addFilterRef = (0, import_element34.useRef)(null);
13520 const filters = use_filters_default(fields, view);
13521 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13522 add_filter_default,
13523 {
13524 filters,
13525 view,
13526 onChangeView,
13527 ref: addFilterRef,
13528 setOpenedFilter
13529 },
13530 "add-filter"
13531 );
13532 const visibleFilters = filters.filter((filter) => filter.isVisible);
13533 if (visibleFilters.length === 0) {
13534 return null;
13535 }
13536 const filterComponents = [
13537 ...visibleFilters.map((filter) => {
13538 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13539 Filter,
13540 {
13541 filter,
13542 view,
13543 fields,
13544 onChangeView,
13545 addFilterRef,
13546 openedFilter
13547 },
13548 filter.field
13549 );
13550 }),
13551 addFilter
13552 ];
13553 filterComponents.push(
13554 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13555 ResetFilter,
13556 {
13557 filters,
13558 view,
13559 onChangeView
13560 },
13561 "reset-filters"
13562 )
13563 );
13564 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13565 Stack,
13566 {
13567 direction: "row",
13568 justify: "flex-start",
13569 gap: "sm",
13570 style: { width: "fit-content" },
13571 wrap: "wrap",
13572 className,
13573 children: filterComponents
13574 }
13575 );
13576 }
13577 var filters_default = (0, import_element34.memo)(Filters);
13578
13579 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
13580 var import_element35 = __toESM(require_element(), 1);
13581 var import_components23 = __toESM(require_components(), 1);
13582 var import_i18n27 = __toESM(require_i18n(), 1);
13583 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13584 function FiltersToggle() {
13585 const {
13586 filters,
13587 view,
13588 onChangeView,
13589 setOpenedFilter,
13590 isShowingFilter,
13591 setIsShowingFilter
13592 } = (0, import_element35.useContext)(dataviews_context_default);
13593 const buttonRef = (0, import_element35.useRef)(null);
13594 const onChangeViewWithFilterVisibility = (0, import_element35.useCallback)(
13595 (_view) => {
13596 onChangeView(_view);
13597 setIsShowingFilter(true);
13598 },
13599 [onChangeView, setIsShowingFilter]
13600 );
13601 if (filters.length === 0) {
13602 return null;
13603 }
13604 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
13605 const addFilterButtonProps = {
13606 label: (0, import_i18n27.__)("Add filter"),
13607 "aria-expanded": false,
13608 isPressed: false
13609 };
13610 const toggleFiltersButtonProps = {
13611 label: (0, import_i18n27._x)("Filter", "verb"),
13612 "aria-expanded": isShowingFilter,
13613 isPressed: isShowingFilter,
13614 onClick: () => {
13615 if (!isShowingFilter) {
13616 setOpenedFilter(null);
13617 }
13618 setIsShowingFilter(!isShowingFilter);
13619 }
13620 };
13621 const hasPrimaryOrLockedFilters = filters.some(
13622 (filter) => filter.isPrimary || filter.isLocked
13623 );
13624 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13625 import_components23.Button,
13626 {
13627 ref: buttonRef,
13628 className: "dataviews-filters__visibility-toggle",
13629 size: "compact",
13630 icon: funnel_default,
13631 disabled: hasPrimaryOrLockedFilters,
13632 accessibleWhenDisabled: true,
13633 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
13634 }
13635 );
13636 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13637 AddFilterMenu,
13638 {
13639 filters,
13640 view,
13641 onChangeView: onChangeViewWithFilterVisibility,
13642 setOpenedFilter,
13643 triggerProps: { render: buttonComponent }
13644 }
13645 ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13646 FilterVisibilityToggle,
13647 {
13648 buttonRef,
13649 filtersCount: view.filters?.length,
13650 children: buttonComponent
13651 }
13652 ) });
13653 }
13654 function FilterVisibilityToggle({
13655 buttonRef,
13656 filtersCount,
13657 children
13658 }) {
13659 (0, import_element35.useEffect)(
13660 () => () => {
13661 buttonRef.current?.focus();
13662 },
13663 [buttonRef]
13664 );
13665 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
13666 children,
13667 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
13668 ] });
13669 }
13670 var toggle_default = FiltersToggle;
13671
13672 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
13673 var import_element36 = __toESM(require_element(), 1);
13674 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13675 function FiltersToggled(props) {
13676 const { isShowingFilter } = (0, import_element36.useContext)(dataviews_context_default);
13677 if (!isShowingFilter) {
13678 return null;
13679 }
13680 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(filters_default, { ...props });
13681 }
13682 var filters_toggled_default = FiltersToggled;
13683
13684 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
13685 var import_element37 = __toESM(require_element(), 1);
13686 var import_components24 = __toESM(require_components(), 1);
13687 var import_i18n28 = __toESM(require_i18n(), 1);
13688 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13689 function DataViewsLayout({ className }) {
13690 const {
13691 actions = [],
13692 data,
13693 fields,
13694 getItemId,
13695 getItemLevel,
13696 hasInitiallyLoaded,
13697 isLoading,
13698 view,
13699 onChangeView,
13700 selection,
13701 onChangeSelection,
13702 setOpenedFilter,
13703 onClickItem,
13704 isItemClickable,
13705 renderItemLink,
13706 defaultLayouts,
13707 containerRef,
13708 empty = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { children: (0, import_i18n28.__)("No results") })
13709 } = (0, import_element37.useContext)(dataviews_context_default);
13710 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
13711 delay: 200
13712 });
13713 if (!hasInitiallyLoaded) {
13714 if (!isDelayedInitialLoading) {
13715 return null;
13716 }
13717 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_components24.Spinner, {}) }) });
13718 }
13719 const ViewComponent = VIEW_LAYOUTS.find(
13720 (v2) => v2.type === view.type && defaultLayouts[v2.type]
13721 )?.component;
13722 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13723 ViewComponent,
13724 {
13725 className,
13726 actions,
13727 data,
13728 fields,
13729 getItemId,
13730 getItemLevel,
13731 isLoading,
13732 onChangeView,
13733 onChangeSelection,
13734 selection,
13735 setOpenedFilter,
13736 onClickItem,
13737 renderItemLink,
13738 isItemClickable,
13739 view,
13740 empty
13741 }
13742 ) });
13743 }
13744
13745 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
13746 var import_element38 = __toESM(require_element(), 1);
13747 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13748 var EMPTY_ARRAY5 = [];
13749 function DataViewsFooter() {
13750 const {
13751 view,
13752 paginationInfo: { totalItems = 0, totalPages },
13753 data,
13754 actions = EMPTY_ARRAY5,
13755 isLoading,
13756 hasInitiallyLoaded
13757 } = (0, import_element38.useContext)(dataviews_context_default);
13758 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
13759 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
13760 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
13761 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
13762 return null;
13763 }
13764 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13765 "div",
13766 {
13767 className: "dataviews-footer",
13768 inert: isRefreshing ? "true" : void 0,
13769 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13770 Stack,
13771 {
13772 direction: "row",
13773 justify: "end",
13774 align: "center",
13775 className: clsx_default("dataviews-footer__content", {
13776 "is-refreshing": isDelayedRefreshing
13777 }),
13778 gap: "sm",
13779 children: [
13780 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(BulkActionsFooter, {}),
13781 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(dataviews_pagination_default, {})
13782 ]
13783 }
13784 )
13785 }
13786 );
13787 }
13788
13789 // packages/dataviews/build-module/components/dataviews-search/index.mjs
13790 var import_i18n29 = __toESM(require_i18n(), 1);
13791 var import_element39 = __toESM(require_element(), 1);
13792 var import_components25 = __toESM(require_components(), 1);
13793 var import_compose9 = __toESM(require_compose(), 1);
13794 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13795 var DataViewsSearch = (0, import_element39.memo)(function Search({ label }) {
13796 const { view, onChangeView } = (0, import_element39.useContext)(dataviews_context_default);
13797 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
13798 view.search
13799 );
13800 (0, import_element39.useEffect)(() => {
13801 if (view.search !== debouncedSearch) {
13802 setSearch(view.search ?? "");
13803 }
13804 }, [view.search, setSearch]);
13805 const onChangeViewRef = (0, import_element39.useRef)(onChangeView);
13806 const viewRef = (0, import_element39.useRef)(view);
13807 (0, import_element39.useEffect)(() => {
13808 onChangeViewRef.current = onChangeView;
13809 viewRef.current = view;
13810 }, [onChangeView, view]);
13811 (0, import_element39.useEffect)(() => {
13812 if (debouncedSearch !== viewRef.current?.search) {
13813 onChangeViewRef.current({
13814 ...viewRef.current,
13815 page: view.page ? 1 : void 0,
13816 startPosition: view.startPosition ? 1 : void 0,
13817 search: debouncedSearch
13818 });
13819 }
13820 }, [debouncedSearch]);
13821 const searchLabel = label || (0, import_i18n29.__)("Search");
13822 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13823 import_components25.SearchControl,
13824 {
13825 className: "dataviews-search",
13826 onChange: setSearch,
13827 value: search,
13828 label: searchLabel,
13829 placeholder: searchLabel,
13830 size: "compact"
13831 }
13832 );
13833 });
13834 var dataviews_search_default = DataViewsSearch;
13835
13836 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
13837 var import_components26 = __toESM(require_components(), 1);
13838 var import_i18n30 = __toESM(require_i18n(), 1);
13839 var import_element40 = __toESM(require_element(), 1);
13840 var import_warning = __toESM(require_warning(), 1);
13841 var import_compose10 = __toESM(require_compose(), 1);
13842 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
13843 var { Menu: Menu5 } = unlock2(import_components26.privateApis);
13844 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
13845 className: "dataviews-config__popover",
13846 placement: "bottom-end",
13847 offset: 9
13848 };
13849 function ViewTypeMenu() {
13850 const { view, onChangeView, defaultLayouts } = (0, import_element40.useContext)(dataviews_context_default);
13851 const availableLayouts = Object.keys(defaultLayouts);
13852 if (availableLayouts.length <= 1) {
13853 return null;
13854 }
13855 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
13856 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Menu5, { children: [
13857 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13858 Menu5.TriggerButton,
13859 {
13860 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13861 import_components26.Button,
13862 {
13863 size: "compact",
13864 icon: activeView?.icon,
13865 label: (0, import_i18n30.__)("Layout")
13866 }
13867 )
13868 }
13869 ),
13870 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
13871 const config = VIEW_LAYOUTS.find(
13872 (v2) => v2.type === layout
13873 );
13874 if (!config) {
13875 return null;
13876 }
13877 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13878 Menu5.RadioItem,
13879 {
13880 value: layout,
13881 name: "view-actions-available-view",
13882 checked: layout === view.type,
13883 hideOnClick: true,
13884 onChange: (e2) => {
13885 switch (e2.target.value) {
13886 case "list":
13887 case "grid":
13888 case "table":
13889 case "pickerGrid":
13890 case "pickerTable":
13891 case "activity":
13892 const viewWithoutLayout = { ...view };
13893 if ("layout" in viewWithoutLayout) {
13894 delete viewWithoutLayout.layout;
13895 }
13896 return onChangeView({
13897 ...viewWithoutLayout,
13898 type: e2.target.value,
13899 ...defaultLayouts[e2.target.value]
13900 });
13901 }
13902 (0, import_warning.default)("Invalid dataview");
13903 },
13904 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Menu5.ItemLabel, { children: config.label })
13905 },
13906 layout
13907 );
13908 }) })
13909 ] });
13910 }
13911 function SortFieldControl() {
13912 const { view, fields, onChangeView } = (0, import_element40.useContext)(dataviews_context_default);
13913 const orderOptions = (0, import_element40.useMemo)(() => {
13914 const sortableFields = fields.filter(
13915 (field) => field.enableSorting !== false
13916 );
13917 return sortableFields.map((field) => {
13918 return {
13919 label: field.label,
13920 value: field.id
13921 };
13922 });
13923 }, [fields]);
13924 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13925 import_components26.SelectControl,
13926 {
13927 __next40pxDefaultSize: true,
13928 label: (0, import_i18n30.__)("Sort by"),
13929 value: view.sort?.field,
13930 options: orderOptions,
13931 onChange: (value) => {
13932 onChangeView({
13933 ...view,
13934 sort: {
13935 direction: view?.sort?.direction || "desc",
13936 field: value
13937 },
13938 showLevels: false
13939 });
13940 }
13941 }
13942 );
13943 }
13944 function SortDirectionControl() {
13945 const { view, fields, onChangeView } = (0, import_element40.useContext)(dataviews_context_default);
13946 const sortableFields = fields.filter(
13947 (field) => field.enableSorting !== false
13948 );
13949 if (sortableFields.length === 0) {
13950 return null;
13951 }
13952 let value = view.sort?.direction;
13953 if (!value && view.sort?.field) {
13954 value = "desc";
13955 }
13956 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13957 import_components26.__experimentalToggleGroupControl,
13958 {
13959 className: "dataviews-view-config__sort-direction",
13960 __next40pxDefaultSize: true,
13961 isBlock: true,
13962 label: (0, import_i18n30.__)("Order"),
13963 value,
13964 onChange: (newDirection) => {
13965 if (newDirection === "asc" || newDirection === "desc") {
13966 onChangeView({
13967 ...view,
13968 sort: {
13969 direction: newDirection,
13970 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
13971 fields.find(
13972 (field) => field.enableSorting !== false
13973 )?.id || ""
13974 },
13975 showLevels: false
13976 });
13977 return;
13978 }
13979 (0, import_warning.default)("Invalid direction");
13980 },
13981 children: SORTING_DIRECTIONS.map((direction) => {
13982 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13983 import_components26.__experimentalToggleGroupControlOptionIcon,
13984 {
13985 value: direction,
13986 icon: sortIcons[direction],
13987 label: sortLabels[direction]
13988 },
13989 direction
13990 );
13991 })
13992 }
13993 );
13994 }
13995 function ItemsPerPageControl() {
13996 const { view, config, onChangeView } = (0, import_element40.useContext)(dataviews_context_default);
13997 const { infiniteScrollEnabled } = view;
13998 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
13999 return null;
14000 }
14001 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14002 import_components26.__experimentalToggleGroupControl,
14003 {
14004 __next40pxDefaultSize: true,
14005 isBlock: true,
14006 label: (0, import_i18n30.__)("Items per page"),
14007 value: view.perPage || 10,
14008 disabled: !view?.sort?.field,
14009 onChange: (newItemsPerPage) => {
14010 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
14011 onChangeView({
14012 ...view,
14013 perPage: newItemsPerPageNumber,
14014 page: 1
14015 });
14016 },
14017 children: config.perPageSizes.map((value) => {
14018 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14019 import_components26.__experimentalToggleGroupControlOption,
14020 {
14021 value,
14022 label: value.toString()
14023 },
14024 value
14025 );
14026 })
14027 }
14028 );
14029 }
14030 function ResetViewButton() {
14031 const { onReset } = (0, import_element40.useContext)(dataviews_context_default);
14032 if (onReset === void 0) {
14033 return null;
14034 }
14035 const isDisabled = onReset === false;
14036 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14037 import_components26.Button,
14038 {
14039 variant: "tertiary",
14040 size: "compact",
14041 disabled: isDisabled,
14042 accessibleWhenDisabled: true,
14043 className: "dataviews-view-config__reset-button",
14044 onClick: () => {
14045 if (typeof onReset === "function") {
14046 onReset();
14047 }
14048 },
14049 children: (0, import_i18n30.__)("Reset view")
14050 }
14051 );
14052 }
14053 function DataviewsViewConfigDropdown() {
14054 const { view, onReset } = (0, import_element40.useContext)(dataviews_context_default);
14055 const popoverId = (0, import_compose10.useInstanceId)(
14056 _DataViewsViewConfig,
14057 "dataviews-view-config-dropdown"
14058 );
14059 const activeLayout = VIEW_LAYOUTS.find(
14060 (layout) => layout.type === view.type
14061 );
14062 const isModified = typeof onReset === "function";
14063 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14064 import_components26.Dropdown,
14065 {
14066 expandOnMobile: true,
14067 popoverProps: {
14068 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
14069 id: popoverId
14070 },
14071 renderToggle: ({ onToggle, isOpen }) => {
14072 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
14073 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14074 import_components26.Button,
14075 {
14076 size: "compact",
14077 icon: cog_default,
14078 label: (0, import_i18n30._x)(
14079 "View options",
14080 "View is used as a noun"
14081 ),
14082 onClick: onToggle,
14083 "aria-expanded": isOpen ? "true" : "false",
14084 "aria-controls": popoverId
14085 }
14086 ),
14087 isModified && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
14088 ] });
14089 },
14090 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14091 import_components26.__experimentalDropdownContentWrapper,
14092 {
14093 paddingSize: "medium",
14094 className: "dataviews-config__popover-content-wrapper",
14095 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14096 Stack,
14097 {
14098 direction: "column",
14099 className: "dataviews-view-config",
14100 gap: "xl",
14101 children: [
14102 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14103 Stack,
14104 {
14105 direction: "row",
14106 justify: "space-between",
14107 align: "center",
14108 className: "dataviews-view-config__header",
14109 children: [
14110 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14111 import_components26.__experimentalHeading,
14112 {
14113 level: 2,
14114 className: "dataviews-settings-section__title",
14115 children: (0, import_i18n30.__)("Appearance")
14116 }
14117 ),
14118 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ResetViewButton, {})
14119 ]
14120 }
14121 ),
14122 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14123 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14124 Stack,
14125 {
14126 direction: "row",
14127 gap: "sm",
14128 className: "dataviews-view-config__sort-controls",
14129 children: [
14130 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(SortFieldControl, {}),
14131 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(SortDirectionControl, {})
14132 ]
14133 }
14134 ),
14135 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(activeLayout.viewConfigOptions, {}),
14136 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ItemsPerPageControl, {}),
14137 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(PropertiesSection, {})
14138 ] })
14139 ]
14140 }
14141 )
14142 }
14143 )
14144 }
14145 );
14146 }
14147 function _DataViewsViewConfig() {
14148 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14149 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ViewTypeMenu, {}),
14150 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DataviewsViewConfigDropdown, {})
14151 ] });
14152 }
14153 var DataViewsViewConfig = (0, import_element40.memo)(_DataViewsViewConfig);
14154 var dataviews_view_config_default = DataViewsViewConfig;
14155
14156 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
14157 var import_components27 = __toESM(require_components(), 1);
14158 var import_element41 = __toESM(require_element(), 1);
14159
14160 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
14161 function getCustomValidity(isValid2, validity) {
14162 let customValidity;
14163 if (isValid2?.required && validity?.required) {
14164 customValidity = validity?.required?.message ? validity.required : void 0;
14165 } else if (isValid2?.pattern && validity?.pattern) {
14166 customValidity = validity.pattern;
14167 } else if (isValid2?.min && validity?.min) {
14168 customValidity = validity.min;
14169 } else if (isValid2?.max && validity?.max) {
14170 customValidity = validity.max;
14171 } else if (isValid2?.minLength && validity?.minLength) {
14172 customValidity = validity.minLength;
14173 } else if (isValid2?.maxLength && validity?.maxLength) {
14174 customValidity = validity.maxLength;
14175 } else if (isValid2?.elements && validity?.elements) {
14176 customValidity = validity.elements;
14177 } else if (validity?.custom) {
14178 customValidity = validity.custom;
14179 }
14180 return customValidity;
14181 }
14182
14183 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
14184 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14185 var { ValidatedCheckboxControl } = unlock2(import_components27.privateApis);
14186 function Checkbox({
14187 field,
14188 onChange,
14189 data,
14190 hideLabelFromVision,
14191 markWhenOptional,
14192 validity
14193 }) {
14194 const { getValue, setValue, label, description, isValid: isValid2 } = field;
14195 const disabled = field.isDisabled({ item: data, field });
14196 const onChangeControl = (0, import_element41.useCallback)(() => {
14197 onChange(
14198 setValue({ item: data, value: !getValue({ item: data }) })
14199 );
14200 }, [data, getValue, onChange, setValue]);
14201 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14202 ValidatedCheckboxControl,
14203 {
14204 required: !!field.isValid?.required,
14205 markWhenOptional,
14206 customValidity: getCustomValidity(isValid2, validity),
14207 hidden: hideLabelFromVision,
14208 label,
14209 help: description,
14210 checked: getValue({ item: data }),
14211 onChange: onChangeControl,
14212 disabled
14213 }
14214 );
14215 }
14216
14217 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
14218 var import_components28 = __toESM(require_components(), 1);
14219 var import_element42 = __toESM(require_element(), 1);
14220 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14221 var { ValidatedComboboxControl } = unlock2(import_components28.privateApis);
14222 function Combobox3({
14223 data,
14224 field,
14225 onChange,
14226 hideLabelFromVision,
14227 validity
14228 }) {
14229 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
14230 const value = getValue({ item: data }) ?? "";
14231 const onChangeControl = (0, import_element42.useCallback)(
14232 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
14233 [data, onChange, setValue]
14234 );
14235 const { elements, isLoading } = useElements({
14236 elements: field.elements,
14237 getElements: field.getElements
14238 });
14239 if (isLoading) {
14240 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components28.Spinner, {});
14241 }
14242 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14243 ValidatedComboboxControl,
14244 {
14245 required: !!field.isValid?.required,
14246 customValidity: getCustomValidity(isValid2, validity),
14247 label,
14248 value,
14249 help: description,
14250 placeholder,
14251 options: elements,
14252 onChange: onChangeControl,
14253 hideLabelFromVision,
14254 allowReset: true,
14255 expandOnFocus: true
14256 }
14257 );
14258 }
14259
14260 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
14261 var import_components30 = __toESM(require_components(), 1);
14262 var import_element45 = __toESM(require_element(), 1);
14263 var import_i18n32 = __toESM(require_i18n(), 1);
14264 var import_date3 = __toESM(require_date(), 1);
14265
14266 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
14267 var import_components29 = __toESM(require_components(), 1);
14268 var import_element43 = __toESM(require_element(), 1);
14269 var import_i18n31 = __toESM(require_i18n(), 1);
14270 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
14271 var TIME_UNITS_OPTIONS = {
14272 [OPERATOR_IN_THE_PAST]: [
14273 { value: "days", label: (0, import_i18n31.__)("Days") },
14274 { value: "weeks", label: (0, import_i18n31.__)("Weeks") },
14275 { value: "months", label: (0, import_i18n31.__)("Months") },
14276 { value: "years", label: (0, import_i18n31.__)("Years") }
14277 ],
14278 [OPERATOR_OVER]: [
14279 { value: "days", label: (0, import_i18n31.__)("Days ago") },
14280 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") },
14281 { value: "months", label: (0, import_i18n31.__)("Months ago") },
14282 { value: "years", label: (0, import_i18n31.__)("Years ago") }
14283 ]
14284 };
14285 function RelativeDateControl({
14286 className,
14287 data,
14288 field,
14289 onChange,
14290 hideLabelFromVision,
14291 operator
14292 }) {
14293 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
14294 const { id, label, description, getValue, setValue } = field;
14295 const disabled = field.isDisabled({ item: data, field });
14296 const fieldValue = getValue({ item: data });
14297 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
14298 const onChangeValue = (0, import_element43.useCallback)(
14299 (newValue) => onChange(
14300 setValue({
14301 item: data,
14302 value: { value: Number(newValue), unit }
14303 })
14304 ),
14305 [onChange, setValue, data, unit]
14306 );
14307 const onChangeUnit = (0, import_element43.useCallback)(
14308 (newUnit) => onChange(
14309 setValue({
14310 item: data,
14311 value: { value: relValue, unit: newUnit }
14312 })
14313 ),
14314 [onChange, setValue, data, relValue]
14315 );
14316 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14317 import_components29.BaseControl,
14318 {
14319 id,
14320 className: clsx_default(className, "dataviews-controls__relative-date"),
14321 label,
14322 hideLabelFromVision,
14323 help: description,
14324 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Stack, { direction: "row", gap: "sm", children: [
14325 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14326 import_components29.__experimentalNumberControl,
14327 {
14328 __next40pxDefaultSize: true,
14329 className: "dataviews-controls__relative-date-number",
14330 spinControls: "none",
14331 min: 1,
14332 step: 1,
14333 value: relValue,
14334 onChange: onChangeValue,
14335 disabled
14336 }
14337 ),
14338 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14339 import_components29.SelectControl,
14340 {
14341 className: "dataviews-controls__relative-date-unit",
14342 __next40pxDefaultSize: true,
14343 label: (0, import_i18n31.__)("Unit"),
14344 value: unit,
14345 options,
14346 onChange: onChangeUnit,
14347 hideLabelFromVision: true,
14348 disabled
14349 }
14350 )
14351 ] })
14352 }
14353 );
14354 }
14355
14356 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
14357 var import_element44 = __toESM(require_element(), 1);
14358 function useDisabledDateMatchers(isValid2, parseDateFn) {
14359 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
14360 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
14361 const disabledMatchers = (0, import_element44.useMemo)(() => {
14362 const matchers = [];
14363 if (minConstraint) {
14364 const minDate = parseDateFn(minConstraint);
14365 if (minDate) {
14366 matchers.push({ before: minDate });
14367 }
14368 }
14369 if (maxConstraint) {
14370 const maxDate = parseDateFn(maxConstraint);
14371 if (maxDate) {
14372 matchers.push({ after: maxDate });
14373 }
14374 }
14375 return matchers.length > 0 ? matchers : void 0;
14376 }, [minConstraint, maxConstraint, parseDateFn]);
14377 return { minConstraint, maxConstraint, disabledMatchers };
14378 }
14379
14380 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
14381 var import_date2 = __toESM(require_date(), 1);
14382 function parseDateTime(dateTimeString) {
14383 if (!dateTimeString) {
14384 return null;
14385 }
14386 const parsed = (0, import_date2.getDate)(dateTimeString);
14387 return parsed && isValid(parsed) ? parsed : null;
14388 }
14389
14390 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
14391 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
14392 var { DateCalendar, ValidatedInputControl } = unlock2(import_components30.privateApis);
14393 var formatDateTime = (value) => {
14394 if (!value) {
14395 return "";
14396 }
14397 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
14398 };
14399 function CalendarDateTimeControl({
14400 data,
14401 field,
14402 onChange,
14403 hideLabelFromVision,
14404 markWhenOptional,
14405 validity,
14406 config
14407 }) {
14408 const { compact } = config || {};
14409 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
14410 const disabled = field.isDisabled({ item: data, field });
14411 const fieldValue = getValue({ item: data });
14412 const value = typeof fieldValue === "string" ? fieldValue : void 0;
14413 const [calendarMonth, setCalendarMonth] = (0, import_element45.useState)(() => {
14414 const parsedDate = parseDateTime(value);
14415 return parsedDate || /* @__PURE__ */ new Date();
14416 });
14417 const inputControlRef = (0, import_element45.useRef)(null);
14418 const validationTimeoutRef = (0, import_element45.useRef)(void 0);
14419 const previousFocusRef = (0, import_element45.useRef)(null);
14420 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
14421 const onChangeCallback = (0, import_element45.useCallback)(
14422 (newValue) => onChange(setValue({ item: data, value: newValue })),
14423 [data, onChange, setValue]
14424 );
14425 (0, import_element45.useEffect)(() => {
14426 return () => {
14427 if (validationTimeoutRef.current) {
14428 clearTimeout(validationTimeoutRef.current);
14429 }
14430 };
14431 }, []);
14432 const onSelectDate = (0, import_element45.useCallback)(
14433 (newDate) => {
14434 let dateTimeValue;
14435 if (newDate) {
14436 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
14437 let wpTime;
14438 if (value) {
14439 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
14440 } else {
14441 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
14442 }
14443 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
14444 dateTimeValue = finalDateTime.toISOString();
14445 onChangeCallback(dateTimeValue);
14446 if (validationTimeoutRef.current) {
14447 clearTimeout(validationTimeoutRef.current);
14448 }
14449 } else {
14450 onChangeCallback(void 0);
14451 }
14452 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
14453 validationTimeoutRef.current = setTimeout(() => {
14454 if (inputControlRef.current) {
14455 inputControlRef.current.focus();
14456 inputControlRef.current.blur();
14457 onChangeCallback(dateTimeValue);
14458 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
14459 previousFocusRef.current.focus();
14460 }
14461 }
14462 }, 0);
14463 },
14464 [onChangeCallback, value]
14465 );
14466 const handleManualDateTimeChange = (0, import_element45.useCallback)(
14467 (newValue) => {
14468 if (newValue) {
14469 const dateTime = (0, import_date3.getDate)(newValue);
14470 onChangeCallback(dateTime.toISOString());
14471 const parsedDate = parseDateTime(dateTime.toISOString());
14472 if (parsedDate) {
14473 setCalendarMonth(parsedDate);
14474 }
14475 } else {
14476 onChangeCallback(void 0);
14477 }
14478 },
14479 [onChangeCallback]
14480 );
14481 const { format: fieldFormat } = field;
14482 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
14483 const {
14484 timezone: { string: timezoneString }
14485 } = (0, import_date3.getSettings)();
14486 let displayLabel = label;
14487 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
14488 displayLabel = `${label} (${(0, import_i18n32.__)("Required")})`;
14489 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
14490 displayLabel = `${label} (${(0, import_i18n32.__)("Optional")})`;
14491 }
14492 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14493 import_components30.BaseControl,
14494 {
14495 id,
14496 label: displayLabel,
14497 help: description,
14498 hideLabelFromVision,
14499 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14500 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14501 ValidatedInputControl,
14502 {
14503 ref: inputControlRef,
14504 __next40pxDefaultSize: true,
14505 required: !!isValid2?.required,
14506 customValidity: getCustomValidity(isValid2, validity),
14507 type: "datetime-local",
14508 label: (0, import_i18n32.__)("Date time"),
14509 hideLabelFromVision: true,
14510 value: formatDateTime(value),
14511 onChange: handleManualDateTimeChange,
14512 disabled,
14513 min: minConstraint ? formatDateTime(minConstraint) : void 0,
14514 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
14515 }
14516 ),
14517 !compact && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14518 DateCalendar,
14519 {
14520 style: { width: "100%" },
14521 selected: value ? parseDateTime(value) || void 0 : void 0,
14522 onSelect: onSelectDate,
14523 month: calendarMonth,
14524 onMonthChange: setCalendarMonth,
14525 timeZone: timezoneString || void 0,
14526 weekStartsOn,
14527 disabled: disabled || disabledMatchers
14528 }
14529 )
14530 ] })
14531 }
14532 );
14533 }
14534 function DateTime({
14535 data,
14536 field,
14537 onChange,
14538 hideLabelFromVision,
14539 markWhenOptional,
14540 operator,
14541 validity,
14542 config
14543 }) {
14544 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
14545 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14546 RelativeDateControl,
14547 {
14548 className: "dataviews-controls__datetime",
14549 data,
14550 field,
14551 onChange,
14552 hideLabelFromVision,
14553 operator
14554 }
14555 );
14556 }
14557 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14558 CalendarDateTimeControl,
14559 {
14560 data,
14561 field,
14562 onChange,
14563 hideLabelFromVision,
14564 markWhenOptional,
14565 validity,
14566 config
14567 }
14568 );
14569 }
14570
14571 // packages/dataviews/build-module/components/dataform-controls/date.mjs
14572 var import_components31 = __toESM(require_components(), 1);
14573 var import_element46 = __toESM(require_element(), 1);
14574 var import_i18n33 = __toESM(require_i18n(), 1);
14575 var import_date4 = __toESM(require_date(), 1);
14576 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
14577 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components31.privateApis);
14578 var DATE_PRESETS = [
14579 {
14580 id: "today",
14581 label: (0, import_i18n33.__)("Today"),
14582 getValue: () => (0, import_date4.getDate)(null)
14583 },
14584 {
14585 id: "yesterday",
14586 label: (0, import_i18n33.__)("Yesterday"),
14587 getValue: () => {
14588 const today = (0, import_date4.getDate)(null);
14589 return subDays(today, 1);
14590 }
14591 },
14592 {
14593 id: "past-week",
14594 label: (0, import_i18n33.__)("Past week"),
14595 getValue: () => {
14596 const today = (0, import_date4.getDate)(null);
14597 return subDays(today, 7);
14598 }
14599 },
14600 {
14601 id: "past-month",
14602 label: (0, import_i18n33.__)("Past month"),
14603 getValue: () => {
14604 const today = (0, import_date4.getDate)(null);
14605 return subMonths(today, 1);
14606 }
14607 }
14608 ];
14609 var DATE_RANGE_PRESETS = [
14610 {
14611 id: "last-7-days",
14612 label: (0, import_i18n33.__)("Last 7 days"),
14613 getValue: () => {
14614 const today = (0, import_date4.getDate)(null);
14615 return [subDays(today, 7), today];
14616 }
14617 },
14618 {
14619 id: "last-30-days",
14620 label: (0, import_i18n33.__)("Last 30 days"),
14621 getValue: () => {
14622 const today = (0, import_date4.getDate)(null);
14623 return [subDays(today, 30), today];
14624 }
14625 },
14626 {
14627 id: "month-to-date",
14628 label: (0, import_i18n33.__)("Month to date"),
14629 getValue: () => {
14630 const today = (0, import_date4.getDate)(null);
14631 return [startOfMonth(today), today];
14632 }
14633 },
14634 {
14635 id: "last-year",
14636 label: (0, import_i18n33.__)("Last year"),
14637 getValue: () => {
14638 const today = (0, import_date4.getDate)(null);
14639 return [subYears(today, 1), today];
14640 }
14641 },
14642 {
14643 id: "year-to-date",
14644 label: (0, import_i18n33.__)("Year to date"),
14645 getValue: () => {
14646 const today = (0, import_date4.getDate)(null);
14647 return [startOfYear(today), today];
14648 }
14649 }
14650 ];
14651 var parseDate = (dateString) => {
14652 if (!dateString) {
14653 return null;
14654 }
14655 const parsed = (0, import_date4.getDate)(dateString);
14656 return parsed && isValid(parsed) ? parsed : null;
14657 };
14658 var formatDate = (date) => {
14659 if (!date) {
14660 return "";
14661 }
14662 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
14663 };
14664 function ValidatedDateControl({
14665 field,
14666 validity,
14667 inputRefs,
14668 isTouched,
14669 setIsTouched,
14670 children
14671 }) {
14672 const { isValid: isValid2 } = field;
14673 const [customValidity, setCustomValidity] = (0, import_element46.useState)(void 0);
14674 const validateRefs = (0, import_element46.useCallback)(() => {
14675 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14676 for (const ref of refs) {
14677 const input = ref.current;
14678 if (input && !input.validity.valid) {
14679 setCustomValidity({
14680 type: "invalid",
14681 message: input.validationMessage
14682 });
14683 return;
14684 }
14685 }
14686 setCustomValidity(void 0);
14687 }, [inputRefs]);
14688 (0, import_element46.useEffect)(() => {
14689 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14690 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
14691 for (const ref of refs) {
14692 const input = ref.current;
14693 if (input) {
14694 input.setCustomValidity(
14695 result?.type === "invalid" && result.message ? result.message : ""
14696 );
14697 }
14698 }
14699 }, [inputRefs, isValid2, validity]);
14700 (0, import_element46.useEffect)(() => {
14701 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14702 const handleInvalid = (event) => {
14703 event.preventDefault();
14704 setIsTouched(true);
14705 };
14706 for (const ref of refs) {
14707 ref.current?.addEventListener("invalid", handleInvalid);
14708 }
14709 return () => {
14710 for (const ref of refs) {
14711 ref.current?.removeEventListener("invalid", handleInvalid);
14712 }
14713 };
14714 }, [inputRefs, setIsTouched]);
14715 (0, import_element46.useEffect)(() => {
14716 if (!isTouched) {
14717 return;
14718 }
14719 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
14720 if (result) {
14721 setCustomValidity(result);
14722 } else {
14723 validateRefs();
14724 }
14725 }, [isTouched, isValid2, validity, validateRefs]);
14726 const onBlur = (event) => {
14727 if (isTouched) {
14728 return;
14729 }
14730 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
14731 setIsTouched(true);
14732 }
14733 };
14734 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { onBlur, children: [
14735 children,
14736 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14737 "p",
14738 {
14739 className: clsx_default(
14740 "components-validated-control__indicator",
14741 customValidity.type === "invalid" ? "is-invalid" : void 0
14742 ),
14743 children: [
14744 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14745 import_components31.Icon,
14746 {
14747 className: "components-validated-control__indicator-icon",
14748 icon: error_default,
14749 size: 16,
14750 fill: "currentColor"
14751 }
14752 ),
14753 customValidity.message
14754 ]
14755 }
14756 ) })
14757 ] });
14758 }
14759 function CalendarDateControl({
14760 data,
14761 field,
14762 onChange,
14763 hideLabelFromVision,
14764 markWhenOptional,
14765 validity
14766 }) {
14767 const {
14768 id,
14769 label,
14770 description,
14771 setValue,
14772 getValue,
14773 isValid: isValid2,
14774 format: fieldFormat
14775 } = field;
14776 const disabled = field.isDisabled({ item: data, field });
14777 const [selectedPresetId, setSelectedPresetId] = (0, import_element46.useState)(
14778 null
14779 );
14780 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
14781 const fieldValue = getValue({ item: data });
14782 const value = typeof fieldValue === "string" ? fieldValue : void 0;
14783 const [calendarMonth, setCalendarMonth] = (0, import_element46.useState)(() => {
14784 const parsedDate = parseDate(value);
14785 return parsedDate || /* @__PURE__ */ new Date();
14786 });
14787 const [isTouched, setIsTouched] = (0, import_element46.useState)(false);
14788 const validityTargetRef = (0, import_element46.useRef)(null);
14789 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
14790 const onChangeCallback = (0, import_element46.useCallback)(
14791 (newValue) => onChange(setValue({ item: data, value: newValue })),
14792 [data, onChange, setValue]
14793 );
14794 const onSelectDate = (0, import_element46.useCallback)(
14795 (newDate) => {
14796 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
14797 onChangeCallback(dateValue);
14798 setSelectedPresetId(null);
14799 setIsTouched(true);
14800 },
14801 [onChangeCallback]
14802 );
14803 const handlePresetClick = (0, import_element46.useCallback)(
14804 (preset) => {
14805 const presetDate = preset.getValue();
14806 const dateValue = formatDate(presetDate);
14807 setCalendarMonth(presetDate);
14808 onChangeCallback(dateValue);
14809 setSelectedPresetId(preset.id);
14810 setIsTouched(true);
14811 },
14812 [onChangeCallback]
14813 );
14814 const handleManualDateChange = (0, import_element46.useCallback)(
14815 (newValue) => {
14816 onChangeCallback(newValue);
14817 if (newValue) {
14818 const parsedDate = parseDate(newValue);
14819 if (parsedDate) {
14820 setCalendarMonth(parsedDate);
14821 }
14822 }
14823 setSelectedPresetId(null);
14824 setIsTouched(true);
14825 },
14826 [onChangeCallback]
14827 );
14828 const {
14829 timezone: { string: timezoneString }
14830 } = (0, import_date4.getSettings)();
14831 let displayLabel = label;
14832 if (isValid2?.required && !markWhenOptional) {
14833 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
14834 } else if (!isValid2?.required && markWhenOptional) {
14835 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
14836 }
14837 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14838 ValidatedDateControl,
14839 {
14840 field,
14841 validity,
14842 inputRefs: validityTargetRef,
14843 isTouched,
14844 setIsTouched,
14845 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14846 import_components31.BaseControl,
14847 {
14848 id,
14849 className: "dataviews-controls__date",
14850 label: displayLabel,
14851 help: description,
14852 hideLabelFromVision,
14853 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14854 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14855 Stack,
14856 {
14857 direction: "row",
14858 gap: "sm",
14859 wrap: "wrap",
14860 justify: "flex-start",
14861 children: [
14862 DATE_PRESETS.map((preset) => {
14863 const isSelected2 = selectedPresetId === preset.id;
14864 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14865 import_components31.Button,
14866 {
14867 className: "dataviews-controls__date-preset",
14868 variant: "tertiary",
14869 isPressed: isSelected2,
14870 size: "small",
14871 disabled,
14872 accessibleWhenDisabled: true,
14873 onClick: () => handlePresetClick(preset),
14874 children: preset.label
14875 },
14876 preset.id
14877 );
14878 }),
14879 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14880 import_components31.Button,
14881 {
14882 className: "dataviews-controls__date-preset",
14883 variant: "tertiary",
14884 isPressed: !selectedPresetId,
14885 size: "small",
14886 disabled: !!selectedPresetId || disabled,
14887 accessibleWhenDisabled: true,
14888 children: (0, import_i18n33.__)("Custom")
14889 }
14890 )
14891 ]
14892 }
14893 ),
14894 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14895 import_components31.__experimentalInputControl,
14896 {
14897 __next40pxDefaultSize: true,
14898 ref: validityTargetRef,
14899 type: "date",
14900 label: (0, import_i18n33.__)("Date"),
14901 hideLabelFromVision: true,
14902 value,
14903 onChange: handleManualDateChange,
14904 required: !!field.isValid?.required,
14905 disabled,
14906 min: minConstraint,
14907 max: maxConstraint
14908 }
14909 ),
14910 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14911 DateCalendar2,
14912 {
14913 style: { width: "100%" },
14914 selected: value ? parseDate(value) || void 0 : void 0,
14915 onSelect: onSelectDate,
14916 month: calendarMonth,
14917 onMonthChange: setCalendarMonth,
14918 timeZone: timezoneString || void 0,
14919 weekStartsOn,
14920 disabled: disabled || disabledMatchers,
14921 disableNavigation: disabled
14922 }
14923 )
14924 ] })
14925 }
14926 )
14927 }
14928 );
14929 }
14930 function CalendarDateRangeControl({
14931 data,
14932 field,
14933 onChange,
14934 hideLabelFromVision,
14935 markWhenOptional,
14936 validity
14937 }) {
14938 const {
14939 id,
14940 label,
14941 description,
14942 getValue,
14943 setValue,
14944 isValid: isValid2,
14945 format: fieldFormat
14946 } = field;
14947 const disabled = field.isDisabled({ item: data, field });
14948 let value;
14949 const fieldValue = getValue({ item: data });
14950 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
14951 value = fieldValue;
14952 }
14953 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
14954 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
14955 const onChangeCallback = (0, import_element46.useCallback)(
14956 (newValue) => {
14957 onChange(
14958 setValue({
14959 item: data,
14960 value: newValue
14961 })
14962 );
14963 },
14964 [data, onChange, setValue]
14965 );
14966 const [selectedPresetId, setSelectedPresetId] = (0, import_element46.useState)(
14967 null
14968 );
14969 const selectedRange = (0, import_element46.useMemo)(() => {
14970 if (!value) {
14971 return { from: void 0, to: void 0 };
14972 }
14973 const [from, to] = value;
14974 return {
14975 from: parseDate(from) || void 0,
14976 to: parseDate(to) || void 0
14977 };
14978 }, [value]);
14979 const [calendarMonth, setCalendarMonth] = (0, import_element46.useState)(() => {
14980 return selectedRange.from || /* @__PURE__ */ new Date();
14981 });
14982 const [isTouched, setIsTouched] = (0, import_element46.useState)(false);
14983 const fromInputRef = (0, import_element46.useRef)(null);
14984 const toInputRef = (0, import_element46.useRef)(null);
14985 const updateDateRange = (0, import_element46.useCallback)(
14986 (fromDate, toDate2) => {
14987 if (fromDate && toDate2) {
14988 onChangeCallback([
14989 formatDate(fromDate),
14990 formatDate(toDate2)
14991 ]);
14992 } else if (!fromDate && !toDate2) {
14993 onChangeCallback(void 0);
14994 }
14995 },
14996 [onChangeCallback]
14997 );
14998 const onSelectCalendarRange = (0, import_element46.useCallback)(
14999 (newRange) => {
15000 updateDateRange(newRange?.from, newRange?.to);
15001 setSelectedPresetId(null);
15002 setIsTouched(true);
15003 },
15004 [updateDateRange]
15005 );
15006 const handlePresetClick = (0, import_element46.useCallback)(
15007 (preset) => {
15008 const [startDate, endDate] = preset.getValue();
15009 setCalendarMonth(startDate);
15010 updateDateRange(startDate, endDate);
15011 setSelectedPresetId(preset.id);
15012 setIsTouched(true);
15013 },
15014 [updateDateRange]
15015 );
15016 const handleManualDateChange = (0, import_element46.useCallback)(
15017 (fromOrTo, newValue) => {
15018 const [currentFrom, currentTo] = value || [
15019 void 0,
15020 void 0
15021 ];
15022 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
15023 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
15024 updateDateRange(updatedFrom, updatedTo);
15025 if (newValue) {
15026 const parsedDate = parseDate(newValue);
15027 if (parsedDate) {
15028 setCalendarMonth(parsedDate);
15029 }
15030 }
15031 setSelectedPresetId(null);
15032 setIsTouched(true);
15033 },
15034 [value, updateDateRange]
15035 );
15036 const { timezone } = (0, import_date4.getSettings)();
15037 let displayLabel = label;
15038 if (field.isValid?.required && !markWhenOptional) {
15039 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
15040 } else if (!field.isValid?.required && markWhenOptional) {
15041 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
15042 }
15043 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15044 ValidatedDateControl,
15045 {
15046 field,
15047 validity,
15048 inputRefs: [fromInputRef, toInputRef],
15049 isTouched,
15050 setIsTouched,
15051 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15052 import_components31.BaseControl,
15053 {
15054 id,
15055 className: "dataviews-controls__date",
15056 label: displayLabel,
15057 help: description,
15058 hideLabelFromVision,
15059 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Stack, { direction: "column", gap: "lg", children: [
15060 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
15061 Stack,
15062 {
15063 direction: "row",
15064 gap: "sm",
15065 wrap: "wrap",
15066 justify: "flex-start",
15067 children: [
15068 DATE_RANGE_PRESETS.map((preset) => {
15069 const isSelected2 = selectedPresetId === preset.id;
15070 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15071 import_components31.Button,
15072 {
15073 className: "dataviews-controls__date-preset",
15074 variant: "tertiary",
15075 isPressed: isSelected2,
15076 size: "small",
15077 disabled,
15078 accessibleWhenDisabled: true,
15079 onClick: () => handlePresetClick(preset),
15080 children: preset.label
15081 },
15082 preset.id
15083 );
15084 }),
15085 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15086 import_components31.Button,
15087 {
15088 className: "dataviews-controls__date-preset",
15089 variant: "tertiary",
15090 isPressed: !selectedPresetId,
15091 size: "small",
15092 accessibleWhenDisabled: true,
15093 disabled: !!selectedPresetId || disabled,
15094 children: (0, import_i18n33.__)("Custom")
15095 }
15096 )
15097 ]
15098 }
15099 ),
15100 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
15101 Stack,
15102 {
15103 direction: "row",
15104 gap: "sm",
15105 justify: "space-between",
15106 className: "dataviews-controls__date-range-inputs",
15107 children: [
15108 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15109 import_components31.__experimentalInputControl,
15110 {
15111 __next40pxDefaultSize: true,
15112 ref: fromInputRef,
15113 type: "date",
15114 label: (0, import_i18n33.__)("From"),
15115 hideLabelFromVision: true,
15116 value: value?.[0],
15117 onChange: (newValue) => handleManualDateChange("from", newValue),
15118 required: !!field.isValid?.required,
15119 disabled,
15120 min: minConstraint,
15121 max: maxConstraint
15122 }
15123 ),
15124 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15125 import_components31.__experimentalInputControl,
15126 {
15127 __next40pxDefaultSize: true,
15128 ref: toInputRef,
15129 type: "date",
15130 label: (0, import_i18n33.__)("To"),
15131 hideLabelFromVision: true,
15132 value: value?.[1],
15133 onChange: (newValue) => handleManualDateChange("to", newValue),
15134 required: !!field.isValid?.required,
15135 disabled,
15136 min: minConstraint,
15137 max: maxConstraint
15138 }
15139 )
15140 ]
15141 }
15142 ),
15143 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15144 DateRangeCalendar,
15145 {
15146 style: { width: "100%" },
15147 selected: selectedRange,
15148 onSelect: onSelectCalendarRange,
15149 month: calendarMonth,
15150 onMonthChange: setCalendarMonth,
15151 timeZone: timezone.string || void 0,
15152 weekStartsOn,
15153 disabled: disabled || disabledMatchers
15154 }
15155 )
15156 ] })
15157 }
15158 )
15159 }
15160 );
15161 }
15162 function DateControl({
15163 data,
15164 field,
15165 onChange,
15166 hideLabelFromVision,
15167 markWhenOptional,
15168 operator,
15169 validity
15170 }) {
15171 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
15172 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15173 RelativeDateControl,
15174 {
15175 className: "dataviews-controls__date",
15176 data,
15177 field,
15178 onChange,
15179 hideLabelFromVision,
15180 operator
15181 }
15182 );
15183 }
15184 if (operator === OPERATOR_BETWEEN) {
15185 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15186 CalendarDateRangeControl,
15187 {
15188 data,
15189 field,
15190 onChange,
15191 hideLabelFromVision,
15192 markWhenOptional,
15193 validity
15194 }
15195 );
15196 }
15197 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15198 CalendarDateControl,
15199 {
15200 data,
15201 field,
15202 onChange,
15203 hideLabelFromVision,
15204 markWhenOptional,
15205 validity
15206 }
15207 );
15208 }
15209
15210 // packages/dataviews/build-module/components/dataform-controls/select.mjs
15211 var import_components32 = __toESM(require_components(), 1);
15212 var import_element47 = __toESM(require_element(), 1);
15213 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
15214 var { ValidatedSelectControl } = unlock2(import_components32.privateApis);
15215 function Select({
15216 data,
15217 field,
15218 onChange,
15219 hideLabelFromVision,
15220 markWhenOptional,
15221 validity
15222 }) {
15223 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
15224 const disabled = field.isDisabled({ item: data, field });
15225 const isMultiple = type === "array";
15226 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
15227 const onChangeControl = (0, import_element47.useCallback)(
15228 (newValue) => onChange(setValue({ item: data, value: newValue })),
15229 [data, onChange, setValue]
15230 );
15231 const { elements, isLoading } = useElements({
15232 elements: field.elements,
15233 getElements: field.getElements
15234 });
15235 if (isLoading) {
15236 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_components32.Spinner, {});
15237 }
15238 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
15239 ValidatedSelectControl,
15240 {
15241 required: !!field.isValid?.required,
15242 markWhenOptional,
15243 customValidity: getCustomValidity(isValid2, validity),
15244 label,
15245 value,
15246 help: description,
15247 options: elements,
15248 onChange: onChangeControl,
15249 __next40pxDefaultSize: true,
15250 hideLabelFromVision,
15251 multiple: isMultiple,
15252 disabled
15253 }
15254 );
15255 }
15256
15257 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
15258 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
15259 var ELEMENTS_THRESHOLD = 10;
15260 function AdaptiveSelect(props) {
15261 const { field } = props;
15262 const { elements } = useElements({
15263 elements: field.elements,
15264 getElements: field.getElements
15265 });
15266 if (elements.length >= ELEMENTS_THRESHOLD) {
15267 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Combobox3, { ...props });
15268 }
15269 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Select, { ...props });
15270 }
15271
15272 // packages/dataviews/build-module/components/dataform-controls/email.mjs
15273 var import_components34 = __toESM(require_components(), 1);
15274
15275 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
15276 var import_components33 = __toESM(require_components(), 1);
15277 var import_element48 = __toESM(require_element(), 1);
15278 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
15279 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components33.privateApis);
15280 function ValidatedText({
15281 data,
15282 field,
15283 onChange,
15284 hideLabelFromVision,
15285 markWhenOptional,
15286 type,
15287 prefix,
15288 suffix,
15289 validity
15290 }) {
15291 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
15292 const value = getValue({ item: data });
15293 const disabled = field.isDisabled({ item: data, field });
15294 const onChangeControl = (0, import_element48.useCallback)(
15295 (newValue) => onChange(
15296 setValue({
15297 item: data,
15298 value: newValue
15299 })
15300 ),
15301 [data, setValue, onChange]
15302 );
15303 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15304 ValidatedInputControl2,
15305 {
15306 required: !!isValid2.required,
15307 markWhenOptional,
15308 customValidity: getCustomValidity(isValid2, validity),
15309 label,
15310 placeholder,
15311 value: value ?? "",
15312 help: description,
15313 onChange: onChangeControl,
15314 hideLabelFromVision,
15315 type,
15316 prefix,
15317 suffix,
15318 disabled,
15319 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
15320 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
15321 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
15322 __next40pxDefaultSize: true
15323 }
15324 );
15325 }
15326
15327 // packages/dataviews/build-module/components/dataform-controls/email.mjs
15328 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15329 function Email({
15330 data,
15331 field,
15332 onChange,
15333 hideLabelFromVision,
15334 markWhenOptional,
15335 validity
15336 }) {
15337 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15338 ValidatedText,
15339 {
15340 ...{
15341 data,
15342 field,
15343 onChange,
15344 hideLabelFromVision,
15345 markWhenOptional,
15346 validity,
15347 type: "email",
15348 prefix: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components34.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components34.Icon, { icon: envelope_default }) })
15349 }
15350 }
15351 );
15352 }
15353
15354 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
15355 var import_components35 = __toESM(require_components(), 1);
15356 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15357 function Telephone({
15358 data,
15359 field,
15360 onChange,
15361 hideLabelFromVision,
15362 markWhenOptional,
15363 validity
15364 }) {
15365 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15366 ValidatedText,
15367 {
15368 ...{
15369 data,
15370 field,
15371 onChange,
15372 hideLabelFromVision,
15373 markWhenOptional,
15374 validity,
15375 type: "tel",
15376 prefix: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components35.Icon, { icon: mobile_default }) })
15377 }
15378 }
15379 );
15380 }
15381
15382 // packages/dataviews/build-module/components/dataform-controls/url.mjs
15383 var import_components36 = __toESM(require_components(), 1);
15384 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
15385 function Url({
15386 data,
15387 field,
15388 onChange,
15389 hideLabelFromVision,
15390 markWhenOptional,
15391 validity
15392 }) {
15393 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15394 ValidatedText,
15395 {
15396 ...{
15397 data,
15398 field,
15399 onChange,
15400 hideLabelFromVision,
15401 markWhenOptional,
15402 validity,
15403 type: "url",
15404 prefix: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components36.Icon, { icon: link_default }) })
15405 }
15406 }
15407 );
15408 }
15409
15410 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
15411 var import_components37 = __toESM(require_components(), 1);
15412 var import_element49 = __toESM(require_element(), 1);
15413 var import_i18n34 = __toESM(require_i18n(), 1);
15414 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15415 var { ValidatedNumberControl } = unlock2(import_components37.privateApis);
15416 function toNumberOrEmpty(value) {
15417 if (value === "" || value === void 0) {
15418 return "";
15419 }
15420 const number = Number(value);
15421 return Number.isFinite(number) ? number : "";
15422 }
15423 function BetweenControls({
15424 value,
15425 onChange,
15426 hideLabelFromVision,
15427 step
15428 }) {
15429 const [min = "", max = ""] = value;
15430 const onChangeMin = (0, import_element49.useCallback)(
15431 (newValue) => onChange([toNumberOrEmpty(newValue), max]),
15432 [onChange, max]
15433 );
15434 const onChangeMax = (0, import_element49.useCallback)(
15435 (newValue) => onChange([min, toNumberOrEmpty(newValue)]),
15436 [onChange, min]
15437 );
15438 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15439 import_components37.BaseControl,
15440 {
15441 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."),
15442 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
15443 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15444 import_components37.__experimentalNumberControl,
15445 {
15446 label: (0, import_i18n34.__)("Min."),
15447 value: min,
15448 max: max ? Number(max) - step : void 0,
15449 onChange: onChangeMin,
15450 __next40pxDefaultSize: true,
15451 hideLabelFromVision,
15452 step
15453 }
15454 ),
15455 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15456 import_components37.__experimentalNumberControl,
15457 {
15458 label: (0, import_i18n34.__)("Max."),
15459 value: max,
15460 min: min ? Number(min) + step : void 0,
15461 onChange: onChangeMax,
15462 __next40pxDefaultSize: true,
15463 hideLabelFromVision,
15464 step
15465 }
15466 )
15467 ] })
15468 }
15469 );
15470 }
15471 function ValidatedNumber({
15472 data,
15473 field,
15474 onChange,
15475 hideLabelFromVision,
15476 markWhenOptional,
15477 operator,
15478 validity
15479 }) {
15480 const decimals = field.format?.decimals ?? 0;
15481 const step = Math.pow(10, Math.abs(decimals) * -1);
15482 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15483 const value = getValue({ item: data }) ?? "";
15484 const disabled = field.isDisabled({ item: data, field });
15485 const onChangeControl = (0, import_element49.useCallback)(
15486 (newValue) => {
15487 onChange(
15488 setValue({
15489 item: data,
15490 // Do not convert an empty string or undefined to a number,
15491 // otherwise there's a mismatch between the UI control (empty)
15492 // and the data relied by onChange (0).
15493 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
15494 })
15495 );
15496 },
15497 [data, onChange, setValue]
15498 );
15499 const onChangeBetweenControls = (0, import_element49.useCallback)(
15500 (newValue) => {
15501 onChange(
15502 setValue({
15503 item: data,
15504 value: newValue
15505 })
15506 );
15507 },
15508 [data, onChange, setValue]
15509 );
15510 if (operator === OPERATOR_BETWEEN) {
15511 let valueBetween = ["", ""];
15512 if (Array.isArray(value) && value.length === 2 && value.every(
15513 (element) => typeof element === "number" || element === ""
15514 )) {
15515 valueBetween = value;
15516 }
15517 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15518 BetweenControls,
15519 {
15520 value: valueBetween,
15521 onChange: onChangeBetweenControls,
15522 hideLabelFromVision,
15523 step
15524 }
15525 );
15526 }
15527 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15528 ValidatedNumberControl,
15529 {
15530 required: !!isValid2.required,
15531 markWhenOptional,
15532 customValidity: getCustomValidity(isValid2, validity),
15533 label,
15534 help: description,
15535 value,
15536 onChange: onChangeControl,
15537 __next40pxDefaultSize: true,
15538 hideLabelFromVision,
15539 step,
15540 min: isValid2.min ? isValid2.min.constraint : void 0,
15541 max: isValid2.max ? isValid2.max.constraint : void 0,
15542 disabled
15543 }
15544 );
15545 }
15546
15547 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
15548 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
15549 function Integer(props) {
15550 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ValidatedNumber, { ...props });
15551 }
15552
15553 // packages/dataviews/build-module/components/dataform-controls/number.mjs
15554 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
15555 function Number2(props) {
15556 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ValidatedNumber, { ...props });
15557 }
15558
15559 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
15560 var import_components38 = __toESM(require_components(), 1);
15561 var import_element50 = __toESM(require_element(), 1);
15562 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
15563 var { ValidatedRadioControl } = unlock2(import_components38.privateApis);
15564 function Radio({
15565 data,
15566 field,
15567 onChange,
15568 hideLabelFromVision,
15569 markWhenOptional,
15570 validity
15571 }) {
15572 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15573 const disabled = field.isDisabled({ item: data, field });
15574 const { elements, isLoading } = useElements({
15575 elements: field.elements,
15576 getElements: field.getElements
15577 });
15578 const value = getValue({ item: data });
15579 const onChangeControl = (0, import_element50.useCallback)(
15580 (newValue) => onChange(setValue({ item: data, value: newValue })),
15581 [data, onChange, setValue]
15582 );
15583 if (isLoading) {
15584 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components38.Spinner, {});
15585 }
15586 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
15587 ValidatedRadioControl,
15588 {
15589 required: !!field.isValid?.required,
15590 markWhenOptional,
15591 customValidity: getCustomValidity(isValid2, validity),
15592 label,
15593 help: description,
15594 onChange: onChangeControl,
15595 options: elements,
15596 selected: value,
15597 hideLabelFromVision,
15598 disabled
15599 }
15600 );
15601 }
15602
15603 // packages/dataviews/build-module/components/dataform-controls/text.mjs
15604 var import_element51 = __toESM(require_element(), 1);
15605 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
15606 function Text3({
15607 data,
15608 field,
15609 onChange,
15610 hideLabelFromVision,
15611 markWhenOptional,
15612 config,
15613 validity
15614 }) {
15615 const { prefix, suffix } = config || {};
15616 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
15617 ValidatedText,
15618 {
15619 ...{
15620 data,
15621 field,
15622 onChange,
15623 hideLabelFromVision,
15624 markWhenOptional,
15625 validity,
15626 prefix: prefix ? (0, import_element51.createElement)(prefix) : void 0,
15627 suffix: suffix ? (0, import_element51.createElement)(suffix) : void 0
15628 }
15629 }
15630 );
15631 }
15632
15633 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
15634 var import_components39 = __toESM(require_components(), 1);
15635 var import_element52 = __toESM(require_element(), 1);
15636 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
15637 var { ValidatedToggleControl } = unlock2(import_components39.privateApis);
15638 function Toggle({
15639 field,
15640 onChange,
15641 data,
15642 hideLabelFromVision,
15643 markWhenOptional,
15644 validity
15645 }) {
15646 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15647 const disabled = field.isDisabled({ item: data, field });
15648 const onChangeControl = (0, import_element52.useCallback)(() => {
15649 onChange(
15650 setValue({ item: data, value: !getValue({ item: data }) })
15651 );
15652 }, [onChange, setValue, data, getValue]);
15653 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15654 ValidatedToggleControl,
15655 {
15656 required: !!isValid2.required,
15657 markWhenOptional,
15658 customValidity: getCustomValidity(isValid2, validity),
15659 hidden: hideLabelFromVision,
15660 label,
15661 help: description,
15662 checked: getValue({ item: data }),
15663 onChange: onChangeControl,
15664 disabled
15665 }
15666 );
15667 }
15668
15669 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
15670 var import_components40 = __toESM(require_components(), 1);
15671 var import_element53 = __toESM(require_element(), 1);
15672 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
15673 var { ValidatedTextareaControl } = unlock2(import_components40.privateApis);
15674 function Textarea({
15675 data,
15676 field,
15677 onChange,
15678 hideLabelFromVision,
15679 markWhenOptional,
15680 config,
15681 validity
15682 }) {
15683 const { rows = 4 } = config || {};
15684 const disabled = field.isDisabled({ item: data, field });
15685 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
15686 const value = field.getValue({ item: data });
15687 const onChangeControl = (0, import_element53.useCallback)(
15688 (newValue) => onChange(setValue({ item: data, value: newValue })),
15689 [data, onChange, setValue]
15690 );
15691 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
15692 ValidatedTextareaControl,
15693 {
15694 required: !!isValid2.required,
15695 markWhenOptional,
15696 customValidity: getCustomValidity(isValid2, validity),
15697 label,
15698 placeholder,
15699 value: value ?? "",
15700 help: description,
15701 onChange: onChangeControl,
15702 rows,
15703 disabled,
15704 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
15705 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
15706 __next40pxDefaultSize: true,
15707 hideLabelFromVision
15708 }
15709 );
15710 }
15711
15712 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
15713 var import_components41 = __toESM(require_components(), 1);
15714 var import_element54 = __toESM(require_element(), 1);
15715 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
15716 var { ValidatedToggleGroupControl } = unlock2(import_components41.privateApis);
15717 function ToggleGroup({
15718 data,
15719 field,
15720 onChange,
15721 hideLabelFromVision,
15722 markWhenOptional,
15723 validity
15724 }) {
15725 const { getValue, setValue, isValid: isValid2 } = field;
15726 const disabled = field.isDisabled({ item: data, field });
15727 const value = getValue({ item: data });
15728 const onChangeControl = (0, import_element54.useCallback)(
15729 (newValue) => onChange(setValue({ item: data, value: newValue })),
15730 [data, onChange, setValue]
15731 );
15732 const { elements, isLoading } = useElements({
15733 elements: field.elements,
15734 getElements: field.getElements
15735 });
15736 if (isLoading) {
15737 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_components41.Spinner, {});
15738 }
15739 if (elements.length === 0) {
15740 return null;
15741 }
15742 const selectedOption = elements.find((el) => el.value === value);
15743 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15744 ValidatedToggleGroupControl,
15745 {
15746 required: !!field.isValid?.required,
15747 markWhenOptional,
15748 customValidity: getCustomValidity(isValid2, validity),
15749 __next40pxDefaultSize: true,
15750 isBlock: true,
15751 label: field.label,
15752 help: selectedOption?.description || field.description,
15753 onChange: onChangeControl,
15754 value,
15755 hideLabelFromVision,
15756 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15757 import_components41.__experimentalToggleGroupControlOption,
15758 {
15759 label: el.label,
15760 value: el.value,
15761 disabled
15762 },
15763 el.value
15764 ))
15765 }
15766 );
15767 }
15768
15769 // packages/dataviews/build-module/components/dataform-controls/array.mjs
15770 var import_components42 = __toESM(require_components(), 1);
15771 var import_element55 = __toESM(require_element(), 1);
15772 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
15773 var { ValidatedFormTokenField } = unlock2(import_components42.privateApis);
15774 function ArrayControl({
15775 data,
15776 field,
15777 onChange,
15778 hideLabelFromVision,
15779 markWhenOptional,
15780 validity
15781 }) {
15782 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
15783 const value = getValue({ item: data });
15784 const disabled = field.isDisabled({ item: data, field });
15785 const { elements, isLoading } = useElements({
15786 elements: field.elements,
15787 getElements: field.getElements
15788 });
15789 const arrayValueAsElements = (0, import_element55.useMemo)(
15790 () => Array.isArray(value) ? value.map((token) => {
15791 const element = elements?.find(
15792 (suggestion) => suggestion.value === token
15793 );
15794 return element || { value: token, label: token };
15795 }) : [],
15796 [value, elements]
15797 );
15798 const onChangeControl = (0, import_element55.useCallback)(
15799 (tokens) => {
15800 const valueTokens = tokens.map((token) => {
15801 if (typeof token === "object" && "value" in token) {
15802 return token.value;
15803 }
15804 return token;
15805 });
15806 onChange(setValue({ item: data, value: valueTokens }));
15807 },
15808 [onChange, setValue, data]
15809 );
15810 if (isLoading) {
15811 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components42.Spinner, {});
15812 }
15813 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15814 ValidatedFormTokenField,
15815 {
15816 required: !!isValid2?.required,
15817 markWhenOptional,
15818 customValidity: getCustomValidity(isValid2, validity),
15819 label: hideLabelFromVision ? void 0 : label,
15820 value: arrayValueAsElements,
15821 onChange: onChangeControl,
15822 placeholder,
15823 suggestions: elements?.map((element) => element.value),
15824 disabled,
15825 __experimentalValidateInput: (token) => {
15826 if (field.isValid?.elements && elements) {
15827 return elements.some(
15828 (element) => element.value === token || element.label === token
15829 );
15830 }
15831 return true;
15832 },
15833 __experimentalExpandOnFocus: elements && elements.length > 0,
15834 help: description ?? (field.isValid?.elements ? "" : void 0),
15835 displayTransform: (token) => {
15836 if (typeof token === "object" && "label" in token) {
15837 return token.label;
15838 }
15839 if (typeof token === "string" && elements) {
15840 const element = elements.find(
15841 (el) => el.value === token
15842 );
15843 return element?.label || token;
15844 }
15845 return token;
15846 },
15847 __experimentalRenderItem: ({ item }) => {
15848 if (typeof item === "string" && elements) {
15849 const element = elements.find(
15850 (el) => el.value === item
15851 );
15852 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { children: element?.label || item });
15853 }
15854 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { children: item });
15855 }
15856 }
15857 );
15858 }
15859
15860 // node_modules/colord/index.mjs
15861 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
15862 var t = function(r3) {
15863 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
15864 };
15865 var n = function(r3, t2, n2) {
15866 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
15867 };
15868 var e = function(r3, t2, n2) {
15869 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
15870 };
15871 var u = function(r3) {
15872 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
15873 };
15874 var a = function(r3) {
15875 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
15876 };
15877 var o = function(r3) {
15878 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
15879 };
15880 var i = /^#([0-9a-f]{3,8})$/i;
15881 var s = function(r3) {
15882 var t2 = r3.toString(16);
15883 return t2.length < 2 ? "0" + t2 : t2;
15884 };
15885 var h = function(r3) {
15886 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;
15887 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
15888 };
15889 var b = function(r3) {
15890 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
15891 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
15892 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;
15893 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 };
15894 };
15895 var g = function(r3) {
15896 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
15897 };
15898 var d = function(r3) {
15899 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
15900 };
15901 var f = function(r3) {
15902 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 }));
15903 var t2, n2, e2;
15904 };
15905 var c = function(r3) {
15906 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 };
15907 var t2, n2, e2, u2;
15908 };
15909 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15910 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15911 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15912 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15913 var y = { string: [[function(r3) {
15914 var t2 = i.exec(r3);
15915 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;
15916 }, "hex"], [function(r3) {
15917 var t2 = v.exec(r3) || m.exec(r3);
15918 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;
15919 }, "rgb"], [function(t2) {
15920 var n2 = l.exec(t2) || p.exec(t2);
15921 if (!n2) return null;
15922 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) });
15923 return f(a2);
15924 }, "hsl"]], object: [[function(r3) {
15925 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
15926 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
15927 }, "rgb"], [function(r3) {
15928 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
15929 if (!t(n2) || !t(e2) || !t(u2)) return null;
15930 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
15931 return f(i2);
15932 }, "hsl"], [function(r3) {
15933 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
15934 if (!t(n2) || !t(a2) || !t(o2)) return null;
15935 var h2 = (function(r4) {
15936 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
15937 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
15938 return b(h2);
15939 }, "hsv"]] };
15940 var N = function(r3, t2) {
15941 for (var n2 = 0; n2 < t2.length; n2++) {
15942 var e2 = t2[n2][0](r3);
15943 if (e2) return [e2, t2[n2][1]];
15944 }
15945 return [null, void 0];
15946 };
15947 var x = function(r3) {
15948 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
15949 };
15950 var M = function(r3, t2) {
15951 var n2 = c(r3);
15952 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
15953 };
15954 var H = function(r3) {
15955 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
15956 };
15957 var $ = function(r3, t2) {
15958 var n2 = c(r3);
15959 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
15960 };
15961 var j = (function() {
15962 function r3(r4) {
15963 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
15964 }
15965 return r3.prototype.isValid = function() {
15966 return null !== this.parsed;
15967 }, r3.prototype.brightness = function() {
15968 return n(H(this.rgba), 2);
15969 }, r3.prototype.isDark = function() {
15970 return H(this.rgba) < 0.5;
15971 }, r3.prototype.isLight = function() {
15972 return H(this.rgba) >= 0.5;
15973 }, r3.prototype.toHex = function() {
15974 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;
15975 var r4, t2, e2, u2, a2, i2;
15976 }, r3.prototype.toRgb = function() {
15977 return o(this.rgba);
15978 }, r3.prototype.toRgbString = function() {
15979 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 + ")";
15980 var r4, t2, n2, e2, u2;
15981 }, r3.prototype.toHsl = function() {
15982 return d(c(this.rgba));
15983 }, r3.prototype.toHslString = function() {
15984 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 + "%)";
15985 var r4, t2, n2, e2, u2;
15986 }, r3.prototype.toHsv = function() {
15987 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
15988 var r4;
15989 }, r3.prototype.invert = function() {
15990 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
15991 var r4;
15992 }, r3.prototype.saturate = function(r4) {
15993 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
15994 }, r3.prototype.desaturate = function(r4) {
15995 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
15996 }, r3.prototype.grayscale = function() {
15997 return w(M(this.rgba, -1));
15998 }, r3.prototype.lighten = function(r4) {
15999 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
16000 }, r3.prototype.darken = function(r4) {
16001 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
16002 }, r3.prototype.rotate = function(r4) {
16003 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
16004 }, r3.prototype.alpha = function(r4) {
16005 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
16006 var t2;
16007 }, r3.prototype.hue = function(r4) {
16008 var t2 = c(this.rgba);
16009 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
16010 }, r3.prototype.isEqual = function(r4) {
16011 return this.toHex() === w(r4).toHex();
16012 }, r3;
16013 })();
16014 var w = function(r3) {
16015 return r3 instanceof j ? r3 : new j(r3);
16016 };
16017
16018 // packages/dataviews/build-module/components/dataform-controls/color.mjs
16019 var import_components43 = __toESM(require_components(), 1);
16020 var import_element56 = __toESM(require_element(), 1);
16021 var import_i18n35 = __toESM(require_i18n(), 1);
16022 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
16023 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components43.privateApis);
16024 var ColorPickerDropdown = ({
16025 color,
16026 onColorChange,
16027 disabled
16028 }) => {
16029 const validColor = color && w(color).isValid() ? color : "#ffffff";
16030 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16031 import_components43.Dropdown,
16032 {
16033 className: "dataviews-controls__color-picker-dropdown",
16034 popoverProps: { resize: false },
16035 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16036 import_components43.Button,
16037 {
16038 onClick: onToggle,
16039 "aria-label": (0, import_i18n35.__)("Open color picker"),
16040 size: "small",
16041 disabled,
16042 accessibleWhenDisabled: true,
16043 icon: () => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
16044 }
16045 ),
16046 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16047 import_components43.ColorPicker,
16048 {
16049 color: validColor,
16050 onChange: onColorChange,
16051 enableAlpha: true
16052 }
16053 ) })
16054 }
16055 );
16056 };
16057 function Color({
16058 data,
16059 field,
16060 onChange,
16061 hideLabelFromVision,
16062 markWhenOptional,
16063 validity
16064 }) {
16065 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
16066 const disabled = field.isDisabled({ item: data, field });
16067 const value = field.getValue({ item: data }) || "";
16068 const handleColorChange = (0, import_element56.useCallback)(
16069 (newColor) => {
16070 onChange(setValue({ item: data, value: newColor }));
16071 },
16072 [data, onChange, setValue]
16073 );
16074 const handleInputChange = (0, import_element56.useCallback)(
16075 (newValue) => {
16076 onChange(setValue({ item: data, value: newValue || "" }));
16077 },
16078 [data, onChange, setValue]
16079 );
16080 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16081 ValidatedInputControl3,
16082 {
16083 required: !!field.isValid?.required,
16084 markWhenOptional,
16085 customValidity: getCustomValidity(isValid2, validity),
16086 label,
16087 placeholder,
16088 value,
16089 help: description,
16090 onChange: handleInputChange,
16091 hideLabelFromVision,
16092 type: "text",
16093 disabled,
16094 prefix: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16095 ColorPickerDropdown,
16096 {
16097 color: value,
16098 onColorChange: handleColorChange,
16099 disabled
16100 }
16101 ) })
16102 }
16103 );
16104 }
16105
16106 // packages/dataviews/build-module/components/dataform-controls/password.mjs
16107 var import_components44 = __toESM(require_components(), 1);
16108 var import_element57 = __toESM(require_element(), 1);
16109 var import_i18n36 = __toESM(require_i18n(), 1);
16110 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
16111 function Password({
16112 data,
16113 field,
16114 onChange,
16115 hideLabelFromVision,
16116 markWhenOptional,
16117 validity
16118 }) {
16119 const [isVisible2, setIsVisible] = (0, import_element57.useState)(false);
16120 const disabled = field.isDisabled({ item: data, field });
16121 const toggleVisibility = (0, import_element57.useCallback)(() => {
16122 setIsVisible((prev) => !prev);
16123 }, []);
16124 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16125 ValidatedText,
16126 {
16127 ...{
16128 data,
16129 field,
16130 onChange,
16131 hideLabelFromVision,
16132 markWhenOptional,
16133 validity,
16134 type: isVisible2 ? "text" : "password",
16135 suffix: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16136 import_components44.Button,
16137 {
16138 icon: isVisible2 ? unseen_default : seen_default,
16139 onClick: toggleVisibility,
16140 size: "small",
16141 label: isVisible2 ? (0, import_i18n36.__)("Hide password") : (0, import_i18n36.__)("Show password"),
16142 disabled,
16143 accessibleWhenDisabled: true
16144 }
16145 ) })
16146 }
16147 }
16148 );
16149 }
16150
16151 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
16152 function hasElements(field) {
16153 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
16154 }
16155
16156 // packages/dataviews/build-module/components/dataform-controls/index.mjs
16157 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
16158 var FORM_CONTROLS = {
16159 adaptiveSelect: AdaptiveSelect,
16160 array: ArrayControl,
16161 checkbox: Checkbox,
16162 color: Color,
16163 combobox: Combobox3,
16164 datetime: DateTime,
16165 date: DateControl,
16166 email: Email,
16167 telephone: Telephone,
16168 url: Url,
16169 integer: Integer,
16170 number: Number2,
16171 password: Password,
16172 radio: Radio,
16173 select: Select,
16174 text: Text3,
16175 toggle: Toggle,
16176 textarea: Textarea,
16177 toggleGroup: ToggleGroup
16178 };
16179 function isEditConfig(value) {
16180 return value && typeof value === "object" && typeof value.control === "string";
16181 }
16182 function createConfiguredControl(config) {
16183 const { control, ...controlConfig } = config;
16184 const BaseControlType = getControlByType(control);
16185 if (BaseControlType === null) {
16186 return null;
16187 }
16188 return function ConfiguredControl(props) {
16189 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BaseControlType, { ...props, config: controlConfig });
16190 };
16191 }
16192 function getControl(field, fallback) {
16193 if (typeof field.Edit === "function") {
16194 return field.Edit;
16195 }
16196 if (typeof field.Edit === "string") {
16197 return getControlByType(field.Edit);
16198 }
16199 if (isEditConfig(field.Edit)) {
16200 return createConfiguredControl(field.Edit);
16201 }
16202 if (hasElements(field) && field.type !== "array") {
16203 return getControlByType("adaptiveSelect");
16204 }
16205 if (fallback === null) {
16206 return null;
16207 }
16208 return getControlByType(fallback);
16209 }
16210 function getControlByType(type) {
16211 if (Object.keys(FORM_CONTROLS).includes(type)) {
16212 return FORM_CONTROLS[type];
16213 }
16214 return null;
16215 }
16216
16217 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
16218 function getFilterBy(field, defaultOperators, validOperators) {
16219 if (field.filterBy === false) {
16220 return false;
16221 }
16222 const operators = field.filterBy?.operators?.filter(
16223 (op) => validOperators.includes(op)
16224 ) ?? defaultOperators;
16225 if (operators.length === 0) {
16226 return false;
16227 }
16228 return {
16229 isPrimary: !!field.filterBy?.isPrimary,
16230 operators
16231 };
16232 }
16233 var get_filter_by_default = getFilterBy;
16234
16235 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
16236 var getValueFromId = (id) => ({ item }) => {
16237 const path = id.split(".");
16238 let value = item;
16239 for (const segment of path) {
16240 if (value.hasOwnProperty(segment)) {
16241 value = value[segment];
16242 } else {
16243 value = void 0;
16244 }
16245 }
16246 return value;
16247 };
16248 var get_value_from_id_default = getValueFromId;
16249
16250 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
16251 var setValueFromId = (id) => ({ value }) => {
16252 const path = id.split(".");
16253 const result = {};
16254 let current = result;
16255 for (const segment of path.slice(0, -1)) {
16256 current[segment] = {};
16257 current = current[segment];
16258 }
16259 current[path.at(-1)] = value;
16260 return result;
16261 };
16262 var set_value_from_id_default = setValueFromId;
16263
16264 // packages/dataviews/build-module/field-types/email.mjs
16265 var import_i18n37 = __toESM(require_i18n(), 1);
16266
16267 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
16268 function RenderFromElements({
16269 item,
16270 field
16271 }) {
16272 const { elements, isLoading } = useElements({
16273 elements: field.elements,
16274 getElements: field.getElements
16275 });
16276 const value = field.getValue({ item });
16277 if (isLoading) {
16278 return value;
16279 }
16280 if (elements.length === 0) {
16281 return value;
16282 }
16283 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
16284 }
16285
16286 // packages/dataviews/build-module/field-types/utils/render-default.mjs
16287 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
16288 function render({
16289 item,
16290 field
16291 }) {
16292 if (field.hasElements) {
16293 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(RenderFromElements, { item, field });
16294 }
16295 return field.getValueFormatted({ item, field });
16296 }
16297
16298 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
16299 var sort_text_default = (a2, b2, direction) => {
16300 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
16301 };
16302
16303 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
16304 function isValidRequired(item, field) {
16305 const value = field.getValue({ item });
16306 return ![void 0, "", null].includes(value);
16307 }
16308
16309 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
16310 function isValidMinLength(item, field) {
16311 if (typeof field.isValid.minLength?.constraint !== "number") {
16312 return false;
16313 }
16314 const value = field.getValue({ item });
16315 if ([void 0, "", null].includes(value)) {
16316 return true;
16317 }
16318 return String(value).length >= field.isValid.minLength.constraint;
16319 }
16320
16321 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
16322 function isValidMaxLength(item, field) {
16323 if (typeof field.isValid.maxLength?.constraint !== "number") {
16324 return false;
16325 }
16326 const value = field.getValue({ item });
16327 if ([void 0, "", null].includes(value)) {
16328 return true;
16329 }
16330 return String(value).length <= field.isValid.maxLength.constraint;
16331 }
16332
16333 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
16334 function isValidPattern(item, field) {
16335 if (field.isValid.pattern?.constraint === void 0) {
16336 return true;
16337 }
16338 try {
16339 const regexp = new RegExp(field.isValid.pattern.constraint);
16340 const value = field.getValue({ item });
16341 if ([void 0, "", null].includes(value)) {
16342 return true;
16343 }
16344 return regexp.test(String(value));
16345 } catch {
16346 return false;
16347 }
16348 }
16349
16350 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
16351 function isValidElements(item, field) {
16352 const elements = field.elements ?? [];
16353 const validValues = elements.map((el) => el.value);
16354 if (validValues.length === 0) {
16355 return true;
16356 }
16357 const value = field.getValue({ item });
16358 return [].concat(value).every((v2) => validValues.includes(v2));
16359 }
16360
16361 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
16362 function getValueFormatted({
16363 item,
16364 field
16365 }) {
16366 return field.getValue({ item });
16367 }
16368 var get_value_formatted_default_default = getValueFormatted;
16369
16370 // packages/dataviews/build-module/field-types/email.mjs
16371 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])?)*$/;
16372 function isValidCustom(item, field) {
16373 const value = field.getValue({ item });
16374 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
16375 return (0, import_i18n37.__)("Value must be a valid email address.");
16376 }
16377 return null;
16378 }
16379 var email_default = {
16380 type: "email",
16381 render,
16382 Edit: "email",
16383 sort: sort_text_default,
16384 enableSorting: true,
16385 enableGlobalSearch: false,
16386 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16387 validOperators: [
16388 OPERATOR_IS,
16389 OPERATOR_IS_NOT,
16390 OPERATOR_CONTAINS,
16391 OPERATOR_NOT_CONTAINS,
16392 OPERATOR_STARTS_WITH,
16393 // Multiple selection
16394 OPERATOR_IS_ANY,
16395 OPERATOR_IS_NONE,
16396 OPERATOR_IS_ALL,
16397 OPERATOR_IS_NOT_ALL
16398 ],
16399 format: {},
16400 getValueFormatted: get_value_formatted_default_default,
16401 validate: {
16402 required: isValidRequired,
16403 pattern: isValidPattern,
16404 minLength: isValidMinLength,
16405 maxLength: isValidMaxLength,
16406 elements: isValidElements,
16407 custom: isValidCustom
16408 }
16409 };
16410
16411 // packages/dataviews/build-module/field-types/integer.mjs
16412 var import_i18n38 = __toESM(require_i18n(), 1);
16413
16414 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
16415 var sort_number_default = (a2, b2, direction) => {
16416 return direction === "asc" ? a2 - b2 : b2 - a2;
16417 };
16418
16419 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
16420 function isValidMin(item, field) {
16421 if (typeof field.isValid.min?.constraint !== "number") {
16422 return false;
16423 }
16424 const value = field.getValue({ item });
16425 if ([void 0, "", null].includes(value)) {
16426 return true;
16427 }
16428 return Number(value) >= field.isValid.min.constraint;
16429 }
16430
16431 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
16432 function isValidMax(item, field) {
16433 if (typeof field.isValid.max?.constraint !== "number") {
16434 return false;
16435 }
16436 const value = field.getValue({ item });
16437 if ([void 0, "", null].includes(value)) {
16438 return true;
16439 }
16440 return Number(value) <= field.isValid.max.constraint;
16441 }
16442
16443 // packages/dataviews/build-module/field-types/integer.mjs
16444 var format2 = {
16445 separatorThousand: ","
16446 };
16447 function getValueFormatted2({
16448 item,
16449 field
16450 }) {
16451 let value = field.getValue({ item });
16452 if (value === null || value === void 0) {
16453 return "";
16454 }
16455 value = Number(value);
16456 if (!Number.isFinite(value)) {
16457 return String(value);
16458 }
16459 let formatInteger;
16460 if (field.type !== "integer") {
16461 formatInteger = format2;
16462 } else {
16463 formatInteger = field.format;
16464 }
16465 const { separatorThousand } = formatInteger;
16466 const integerValue = Math.trunc(value);
16467 if (!separatorThousand) {
16468 return String(integerValue);
16469 }
16470 return String(integerValue).replace(
16471 /\B(?=(\d{3})+(?!\d))/g,
16472 separatorThousand
16473 );
16474 }
16475 function isValidCustom2(item, field) {
16476 const value = field.getValue({ item });
16477 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
16478 return (0, import_i18n38.__)("Value must be an integer.");
16479 }
16480 return null;
16481 }
16482 var integer_default = {
16483 type: "integer",
16484 render,
16485 Edit: "integer",
16486 sort: sort_number_default,
16487 enableSorting: true,
16488 enableGlobalSearch: false,
16489 defaultOperators: [
16490 OPERATOR_IS,
16491 OPERATOR_IS_NOT,
16492 OPERATOR_LESS_THAN,
16493 OPERATOR_GREATER_THAN,
16494 OPERATOR_LESS_THAN_OR_EQUAL,
16495 OPERATOR_GREATER_THAN_OR_EQUAL,
16496 OPERATOR_BETWEEN
16497 ],
16498 validOperators: [
16499 // Single-selection
16500 OPERATOR_IS,
16501 OPERATOR_IS_NOT,
16502 OPERATOR_LESS_THAN,
16503 OPERATOR_GREATER_THAN,
16504 OPERATOR_LESS_THAN_OR_EQUAL,
16505 OPERATOR_GREATER_THAN_OR_EQUAL,
16506 OPERATOR_BETWEEN,
16507 // Multiple-selection
16508 OPERATOR_IS_ANY,
16509 OPERATOR_IS_NONE,
16510 OPERATOR_IS_ALL,
16511 OPERATOR_IS_NOT_ALL
16512 ],
16513 format: format2,
16514 getValueFormatted: getValueFormatted2,
16515 validate: {
16516 required: isValidRequired,
16517 min: isValidMin,
16518 max: isValidMax,
16519 elements: isValidElements,
16520 custom: isValidCustom2
16521 }
16522 };
16523
16524 // packages/dataviews/build-module/field-types/number.mjs
16525 var import_i18n39 = __toESM(require_i18n(), 1);
16526 var format3 = {
16527 separatorThousand: ",",
16528 separatorDecimal: ".",
16529 decimals: 2
16530 };
16531 function getValueFormatted3({
16532 item,
16533 field
16534 }) {
16535 let value = field.getValue({ item });
16536 if (value === null || value === void 0) {
16537 return "";
16538 }
16539 value = Number(value);
16540 if (!Number.isFinite(value)) {
16541 return String(value);
16542 }
16543 let formatNumber;
16544 if (field.type !== "number") {
16545 formatNumber = format3;
16546 } else {
16547 formatNumber = field.format;
16548 }
16549 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
16550 const fixedValue = value.toFixed(decimals);
16551 const [integerPart, decimalPart] = fixedValue.split(".");
16552 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
16553 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
16554 }
16555 function isEmpty2(value) {
16556 return value === "" || value === void 0 || value === null;
16557 }
16558 function isValidCustom3(item, field) {
16559 const value = field.getValue({ item });
16560 if (!isEmpty2(value) && !Number.isFinite(value)) {
16561 return (0, import_i18n39.__)("Value must be a number.");
16562 }
16563 return null;
16564 }
16565 var number_default = {
16566 type: "number",
16567 render,
16568 Edit: "number",
16569 sort: sort_number_default,
16570 enableSorting: true,
16571 enableGlobalSearch: false,
16572 defaultOperators: [
16573 OPERATOR_IS,
16574 OPERATOR_IS_NOT,
16575 OPERATOR_LESS_THAN,
16576 OPERATOR_GREATER_THAN,
16577 OPERATOR_LESS_THAN_OR_EQUAL,
16578 OPERATOR_GREATER_THAN_OR_EQUAL,
16579 OPERATOR_BETWEEN
16580 ],
16581 validOperators: [
16582 // Single-selection
16583 OPERATOR_IS,
16584 OPERATOR_IS_NOT,
16585 OPERATOR_LESS_THAN,
16586 OPERATOR_GREATER_THAN,
16587 OPERATOR_LESS_THAN_OR_EQUAL,
16588 OPERATOR_GREATER_THAN_OR_EQUAL,
16589 OPERATOR_BETWEEN,
16590 // Multiple-selection
16591 OPERATOR_IS_ANY,
16592 OPERATOR_IS_NONE,
16593 OPERATOR_IS_ALL,
16594 OPERATOR_IS_NOT_ALL
16595 ],
16596 format: format3,
16597 getValueFormatted: getValueFormatted3,
16598 validate: {
16599 required: isValidRequired,
16600 min: isValidMin,
16601 max: isValidMax,
16602 elements: isValidElements,
16603 custom: isValidCustom3
16604 }
16605 };
16606
16607 // packages/dataviews/build-module/field-types/text.mjs
16608 var text_default = {
16609 type: "text",
16610 render,
16611 Edit: "text",
16612 sort: sort_text_default,
16613 enableSorting: true,
16614 enableGlobalSearch: false,
16615 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16616 validOperators: [
16617 // Single selection
16618 OPERATOR_IS,
16619 OPERATOR_IS_NOT,
16620 OPERATOR_CONTAINS,
16621 OPERATOR_NOT_CONTAINS,
16622 OPERATOR_STARTS_WITH,
16623 // Multiple selection
16624 OPERATOR_IS_ANY,
16625 OPERATOR_IS_NONE,
16626 OPERATOR_IS_ALL,
16627 OPERATOR_IS_NOT_ALL
16628 ],
16629 format: {},
16630 getValueFormatted: get_value_formatted_default_default,
16631 validate: {
16632 required: isValidRequired,
16633 pattern: isValidPattern,
16634 minLength: isValidMinLength,
16635 maxLength: isValidMaxLength,
16636 elements: isValidElements
16637 }
16638 };
16639
16640 // packages/dataviews/build-module/field-types/datetime.mjs
16641 var import_date7 = __toESM(require_date(), 1);
16642
16643 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
16644 var import_date6 = __toESM(require_date(), 1);
16645 function parseDateLike(value) {
16646 if (!value) {
16647 return null;
16648 }
16649 if (!isValid(new Date(value))) {
16650 return null;
16651 }
16652 const parsed = (0, import_date6.getDate)(value);
16653 return parsed && isValid(parsed) ? parsed : null;
16654 }
16655 function validateDateLikeBoundary(item, field, boundary) {
16656 const constraint = field.isValid[boundary]?.constraint;
16657 if (typeof constraint !== "string") {
16658 return false;
16659 }
16660 const value = field.getValue({ item });
16661 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
16662 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
16663 return true;
16664 }
16665 const parsedConstraint = parseDateLike(constraint);
16666 const parsedValue = parseDateLike(String(boundaryValue));
16667 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
16668 }
16669 function isValidMinDate(item, field) {
16670 return validateDateLikeBoundary(item, field, "min");
16671 }
16672 function isValidMaxDate(item, field) {
16673 return validateDateLikeBoundary(item, field, "max");
16674 }
16675
16676 // packages/dataviews/build-module/field-types/datetime.mjs
16677 var format4 = {
16678 datetime: (0, import_date7.getSettings)().formats.datetime,
16679 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
16680 };
16681 function getValueFormatted4({
16682 item,
16683 field
16684 }) {
16685 const value = field.getValue({ item });
16686 if (["", void 0, null].includes(value)) {
16687 return "";
16688 }
16689 let formatDatetime;
16690 if (field.type !== "datetime") {
16691 formatDatetime = format4;
16692 } else {
16693 formatDatetime = field.format;
16694 }
16695 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
16696 }
16697 var sort = (a2, b2, direction) => {
16698 const timeA = new Date(a2).getTime();
16699 const timeB = new Date(b2).getTime();
16700 return direction === "asc" ? timeA - timeB : timeB - timeA;
16701 };
16702 var datetime_default = {
16703 type: "datetime",
16704 render,
16705 Edit: "datetime",
16706 sort,
16707 enableSorting: true,
16708 enableGlobalSearch: false,
16709 defaultOperators: [
16710 OPERATOR_ON,
16711 OPERATOR_NOT_ON,
16712 OPERATOR_BEFORE,
16713 OPERATOR_AFTER,
16714 OPERATOR_BEFORE_INC,
16715 OPERATOR_AFTER_INC,
16716 OPERATOR_IN_THE_PAST,
16717 OPERATOR_OVER
16718 ],
16719 validOperators: [
16720 OPERATOR_ON,
16721 OPERATOR_NOT_ON,
16722 OPERATOR_BEFORE,
16723 OPERATOR_AFTER,
16724 OPERATOR_BEFORE_INC,
16725 OPERATOR_AFTER_INC,
16726 OPERATOR_IN_THE_PAST,
16727 OPERATOR_OVER
16728 ],
16729 format: format4,
16730 getValueFormatted: getValueFormatted4,
16731 validate: {
16732 required: isValidRequired,
16733 elements: isValidElements,
16734 min: isValidMinDate,
16735 max: isValidMaxDate
16736 }
16737 };
16738
16739 // packages/dataviews/build-module/field-types/date.mjs
16740 var import_date8 = __toESM(require_date(), 1);
16741 var format5 = {
16742 date: (0, import_date8.getSettings)().formats.date,
16743 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
16744 };
16745 function getValueFormatted5({
16746 item,
16747 field
16748 }) {
16749 const value = field.getValue({ item });
16750 if (["", void 0, null].includes(value)) {
16751 return "";
16752 }
16753 let formatDate2;
16754 if (field.type !== "date") {
16755 formatDate2 = format5;
16756 } else {
16757 formatDate2 = field.format;
16758 }
16759 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
16760 }
16761 var sort2 = (a2, b2, direction) => {
16762 const timeA = new Date(a2).getTime();
16763 const timeB = new Date(b2).getTime();
16764 return direction === "asc" ? timeA - timeB : timeB - timeA;
16765 };
16766 var date_default = {
16767 type: "date",
16768 render,
16769 Edit: "date",
16770 sort: sort2,
16771 enableSorting: true,
16772 enableGlobalSearch: false,
16773 defaultOperators: [
16774 OPERATOR_ON,
16775 OPERATOR_NOT_ON,
16776 OPERATOR_BEFORE,
16777 OPERATOR_AFTER,
16778 OPERATOR_BEFORE_INC,
16779 OPERATOR_AFTER_INC,
16780 OPERATOR_IN_THE_PAST,
16781 OPERATOR_OVER,
16782 OPERATOR_BETWEEN
16783 ],
16784 validOperators: [
16785 OPERATOR_ON,
16786 OPERATOR_NOT_ON,
16787 OPERATOR_BEFORE,
16788 OPERATOR_AFTER,
16789 OPERATOR_BEFORE_INC,
16790 OPERATOR_AFTER_INC,
16791 OPERATOR_IN_THE_PAST,
16792 OPERATOR_OVER,
16793 OPERATOR_BETWEEN
16794 ],
16795 format: format5,
16796 getValueFormatted: getValueFormatted5,
16797 validate: {
16798 required: isValidRequired,
16799 elements: isValidElements,
16800 min: isValidMinDate,
16801 max: isValidMaxDate
16802 }
16803 };
16804
16805 // packages/dataviews/build-module/field-types/boolean.mjs
16806 var import_i18n40 = __toESM(require_i18n(), 1);
16807
16808 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
16809 function isValidRequiredForBool(item, field) {
16810 const value = field.getValue({ item });
16811 return value === true;
16812 }
16813
16814 // packages/dataviews/build-module/field-types/boolean.mjs
16815 function getValueFormatted6({
16816 item,
16817 field
16818 }) {
16819 const value = field.getValue({ item });
16820 if (value === true) {
16821 return (0, import_i18n40.__)("True");
16822 }
16823 if (value === false) {
16824 return (0, import_i18n40.__)("False");
16825 }
16826 return "";
16827 }
16828 function isValidCustom4(item, field) {
16829 const value = field.getValue({ item });
16830 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
16831 return (0, import_i18n40.__)("Value must be true, false, or undefined");
16832 }
16833 return null;
16834 }
16835 var sort3 = (a2, b2, direction) => {
16836 const boolA = Boolean(a2);
16837 const boolB = Boolean(b2);
16838 if (boolA === boolB) {
16839 return 0;
16840 }
16841 if (direction === "asc") {
16842 return boolA ? 1 : -1;
16843 }
16844 return boolA ? -1 : 1;
16845 };
16846 var boolean_default = {
16847 type: "boolean",
16848 render,
16849 Edit: "checkbox",
16850 sort: sort3,
16851 validate: {
16852 required: isValidRequiredForBool,
16853 elements: isValidElements,
16854 custom: isValidCustom4
16855 },
16856 enableSorting: true,
16857 enableGlobalSearch: false,
16858 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16859 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16860 format: {},
16861 getValueFormatted: getValueFormatted6
16862 };
16863
16864 // packages/dataviews/build-module/field-types/media.mjs
16865 var media_default = {
16866 type: "media",
16867 render: () => null,
16868 Edit: null,
16869 sort: () => 0,
16870 enableSorting: false,
16871 enableGlobalSearch: false,
16872 defaultOperators: [],
16873 validOperators: [],
16874 format: {},
16875 getValueFormatted: get_value_formatted_default_default,
16876 // cannot validate any constraint, so
16877 // the only available validation for the field author
16878 // would be providing a custom validator.
16879 validate: {}
16880 };
16881
16882 // packages/dataviews/build-module/field-types/array.mjs
16883 var import_i18n41 = __toESM(require_i18n(), 1);
16884
16885 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
16886 function isValidRequiredForArray(item, field) {
16887 const value = field.getValue({ item });
16888 return Array.isArray(value) && value.length > 0 && value.every(
16889 (element) => ![void 0, "", null].includes(element)
16890 );
16891 }
16892
16893 // packages/dataviews/build-module/field-types/array.mjs
16894 function getValueFormatted7({
16895 item,
16896 field
16897 }) {
16898 const value = field.getValue({ item });
16899 const arr = Array.isArray(value) ? value : [];
16900 return arr.join(", ");
16901 }
16902 function render2({ item, field }) {
16903 return getValueFormatted7({ item, field });
16904 }
16905 function isValidCustom5(item, field) {
16906 const value = field.getValue({ item });
16907 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
16908 return (0, import_i18n41.__)("Value must be an array.");
16909 }
16910 if (!value.every((v2) => typeof v2 === "string")) {
16911 return (0, import_i18n41.__)("Every value must be a string.");
16912 }
16913 return null;
16914 }
16915 var sort4 = (a2, b2, direction) => {
16916 const arrA = Array.isArray(a2) ? a2 : [];
16917 const arrB = Array.isArray(b2) ? b2 : [];
16918 if (arrA.length !== arrB.length) {
16919 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
16920 }
16921 const joinedA = arrA.join(",");
16922 const joinedB = arrB.join(",");
16923 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
16924 };
16925 var array_default = {
16926 type: "array",
16927 render: render2,
16928 Edit: "array",
16929 sort: sort4,
16930 enableSorting: true,
16931 enableGlobalSearch: false,
16932 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16933 validOperators: [
16934 OPERATOR_IS_ANY,
16935 OPERATOR_IS_NONE,
16936 OPERATOR_IS_ALL,
16937 OPERATOR_IS_NOT_ALL
16938 ],
16939 format: {},
16940 getValueFormatted: getValueFormatted7,
16941 validate: {
16942 required: isValidRequiredForArray,
16943 elements: isValidElements,
16944 custom: isValidCustom5
16945 }
16946 };
16947
16948 // packages/dataviews/build-module/field-types/password.mjs
16949 function getValueFormatted8({
16950 item,
16951 field
16952 }) {
16953 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
16954 }
16955 var password_default = {
16956 type: "password",
16957 render,
16958 Edit: "password",
16959 sort: () => 0,
16960 // Passwords should not be sortable for security reasons
16961 enableSorting: false,
16962 enableGlobalSearch: false,
16963 defaultOperators: [],
16964 validOperators: [],
16965 format: {},
16966 getValueFormatted: getValueFormatted8,
16967 validate: {
16968 required: isValidRequired,
16969 pattern: isValidPattern,
16970 minLength: isValidMinLength,
16971 maxLength: isValidMaxLength,
16972 elements: isValidElements
16973 }
16974 };
16975
16976 // packages/dataviews/build-module/field-types/telephone.mjs
16977 var telephone_default = {
16978 type: "telephone",
16979 render,
16980 Edit: "telephone",
16981 sort: sort_text_default,
16982 enableSorting: true,
16983 enableGlobalSearch: false,
16984 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16985 validOperators: [
16986 OPERATOR_IS,
16987 OPERATOR_IS_NOT,
16988 OPERATOR_CONTAINS,
16989 OPERATOR_NOT_CONTAINS,
16990 OPERATOR_STARTS_WITH,
16991 // Multiple selection
16992 OPERATOR_IS_ANY,
16993 OPERATOR_IS_NONE,
16994 OPERATOR_IS_ALL,
16995 OPERATOR_IS_NOT_ALL
16996 ],
16997 format: {},
16998 getValueFormatted: get_value_formatted_default_default,
16999 validate: {
17000 required: isValidRequired,
17001 pattern: isValidPattern,
17002 minLength: isValidMinLength,
17003 maxLength: isValidMaxLength,
17004 elements: isValidElements
17005 }
17006 };
17007
17008 // packages/dataviews/build-module/field-types/color.mjs
17009 var import_i18n42 = __toESM(require_i18n(), 1);
17010 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
17011 function render3({ item, field }) {
17012 if (field.hasElements) {
17013 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(RenderFromElements, { item, field });
17014 }
17015 const value = get_value_formatted_default_default({ item, field });
17016 if (!value || !w(value).isValid()) {
17017 return value;
17018 }
17019 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
17020 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17021 "div",
17022 {
17023 style: {
17024 width: "16px",
17025 height: "16px",
17026 borderRadius: "50%",
17027 backgroundColor: value,
17028 border: "1px solid #ddd",
17029 flexShrink: 0
17030 }
17031 }
17032 ),
17033 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { children: value })
17034 ] });
17035 }
17036 function isValidCustom6(item, field) {
17037 const value = field.getValue({ item });
17038 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
17039 return (0, import_i18n42.__)("Value must be a valid color.");
17040 }
17041 return null;
17042 }
17043 var sort5 = (a2, b2, direction) => {
17044 const colorA = w(a2);
17045 const colorB = w(b2);
17046 if (!colorA.isValid() && !colorB.isValid()) {
17047 return 0;
17048 }
17049 if (!colorA.isValid()) {
17050 return direction === "asc" ? 1 : -1;
17051 }
17052 if (!colorB.isValid()) {
17053 return direction === "asc" ? -1 : 1;
17054 }
17055 const hslA = colorA.toHsl();
17056 const hslB = colorB.toHsl();
17057 if (hslA.h !== hslB.h) {
17058 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
17059 }
17060 if (hslA.s !== hslB.s) {
17061 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
17062 }
17063 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
17064 };
17065 var color_default = {
17066 type: "color",
17067 render: render3,
17068 Edit: "color",
17069 sort: sort5,
17070 enableSorting: true,
17071 enableGlobalSearch: false,
17072 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
17073 validOperators: [
17074 OPERATOR_IS,
17075 OPERATOR_IS_NOT,
17076 OPERATOR_IS_ANY,
17077 OPERATOR_IS_NONE
17078 ],
17079 format: {},
17080 getValueFormatted: get_value_formatted_default_default,
17081 validate: {
17082 required: isValidRequired,
17083 elements: isValidElements,
17084 custom: isValidCustom6
17085 }
17086 };
17087
17088 // packages/dataviews/build-module/field-types/url.mjs
17089 var url_default = {
17090 type: "url",
17091 render,
17092 Edit: "url",
17093 sort: sort_text_default,
17094 enableSorting: true,
17095 enableGlobalSearch: false,
17096 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
17097 validOperators: [
17098 OPERATOR_IS,
17099 OPERATOR_IS_NOT,
17100 OPERATOR_CONTAINS,
17101 OPERATOR_NOT_CONTAINS,
17102 OPERATOR_STARTS_WITH,
17103 // Multiple selection
17104 OPERATOR_IS_ANY,
17105 OPERATOR_IS_NONE,
17106 OPERATOR_IS_ALL,
17107 OPERATOR_IS_NOT_ALL
17108 ],
17109 format: {},
17110 getValueFormatted: get_value_formatted_default_default,
17111 validate: {
17112 required: isValidRequired,
17113 pattern: isValidPattern,
17114 minLength: isValidMinLength,
17115 maxLength: isValidMaxLength,
17116 elements: isValidElements
17117 }
17118 };
17119
17120 // packages/dataviews/build-module/field-types/no-type.mjs
17121 var sort6 = (a2, b2, direction) => {
17122 if (typeof a2 === "number" && typeof b2 === "number") {
17123 return sort_number_default(a2, b2, direction);
17124 }
17125 return sort_text_default(a2, b2, direction);
17126 };
17127 var no_type_default = {
17128 // type: no type for this one
17129 render,
17130 Edit: null,
17131 sort: sort6,
17132 enableSorting: true,
17133 enableGlobalSearch: false,
17134 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
17135 validOperators: getAllOperatorNames(),
17136 format: {},
17137 getValueFormatted: get_value_formatted_default_default,
17138 validate: {
17139 required: isValidRequired,
17140 elements: isValidElements
17141 }
17142 };
17143
17144 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
17145 function supportsNumericRangeConstraint(type) {
17146 return type === "integer" || type === "number";
17147 }
17148 function supportsDateRangeConstraint(type) {
17149 return type === "date" || type === "datetime";
17150 }
17151 function normalizeRangeRule(value, fieldType, key) {
17152 const validator = fieldType.validate[key];
17153 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
17154 return { constraint: value, validate: validator };
17155 }
17156 return void 0;
17157 }
17158 function getIsValid(field, fieldType) {
17159 const rules = field.isValid;
17160 let required;
17161 if (rules?.required === true && fieldType.validate.required !== void 0) {
17162 required = {
17163 constraint: true,
17164 validate: fieldType.validate.required
17165 };
17166 }
17167 let elements;
17168 if ((rules?.elements === true || // elements is enabled unless the field opts-out
17169 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
17170 elements = {
17171 constraint: true,
17172 validate: fieldType.validate.elements
17173 };
17174 }
17175 const min = normalizeRangeRule(rules?.min, fieldType, "min");
17176 const max = normalizeRangeRule(rules?.max, fieldType, "max");
17177 const minLengthValue = rules?.minLength;
17178 let minLength;
17179 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
17180 minLength = {
17181 constraint: minLengthValue,
17182 validate: fieldType.validate.minLength
17183 };
17184 }
17185 const maxLengthValue = rules?.maxLength;
17186 let maxLength;
17187 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
17188 maxLength = {
17189 constraint: maxLengthValue,
17190 validate: fieldType.validate.maxLength
17191 };
17192 }
17193 const patternValue = rules?.pattern;
17194 let pattern;
17195 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
17196 pattern = {
17197 constraint: patternValue,
17198 validate: fieldType.validate.pattern
17199 };
17200 }
17201 const custom = rules?.custom ?? fieldType.validate.custom;
17202 return {
17203 required,
17204 elements,
17205 min,
17206 max,
17207 minLength,
17208 maxLength,
17209 pattern,
17210 custom
17211 };
17212 }
17213
17214 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
17215 function getFilter(fieldType) {
17216 return fieldType.validOperators.reduce((accumulator, operator) => {
17217 const operatorObj = getOperatorByName(operator);
17218 if (operatorObj?.filter) {
17219 accumulator[operator] = operatorObj.filter;
17220 }
17221 return accumulator;
17222 }, {});
17223 }
17224
17225 // packages/dataviews/build-module/field-types/utils/get-format.mjs
17226 function getFormat(field, fieldType) {
17227 return {
17228 ...fieldType.format,
17229 ...field.format
17230 };
17231 }
17232 var get_format_default = getFormat;
17233
17234 // packages/dataviews/build-module/field-types/index.mjs
17235 function getFieldTypeByName(type) {
17236 const found = [
17237 email_default,
17238 integer_default,
17239 number_default,
17240 text_default,
17241 datetime_default,
17242 date_default,
17243 boolean_default,
17244 media_default,
17245 array_default,
17246 password_default,
17247 telephone_default,
17248 color_default,
17249 url_default
17250 ].find((fieldType) => fieldType?.type === type);
17251 if (!!found) {
17252 return found;
17253 }
17254 return no_type_default;
17255 }
17256 function normalizeFields(fields) {
17257 return fields.map((field) => {
17258 const fieldType = getFieldTypeByName(field.type);
17259 const getValue = field.getValue || get_value_from_id_default(field.id);
17260 const sort7 = function(a2, b2, direction) {
17261 const aValue = getValue({ item: a2 });
17262 const bValue = getValue({ item: b2 });
17263 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
17264 };
17265 return {
17266 id: field.id,
17267 label: field.label || field.id,
17268 header: field.header || field.label || field.id,
17269 description: field.description,
17270 placeholder: field.placeholder,
17271 getValue,
17272 setValue: field.setValue || set_value_from_id_default(field.id),
17273 elements: field.elements,
17274 getElements: field.getElements,
17275 hasElements: hasElements(field),
17276 isVisible: field.isVisible,
17277 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
17278 enableHiding: field.enableHiding ?? true,
17279 readOnly: field.readOnly ?? false,
17280 // The type provides defaults for the following props
17281 type: fieldType.type,
17282 render: field.render ?? fieldType.render,
17283 Edit: getControl(field, fieldType.Edit),
17284 sort: sort7,
17285 enableSorting: field.enableSorting ?? fieldType.enableSorting,
17286 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
17287 isValid: getIsValid(field, fieldType),
17288 filterBy: get_filter_by_default(
17289 field,
17290 fieldType.defaultOperators,
17291 fieldType.validOperators
17292 ),
17293 filter: getFilter(fieldType),
17294 format: get_format_default(field, fieldType),
17295 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
17296 };
17297 });
17298 }
17299
17300 // packages/dataviews/build-module/hooks/use-data.mjs
17301 var import_element58 = __toESM(require_element(), 1);
17302 function useData({
17303 view,
17304 data: shownData,
17305 getItemId,
17306 isLoading,
17307 paginationInfo,
17308 selection
17309 }) {
17310 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
17311 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element58.useState)(
17312 !isLoading
17313 );
17314 (0, import_element58.useEffect)(() => {
17315 if (!isLoading) {
17316 setHasInitiallyLoaded(true);
17317 }
17318 }, [isLoading]);
17319 const previousDataRef = (0, import_element58.useRef)(shownData);
17320 const previousPaginationInfoRef = (0, import_element58.useRef)(paginationInfo);
17321 (0, import_element58.useEffect)(() => {
17322 if (!isLoading) {
17323 previousDataRef.current = shownData;
17324 previousPaginationInfoRef.current = paginationInfo;
17325 }
17326 }, [shownData, isLoading, paginationInfo]);
17327 const [visibleEntries, setVisibleEntries] = (0, import_element58.useState)([]);
17328 const positionMapRef = (0, import_element58.useRef)(/* @__PURE__ */ new Map());
17329 const allLoadedRecordsRef = (0, import_element58.useRef)([]);
17330 const prevViewParamsRef = (0, import_element58.useRef)({
17331 search: void 0,
17332 filters: void 0,
17333 perPage: void 0
17334 });
17335 const scrollDirectionRef = (0, import_element58.useRef)(void 0);
17336 const prevStartPositionRef = (0, import_element58.useRef)(void 0);
17337 const hasInitializedRef = (0, import_element58.useRef)(false);
17338 const allLoadedRecords = (0, import_element58.useMemo)(() => {
17339 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
17340 if (view.startPosition < prevStartPositionRef.current) {
17341 scrollDirectionRef.current = "up";
17342 } else if (view.startPosition > prevStartPositionRef.current) {
17343 scrollDirectionRef.current = "down";
17344 }
17345 }
17346 prevStartPositionRef.current = view.startPosition;
17347 const currentFiltersKey = JSON.stringify(view.filters ?? []);
17348 const prevFiltersKey = prevViewParamsRef.current.filters;
17349 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
17350 hasInitializedRef.current = true;
17351 prevViewParamsRef.current = {
17352 search: view.search,
17353 filters: currentFiltersKey,
17354 perPage: view.perPage
17355 };
17356 if (shouldReset) {
17357 positionMapRef.current.clear();
17358 scrollDirectionRef.current = void 0;
17359 const startPosition = view.search ? 1 : view.startPosition ?? 1;
17360 const records = shownData.map((record, index) => {
17361 const position = startPosition + index;
17362 positionMapRef.current.set(getItemId(record), position);
17363 return {
17364 ...record,
17365 position
17366 };
17367 });
17368 allLoadedRecordsRef.current = records;
17369 return records;
17370 }
17371 const prev = allLoadedRecordsRef.current;
17372 const shownDataIds = new Set(shownData.map(getItemId));
17373 const scrollDirection = scrollDirectionRef.current;
17374 const basePosition = view.search ? 1 : view.startPosition ?? 1;
17375 const newRecords = shownData.map((record, index) => {
17376 const itemId = getItemId(record);
17377 const position = view.infiniteScrollEnabled ? basePosition + index : void 0;
17378 if (position !== void 0) {
17379 positionMapRef.current.set(itemId, position);
17380 }
17381 return {
17382 ...record,
17383 position
17384 };
17385 });
17386 if (newRecords.length === 0) {
17387 return prev;
17388 }
17389 const prevWithoutDuplicates = prev.filter(
17390 (record) => !shownDataIds.has(getItemId(record))
17391 );
17392 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
17393 allRecords.sort((a2, b2) => {
17394 const posA = a2.position;
17395 const posB = b2.position;
17396 return posA - posB;
17397 });
17398 let result = allRecords;
17399 if (visibleEntries.length > 0) {
17400 const visibleMin = Math.min(...visibleEntries);
17401 const visibleMax = Math.max(...visibleEntries);
17402 const buffer = 20;
17403 const recordPositions = allRecords.map(
17404 (r3) => r3.position
17405 );
17406 const minRecordPos = Math.min(...recordPositions);
17407 const maxRecordPos = Math.max(...recordPositions);
17408 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
17409 if (hasOverlap) {
17410 result = allRecords.filter((record) => {
17411 const itemId = getItemId(record);
17412 const isSelected2 = selection?.includes(itemId);
17413 if (isSelected2) {
17414 return true;
17415 }
17416 const itemPosition = record.position;
17417 if (scrollDirection === "up") {
17418 return itemPosition <= visibleMax + buffer;
17419 } else if (scrollDirection === "down") {
17420 return itemPosition >= visibleMin - buffer;
17421 }
17422 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
17423 });
17424 }
17425 }
17426 allLoadedRecordsRef.current = result;
17427 return result;
17428 }, [
17429 shownData,
17430 view.search,
17431 view.filters,
17432 view.perPage,
17433 view.startPosition,
17434 view.infiniteScrollEnabled,
17435 visibleEntries,
17436 selection,
17437 getItemId
17438 ]);
17439 if (!isInfiniteScrollEnabled) {
17440 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
17441 return {
17442 data: dataToReturn.map((item) => ({
17443 ...item,
17444 position: void 0
17445 })),
17446 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
17447 hasInitiallyLoaded,
17448 setVisibleEntries: void 0
17449 };
17450 }
17451 return {
17452 data: allLoadedRecords,
17453 paginationInfo,
17454 hasInitiallyLoaded,
17455 setVisibleEntries
17456 };
17457 }
17458
17459 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
17460 var import_element59 = __toESM(require_element(), 1);
17461 var import_compose11 = __toESM(require_compose(), 1);
17462 function captureAnchorElement(container, anchorElementRef, direction) {
17463 const containerRect = container.getBoundingClientRect();
17464 const centerY = containerRect.top + containerRect.height / 2;
17465 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
17466 if (items.length === 0) {
17467 return false;
17468 }
17469 const bestAnchor = items.reduce((best, item) => {
17470 const itemRect = item.getBoundingClientRect();
17471 const itemCenterY = itemRect.top + itemRect.height / 2;
17472 const distance = Math.abs(itemCenterY - centerY);
17473 const bestRect = best.getBoundingClientRect();
17474 const bestCenterY = bestRect.top + bestRect.height / 2;
17475 const bestDistance = Math.abs(bestCenterY - centerY);
17476 return distance < bestDistance ? item : best;
17477 });
17478 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
17479 const anchorRect = bestAnchor.getBoundingClientRect();
17480 anchorElementRef.current = {
17481 posinset,
17482 viewportOffset: anchorRect.top - containerRect.top,
17483 direction
17484 };
17485 return true;
17486 }
17487 function useInfiniteScroll({
17488 view,
17489 onChangeView,
17490 isLoading,
17491 paginationInfo,
17492 containerRef,
17493 setVisibleEntries
17494 }) {
17495 const anchorElementRef = (0, import_element59.useRef)(null);
17496 const viewRef = (0, import_element59.useRef)(view);
17497 const isLoadingRef = (0, import_element59.useRef)(isLoading);
17498 const onChangeViewRef = (0, import_element59.useRef)(onChangeView);
17499 const totalItemsRef = (0, import_element59.useRef)(paginationInfo.totalItems);
17500 (0, import_element59.useLayoutEffect)(() => {
17501 viewRef.current = view;
17502 isLoadingRef.current = isLoading;
17503 onChangeViewRef.current = onChangeView;
17504 totalItemsRef.current = paginationInfo.totalItems;
17505 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
17506 const intersectionObserverCallback = (0, import_element59.useCallback)(
17507 (entries) => {
17508 if (!setVisibleEntries) {
17509 return;
17510 }
17511 setVisibleEntries((prev) => {
17512 const newVisibleEntries = new Set(prev);
17513 let hasChanged = false;
17514 entries.forEach((entry) => {
17515 const posInSet = Number(
17516 entry.target?.attributes?.getNamedItem(
17517 "aria-posinset"
17518 )?.value
17519 );
17520 if (isNaN(posInSet)) {
17521 return;
17522 }
17523 if (entry.isIntersecting) {
17524 if (!newVisibleEntries.has(posInSet)) {
17525 newVisibleEntries.add(posInSet);
17526 hasChanged = true;
17527 }
17528 } else if (newVisibleEntries.has(posInSet)) {
17529 newVisibleEntries.delete(posInSet);
17530 hasChanged = true;
17531 }
17532 });
17533 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
17534 });
17535 },
17536 [setVisibleEntries]
17537 );
17538 (0, import_element59.useLayoutEffect)(() => {
17539 const container = containerRef.current;
17540 const anchor = anchorElementRef.current;
17541 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
17542 return;
17543 }
17544 const anchorElement = container.querySelector(
17545 `[aria-posinset="${anchor.posinset}"]`
17546 );
17547 if (anchorElement) {
17548 const containerRect = container.getBoundingClientRect();
17549 const anchorRect = anchorElement.getBoundingClientRect();
17550 const currentOffset = anchorRect.top - containerRect.top;
17551 const scrollAdjustment = currentOffset - anchor.viewportOffset;
17552 if (Math.abs(scrollAdjustment) > 1) {
17553 container.scrollTop += scrollAdjustment;
17554 }
17555 }
17556 anchorElementRef.current = null;
17557 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
17558 const intersectionObserverRef = (0, import_element59.useRef)(
17559 null
17560 );
17561 (0, import_element59.useEffect)(() => {
17562 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
17563 if (intersectionObserverRef.current) {
17564 intersectionObserverRef.current.disconnect();
17565 intersectionObserverRef.current = null;
17566 }
17567 return;
17568 }
17569 intersectionObserverRef.current = new IntersectionObserver(
17570 intersectionObserverCallback,
17571 { root: null, rootMargin: "0px", threshold: 0.1 }
17572 );
17573 return () => {
17574 if (intersectionObserverRef.current) {
17575 intersectionObserverRef.current.disconnect();
17576 intersectionObserverRef.current = null;
17577 }
17578 };
17579 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
17580 (0, import_element59.useEffect)(() => {
17581 if (!view.infiniteScrollEnabled || !containerRef.current) {
17582 return;
17583 }
17584 let lastScrollTop = 0;
17585 const BOTTOM_THRESHOLD = 600;
17586 const TOP_THRESHOLD = 800;
17587 const handleScroll = (0, import_compose11.throttle)((event) => {
17588 const currentView = viewRef.current;
17589 const totalItems = totalItemsRef.current;
17590 const target = event.target;
17591 const scrollTop = target.scrollTop;
17592 const scrollHeight = target.scrollHeight;
17593 const clientHeight = target.clientHeight;
17594 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
17595 lastScrollTop = scrollTop;
17596 if (isLoadingRef.current) {
17597 return;
17598 }
17599 const currentStartPosition = currentView.startPosition || 1;
17600 const batchSize = currentView.perPage || 10;
17601 const currentEndPosition = Math.min(
17602 currentStartPosition + batchSize,
17603 totalItems
17604 );
17605 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
17606 if (currentEndPosition < totalItems) {
17607 const newStartPosition = currentEndPosition;
17608 captureAnchorElement(target, anchorElementRef, "down");
17609 onChangeViewRef.current({
17610 ...currentView,
17611 startPosition: newStartPosition
17612 });
17613 }
17614 }
17615 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
17616 if (currentStartPosition > 1) {
17617 const calculatedStartPosition = currentStartPosition - batchSize;
17618 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
17619 captureAnchorElement(target, anchorElementRef, "up");
17620 onChangeViewRef.current({
17621 ...currentView,
17622 startPosition: newStartPosition
17623 });
17624 }
17625 }
17626 }, 50);
17627 const container = containerRef.current;
17628 container.addEventListener("scroll", handleScroll);
17629 return () => {
17630 container.removeEventListener("scroll", handleScroll);
17631 handleScroll.cancel();
17632 };
17633 }, [containerRef, view.infiniteScrollEnabled]);
17634 return {
17635 intersectionObserver: intersectionObserverRef.current
17636 };
17637 }
17638
17639 // packages/dataviews/build-module/dataviews/index.mjs
17640 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
17641 var defaultGetItemId = (item) => item.id;
17642 var defaultIsItemClickable = () => true;
17643 var EMPTY_ARRAY6 = [];
17644 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
17645 var dataViewsLayouts = VIEW_LAYOUTS.filter(
17646 (viewLayout) => !viewLayout.isPicker
17647 );
17648 function DefaultUI({
17649 header,
17650 search = true,
17651 searchLabel = void 0
17652 }) {
17653 const { view } = (0, import_element60.useContext)(dataviews_context_default);
17654 const isInfiniteScroll = view.infiniteScrollEnabled;
17655 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_jsx_runtime93.Fragment, { children: [
17656 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17657 Stack,
17658 {
17659 direction: "row",
17660 align: "top",
17661 justify: "space-between",
17662 className: clsx_default("dataviews__view-actions", {
17663 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
17664 }),
17665 gap: "xs",
17666 children: [
17667 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17668 Stack,
17669 {
17670 direction: "row",
17671 justify: "start",
17672 gap: "sm",
17673 className: "dataviews__search",
17674 children: [
17675 search && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(dataviews_search_default, { label: searchLabel }),
17676 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(toggle_default, {})
17677 ]
17678 }
17679 ),
17680 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
17681 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(dataviews_view_config_default, {}),
17682 header
17683 ] })
17684 ]
17685 }
17686 ),
17687 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
17688 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(DataViewsLayout, {}),
17689 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(DataViewsFooter, {})
17690 ] });
17691 }
17692 function DataViews({
17693 view,
17694 onChangeView,
17695 fields,
17696 search = true,
17697 searchLabel = void 0,
17698 actions = EMPTY_ARRAY6,
17699 data,
17700 getItemId = defaultGetItemId,
17701 getItemLevel,
17702 isLoading = false,
17703 paginationInfo,
17704 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
17705 selection: selectionProperty,
17706 onChangeSelection,
17707 onClickItem,
17708 renderItemLink,
17709 isItemClickable = defaultIsItemClickable,
17710 header,
17711 children,
17712 config = { perPageSizes: [10, 20, 50, 100] },
17713 empty,
17714 onReset
17715 }) {
17716 const [selectionState, setSelectionState] = (0, import_element60.useState)([]);
17717 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
17718 const selection = isUncontrolled ? selectionState : selectionProperty;
17719 const {
17720 data: displayData,
17721 paginationInfo: displayPaginationInfo,
17722 hasInitiallyLoaded,
17723 setVisibleEntries
17724 } = useData({
17725 view,
17726 data,
17727 getItemId,
17728 isLoading,
17729 selection,
17730 paginationInfo
17731 });
17732 const containerRef = (0, import_element60.useRef)(null);
17733 const [containerWidth, setContainerWidth] = (0, import_element60.useState)(0);
17734 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
17735 (resizeObserverEntries) => {
17736 setContainerWidth(
17737 resizeObserverEntries[0].borderBoxSize[0].inlineSize
17738 );
17739 },
17740 { box: "border-box" }
17741 );
17742 const [openedFilter, setOpenedFilter] = (0, import_element60.useState)(null);
17743 function setSelectionWithChange(value) {
17744 const newValue = typeof value === "function" ? value(selection) : value;
17745 if (isUncontrolled) {
17746 setSelectionState(newValue);
17747 }
17748 if (onChangeSelection) {
17749 onChangeSelection(newValue);
17750 }
17751 }
17752 const _fields = (0, import_element60.useMemo)(() => normalizeFields(fields), [fields]);
17753 const _selection = (0, import_element60.useMemo)(() => {
17754 if (view.infiniteScrollEnabled) {
17755 return selection;
17756 }
17757 return selection.filter(
17758 (id) => data.some((item) => getItemId(item) === id)
17759 );
17760 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
17761 const filters = use_filters_default(_fields, view);
17762 const hasPrimaryOrLockedFilters = (0, import_element60.useMemo)(
17763 () => (filters || []).some(
17764 (filter) => filter.isPrimary || filter.isLocked
17765 ),
17766 [filters]
17767 );
17768 const [isShowingFilter, setIsShowingFilter] = (0, import_element60.useState)(
17769 hasPrimaryOrLockedFilters
17770 );
17771 const { intersectionObserver } = useInfiniteScroll({
17772 view,
17773 onChangeView,
17774 isLoading,
17775 paginationInfo,
17776 containerRef,
17777 setVisibleEntries
17778 });
17779 (0, import_element60.useEffect)(() => {
17780 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
17781 setIsShowingFilter(true);
17782 }
17783 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
17784 const defaultLayouts = (0, import_element60.useMemo)(
17785 () => Object.fromEntries(
17786 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
17787 return dataViewsLayouts.some(
17788 (viewLayout) => viewLayout.type === layoutType
17789 );
17790 }).map(([key, value]) => [
17791 key,
17792 value === true ? {} : value
17793 ])
17794 ),
17795 [defaultLayoutsProperty]
17796 );
17797 if (!defaultLayouts[view.type]) {
17798 return null;
17799 }
17800 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17801 dataviews_context_default.Provider,
17802 {
17803 value: {
17804 view,
17805 onChangeView,
17806 fields: _fields,
17807 actions,
17808 data: displayData,
17809 isLoading,
17810 paginationInfo: displayPaginationInfo,
17811 selection: _selection,
17812 onChangeSelection: setSelectionWithChange,
17813 openedFilter,
17814 setOpenedFilter,
17815 getItemId,
17816 getItemLevel,
17817 isItemClickable,
17818 onClickItem,
17819 renderItemLink,
17820 containerWidth,
17821 containerRef,
17822 resizeObserverRef,
17823 defaultLayouts,
17824 filters,
17825 isShowingFilter,
17826 setIsShowingFilter,
17827 config,
17828 empty,
17829 hasInitiallyLoaded,
17830 onReset,
17831 intersectionObserver
17832 },
17833 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17834 DefaultUI,
17835 {
17836 header,
17837 search,
17838 searchLabel
17839 }
17840 ) })
17841 }
17842 );
17843 }
17844 var DataViewsSubComponents = DataViews;
17845 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
17846 DataViewsSubComponents.Filters = filters_default;
17847 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
17848 DataViewsSubComponents.FiltersToggle = toggle_default;
17849 DataViewsSubComponents.Layout = DataViewsLayout;
17850 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
17851 DataViewsSubComponents.Pagination = DataViewsPagination;
17852 DataViewsSubComponents.Search = dataviews_search_default;
17853 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
17854 DataViewsSubComponents.Footer = DataViewsFooter;
17855 var dataviews_default = DataViewsSubComponents;
17856
17857 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
17858 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
17859 var import_deprecated = __toESM(require_deprecated(), 1);
17860 function normalizeSearchInput2(input = "") {
17861 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
17862 }
17863 var EMPTY_ARRAY7 = [];
17864 function filterSortAndPaginate(data, view, fields) {
17865 if (!data) {
17866 return {
17867 data: EMPTY_ARRAY7,
17868 paginationInfo: { totalItems: 0, totalPages: 0 }
17869 };
17870 }
17871 const _fields = normalizeFields(fields);
17872 let filteredData = [...data];
17873 if (view.search) {
17874 const normalizedSearch = normalizeSearchInput2(view.search);
17875 filteredData = filteredData.filter((item) => {
17876 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
17877 const fieldValue = field.getValue({ item });
17878 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
17879 return values.some(
17880 (value) => normalizeSearchInput2(String(value)).includes(
17881 normalizedSearch
17882 )
17883 );
17884 });
17885 });
17886 }
17887 if (view.filters && view.filters?.length > 0) {
17888 view.filters.forEach((filter) => {
17889 const field = _fields.find(
17890 (_field) => _field.id === filter.field
17891 );
17892 if (field) {
17893 if (filter.operator === OPERATOR_IS_NOT_ALL) {
17894 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
17895 since: "7.0",
17896 alternative: "'isNone'"
17897 });
17898 }
17899 const handler = field.filter[filter.operator];
17900 if (handler) {
17901 filteredData = filteredData.filter(
17902 (item) => handler(item, field, filter.value)
17903 );
17904 }
17905 }
17906 });
17907 }
17908 const sortByField = view.sort?.field ? _fields.find((field) => {
17909 return field.enableSorting !== false && field.id === view.sort?.field;
17910 }) : null;
17911 const groupByField = view.groupBy?.field ? _fields.find((field) => {
17912 return field.enableSorting !== false && field.id === view.groupBy?.field;
17913 }) : null;
17914 if (sortByField || groupByField) {
17915 filteredData.sort((a2, b2) => {
17916 if (groupByField) {
17917 const groupCompare = groupByField.sort(
17918 a2,
17919 b2,
17920 view.groupBy?.direction ?? "asc"
17921 );
17922 if (groupCompare !== 0) {
17923 return groupCompare;
17924 }
17925 }
17926 if (sortByField) {
17927 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
17928 }
17929 return 0;
17930 });
17931 }
17932 let totalItems = filteredData.length;
17933 let totalPages = 1;
17934 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
17935 const start = view.startPosition - 1;
17936 const end = Math.min(start + view.perPage, totalItems);
17937 filteredData = filteredData?.slice(start, end);
17938 } else if (view.page !== void 0 && view.perPage !== void 0) {
17939 const start = (view.page - 1) * view.perPage;
17940 totalItems = filteredData?.length || 0;
17941 totalPages = Math.ceil(totalItems / view.perPage);
17942 filteredData = filteredData?.slice(start, start + view.perPage);
17943 }
17944 return {
17945 data: filteredData,
17946 paginationInfo: {
17947 totalItems,
17948 totalPages
17949 }
17950 };
17951 }
17952
17953 // packages/admin-ui/build-module/navigable-region/index.mjs
17954 var import_element61 = __toESM(require_element(), 1);
17955 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
17956 var NavigableRegion = (0, import_element61.forwardRef)(
17957 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
17958 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17959 Tag,
17960 {
17961 ref,
17962 className: clsx_default("admin-ui-navigable-region", className),
17963 "aria-label": ariaLabel,
17964 role: "region",
17965 tabIndex: "-1",
17966 ...props,
17967 children
17968 }
17969 );
17970 }
17971 );
17972 NavigableRegion.displayName = "NavigableRegion";
17973 var navigable_region_default = NavigableRegion;
17974
17975 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
17976 var import_components45 = __toESM(require_components(), 1);
17977 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components45.createSlotFill)("SidebarToggle");
17978
17979 // packages/admin-ui/build-module/page/header.mjs
17980 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
17981 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
17982 function getRuntime4() {
17983 const globalScope = globalThis;
17984 if (globalScope.__wpStyleRuntime) {
17985 return globalScope.__wpStyleRuntime;
17986 }
17987 globalScope.__wpStyleRuntime = {
17988 documents: /* @__PURE__ */ new Map(),
17989 styles: /* @__PURE__ */ new Map(),
17990 injectedStyles: /* @__PURE__ */ new WeakMap()
17991 };
17992 if (typeof document !== "undefined") {
17993 registerDocument4(document);
17994 }
17995 return globalScope.__wpStyleRuntime;
17996 }
17997 function documentContainsStyleHash4(targetDocument, hash) {
17998 if (!targetDocument.head) {
17999 return false;
18000 }
18001 for (const style of targetDocument.head.querySelectorAll(
18002 `style[${STYLE_HASH_ATTRIBUTE4}]`
18003 )) {
18004 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
18005 return true;
18006 }
18007 }
18008 return false;
18009 }
18010 function injectStyle4(targetDocument, hash, css) {
18011 if (!targetDocument.head) {
18012 return;
18013 }
18014 const runtime = getRuntime4();
18015 let injectedStyles = runtime.injectedStyles.get(targetDocument);
18016 if (!injectedStyles) {
18017 injectedStyles = /* @__PURE__ */ new Set();
18018 runtime.injectedStyles.set(targetDocument, injectedStyles);
18019 }
18020 if (injectedStyles.has(hash)) {
18021 return;
18022 }
18023 if (documentContainsStyleHash4(targetDocument, hash)) {
18024 injectedStyles.add(hash);
18025 return;
18026 }
18027 const style = targetDocument.createElement("style");
18028 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
18029 style.appendChild(targetDocument.createTextNode(css));
18030 targetDocument.head.appendChild(style);
18031 injectedStyles.add(hash);
18032 }
18033 function registerDocument4(targetDocument) {
18034 const runtime = getRuntime4();
18035 runtime.documents.set(
18036 targetDocument,
18037 (runtime.documents.get(targetDocument) ?? 0) + 1
18038 );
18039 for (const [hash, css] of runtime.styles) {
18040 injectStyle4(targetDocument, hash, css);
18041 }
18042 return () => {
18043 const count = runtime.documents.get(targetDocument);
18044 if (count === void 0) {
18045 return;
18046 }
18047 if (count <= 1) {
18048 runtime.documents.delete(targetDocument);
18049 return;
18050 }
18051 runtime.documents.set(targetDocument, count - 1);
18052 };
18053 }
18054 function registerStyle4(hash, css) {
18055 const runtime = getRuntime4();
18056 runtime.styles.set(hash, css);
18057 for (const targetDocument of runtime.documents.keys()) {
18058 injectStyle4(targetDocument, hash, css);
18059 }
18060 }
18061 if (typeof process === "undefined" || true) {
18062 registerStyle4("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)}}");
18063 }
18064 var style_default4 = { "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" };
18065 function Header({
18066 headingLevel = 1,
18067 breadcrumbs,
18068 badges,
18069 visual,
18070 title,
18071 subTitle,
18072 actions,
18073 showSidebarToggle = true
18074 }) {
18075 const HeadingTag = `h${headingLevel}`;
18076 return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
18077 Stack,
18078 {
18079 direction: "column",
18080 className: style_default4.header,
18081 render: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("header", {}),
18082 children: [
18083 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
18084 Stack,
18085 {
18086 className: style_default4["header-content"],
18087 direction: "row",
18088 gap: "sm",
18089 justify: "space-between",
18090 children: [
18091 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
18092 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
18093 SidebarToggleSlot,
18094 {
18095 bubblesVirtually: true,
18096 className: style_default4["sidebar-toggle-slot"]
18097 }
18098 ),
18099 visual && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
18100 "div",
18101 {
18102 className: style_default4["header-visual"],
18103 "aria-hidden": "true",
18104 children: visual
18105 }
18106 ),
18107 title && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
18108 Text,
18109 {
18110 className: style_default4["header-title"],
18111 render: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(HeadingTag, {}),
18112 variant: "heading-lg",
18113 children: title
18114 }
18115 ),
18116 breadcrumbs,
18117 badges
18118 ] }),
18119 actions && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
18120 Stack,
18121 {
18122 align: "center",
18123 className: style_default4["header-actions"],
18124 direction: "row",
18125 gap: "sm",
18126 children: actions
18127 }
18128 )
18129 ]
18130 }
18131 ),
18132 subTitle && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
18133 Text,
18134 {
18135 render: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("p", {}),
18136 variant: "body-md",
18137 className: style_default4["header-subtitle"],
18138 children: subTitle
18139 }
18140 )
18141 ]
18142 }
18143 );
18144 }
18145
18146 // packages/admin-ui/build-module/page/index.mjs
18147 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
18148 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
18149 function getRuntime5() {
18150 const globalScope = globalThis;
18151 if (globalScope.__wpStyleRuntime) {
18152 return globalScope.__wpStyleRuntime;
18153 }
18154 globalScope.__wpStyleRuntime = {
18155 documents: /* @__PURE__ */ new Map(),
18156 styles: /* @__PURE__ */ new Map(),
18157 injectedStyles: /* @__PURE__ */ new WeakMap()
18158 };
18159 if (typeof document !== "undefined") {
18160 registerDocument5(document);
18161 }
18162 return globalScope.__wpStyleRuntime;
18163 }
18164 function documentContainsStyleHash5(targetDocument, hash) {
18165 if (!targetDocument.head) {
18166 return false;
18167 }
18168 for (const style of targetDocument.head.querySelectorAll(
18169 `style[${STYLE_HASH_ATTRIBUTE5}]`
18170 )) {
18171 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
18172 return true;
18173 }
18174 }
18175 return false;
18176 }
18177 function injectStyle5(targetDocument, hash, css) {
18178 if (!targetDocument.head) {
18179 return;
18180 }
18181 const runtime = getRuntime5();
18182 let injectedStyles = runtime.injectedStyles.get(targetDocument);
18183 if (!injectedStyles) {
18184 injectedStyles = /* @__PURE__ */ new Set();
18185 runtime.injectedStyles.set(targetDocument, injectedStyles);
18186 }
18187 if (injectedStyles.has(hash)) {
18188 return;
18189 }
18190 if (documentContainsStyleHash5(targetDocument, hash)) {
18191 injectedStyles.add(hash);
18192 return;
18193 }
18194 const style = targetDocument.createElement("style");
18195 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
18196 style.appendChild(targetDocument.createTextNode(css));
18197 targetDocument.head.appendChild(style);
18198 injectedStyles.add(hash);
18199 }
18200 function registerDocument5(targetDocument) {
18201 const runtime = getRuntime5();
18202 runtime.documents.set(
18203 targetDocument,
18204 (runtime.documents.get(targetDocument) ?? 0) + 1
18205 );
18206 for (const [hash, css] of runtime.styles) {
18207 injectStyle5(targetDocument, hash, css);
18208 }
18209 return () => {
18210 const count = runtime.documents.get(targetDocument);
18211 if (count === void 0) {
18212 return;
18213 }
18214 if (count <= 1) {
18215 runtime.documents.delete(targetDocument);
18216 return;
18217 }
18218 runtime.documents.set(targetDocument, count - 1);
18219 };
18220 }
18221 function registerStyle5(hash, css) {
18222 const runtime = getRuntime5();
18223 runtime.styles.set(hash, css);
18224 for (const targetDocument of runtime.documents.keys()) {
18225 injectStyle5(targetDocument, hash, css);
18226 }
18227 }
18228 if (typeof process === "undefined" || true) {
18229 registerStyle5("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)}}");
18230 }
18231 var style_default5 = { "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" };
18232 function Page({
18233 headingLevel,
18234 breadcrumbs,
18235 badges,
18236 visual,
18237 title,
18238 subTitle,
18239 children,
18240 className,
18241 actions,
18242 ariaLabel,
18243 hasPadding = false,
18244 showSidebarToggle = true
18245 }) {
18246 const classes = clsx_default(style_default5.page, className);
18247 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
18248 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
18249 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
18250 Header,
18251 {
18252 headingLevel,
18253 breadcrumbs,
18254 badges,
18255 visual,
18256 title,
18257 subTitle,
18258 actions,
18259 showSidebarToggle
18260 }
18261 ),
18262 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
18263 "div",
18264 {
18265 className: clsx_default(
18266 style_default5.content,
18267 style_default5["has-padding"]
18268 ),
18269 children
18270 }
18271 ) : children
18272 ] });
18273 }
18274 Page.SidebarToggleFill = SidebarToggleFill;
18275 var page_default = Page;
18276
18277 // routes/pattern-list/stage.tsx
18278 var import_core_data4 = __toESM(require_core_data());
18279 var import_components46 = __toESM(require_components());
18280 var import_data11 = __toESM(require_data());
18281 var import_element64 = __toESM(require_element());
18282 var import_editor = __toESM(require_editor());
18283 var import_patterns3 = __toESM(require_patterns());
18284 var import_i18n47 = __toESM(require_i18n());
18285
18286 // routes/lock-unlock.ts
18287 var import_private_apis3 = __toESM(require_private_apis());
18288 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
18289 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
18290 "@wordpress/routes"
18291 );
18292
18293 // routes/pattern-list/view-utils.ts
18294 var import_i18n43 = __toESM(require_i18n());
18295 var LAYOUT_GRID2 = "grid";
18296 var LAYOUT_TABLE2 = "table";
18297 var DEFAULT_VIEW = {
18298 type: LAYOUT_GRID2,
18299 perPage: 20,
18300 sort: {
18301 field: "title",
18302 direction: "asc"
18303 },
18304 filters: [],
18305 fields: ["sync-status"],
18306 layout: {
18307 badgeFields: ["sync-status"]
18308 },
18309 titleField: "title",
18310 mediaField: "preview"
18311 };
18312 var DEFAULT_VIEWS = [
18313 {
18314 slug: "all",
18315 label: (0, import_i18n43.__)("All patterns")
18316 },
18317 {
18318 slug: "my-patterns",
18319 label: (0, import_i18n43.__)("My patterns")
18320 },
18321 {
18322 slug: "registered",
18323 label: (0, import_i18n43.__)("Registered")
18324 }
18325 ];
18326 var DEFAULT_LAYOUTS2 = {
18327 [LAYOUT_TABLE2]: true,
18328 [LAYOUT_GRID2]: {
18329 layout: {
18330 badgeFields: ["sync-status"]
18331 }
18332 }
18333 };
18334
18335 // routes/pattern-list/fields/preview.tsx
18336 var import_i18n44 = __toESM(require_i18n());
18337 import { Preview } from "@wordpress/lazy-editor";
18338 function PreviewField({ item }) {
18339 return /* @__PURE__ */ React.createElement(
18340 Preview,
18341 {
18342 blocks: item.blocks,
18343 content: item.content,
18344 description: item.description
18345 }
18346 );
18347 }
18348 var previewField = {
18349 label: (0, import_i18n44.__)("Preview"),
18350 id: "preview",
18351 render: PreviewField,
18352 enableSorting: false
18353 };
18354
18355 // routes/pattern-list/fields/sync-status.tsx
18356 var import_i18n45 = __toESM(require_i18n());
18357 var import_patterns = __toESM(require_patterns());
18358 var { PATTERN_SYNC_TYPES } = unlock3(import_patterns.privateApis);
18359 var OPERATOR_IS2 = "is";
18360 var SYNC_FILTERS = [
18361 {
18362 value: PATTERN_SYNC_TYPES.full,
18363 label: (0, import_i18n45._x)("Synced", "pattern (singular)"),
18364 description: (0, import_i18n45.__)("Patterns that are kept in sync across the site.")
18365 },
18366 {
18367 value: PATTERN_SYNC_TYPES.unsynced,
18368 label: (0, import_i18n45._x)("Not synced", "pattern (singular)"),
18369 description: (0, import_i18n45.__)(
18370 "Patterns that can be changed freely without affecting the site."
18371 )
18372 }
18373 ];
18374 var patternStatusField = {
18375 label: (0, import_i18n45.__)("Sync status"),
18376 id: "sync-status",
18377 render: ({ item }) => {
18378 const syncStatus = item.syncStatus;
18379 return /* @__PURE__ */ React.createElement(
18380 "span",
18381 {
18382 className: `routes-pattern-list__field-sync-status-${syncStatus}`
18383 },
18384 SYNC_FILTERS.find(({ value }) => value === syncStatus)?.label
18385 );
18386 },
18387 elements: SYNC_FILTERS,
18388 filterBy: {
18389 operators: [OPERATOR_IS2],
18390 isPrimary: true
18391 },
18392 enableSorting: false
18393 };
18394
18395 // routes/pattern-list/fields/category.tsx
18396 var import_i18n46 = __toESM(require_i18n());
18397 var import_data9 = __toESM(require_data());
18398 var import_core_data2 = __toESM(require_core_data());
18399 var import_element62 = __toESM(require_element());
18400 var OPERATOR_IS3 = "is";
18401 function CategoryField({ item }) {
18402 const blockPatternCategories = (0, import_data9.useSelect)(
18403 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
18404 []
18405 );
18406 const categoryLabels = (0, import_element62.useMemo)(() => {
18407 if (!item.categories || !Array.isArray(item.categories)) {
18408 return [];
18409 }
18410 return item.categories.map((catSlug) => {
18411 const category = blockPatternCategories?.find(
18412 (cat) => cat.name === catSlug
18413 );
18414 return category ? category.label || category.name : null;
18415 }).filter(Boolean);
18416 }, [item.categories, blockPatternCategories]);
18417 if (categoryLabels.length === 0) {
18418 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field__empty" }, "\u2014");
18419 }
18420 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field" }, categoryLabels.join(", "));
18421 }
18422 function usePatternCategories() {
18423 const userPatternCategories = (0, import_data9.useSelect)(
18424 (select2) => select2(import_core_data2.store).getUserPatternCategories(),
18425 []
18426 );
18427 const blockPatternCategories = (0, import_data9.useSelect)(
18428 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
18429 []
18430 );
18431 return (0, import_element62.useMemo)(() => {
18432 const categoryMap = /* @__PURE__ */ new Map();
18433 userPatternCategories?.forEach((cat) => {
18434 if (!categoryMap.has(cat.name)) {
18435 categoryMap.set(cat.name, {
18436 value: cat.name,
18437 label: cat.label || cat.name
18438 });
18439 }
18440 });
18441 blockPatternCategories?.forEach((cat) => {
18442 if (!categoryMap.has(cat.name)) {
18443 categoryMap.set(cat.name, {
18444 value: cat.name,
18445 label: cat.label || cat.name
18446 });
18447 }
18448 });
18449 return Array.from(categoryMap.values()).sort(
18450 (a2, b2) => a2.label.localeCompare(b2.label)
18451 );
18452 }, [userPatternCategories, blockPatternCategories]);
18453 }
18454 function usePatternCategoryField() {
18455 const categories = usePatternCategories();
18456 return {
18457 label: (0, import_i18n46.__)("Category"),
18458 id: "category",
18459 render: CategoryField,
18460 elements: categories,
18461 getValue: ({ item }) => {
18462 return item.categories;
18463 },
18464 filterBy: {
18465 operators: [OPERATOR_IS3],
18466 isPrimary: true
18467 },
18468 enableSorting: false
18469 };
18470 }
18471
18472 // routes/pattern-list/use-patterns.ts
18473 var import_data10 = __toESM(require_data());
18474 var import_core_data3 = __toESM(require_core_data());
18475 var import_element63 = __toESM(require_element());
18476 var import_patterns2 = __toESM(require_patterns());
18477 var import_block_editor = __toESM(require_block_editor());
18478
18479 // routes/pattern-list/utils.ts
18480 var filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex((item) => currentItem.name === item.name);
18481
18482 // routes/pattern-list/use-patterns.ts
18483 var {
18484 PATTERN_TYPES,
18485 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES2,
18486 EXCLUDED_PATTERN_SOURCES,
18487 PATTERN_DEFAULT_CATEGORY
18488 } = unlock3(import_patterns2.privateApis);
18489 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock3(
18490 import_block_editor.privateApis
18491 );
18492 function normalizeThemePattern(pattern) {
18493 return {
18494 id: pattern.name,
18495 title: pattern.title,
18496 content: pattern.content,
18497 keywords: pattern.keywords || [],
18498 type: PATTERN_TYPES.theme,
18499 // Normalize categories to always be an array of slugs
18500 categories: pattern.categories || [],
18501 // Theme patterns are always unsynced
18502 syncStatus: PATTERN_SYNC_TYPES2.unsynced,
18503 description: pattern.description || ""
18504 };
18505 }
18506 function normalizeUserPattern(pattern, userPatternCategories) {
18507 const categories = [];
18508 if (pattern.wp_pattern_category && Array.isArray(pattern.wp_pattern_category)) {
18509 pattern.wp_pattern_category.forEach((catId) => {
18510 const category = userPatternCategories?.find(
18511 (cat) => cat.id === catId
18512 );
18513 if (category) {
18514 categories.push(category.name);
18515 }
18516 });
18517 }
18518 const numericId = pattern.id;
18519 return {
18520 id: pattern.name || pattern.id.toString(),
18521 _recordId: numericId,
18522 // Keep numeric ID for permissions lookup
18523 keywords: [],
18524 type: PATTERN_TYPES.user,
18525 // Normalize categories to always be an array of slugs
18526 categories,
18527 // Normalize sync status
18528 syncStatus: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES2.full,
18529 title: typeof pattern.title === "string" ? pattern.title : pattern.title.raw,
18530 content: typeof pattern.content === "string" ? pattern.content : pattern.content.raw,
18531 description: pattern.excerpt?.raw || "",
18532 blocks: pattern.blocks
18533 };
18534 }
18535 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
18536 return unmatchedTerms.filter(
18537 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
18538 (unprocessedTerm) => unprocessedTerm.includes(term)
18539 )
18540 );
18541 };
18542 function getItemSearchRank(item, searchTerm, config) {
18543 const { categoryId, hasCategory, onlyFilterByCategory } = config;
18544 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === "my-patterns" && item.type === PATTERN_TYPES.user || hasCategory && hasCategory(item, categoryId || "") ? 1 : 0;
18545 if (!rank || onlyFilterByCategory) {
18546 return rank;
18547 }
18548 const normalizedSearchInput = normalizeString2(searchTerm);
18549 const normalizedTitle = normalizeString2(item.title);
18550 if (normalizedSearchInput === normalizedTitle) {
18551 rank += 30;
18552 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
18553 rank += 20;
18554 } else {
18555 const terms = [
18556 item.id,
18557 item.title,
18558 item.description,
18559 ...item.keywords
18560 ].join(" ");
18561 const normalizedSearchTerms = extractWords(normalizedSearchInput);
18562 const unmatchedTerms = removeMatchingTerms(
18563 normalizedSearchTerms,
18564 terms
18565 );
18566 if (unmatchedTerms.length === 0) {
18567 rank += 10;
18568 }
18569 }
18570 return rank;
18571 }
18572 function searchItems(items = [], searchInput = "", config = {}) {
18573 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
18574 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
18575 const searchRankConfig = { ...config, onlyFilterByCategory };
18576 const threshold = onlyFilterByCategory ? 0 : 1;
18577 const rankedItems = items.map((item) => {
18578 return [
18579 item,
18580 getItemSearchRank(item, searchInput, searchRankConfig)
18581 ];
18582 }).filter(([, rank]) => rank > threshold);
18583 if (normalizedSearchTerms.length === 0) {
18584 return rankedItems.map(([item]) => item);
18585 }
18586 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
18587 return rankedItems.map(([item]) => item);
18588 }
18589 var selectThemePatterns = (0, import_data10.createSelector)(
18590 (select2) => {
18591 const { getBlockPatterns } = select2(import_core_data3.store);
18592 const { isResolving: isResolvingSelector } = select2(import_core_data3.store);
18593 const restBlockPatterns = getBlockPatterns();
18594 const patterns = (restBlockPatterns || []).filter(
18595 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
18596 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map(normalizeThemePattern);
18597 return {
18598 patterns,
18599 isResolving: isResolvingSelector("getBlockPatterns")
18600 };
18601 },
18602 (select2) => [
18603 select2(import_core_data3.store).getBlockPatterns(),
18604 select2(import_core_data3.store).isResolving("getBlockPatterns")
18605 ]
18606 );
18607 var selectUserPatterns = (0, import_data10.createSelector)(
18608 (select2, syncStatus = void 0, search = "") => {
18609 const {
18610 getEntityRecords,
18611 isResolving: isResolvingSelector,
18612 getUserPatternCategories
18613 } = select2(import_core_data3.store);
18614 const query = { per_page: -1 };
18615 const patternPosts = getEntityRecords(
18616 "postType",
18617 PATTERN_TYPES.user,
18618 query
18619 );
18620 const userPatternCategories = getUserPatternCategories();
18621 let patterns = (patternPosts ?? []).map(
18622 (pattern) => normalizeUserPattern(pattern, userPatternCategories)
18623 );
18624 const isResolving = isResolvingSelector("getEntityRecords", [
18625 "postType",
18626 PATTERN_TYPES.user,
18627 query
18628 ]);
18629 if (syncStatus) {
18630 patterns = patterns.filter(
18631 (pattern) => pattern.syncStatus === syncStatus
18632 );
18633 }
18634 patterns = searchItems(patterns, search, {
18635 // We exit user pattern retrieval early if we aren't in the
18636 // catch-all category for user created patterns, so it has
18637 // to be in the category.
18638 categoryId: PATTERN_DEFAULT_CATEGORY,
18639 hasCategory: () => true
18640 });
18641 return {
18642 patterns,
18643 isResolving,
18644 categories: userPatternCategories
18645 };
18646 },
18647 (select2) => [
18648 select2(import_core_data3.store).getEntityRecords("postType", PATTERN_TYPES.user, {
18649 per_page: -1
18650 }),
18651 select2(import_core_data3.store).isResolving("getEntityRecords", [
18652 "postType",
18653 PATTERN_TYPES.user,
18654 { per_page: -1 }
18655 ]),
18656 select2(import_core_data3.store).getUserPatternCategories()
18657 ]
18658 );
18659 var selectPatterns = (0, import_data10.createSelector)(
18660 (select2, categoryId, syncStatus, search = "") => {
18661 const {
18662 patterns: themePatterns,
18663 isResolving: isResolvingThemePatterns
18664 } = selectThemePatterns(select2);
18665 const { patterns: userPatterns, isResolving: isResolvingUserPatterns } = selectUserPatterns(select2);
18666 let patterns = [
18667 ...themePatterns || [],
18668 ...userPatterns || []
18669 ];
18670 if (syncStatus) {
18671 patterns = patterns.filter(
18672 (pattern) => pattern.syncStatus === syncStatus
18673 );
18674 }
18675 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
18676 patterns = searchItems(patterns, search, {
18677 categoryId,
18678 hasCategory: (item, currentCategory) => {
18679 return item.categories?.includes(currentCategory);
18680 }
18681 });
18682 } else {
18683 patterns = searchItems(patterns, search, {
18684 categoryId: PATTERN_DEFAULT_CATEGORY,
18685 hasCategory: () => true
18686 });
18687 }
18688 return {
18689 patterns,
18690 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
18691 };
18692 },
18693 (select2) => [
18694 selectThemePatterns(select2),
18695 selectUserPatterns(select2)
18696 ]
18697 );
18698 function useAugmentPatternsWithPermissions(patterns) {
18699 const idsAndTypes = (0, import_element63.useMemo)(
18700 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [
18701 record.type,
18702 record._recordId,
18703 record.id
18704 ]) ?? [],
18705 [patterns]
18706 );
18707 const permissions = (0, import_data10.useSelect)(
18708 (select2) => {
18709 const { getEntityRecordPermissions } = unlock3(
18710 select2(import_core_data3.store)
18711 );
18712 return idsAndTypes.reduce(
18713 (acc, [type, numericId, stringId]) => {
18714 acc[stringId] = getEntityRecordPermissions(
18715 "postType",
18716 type,
18717 numericId
18718 );
18719 return acc;
18720 },
18721 {}
18722 );
18723 },
18724 [idsAndTypes]
18725 );
18726 return (0, import_element63.useMemo)(
18727 () => patterns?.map((record) => ({
18728 ...record,
18729 permissions: permissions?.[record.id] ?? {}
18730 })) ?? [],
18731 [patterns, permissions]
18732 );
18733 }
18734 var usePatterns = (postType, categoryId, { search = "", syncStatus } = {}) => {
18735 return (0, import_data10.useSelect)(
18736 (select2) => {
18737 if (postType === PATTERN_TYPES.user) {
18738 const result = selectUserPatterns(select2, syncStatus, search);
18739 let { patterns } = result;
18740 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
18741 patterns = patterns.filter(
18742 (pattern) => pattern.categories.includes(categoryId)
18743 );
18744 }
18745 return {
18746 patterns,
18747 isResolving: result.isResolving
18748 };
18749 } else if (postType === PATTERN_TYPES.theme) {
18750 const result = selectThemePatterns(select2);
18751 let { patterns } = result;
18752 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
18753 patterns = patterns.filter(
18754 (pattern) => pattern.categories.includes(categoryId)
18755 );
18756 }
18757 patterns = searchItems(patterns, search, {
18758 categoryId: categoryId || PATTERN_DEFAULT_CATEGORY,
18759 hasCategory: () => true
18760 });
18761 return {
18762 patterns,
18763 isResolving: result.isResolving
18764 };
18765 }
18766 return selectPatterns(select2, categoryId, syncStatus, search);
18767 },
18768 [categoryId, postType, search, syncStatus]
18769 );
18770 };
18771 var use_patterns_default = usePatterns;
18772
18773 // routes/pattern-list/style.scss
18774 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='c329396b1f']")) {
18775 const style = document.createElement("style");
18776 style.setAttribute("data-wp-hash", "c329396b1f");
18777 style.appendChild(document.createTextNode(":root{--wp-block-synced-color:#7a00df;--wp-block-synced-color--rgb:122,0,223;--wp-bound-block-color:var(--wp-block-synced-color);--wp-editor-canvas-background:#ddd;--wp-admin-theme-color:#007cba;--wp-admin-theme-color--rgb:0,124,186;--wp-admin-theme-color-darker-10:#006ba1;--wp-admin-theme-color-darker-10--rgb:0,107,160.5;--wp-admin-theme-color-darker-20:#005a87;--wp-admin-theme-color-darker-20--rgb:0,90,135;--wp-admin-border-width-focus:2px}@media (min-resolution:192dpi){:root{--wp-admin-border-width-focus:1.5px}}.patterns-menu-items__convert-modal{z-index:1000001}.patterns-menu-items__convert-modal [role=dialog]>[role=document]{width:350px}.patterns-menu-items__convert-modal .patterns-menu-items__convert-modal-categories{position:relative}.patterns-menu-items__convert-modal .components-form-token-field__suggestions-list:not(:empty){background-color:#fff;border:1px solid var(--wp-admin-theme-color);border-bottom-left-radius:2px;border-bottom-right-radius:2px;box-shadow:0 0 .5px .5px var(--wp-admin-theme-color);box-sizing:border-box;left:-1px;max-height:96px;min-width:auto;position:absolute;width:calc(100% + 2px);z-index:1}.patterns-create-modal__name-input input[type=text]{margin:0}.patterns-rename-pattern-category-modal__validation-message{color:#cc1818}@media (min-width:782px){.patterns-rename-pattern-category-modal__validation-message{width:320px}}.pattern-overrides-control__allow-overrides-button{justify-content:center;width:100%}.routes-pattern-list__tabs-wrapper{border-bottom:1px solid #f0f0f0;padding:0 24px}.dataviews-view-grid__badge-fields .dataviews-view-grid__field-value:has(.routes-pattern-list__field-sync-status-fully){background:rgba(var(--wp-block-synced-color--rgb),.04);color:var(--wp-block-synced-color)}"));
18778 document.head.appendChild(style);
18779 }
18780
18781 // routes/pattern-list/stage.tsx
18782 var { usePostActions, patternTitleField } = unlock3(import_editor.privateApis);
18783 var { Tabs } = unlock3(import_components46.privateApis);
18784 var { PATTERN_TYPES: PATTERN_TYPES2, CreatePatternModal } = unlock3(import_patterns3.privateApis);
18785 function PatternList() {
18786 const invalidate = useInvalidate();
18787 const { type = "all" } = useParams({
18788 from: "/patterns/list/$type"
18789 });
18790 const navigate = useNavigate();
18791 const searchParams = useSearch({ from: "/patterns/list/$type" });
18792 const postTypeObject = (0, import_data11.useSelect)(
18793 (select2) => select2(import_core_data4.store).getPostType("wp_block"),
18794 []
18795 );
18796 const labels = postTypeObject?.labels;
18797 const canCreateRecord = (0, import_data11.useSelect)(
18798 (select2) => select2(import_core_data4.store).canUser("create", {
18799 kind: "postType",
18800 name: "wp_block"
18801 }),
18802 []
18803 );
18804 const [showPatternModal, setShowPatternModal] = (0, import_element64.useState)(false);
18805 const handleQueryParamsChange = (0, import_element64.useCallback)(
18806 (params) => {
18807 navigate({
18808 search: {
18809 ...searchParams,
18810 ...params
18811 }
18812 });
18813 },
18814 [searchParams, navigate]
18815 );
18816 const { view, isModified, updateView, resetToDefault } = useView({
18817 kind: "postType",
18818 name: "wp_block",
18819 slug: "default-new",
18820 defaultView: DEFAULT_VIEW,
18821 queryParams: searchParams,
18822 onChangeQueryParams: handleQueryParamsChange
18823 });
18824 const onReset = () => {
18825 resetToDefault();
18826 invalidate();
18827 };
18828 const onChangeView = (newView) => {
18829 updateView(newView);
18830 if (newView.type !== view.type) {
18831 invalidate();
18832 }
18833 };
18834 const categoryFilter = (0, import_element64.useMemo)(() => {
18835 const filter = view.filters?.find((f2) => f2.field === "category");
18836 return filter?.value || "all-patterns";
18837 }, [view.filters]);
18838 const syncStatusFilter = (0, import_element64.useMemo)(() => {
18839 const filter = view.filters?.find((f2) => f2.field === "sync-status");
18840 return filter?.value;
18841 }, [view.filters]);
18842 const patternType = (0, import_element64.useMemo)(() => {
18843 if (type === "my-patterns") {
18844 return PATTERN_TYPES2.user;
18845 } else if (type === "registered") {
18846 return PATTERN_TYPES2.theme;
18847 }
18848 return null;
18849 }, [type]);
18850 const { patterns, isResolving } = use_patterns_default(
18851 patternType,
18852 categoryFilter,
18853 {
18854 search: view.search,
18855 syncStatus: syncStatusFilter
18856 }
18857 );
18858 const patternsWithPermissions = useAugmentPatternsWithPermissions(patterns);
18859 const patternCategoryField = usePatternCategoryField();
18860 const fields = (0, import_element64.useMemo)(() => {
18861 const patternFields = [
18862 previewField,
18863 patternTitleField,
18864 patternCategoryField
18865 ];
18866 if (type === "my-patterns" || type === "all") {
18867 patternFields.push(patternStatusField);
18868 }
18869 return patternFields;
18870 }, [type, patternCategoryField]);
18871 const { data: posts, paginationInfo } = (0, import_element64.useMemo)(() => {
18872 const viewWithoutFilters = { ...view };
18873 delete viewWithoutFilters.search;
18874 viewWithoutFilters.filters = [];
18875 return filterSortAndPaginate(
18876 patternsWithPermissions,
18877 viewWithoutFilters,
18878 fields
18879 );
18880 }, [patternsWithPermissions, view, fields]);
18881 const { totalItems, totalPages } = paginationInfo;
18882 const cleanupDeletedPostIdsFromUrl = (0, import_element64.useCallback)(
18883 (deletedItems) => {
18884 const deletedIds = deletedItems.map((item) => item.id);
18885 const currentPostIds = searchParams.postIds || [];
18886 const remainingPostIds = currentPostIds.filter(
18887 (id) => !deletedIds.includes(id)
18888 );
18889 if (remainingPostIds.length !== currentPostIds.length) {
18890 navigate({
18891 search: {
18892 ...searchParams,
18893 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0
18894 }
18895 });
18896 } else {
18897 invalidate();
18898 }
18899 },
18900 [invalidate, searchParams, navigate]
18901 );
18902 const postTypeActions = usePostActions({
18903 postType: "wp_block",
18904 context: "list",
18905 onActionPerformed: (actionId, items) => {
18906 if (actionId === "move-to-trash" || actionId === "permanently-delete") {
18907 cleanupDeletedPostIdsFromUrl(items);
18908 }
18909 }
18910 });
18911 const actions = (0, import_element64.useMemo)(() => {
18912 return [
18913 ...postTypeActions?.flatMap((action) => {
18914 if (action.id === "view-post-revisions") {
18915 return [];
18916 }
18917 return [action];
18918 })
18919 ];
18920 }, [postTypeActions]);
18921 const handleTabChange = (0, import_element64.useCallback)(
18922 (typeSlug) => {
18923 navigate({
18924 to: `/patterns/list/${typeSlug}`
18925 });
18926 },
18927 [navigate]
18928 );
18929 if (!postTypeObject) {
18930 return null;
18931 }
18932 const selection = searchParams.postIds ?? [];
18933 if (view.type === "list" && selection.length === 0 && posts?.length > 0) {
18934 selection.push(posts[0].id);
18935 }
18936 if (view.type === "list") {
18937 selection.splice(1);
18938 }
18939 return /* @__PURE__ */ React.createElement(
18940 page_default,
18941 {
18942 title: (0, import_i18n47.__)("Patterns"),
18943 headingLevel: 2,
18944 subTitle: (0, import_i18n47.__)(
18945 "Reusable design elements for your site. Create once, use everywhere."
18946 ),
18947 className: "pattern-page",
18948 actions: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement(
18949 import_components46.Button,
18950 {
18951 variant: "primary",
18952 onClick: () => setShowPatternModal(true),
18953 size: "compact"
18954 },
18955 labels.add_new_item
18956 ),
18957 hasPadding: false
18958 },
18959 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-pattern-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement(
18960 Tabs,
18961 {
18962 onSelect: handleTabChange,
18963 selectedTabId: type ?? "all"
18964 },
18965 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map(
18966 (filter) => /* @__PURE__ */ React.createElement(
18967 Tabs.Tab,
18968 {
18969 tabId: filter.slug,
18970 key: filter.slug
18971 },
18972 filter.label
18973 )
18974 ))
18975 )),
18976 /* @__PURE__ */ React.createElement(
18977 dataviews_default,
18978 {
18979 data: posts,
18980 fields,
18981 view,
18982 onChangeView,
18983 actions,
18984 isLoading: isResolving,
18985 paginationInfo: {
18986 totalItems,
18987 totalPages
18988 },
18989 defaultLayouts: DEFAULT_LAYOUTS2,
18990 selection,
18991 onReset: isModified ? onReset : false,
18992 onChangeSelection: (items) => {
18993 navigate({
18994 search: {
18995 ...searchParams,
18996 postIds: items.length > 0 ? items : void 0,
18997 edit: items.length === 0 ? void 0 : searchParams.edit
18998 }
18999 });
19000 },
19001 isItemClickable: (item) => item.type !== PATTERN_TYPES2.theme,
19002 renderItemLink: ({
19003 item,
19004 ...props
19005 }) => /* @__PURE__ */ React.createElement(
19006 Link,
19007 {
19008 to: `/types/wp_block/edit/${encodeURIComponent(
19009 item.id
19010 )}`,
19011 ...props,
19012 onClick: (event) => {
19013 event.stopPropagation();
19014 }
19015 }
19016 )
19017 }
19018 ),
19019 showPatternModal && /* @__PURE__ */ React.createElement(
19020 CreatePatternModal,
19021 {
19022 onClose: () => setShowPatternModal(false),
19023 onSuccess: ({
19024 pattern
19025 }) => {
19026 setShowPatternModal(false);
19027 navigate({
19028 to: `/types/wp_block/edit/${encodeURIComponent(
19029 pattern.id
19030 )}`
19031 });
19032 },
19033 content: []
19034 }
19035 )
19036 );
19037 }
19038 var stage = PatternList;
19039 export {
19040 stage
19041 };
19042 /*! Bundled license information:
19043
19044 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
19045 (**
19046 * @license React
19047 * use-sync-external-store-shim.development.js
19048 *
19049 * Copyright (c) Meta Platforms, Inc. and affiliates.
19050 *
19051 * This source code is licensed under the MIT license found in the
19052 * LICENSE file in the root directory of this source tree.
19053 *)
19054 */
19055