PluginProbe
Gutenberg / 23.0.1
Gutenberg v23.0.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 / guidelines / content.js

content.js in Gutenberg 23.0.1, at build/routes/guidelines/content.js

22,849 lines 784.5 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 __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/components
39 var require_components = __commonJS({
40 "package-external:@wordpress/components"(exports, module) {
41 module.exports = window.wp.components;
42 }
43 });
44
45 // vendor-external:react/jsx-runtime
46 var require_jsx_runtime = __commonJS({
47 "vendor-external:react/jsx-runtime"(exports, module) {
48 module.exports = window.ReactJSXRuntime;
49 }
50 });
51
52 // package-external:@wordpress/element
53 var require_element = __commonJS({
54 "package-external:@wordpress/element"(exports, module) {
55 module.exports = window.wp.element;
56 }
57 });
58
59 // vendor-external:react
60 var require_react = __commonJS({
61 "vendor-external:react"(exports, module) {
62 module.exports = window.React;
63 }
64 });
65
66 // vendor-external:react-dom
67 var require_react_dom = __commonJS({
68 "vendor-external:react-dom"(exports, module) {
69 module.exports = window.ReactDOM;
70 }
71 });
72
73 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
74 var require_use_sync_external_store_shim_development = __commonJS({
75 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
76 "use strict";
77 (function() {
78 function is(x2, y2) {
79 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
80 }
81 function useSyncExternalStore$2(subscribe2, getSnapshot) {
82 didWarnOld18Alpha || void 0 === React26.startTransition || (didWarnOld18Alpha = true, console.error(
83 "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."
84 ));
85 var value = getSnapshot();
86 if (!didWarnUncachedGetSnapshot) {
87 var cachedValue = getSnapshot();
88 objectIs(value, cachedValue) || (console.error(
89 "The result of getSnapshot should be cached to avoid an infinite loop"
90 ), didWarnUncachedGetSnapshot = true);
91 }
92 cachedValue = useState41({
93 inst: { value, getSnapshot }
94 });
95 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
96 useLayoutEffect5(
97 function() {
98 inst.value = value;
99 inst.getSnapshot = getSnapshot;
100 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
101 },
102 [subscribe2, value, getSnapshot]
103 );
104 useEffect36(
105 function() {
106 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
107 return subscribe2(function() {
108 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
109 });
110 },
111 [subscribe2]
112 );
113 useDebugValue(value);
114 return value;
115 }
116 function checkIfSnapshotChanged(inst) {
117 var latestGetSnapshot = inst.getSnapshot;
118 inst = inst.value;
119 try {
120 var nextValue = latestGetSnapshot();
121 return !objectIs(inst, nextValue);
122 } catch (error2) {
123 return true;
124 }
125 }
126 function useSyncExternalStore$1(subscribe2, getSnapshot) {
127 return getSnapshot();
128 }
129 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
130 var React26 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState41 = React26.useState, useEffect36 = React26.useEffect, useLayoutEffect5 = React26.useLayoutEffect, useDebugValue = React26.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
131 exports.useSyncExternalStore = void 0 !== React26.useSyncExternalStore ? React26.useSyncExternalStore : shim;
132 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
133 })();
134 }
135 });
136
137 // node_modules/use-sync-external-store/shim/index.js
138 var require_shim = __commonJS({
139 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
140 "use strict";
141 if (false) {
142 module.exports = null;
143 } else {
144 module.exports = require_use_sync_external_store_shim_development();
145 }
146 }
147 });
148
149 // package-external:@wordpress/primitives
150 var require_primitives = __commonJS({
151 "package-external:@wordpress/primitives"(exports, module) {
152 module.exports = window.wp.primitives;
153 }
154 });
155
156 // package-external:@wordpress/private-apis
157 var require_private_apis = __commonJS({
158 "package-external:@wordpress/private-apis"(exports, module) {
159 module.exports = window.wp.privateApis;
160 }
161 });
162
163 // package-external:@wordpress/compose
164 var require_compose = __commonJS({
165 "package-external:@wordpress/compose"(exports, module) {
166 module.exports = window.wp.compose;
167 }
168 });
169
170 // package-external:@wordpress/keycodes
171 var require_keycodes = __commonJS({
172 "package-external:@wordpress/keycodes"(exports, module) {
173 module.exports = window.wp.keycodes;
174 }
175 });
176
177 // package-external:@wordpress/data
178 var require_data = __commonJS({
179 "package-external:@wordpress/data"(exports, module) {
180 module.exports = window.wp.data;
181 }
182 });
183
184 // node_modules/remove-accents/index.js
185 var require_remove_accents = __commonJS({
186 "node_modules/remove-accents/index.js"(exports, module) {
187 var characterMap = {
188 "\xC0": "A",
189 "\xC1": "A",
190 "\xC2": "A",
191 "\xC3": "A",
192 "\xC4": "A",
193 "\xC5": "A",
194 "\u1EA4": "A",
195 "\u1EAE": "A",
196 "\u1EB2": "A",
197 "\u1EB4": "A",
198 "\u1EB6": "A",
199 "\xC6": "AE",
200 "\u1EA6": "A",
201 "\u1EB0": "A",
202 "\u0202": "A",
203 "\u1EA2": "A",
204 "\u1EA0": "A",
205 "\u1EA8": "A",
206 "\u1EAA": "A",
207 "\u1EAC": "A",
208 "\xC7": "C",
209 "\u1E08": "C",
210 "\xC8": "E",
211 "\xC9": "E",
212 "\xCA": "E",
213 "\xCB": "E",
214 "\u1EBE": "E",
215 "\u1E16": "E",
216 "\u1EC0": "E",
217 "\u1E14": "E",
218 "\u1E1C": "E",
219 "\u0206": "E",
220 "\u1EBA": "E",
221 "\u1EBC": "E",
222 "\u1EB8": "E",
223 "\u1EC2": "E",
224 "\u1EC4": "E",
225 "\u1EC6": "E",
226 "\xCC": "I",
227 "\xCD": "I",
228 "\xCE": "I",
229 "\xCF": "I",
230 "\u1E2E": "I",
231 "\u020A": "I",
232 "\u1EC8": "I",
233 "\u1ECA": "I",
234 "\xD0": "D",
235 "\xD1": "N",
236 "\xD2": "O",
237 "\xD3": "O",
238 "\xD4": "O",
239 "\xD5": "O",
240 "\xD6": "O",
241 "\xD8": "O",
242 "\u1ED0": "O",
243 "\u1E4C": "O",
244 "\u1E52": "O",
245 "\u020E": "O",
246 "\u1ECE": "O",
247 "\u1ECC": "O",
248 "\u1ED4": "O",
249 "\u1ED6": "O",
250 "\u1ED8": "O",
251 "\u1EDC": "O",
252 "\u1EDE": "O",
253 "\u1EE0": "O",
254 "\u1EDA": "O",
255 "\u1EE2": "O",
256 "\xD9": "U",
257 "\xDA": "U",
258 "\xDB": "U",
259 "\xDC": "U",
260 "\u1EE6": "U",
261 "\u1EE4": "U",
262 "\u1EEC": "U",
263 "\u1EEE": "U",
264 "\u1EF0": "U",
265 "\xDD": "Y",
266 "\xE0": "a",
267 "\xE1": "a",
268 "\xE2": "a",
269 "\xE3": "a",
270 "\xE4": "a",
271 "\xE5": "a",
272 "\u1EA5": "a",
273 "\u1EAF": "a",
274 "\u1EB3": "a",
275 "\u1EB5": "a",
276 "\u1EB7": "a",
277 "\xE6": "ae",
278 "\u1EA7": "a",
279 "\u1EB1": "a",
280 "\u0203": "a",
281 "\u1EA3": "a",
282 "\u1EA1": "a",
283 "\u1EA9": "a",
284 "\u1EAB": "a",
285 "\u1EAD": "a",
286 "\xE7": "c",
287 "\u1E09": "c",
288 "\xE8": "e",
289 "\xE9": "e",
290 "\xEA": "e",
291 "\xEB": "e",
292 "\u1EBF": "e",
293 "\u1E17": "e",
294 "\u1EC1": "e",
295 "\u1E15": "e",
296 "\u1E1D": "e",
297 "\u0207": "e",
298 "\u1EBB": "e",
299 "\u1EBD": "e",
300 "\u1EB9": "e",
301 "\u1EC3": "e",
302 "\u1EC5": "e",
303 "\u1EC7": "e",
304 "\xEC": "i",
305 "\xED": "i",
306 "\xEE": "i",
307 "\xEF": "i",
308 "\u1E2F": "i",
309 "\u020B": "i",
310 "\u1EC9": "i",
311 "\u1ECB": "i",
312 "\xF0": "d",
313 "\xF1": "n",
314 "\xF2": "o",
315 "\xF3": "o",
316 "\xF4": "o",
317 "\xF5": "o",
318 "\xF6": "o",
319 "\xF8": "o",
320 "\u1ED1": "o",
321 "\u1E4D": "o",
322 "\u1E53": "o",
323 "\u020F": "o",
324 "\u1ECF": "o",
325 "\u1ECD": "o",
326 "\u1ED5": "o",
327 "\u1ED7": "o",
328 "\u1ED9": "o",
329 "\u1EDD": "o",
330 "\u1EDF": "o",
331 "\u1EE1": "o",
332 "\u1EDB": "o",
333 "\u1EE3": "o",
334 "\xF9": "u",
335 "\xFA": "u",
336 "\xFB": "u",
337 "\xFC": "u",
338 "\u1EE7": "u",
339 "\u1EE5": "u",
340 "\u1EED": "u",
341 "\u1EEF": "u",
342 "\u1EF1": "u",
343 "\xFD": "y",
344 "\xFF": "y",
345 "\u0100": "A",
346 "\u0101": "a",
347 "\u0102": "A",
348 "\u0103": "a",
349 "\u0104": "A",
350 "\u0105": "a",
351 "\u0106": "C",
352 "\u0107": "c",
353 "\u0108": "C",
354 "\u0109": "c",
355 "\u010A": "C",
356 "\u010B": "c",
357 "\u010C": "C",
358 "\u010D": "c",
359 "C\u0306": "C",
360 "c\u0306": "c",
361 "\u010E": "D",
362 "\u010F": "d",
363 "\u0110": "D",
364 "\u0111": "d",
365 "\u0112": "E",
366 "\u0113": "e",
367 "\u0114": "E",
368 "\u0115": "e",
369 "\u0116": "E",
370 "\u0117": "e",
371 "\u0118": "E",
372 "\u0119": "e",
373 "\u011A": "E",
374 "\u011B": "e",
375 "\u011C": "G",
376 "\u01F4": "G",
377 "\u011D": "g",
378 "\u01F5": "g",
379 "\u011E": "G",
380 "\u011F": "g",
381 "\u0120": "G",
382 "\u0121": "g",
383 "\u0122": "G",
384 "\u0123": "g",
385 "\u0124": "H",
386 "\u0125": "h",
387 "\u0126": "H",
388 "\u0127": "h",
389 "\u1E2A": "H",
390 "\u1E2B": "h",
391 "\u0128": "I",
392 "\u0129": "i",
393 "\u012A": "I",
394 "\u012B": "i",
395 "\u012C": "I",
396 "\u012D": "i",
397 "\u012E": "I",
398 "\u012F": "i",
399 "\u0130": "I",
400 "\u0131": "i",
401 "\u0132": "IJ",
402 "\u0133": "ij",
403 "\u0134": "J",
404 "\u0135": "j",
405 "\u0136": "K",
406 "\u0137": "k",
407 "\u1E30": "K",
408 "\u1E31": "k",
409 "K\u0306": "K",
410 "k\u0306": "k",
411 "\u0139": "L",
412 "\u013A": "l",
413 "\u013B": "L",
414 "\u013C": "l",
415 "\u013D": "L",
416 "\u013E": "l",
417 "\u013F": "L",
418 "\u0140": "l",
419 "\u0141": "l",
420 "\u0142": "l",
421 "\u1E3E": "M",
422 "\u1E3F": "m",
423 "M\u0306": "M",
424 "m\u0306": "m",
425 "\u0143": "N",
426 "\u0144": "n",
427 "\u0145": "N",
428 "\u0146": "n",
429 "\u0147": "N",
430 "\u0148": "n",
431 "\u0149": "n",
432 "N\u0306": "N",
433 "n\u0306": "n",
434 "\u014C": "O",
435 "\u014D": "o",
436 "\u014E": "O",
437 "\u014F": "o",
438 "\u0150": "O",
439 "\u0151": "o",
440 "\u0152": "OE",
441 "\u0153": "oe",
442 "P\u0306": "P",
443 "p\u0306": "p",
444 "\u0154": "R",
445 "\u0155": "r",
446 "\u0156": "R",
447 "\u0157": "r",
448 "\u0158": "R",
449 "\u0159": "r",
450 "R\u0306": "R",
451 "r\u0306": "r",
452 "\u0212": "R",
453 "\u0213": "r",
454 "\u015A": "S",
455 "\u015B": "s",
456 "\u015C": "S",
457 "\u015D": "s",
458 "\u015E": "S",
459 "\u0218": "S",
460 "\u0219": "s",
461 "\u015F": "s",
462 "\u0160": "S",
463 "\u0161": "s",
464 "\u0162": "T",
465 "\u0163": "t",
466 "\u021B": "t",
467 "\u021A": "T",
468 "\u0164": "T",
469 "\u0165": "t",
470 "\u0166": "T",
471 "\u0167": "t",
472 "T\u0306": "T",
473 "t\u0306": "t",
474 "\u0168": "U",
475 "\u0169": "u",
476 "\u016A": "U",
477 "\u016B": "u",
478 "\u016C": "U",
479 "\u016D": "u",
480 "\u016E": "U",
481 "\u016F": "u",
482 "\u0170": "U",
483 "\u0171": "u",
484 "\u0172": "U",
485 "\u0173": "u",
486 "\u0216": "U",
487 "\u0217": "u",
488 "V\u0306": "V",
489 "v\u0306": "v",
490 "\u0174": "W",
491 "\u0175": "w",
492 "\u1E82": "W",
493 "\u1E83": "w",
494 "X\u0306": "X",
495 "x\u0306": "x",
496 "\u0176": "Y",
497 "\u0177": "y",
498 "\u0178": "Y",
499 "Y\u0306": "Y",
500 "y\u0306": "y",
501 "\u0179": "Z",
502 "\u017A": "z",
503 "\u017B": "Z",
504 "\u017C": "z",
505 "\u017D": "Z",
506 "\u017E": "z",
507 "\u017F": "s",
508 "\u0192": "f",
509 "\u01A0": "O",
510 "\u01A1": "o",
511 "\u01AF": "U",
512 "\u01B0": "u",
513 "\u01CD": "A",
514 "\u01CE": "a",
515 "\u01CF": "I",
516 "\u01D0": "i",
517 "\u01D1": "O",
518 "\u01D2": "o",
519 "\u01D3": "U",
520 "\u01D4": "u",
521 "\u01D5": "U",
522 "\u01D6": "u",
523 "\u01D7": "U",
524 "\u01D8": "u",
525 "\u01D9": "U",
526 "\u01DA": "u",
527 "\u01DB": "U",
528 "\u01DC": "u",
529 "\u1EE8": "U",
530 "\u1EE9": "u",
531 "\u1E78": "U",
532 "\u1E79": "u",
533 "\u01FA": "A",
534 "\u01FB": "a",
535 "\u01FC": "AE",
536 "\u01FD": "ae",
537 "\u01FE": "O",
538 "\u01FF": "o",
539 "\xDE": "TH",
540 "\xFE": "th",
541 "\u1E54": "P",
542 "\u1E55": "p",
543 "\u1E64": "S",
544 "\u1E65": "s",
545 "X\u0301": "X",
546 "x\u0301": "x",
547 "\u0403": "\u0413",
548 "\u0453": "\u0433",
549 "\u040C": "\u041A",
550 "\u045C": "\u043A",
551 "A\u030B": "A",
552 "a\u030B": "a",
553 "E\u030B": "E",
554 "e\u030B": "e",
555 "I\u030B": "I",
556 "i\u030B": "i",
557 "\u01F8": "N",
558 "\u01F9": "n",
559 "\u1ED2": "O",
560 "\u1ED3": "o",
561 "\u1E50": "O",
562 "\u1E51": "o",
563 "\u1EEA": "U",
564 "\u1EEB": "u",
565 "\u1E80": "W",
566 "\u1E81": "w",
567 "\u1EF2": "Y",
568 "\u1EF3": "y",
569 "\u0200": "A",
570 "\u0201": "a",
571 "\u0204": "E",
572 "\u0205": "e",
573 "\u0208": "I",
574 "\u0209": "i",
575 "\u020C": "O",
576 "\u020D": "o",
577 "\u0210": "R",
578 "\u0211": "r",
579 "\u0214": "U",
580 "\u0215": "u",
581 "B\u030C": "B",
582 "b\u030C": "b",
583 "\u010C\u0323": "C",
584 "\u010D\u0323": "c",
585 "\xCA\u030C": "E",
586 "\xEA\u030C": "e",
587 "F\u030C": "F",
588 "f\u030C": "f",
589 "\u01E6": "G",
590 "\u01E7": "g",
591 "\u021E": "H",
592 "\u021F": "h",
593 "J\u030C": "J",
594 "\u01F0": "j",
595 "\u01E8": "K",
596 "\u01E9": "k",
597 "M\u030C": "M",
598 "m\u030C": "m",
599 "P\u030C": "P",
600 "p\u030C": "p",
601 "Q\u030C": "Q",
602 "q\u030C": "q",
603 "\u0158\u0329": "R",
604 "\u0159\u0329": "r",
605 "\u1E66": "S",
606 "\u1E67": "s",
607 "V\u030C": "V",
608 "v\u030C": "v",
609 "W\u030C": "W",
610 "w\u030C": "w",
611 "X\u030C": "X",
612 "x\u030C": "x",
613 "Y\u030C": "Y",
614 "y\u030C": "y",
615 "A\u0327": "A",
616 "a\u0327": "a",
617 "B\u0327": "B",
618 "b\u0327": "b",
619 "\u1E10": "D",
620 "\u1E11": "d",
621 "\u0228": "E",
622 "\u0229": "e",
623 "\u0190\u0327": "E",
624 "\u025B\u0327": "e",
625 "\u1E28": "H",
626 "\u1E29": "h",
627 "I\u0327": "I",
628 "i\u0327": "i",
629 "\u0197\u0327": "I",
630 "\u0268\u0327": "i",
631 "M\u0327": "M",
632 "m\u0327": "m",
633 "O\u0327": "O",
634 "o\u0327": "o",
635 "Q\u0327": "Q",
636 "q\u0327": "q",
637 "U\u0327": "U",
638 "u\u0327": "u",
639 "X\u0327": "X",
640 "x\u0327": "x",
641 "Z\u0327": "Z",
642 "z\u0327": "z",
643 "\u0439": "\u0438",
644 "\u0419": "\u0418",
645 "\u0451": "\u0435",
646 "\u0401": "\u0415"
647 };
648 var chars = Object.keys(characterMap).join("|");
649 var allAccents = new RegExp(chars, "g");
650 var firstAccent = new RegExp(chars, "");
651 function matcher(match2) {
652 return characterMap[match2];
653 }
654 var removeAccents3 = function(string) {
655 return string.replace(allAccents, matcher);
656 };
657 var hasAccents = function(string) {
658 return !!string.match(firstAccent);
659 };
660 module.exports = removeAccents3;
661 module.exports.has = hasAccents;
662 module.exports.remove = removeAccents3;
663 }
664 });
665
666 // node_modules/fast-deep-equal/es6/index.js
667 var require_es6 = __commonJS({
668 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
669 "use strict";
670 module.exports = function equal(a2, b2) {
671 if (a2 === b2) return true;
672 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
673 if (a2.constructor !== b2.constructor) return false;
674 var length, i2, keys;
675 if (Array.isArray(a2)) {
676 length = a2.length;
677 if (length != b2.length) return false;
678 for (i2 = length; i2-- !== 0; )
679 if (!equal(a2[i2], b2[i2])) return false;
680 return true;
681 }
682 if (a2 instanceof Map && b2 instanceof Map) {
683 if (a2.size !== b2.size) return false;
684 for (i2 of a2.entries())
685 if (!b2.has(i2[0])) return false;
686 for (i2 of a2.entries())
687 if (!equal(i2[1], b2.get(i2[0]))) return false;
688 return true;
689 }
690 if (a2 instanceof Set && b2 instanceof Set) {
691 if (a2.size !== b2.size) return false;
692 for (i2 of a2.entries())
693 if (!b2.has(i2[0])) return false;
694 return true;
695 }
696 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
697 length = a2.length;
698 if (length != b2.length) return false;
699 for (i2 = length; i2-- !== 0; )
700 if (a2[i2] !== b2[i2]) return false;
701 return true;
702 }
703 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
704 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
705 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
706 keys = Object.keys(a2);
707 length = keys.length;
708 if (length !== Object.keys(b2).length) return false;
709 for (i2 = length; i2-- !== 0; )
710 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
711 for (i2 = length; i2-- !== 0; ) {
712 var key = keys[i2];
713 if (!equal(a2[key], b2[key])) return false;
714 }
715 return true;
716 }
717 return a2 !== a2 && b2 !== b2;
718 };
719 }
720 });
721
722 // package-external:@wordpress/date
723 var require_date = __commonJS({
724 "package-external:@wordpress/date"(exports, module) {
725 module.exports = window.wp.date;
726 }
727 });
728
729 // package-external:@wordpress/warning
730 var require_warning = __commonJS({
731 "package-external:@wordpress/warning"(exports, module) {
732 module.exports = window.wp.warning;
733 }
734 });
735
736 // node_modules/deepmerge/dist/cjs.js
737 var require_cjs = __commonJS({
738 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
739 "use strict";
740 var isMergeableObject = function isMergeableObject2(value) {
741 return isNonNullObject(value) && !isSpecial(value);
742 };
743 function isNonNullObject(value) {
744 return !!value && typeof value === "object";
745 }
746 function isSpecial(value) {
747 var stringValue = Object.prototype.toString.call(value);
748 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
749 }
750 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
751 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
752 function isReactElement(value) {
753 return value.$$typeof === REACT_ELEMENT_TYPE;
754 }
755 function emptyTarget(val) {
756 return Array.isArray(val) ? [] : {};
757 }
758 function cloneUnlessOtherwiseSpecified(value, options) {
759 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
760 }
761 function defaultArrayMerge(target, source, options) {
762 return target.concat(source).map(function(element) {
763 return cloneUnlessOtherwiseSpecified(element, options);
764 });
765 }
766 function getMergeFunction(key, options) {
767 if (!options.customMerge) {
768 return deepmerge;
769 }
770 var customMerge = options.customMerge(key);
771 return typeof customMerge === "function" ? customMerge : deepmerge;
772 }
773 function getEnumerableOwnPropertySymbols(target) {
774 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
775 return Object.propertyIsEnumerable.call(target, symbol3);
776 }) : [];
777 }
778 function getKeys2(target) {
779 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
780 }
781 function propertyIsOnObject(object, property) {
782 try {
783 return property in object;
784 } catch (_) {
785 return false;
786 }
787 }
788 function propertyIsUnsafe(target, key) {
789 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
790 }
791 function mergeObject(target, source, options) {
792 var destination = {};
793 if (options.isMergeableObject(target)) {
794 getKeys2(target).forEach(function(key) {
795 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
796 });
797 }
798 getKeys2(source).forEach(function(key) {
799 if (propertyIsUnsafe(target, key)) {
800 return;
801 }
802 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
803 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
804 } else {
805 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
806 }
807 });
808 return destination;
809 }
810 function deepmerge(target, source, options) {
811 options = options || {};
812 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
813 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
814 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
815 var sourceIsArray = Array.isArray(source);
816 var targetIsArray = Array.isArray(target);
817 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
818 if (!sourceAndTargetTypesMatch) {
819 return cloneUnlessOtherwiseSpecified(source, options);
820 } else if (sourceIsArray) {
821 return options.arrayMerge(target, source, options);
822 } else {
823 return mergeObject(target, source, options);
824 }
825 }
826 deepmerge.all = function deepmergeAll(array, options) {
827 if (!Array.isArray(array)) {
828 throw new Error("first argument should be an array");
829 }
830 return array.reduce(function(prev, next) {
831 return deepmerge(prev, next, options);
832 }, {});
833 };
834 var deepmerge_1 = deepmerge;
835 module.exports = deepmerge_1;
836 }
837 });
838
839 // package-external:@wordpress/deprecated
840 var require_deprecated = __commonJS({
841 "package-external:@wordpress/deprecated"(exports, module) {
842 module.exports = window.wp.deprecated;
843 }
844 });
845
846 // package-external:@wordpress/notices
847 var require_notices = __commonJS({
848 "package-external:@wordpress/notices"(exports, module) {
849 module.exports = window.wp.notices;
850 }
851 });
852
853 // package-external:@wordpress/api-fetch
854 var require_api_fetch = __commonJS({
855 "package-external:@wordpress/api-fetch"(exports, module) {
856 module.exports = window.wp.apiFetch;
857 }
858 });
859
860 // package-external:@wordpress/blob
861 var require_blob = __commonJS({
862 "package-external:@wordpress/blob"(exports, module) {
863 module.exports = window.wp.blob;
864 }
865 });
866
867 // package-external:@wordpress/blocks
868 var require_blocks = __commonJS({
869 "package-external:@wordpress/blocks"(exports, module) {
870 module.exports = window.wp.blocks;
871 }
872 });
873
874 // node_modules/clsx/dist/clsx.mjs
875 function r(e2) {
876 var t2, f2, n2 = "";
877 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
878 else if ("object" == typeof e2) if (Array.isArray(e2)) {
879 var o2 = e2.length;
880 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
881 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
882 return n2;
883 }
884 function clsx() {
885 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
886 return n2;
887 }
888 var clsx_default = clsx;
889
890 // packages/admin-ui/build-module/navigable-region/index.mjs
891 var import_element = __toESM(require_element(), 1);
892 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
893 var NavigableRegion = (0, import_element.forwardRef)(
894 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
895 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
896 Tag,
897 {
898 ref,
899 className: clsx_default("admin-ui-navigable-region", className),
900 "aria-label": ariaLabel,
901 role: "region",
902 tabIndex: "-1",
903 ...props,
904 children
905 }
906 );
907 }
908 );
909 NavigableRegion.displayName = "NavigableRegion";
910 var navigable_region_default = NavigableRegion;
911
912 // packages/ui/build-module/badge/badge.mjs
913 var import_element3 = __toESM(require_element(), 1);
914
915 // node_modules/@base-ui/utils/esm/useControlled.js
916 var React2 = __toESM(require_react(), 1);
917
918 // node_modules/@base-ui/utils/esm/error.js
919 var set;
920 if (true) {
921 set = /* @__PURE__ */ new Set();
922 }
923 function error(...messages) {
924 if (true) {
925 const messageKey = messages.join(" ");
926 if (!set.has(messageKey)) {
927 set.add(messageKey);
928 console.error(`Base UI: ${messageKey}`);
929 }
930 }
931 }
932
933 // node_modules/@base-ui/utils/esm/useControlled.js
934 function useControlled({
935 controlled,
936 default: defaultProp,
937 name,
938 state = "value"
939 }) {
940 const {
941 current: isControlled
942 } = React2.useRef(controlled !== void 0);
943 const [valueState, setValue] = React2.useState(defaultProp);
944 const value = isControlled ? controlled : valueState;
945 if (true) {
946 React2.useEffect(() => {
947 if (isControlled !== (controlled !== void 0)) {
948 error([`A component is changing the ${isControlled ? "" : "un"}controlled ${state} state of ${name} to be ${isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${name} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n"));
949 }
950 }, [state, name, controlled]);
951 const {
952 current: defaultValue2
953 } = React2.useRef(defaultProp);
954 React2.useEffect(() => {
955 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
956 error([`A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. To suppress this warning opt to use a controlled ${name}.`].join("\n"));
957 }
958 }, [defaultProp]);
959 }
960 const setValueIfUncontrolled = React2.useCallback((newValue) => {
961 if (!isControlled) {
962 setValue(newValue);
963 }
964 }, []);
965 return [value, setValueIfUncontrolled];
966 }
967 function serializeToDevModeString(input) {
968 let nextId = 0;
969 const seen = /* @__PURE__ */ new WeakMap();
970 try {
971 const result = JSON.stringify(input, function replacer(key, value) {
972 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
973 return void 0;
974 }
975 if (typeof value === "bigint") {
976 return `__bigint__:${value}`;
977 }
978 if (value !== null && typeof value === "object") {
979 const id = seen.get(value);
980 if (id !== void 0) {
981 return `__object__:${id}`;
982 }
983 seen.set(value, nextId);
984 nextId += 1;
985 }
986 return value;
987 });
988 return result ?? `__top__:${typeof input}`;
989 } catch {
990 return "__unserializable__";
991 }
992 }
993
994 // node_modules/@base-ui/utils/esm/useStableCallback.js
995 var React4 = __toESM(require_react(), 1);
996
997 // node_modules/@base-ui/utils/esm/useRefWithInit.js
998 var React3 = __toESM(require_react(), 1);
999 var UNINITIALIZED = {};
1000 function useRefWithInit(init2, initArg) {
1001 const ref = React3.useRef(UNINITIALIZED);
1002 if (ref.current === UNINITIALIZED) {
1003 ref.current = init2(initArg);
1004 }
1005 return ref;
1006 }
1007
1008 // node_modules/@base-ui/utils/esm/useStableCallback.js
1009 var useInsertionEffect = React4[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
1010 var useSafeInsertionEffect = (
1011 // React 17 doesn't have useInsertionEffect.
1012 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1013 useInsertionEffect !== React4.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1014 );
1015 function useStableCallback(callback) {
1016 const stable = useRefWithInit(createStableCallback).current;
1017 stable.next = callback;
1018 useSafeInsertionEffect(stable.effect);
1019 return stable.trampoline;
1020 }
1021 function createStableCallback() {
1022 const stable = {
1023 next: void 0,
1024 callback: assertNotCalled,
1025 trampoline: (...args) => stable.callback?.(...args),
1026 effect: () => {
1027 stable.callback = stable.next;
1028 }
1029 };
1030 return stable;
1031 }
1032 function assertNotCalled() {
1033 if (true) {
1034 throw (
1035 /* minify-error-disabled */
1036 new Error("Base UI: Cannot call an event handler while rendering.")
1037 );
1038 }
1039 }
1040
1041 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1042 var React5 = __toESM(require_react(), 1);
1043 var noop = () => {
1044 };
1045 var useIsoLayoutEffect = typeof document !== "undefined" ? React5.useLayoutEffect : noop;
1046
1047 // node_modules/@base-ui/utils/esm/warn.js
1048 var set2;
1049 if (true) {
1050 set2 = /* @__PURE__ */ new Set();
1051 }
1052 function warn(...messages) {
1053 if (true) {
1054 const messageKey = messages.join(" ");
1055 if (!set2.has(messageKey)) {
1056 set2.add(messageKey);
1057 console.warn(`Base UI: ${messageKey}`);
1058 }
1059 }
1060 }
1061
1062 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
1063 var React8 = __toESM(require_react(), 1);
1064
1065 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1066 function useMergedRefs(a2, b2, c2, d2) {
1067 const forkRef = useRefWithInit(createForkRef).current;
1068 if (didChange(forkRef, a2, b2, c2, d2)) {
1069 update(forkRef, [a2, b2, c2, d2]);
1070 }
1071 return forkRef.callback;
1072 }
1073 function useMergedRefsN(refs) {
1074 const forkRef = useRefWithInit(createForkRef).current;
1075 if (didChangeN(forkRef, refs)) {
1076 update(forkRef, refs);
1077 }
1078 return forkRef.callback;
1079 }
1080 function createForkRef() {
1081 return {
1082 callback: null,
1083 cleanup: null,
1084 refs: []
1085 };
1086 }
1087 function didChange(forkRef, a2, b2, c2, d2) {
1088 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1089 }
1090 function didChangeN(forkRef, newRefs) {
1091 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1092 }
1093 function update(forkRef, refs) {
1094 forkRef.refs = refs;
1095 if (refs.every((ref) => ref == null)) {
1096 forkRef.callback = null;
1097 return;
1098 }
1099 forkRef.callback = (instance) => {
1100 if (forkRef.cleanup) {
1101 forkRef.cleanup();
1102 forkRef.cleanup = null;
1103 }
1104 if (instance != null) {
1105 const cleanupCallbacks = Array(refs.length).fill(null);
1106 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1107 const ref = refs[i2];
1108 if (ref == null) {
1109 continue;
1110 }
1111 switch (typeof ref) {
1112 case "function": {
1113 const refCleanup = ref(instance);
1114 if (typeof refCleanup === "function") {
1115 cleanupCallbacks[i2] = refCleanup;
1116 }
1117 break;
1118 }
1119 case "object": {
1120 ref.current = instance;
1121 break;
1122 }
1123 default:
1124 }
1125 }
1126 forkRef.cleanup = () => {
1127 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1128 const ref = refs[i2];
1129 if (ref == null) {
1130 continue;
1131 }
1132 switch (typeof ref) {
1133 case "function": {
1134 const cleanupCallback = cleanupCallbacks[i2];
1135 if (typeof cleanupCallback === "function") {
1136 cleanupCallback();
1137 } else {
1138 ref(null);
1139 }
1140 break;
1141 }
1142 case "object": {
1143 ref.current = null;
1144 break;
1145 }
1146 default:
1147 }
1148 }
1149 };
1150 }
1151 };
1152 }
1153
1154 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1155 var React7 = __toESM(require_react(), 1);
1156
1157 // node_modules/@base-ui/utils/esm/reactVersion.js
1158 var React6 = __toESM(require_react(), 1);
1159 var majorVersion = parseInt(React6.version, 10);
1160 function isReactVersionAtLeast(reactVersionToCheck) {
1161 return majorVersion >= reactVersionToCheck;
1162 }
1163
1164 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1165 function getReactElementRef(element) {
1166 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1167 return null;
1168 }
1169 const reactElement = element;
1170 const propsWithRef = reactElement.props;
1171 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1172 }
1173
1174 // node_modules/@base-ui/utils/esm/mergeObjects.js
1175 function mergeObjects(a2, b2) {
1176 if (a2 && !b2) {
1177 return a2;
1178 }
1179 if (!a2 && b2) {
1180 return b2;
1181 }
1182 if (a2 || b2) {
1183 return {
1184 ...a2,
1185 ...b2
1186 };
1187 }
1188 return void 0;
1189 }
1190
1191 // node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
1192 function getStateAttributesProps(state, customMapping) {
1193 const props = {};
1194 for (const key in state) {
1195 const value = state[key];
1196 if (customMapping?.hasOwnProperty(key)) {
1197 const customProps = customMapping[key](value);
1198 if (customProps != null) {
1199 Object.assign(props, customProps);
1200 }
1201 continue;
1202 }
1203 if (value === true) {
1204 props[`data-${key.toLowerCase()}`] = "";
1205 } else if (value) {
1206 props[`data-${key.toLowerCase()}`] = value.toString();
1207 }
1208 }
1209 return props;
1210 }
1211
1212 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1213 function resolveClassName(className, state) {
1214 return typeof className === "function" ? className(state) : className;
1215 }
1216
1217 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1218 function resolveStyle(style, state) {
1219 return typeof style === "function" ? style(state) : style;
1220 }
1221
1222 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1223 var EMPTY_PROPS = {};
1224 function mergeProps(a2, b2, c2, d2, e2) {
1225 if (!c2 && !d2 && !e2 && !a2) {
1226 return createInitialMergedProps(b2);
1227 }
1228 let merged = createInitialMergedProps(a2);
1229 if (b2) {
1230 merged = mergeInto(merged, b2);
1231 }
1232 if (c2) {
1233 merged = mergeInto(merged, c2);
1234 }
1235 if (d2) {
1236 merged = mergeInto(merged, d2);
1237 }
1238 if (e2) {
1239 merged = mergeInto(merged, e2);
1240 }
1241 return merged;
1242 }
1243 function mergePropsN(props) {
1244 if (props.length === 0) {
1245 return EMPTY_PROPS;
1246 }
1247 if (props.length === 1) {
1248 return createInitialMergedProps(props[0]);
1249 }
1250 let merged = createInitialMergedProps(props[0]);
1251 for (let i2 = 1; i2 < props.length; i2 += 1) {
1252 merged = mergeInto(merged, props[i2]);
1253 }
1254 return merged;
1255 }
1256 function createInitialMergedProps(inputProps) {
1257 if (isPropsGetter(inputProps)) {
1258 return {
1259 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1260 };
1261 }
1262 return copyInitialProps(inputProps);
1263 }
1264 function mergeInto(merged, inputProps) {
1265 if (isPropsGetter(inputProps)) {
1266 return resolvePropsGetter(inputProps, merged);
1267 }
1268 return mutablyMergeInto(merged, inputProps);
1269 }
1270 function copyInitialProps(inputProps) {
1271 const copiedProps = {
1272 ...inputProps
1273 };
1274 for (const propName in copiedProps) {
1275 const propValue = copiedProps[propName];
1276 if (isEventHandler(propName, propValue)) {
1277 copiedProps[propName] = wrapEventHandler(propValue);
1278 }
1279 }
1280 return copiedProps;
1281 }
1282 function mutablyMergeInto(mergedProps, externalProps) {
1283 if (!externalProps) {
1284 return mergedProps;
1285 }
1286 for (const propName in externalProps) {
1287 const externalPropValue = externalProps[propName];
1288 switch (propName) {
1289 case "style": {
1290 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1291 break;
1292 }
1293 case "className": {
1294 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1295 break;
1296 }
1297 default: {
1298 if (isEventHandler(propName, externalPropValue)) {
1299 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1300 } else {
1301 mergedProps[propName] = externalPropValue;
1302 }
1303 }
1304 }
1305 }
1306 return mergedProps;
1307 }
1308 function isEventHandler(key, value) {
1309 const code0 = key.charCodeAt(0);
1310 const code1 = key.charCodeAt(1);
1311 const code2 = key.charCodeAt(2);
1312 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1313 }
1314 function isPropsGetter(inputProps) {
1315 return typeof inputProps === "function";
1316 }
1317 function resolvePropsGetter(inputProps, previousProps) {
1318 if (isPropsGetter(inputProps)) {
1319 return inputProps(previousProps);
1320 }
1321 return inputProps ?? EMPTY_PROPS;
1322 }
1323 function mergeEventHandlers(ourHandler, theirHandler) {
1324 if (!theirHandler) {
1325 return ourHandler;
1326 }
1327 if (!ourHandler) {
1328 return wrapEventHandler(theirHandler);
1329 }
1330 return (event) => {
1331 if (isSyntheticEvent(event)) {
1332 const baseUIEvent = event;
1333 makeEventPreventable(baseUIEvent);
1334 const result2 = theirHandler(baseUIEvent);
1335 if (!baseUIEvent.baseUIHandlerPrevented) {
1336 ourHandler?.(baseUIEvent);
1337 }
1338 return result2;
1339 }
1340 const result = theirHandler(event);
1341 ourHandler?.(event);
1342 return result;
1343 };
1344 }
1345 function wrapEventHandler(handler) {
1346 if (!handler) {
1347 return handler;
1348 }
1349 return (event) => {
1350 if (isSyntheticEvent(event)) {
1351 makeEventPreventable(event);
1352 }
1353 return handler(event);
1354 };
1355 }
1356 function makeEventPreventable(event) {
1357 event.preventBaseUIHandler = () => {
1358 event.baseUIHandlerPrevented = true;
1359 };
1360 return event;
1361 }
1362 function mergeClassNames(ourClassName, theirClassName) {
1363 if (theirClassName) {
1364 if (ourClassName) {
1365 return theirClassName + " " + ourClassName;
1366 }
1367 return theirClassName;
1368 }
1369 return ourClassName;
1370 }
1371 function isSyntheticEvent(event) {
1372 return event != null && typeof event === "object" && "nativeEvent" in event;
1373 }
1374
1375 // node_modules/@base-ui/utils/esm/empty.js
1376 var EMPTY_ARRAY = Object.freeze([]);
1377 var EMPTY_OBJECT = Object.freeze({});
1378
1379 // node_modules/@base-ui/react/esm/utils/constants.js
1380 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
1381 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
1382 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
1383 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
1384
1385 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
1386 var import_react = __toESM(require_react(), 1);
1387 function useRenderElement(element, componentProps, params = {}) {
1388 const renderProp = componentProps.render;
1389 const outProps = useRenderElementProps(componentProps, params);
1390 if (params.enabled === false) {
1391 return null;
1392 }
1393 const state = params.state ?? EMPTY_OBJECT;
1394 return evaluateRenderProp(element, renderProp, outProps, state);
1395 }
1396 function useRenderElementProps(componentProps, params = {}) {
1397 const {
1398 className: classNameProp,
1399 style: styleProp,
1400 render: renderProp
1401 } = componentProps;
1402 const {
1403 state = EMPTY_OBJECT,
1404 ref,
1405 props,
1406 stateAttributesMapping: stateAttributesMapping2,
1407 enabled = true
1408 } = params;
1409 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1410 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1411 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping2) : EMPTY_OBJECT;
1412 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1413 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1414 if (typeof document !== "undefined") {
1415 if (!enabled) {
1416 useMergedRefs(null, null);
1417 } else if (Array.isArray(ref)) {
1418 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1419 } else {
1420 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1421 }
1422 }
1423 if (!enabled) {
1424 return EMPTY_OBJECT;
1425 }
1426 if (className !== void 0) {
1427 outProps.className = mergeClassNames(outProps.className, className);
1428 }
1429 if (style !== void 0) {
1430 outProps.style = mergeObjects(outProps.style, style);
1431 }
1432 return outProps;
1433 }
1434 function resolveRenderFunctionProps(props) {
1435 if (Array.isArray(props)) {
1436 return mergePropsN(props);
1437 }
1438 return mergeProps(void 0, props);
1439 }
1440 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1441 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1442 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1443 function evaluateRenderProp(element, render4, props, state) {
1444 if (render4) {
1445 if (typeof render4 === "function") {
1446 if (true) {
1447 warnIfRenderPropLooksLikeComponent(render4);
1448 }
1449 return render4(props, state);
1450 }
1451 const mergedProps = mergeProps(props, render4.props);
1452 mergedProps.ref = props.ref;
1453 let newElement = render4;
1454 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1455 const children = React8.Children.toArray(render4);
1456 newElement = children[0];
1457 }
1458 if (true) {
1459 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1460 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"));
1461 }
1462 }
1463 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1464 }
1465 if (element) {
1466 if (typeof element === "string") {
1467 return renderTag(element, props);
1468 }
1469 }
1470 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1471 }
1472 function warnIfRenderPropLooksLikeComponent(renderFn) {
1473 const functionName = renderFn.name;
1474 if (functionName.length === 0) {
1475 return;
1476 }
1477 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1478 return;
1479 }
1480 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1481 return;
1482 }
1483 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");
1484 }
1485 function renderTag(Tag, props) {
1486 if (Tag === "button") {
1487 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1488 type: "button",
1489 ...props,
1490 key: props.key
1491 });
1492 }
1493 if (Tag === "img") {
1494 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1495 alt: "",
1496 ...props,
1497 key: props.key
1498 });
1499 }
1500 return /* @__PURE__ */ React8.createElement(Tag, props);
1501 }
1502
1503 // node_modules/@base-ui/react/esm/utils/reason-parts.js
1504 var reason_parts_exports = {};
1505 __export(reason_parts_exports, {
1506 cancelOpen: () => cancelOpen,
1507 chipRemovePress: () => chipRemovePress,
1508 clearPress: () => clearPress,
1509 closePress: () => closePress,
1510 closeWatcher: () => closeWatcher,
1511 dayPress: () => dayPress,
1512 decrementPress: () => decrementPress,
1513 disabled: () => disabled,
1514 drag: () => drag,
1515 escapeKey: () => escapeKey,
1516 focusOut: () => focusOut,
1517 imperativeAction: () => imperativeAction,
1518 incrementPress: () => incrementPress,
1519 inputBlur: () => inputBlur,
1520 inputChange: () => inputChange,
1521 inputClear: () => inputClear,
1522 inputPaste: () => inputPaste,
1523 inputPress: () => inputPress,
1524 itemPress: () => itemPress,
1525 keyboard: () => keyboard,
1526 linkPress: () => linkPress,
1527 listNavigation: () => listNavigation,
1528 monthChange: () => monthChange,
1529 none: () => none,
1530 outsidePress: () => outsidePress,
1531 pointer: () => pointer,
1532 scrub: () => scrub,
1533 siblingOpen: () => siblingOpen,
1534 swipe: () => swipe,
1535 trackPress: () => trackPress,
1536 triggerFocus: () => triggerFocus,
1537 triggerHover: () => triggerHover,
1538 triggerPress: () => triggerPress,
1539 valuePropChange: () => valuePropChange,
1540 wheel: () => wheel,
1541 windowResize: () => windowResize
1542 });
1543 var none = "none";
1544 var triggerPress = "trigger-press";
1545 var triggerHover = "trigger-hover";
1546 var triggerFocus = "trigger-focus";
1547 var outsidePress = "outside-press";
1548 var itemPress = "item-press";
1549 var closePress = "close-press";
1550 var linkPress = "link-press";
1551 var clearPress = "clear-press";
1552 var chipRemovePress = "chip-remove-press";
1553 var trackPress = "track-press";
1554 var incrementPress = "increment-press";
1555 var decrementPress = "decrement-press";
1556 var inputChange = "input-change";
1557 var inputClear = "input-clear";
1558 var inputBlur = "input-blur";
1559 var inputPaste = "input-paste";
1560 var inputPress = "input-press";
1561 var focusOut = "focus-out";
1562 var escapeKey = "escape-key";
1563 var closeWatcher = "close-watcher";
1564 var listNavigation = "list-navigation";
1565 var keyboard = "keyboard";
1566 var pointer = "pointer";
1567 var drag = "drag";
1568 var wheel = "wheel";
1569 var scrub = "scrub";
1570 var cancelOpen = "cancel-open";
1571 var siblingOpen = "sibling-open";
1572 var disabled = "disabled";
1573 var imperativeAction = "imperative-action";
1574 var swipe = "swipe";
1575 var windowResize = "window-resize";
1576 var dayPress = "day-press";
1577 var monthChange = "month-change";
1578 var valuePropChange = "value-prop-change";
1579
1580 // node_modules/@base-ui/react/esm/utils/createBaseUIEventDetails.js
1581 function createChangeEventDetails(reason, event, trigger, customProperties) {
1582 let canceled = false;
1583 let allowPropagation = false;
1584 const custom = customProperties ?? EMPTY_OBJECT;
1585 const details = {
1586 reason,
1587 event: event ?? new Event("base-ui"),
1588 cancel() {
1589 canceled = true;
1590 },
1591 allowPropagation() {
1592 allowPropagation = true;
1593 },
1594 get isCanceled() {
1595 return canceled;
1596 },
1597 get isPropagationAllowed() {
1598 return allowPropagation;
1599 },
1600 trigger,
1601 ...custom
1602 };
1603 return details;
1604 }
1605
1606 // node_modules/@base-ui/utils/esm/useId.js
1607 var React10 = __toESM(require_react(), 1);
1608
1609 // node_modules/@base-ui/utils/esm/safeReact.js
1610 var React9 = __toESM(require_react(), 1);
1611 var SafeReact = {
1612 ...React9
1613 };
1614
1615 // node_modules/@base-ui/utils/esm/useId.js
1616 var globalId = 0;
1617 function useGlobalId(idOverride, prefix = "mui") {
1618 const [defaultId, setDefaultId] = React10.useState(idOverride);
1619 const id = idOverride || defaultId;
1620 React10.useEffect(() => {
1621 if (defaultId == null) {
1622 globalId += 1;
1623 setDefaultId(`${prefix}-${globalId}`);
1624 }
1625 }, [defaultId, prefix]);
1626 return id;
1627 }
1628 var maybeReactUseId = SafeReact.useId;
1629 function useId(idOverride, prefix) {
1630 if (maybeReactUseId !== void 0) {
1631 const reactId = maybeReactUseId();
1632 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1633 }
1634 return useGlobalId(idOverride, prefix);
1635 }
1636
1637 // node_modules/@base-ui/react/esm/utils/useBaseUiId.js
1638 function useBaseUiId(idOverride) {
1639 return useId(idOverride, "base-ui");
1640 }
1641
1642 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1643 var React13 = __toESM(require_react(), 1);
1644
1645 // node_modules/@base-ui/react/esm/utils/useAnimationsFinished.js
1646 var ReactDOM = __toESM(require_react_dom(), 1);
1647
1648 // node_modules/@base-ui/utils/esm/useOnMount.js
1649 var React11 = __toESM(require_react(), 1);
1650 var EMPTY = [];
1651 function useOnMount(fn) {
1652 React11.useEffect(fn, EMPTY);
1653 }
1654
1655 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1656 var EMPTY2 = null;
1657 var LAST_RAF = globalThis.requestAnimationFrame;
1658 var Scheduler = class {
1659 /* This implementation uses an array as a backing data-structure for frame callbacks.
1660 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1661 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1662 * be much more efficient if there is a call pattern that alterns as
1663 * "request-cancel-request-cancel-…".
1664 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1665 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1666 callbacks = [];
1667 callbacksCount = 0;
1668 nextId = 1;
1669 startId = 1;
1670 isScheduled = false;
1671 tick = (timestamp) => {
1672 this.isScheduled = false;
1673 const currentCallbacks = this.callbacks;
1674 const currentCallbacksCount = this.callbacksCount;
1675 this.callbacks = [];
1676 this.callbacksCount = 0;
1677 this.startId = this.nextId;
1678 if (currentCallbacksCount > 0) {
1679 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1680 currentCallbacks[i2]?.(timestamp);
1681 }
1682 }
1683 };
1684 request(fn) {
1685 const id = this.nextId;
1686 this.nextId += 1;
1687 this.callbacks.push(fn);
1688 this.callbacksCount += 1;
1689 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1690 if (!this.isScheduled || didRAFChange) {
1691 requestAnimationFrame(this.tick);
1692 this.isScheduled = true;
1693 }
1694 return id;
1695 }
1696 cancel(id) {
1697 const index = id - this.startId;
1698 if (index < 0 || index >= this.callbacks.length) {
1699 return;
1700 }
1701 this.callbacks[index] = null;
1702 this.callbacksCount -= 1;
1703 }
1704 };
1705 var scheduler = new Scheduler();
1706 var AnimationFrame = class _AnimationFrame {
1707 static create() {
1708 return new _AnimationFrame();
1709 }
1710 static request(fn) {
1711 return scheduler.request(fn);
1712 }
1713 static cancel(id) {
1714 return scheduler.cancel(id);
1715 }
1716 currentId = EMPTY2;
1717 /**
1718 * Executes `fn` after `delay`, clearing any previously scheduled call.
1719 */
1720 request(fn) {
1721 this.cancel();
1722 this.currentId = scheduler.request(() => {
1723 this.currentId = EMPTY2;
1724 fn();
1725 });
1726 }
1727 cancel = () => {
1728 if (this.currentId !== EMPTY2) {
1729 scheduler.cancel(this.currentId);
1730 this.currentId = EMPTY2;
1731 }
1732 };
1733 disposeEffect = () => {
1734 return this.cancel;
1735 };
1736 };
1737 function useAnimationFrame() {
1738 const timeout = useRefWithInit(AnimationFrame.create).current;
1739 useOnMount(timeout.disposeEffect);
1740 return timeout;
1741 }
1742
1743 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1744 function resolveRef(maybeRef) {
1745 if (maybeRef == null) {
1746 return maybeRef;
1747 }
1748 return "current" in maybeRef ? maybeRef.current : maybeRef;
1749 }
1750
1751 // node_modules/@base-ui/react/esm/utils/stateAttributesMapping.js
1752 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1753 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1754 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1755 return TransitionStatusDataAttributes2;
1756 })({});
1757 var STARTING_HOOK = {
1758 [TransitionStatusDataAttributes.startingStyle]: ""
1759 };
1760 var ENDING_HOOK = {
1761 [TransitionStatusDataAttributes.endingStyle]: ""
1762 };
1763 var transitionStatusMapping = {
1764 transitionStatus(value) {
1765 if (value === "starting") {
1766 return STARTING_HOOK;
1767 }
1768 if (value === "ending") {
1769 return ENDING_HOOK;
1770 }
1771 return null;
1772 }
1773 };
1774
1775 // node_modules/@base-ui/react/esm/utils/useAnimationsFinished.js
1776 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1777 const frame = useAnimationFrame();
1778 return useStableCallback((fnToExecute, signal = null) => {
1779 frame.cancel();
1780 const element = resolveRef(elementOrRef);
1781 if (element == null) {
1782 return;
1783 }
1784 const resolvedElement = element;
1785 const done = () => {
1786 ReactDOM.flushSync(fnToExecute);
1787 };
1788 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1789 fnToExecute();
1790 return;
1791 }
1792 function exec() {
1793 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1794 if (!signal?.aborted) {
1795 done();
1796 }
1797 }).catch(() => {
1798 if (treatAbortedAsFinished) {
1799 if (!signal?.aborted) {
1800 done();
1801 }
1802 return;
1803 }
1804 const currentAnimations = resolvedElement.getAnimations();
1805 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1806 exec();
1807 }
1808 });
1809 }
1810 if (waitForStartingStyleRemoved) {
1811 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1812 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1813 frame.request(exec);
1814 return;
1815 }
1816 const attributeObserver = new MutationObserver(() => {
1817 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1818 attributeObserver.disconnect();
1819 exec();
1820 }
1821 });
1822 attributeObserver.observe(resolvedElement, {
1823 attributes: true,
1824 attributeFilter: [startingStyleAttribute]
1825 });
1826 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1827 once: true
1828 });
1829 return;
1830 }
1831 frame.request(exec);
1832 });
1833 }
1834
1835 // node_modules/@base-ui/react/esm/utils/useTransitionStatus.js
1836 var React12 = __toESM(require_react(), 1);
1837 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1838 const [transitionStatus, setTransitionStatus] = React12.useState(open && enableIdleState ? "idle" : void 0);
1839 const [mounted, setMounted] = React12.useState(open);
1840 if (open && !mounted) {
1841 setMounted(true);
1842 setTransitionStatus("starting");
1843 }
1844 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1845 setTransitionStatus("ending");
1846 }
1847 if (!open && !mounted && transitionStatus === "ending") {
1848 setTransitionStatus(void 0);
1849 }
1850 useIsoLayoutEffect(() => {
1851 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1852 const frame = AnimationFrame.request(() => {
1853 setTransitionStatus("ending");
1854 });
1855 return () => {
1856 AnimationFrame.cancel(frame);
1857 };
1858 }
1859 return void 0;
1860 }, [open, mounted, transitionStatus, deferEndingState]);
1861 useIsoLayoutEffect(() => {
1862 if (!open || enableIdleState) {
1863 return void 0;
1864 }
1865 const frame = AnimationFrame.request(() => {
1866 setTransitionStatus(void 0);
1867 });
1868 return () => {
1869 AnimationFrame.cancel(frame);
1870 };
1871 }, [enableIdleState, open]);
1872 useIsoLayoutEffect(() => {
1873 if (!open || !enableIdleState) {
1874 return void 0;
1875 }
1876 if (open && mounted && transitionStatus !== "idle") {
1877 setTransitionStatus("starting");
1878 }
1879 const frame = AnimationFrame.request(() => {
1880 setTransitionStatus("idle");
1881 });
1882 return () => {
1883 AnimationFrame.cancel(frame);
1884 };
1885 }, [enableIdleState, open, mounted, transitionStatus]);
1886 return {
1887 mounted,
1888 setMounted,
1889 transitionStatus
1890 };
1891 }
1892
1893 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1894 function useCollapsibleRoot(parameters) {
1895 const {
1896 open: openParam,
1897 defaultOpen,
1898 onOpenChange,
1899 disabled: disabled2
1900 } = parameters;
1901 const isControlled = openParam !== void 0;
1902 const [open, setOpen] = useControlled({
1903 controlled: openParam,
1904 default: defaultOpen,
1905 name: "Collapsible",
1906 state: "open"
1907 });
1908 const {
1909 mounted,
1910 setMounted,
1911 transitionStatus
1912 } = useTransitionStatus(open, true, true);
1913 const [visible, setVisible] = React13.useState(open);
1914 const [{
1915 height,
1916 width
1917 }, setDimensions] = React13.useState({
1918 height: void 0,
1919 width: void 0
1920 });
1921 const defaultPanelId = useBaseUiId();
1922 const [panelIdState, setPanelIdState] = React13.useState();
1923 const panelId = panelIdState ?? defaultPanelId;
1924 const [hiddenUntilFound, setHiddenUntilFound] = React13.useState(false);
1925 const [keepMounted, setKeepMounted] = React13.useState(false);
1926 const abortControllerRef = React13.useRef(null);
1927 const animationTypeRef = React13.useRef(null);
1928 const transitionDimensionRef = React13.useRef(null);
1929 const panelRef = React13.useRef(null);
1930 const runOnceAnimationsFinish = useAnimationsFinished(panelRef, false);
1931 const handleTrigger = useStableCallback((event) => {
1932 const nextOpen = !open;
1933 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
1934 onOpenChange(nextOpen, eventDetails);
1935 if (eventDetails.isCanceled) {
1936 return;
1937 }
1938 const panel = panelRef.current;
1939 if (animationTypeRef.current === "css-animation" && panel != null) {
1940 panel.style.removeProperty("animation-name");
1941 }
1942 if (!hiddenUntilFound && !keepMounted) {
1943 if (animationTypeRef.current != null && animationTypeRef.current !== "css-animation") {
1944 if (!mounted && nextOpen) {
1945 setMounted(true);
1946 }
1947 }
1948 if (animationTypeRef.current === "css-animation") {
1949 if (!visible && nextOpen) {
1950 setVisible(true);
1951 }
1952 if (!mounted && nextOpen) {
1953 setMounted(true);
1954 }
1955 }
1956 }
1957 setOpen(nextOpen);
1958 if (animationTypeRef.current === "none" && mounted && !nextOpen) {
1959 setMounted(false);
1960 }
1961 });
1962 useIsoLayoutEffect(() => {
1963 if (isControlled && animationTypeRef.current === "none" && !open) {
1964 setMounted(false);
1965 }
1966 }, [isControlled, open, openParam, setMounted]);
1967 return React13.useMemo(() => ({
1968 abortControllerRef,
1969 animationTypeRef,
1970 disabled: disabled2,
1971 handleTrigger,
1972 height,
1973 mounted,
1974 open,
1975 panelId,
1976 panelRef,
1977 runOnceAnimationsFinish,
1978 setDimensions,
1979 setHiddenUntilFound,
1980 setKeepMounted,
1981 setMounted,
1982 setOpen,
1983 setPanelIdState,
1984 setVisible,
1985 transitionDimensionRef,
1986 transitionStatus,
1987 visible,
1988 width
1989 }), [abortControllerRef, animationTypeRef, disabled2, handleTrigger, height, mounted, open, panelId, panelRef, runOnceAnimationsFinish, setDimensions, setHiddenUntilFound, setKeepMounted, setMounted, setOpen, setVisible, transitionDimensionRef, transitionStatus, visible, width]);
1990 }
1991
1992 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js
1993 var React14 = __toESM(require_react(), 1);
1994 var CollapsibleRootContext = /* @__PURE__ */ React14.createContext(void 0);
1995 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
1996 function useCollapsibleRootContext() {
1997 const context = React14.useContext(CollapsibleRootContext);
1998 if (context === void 0) {
1999 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
2000 }
2001 return context;
2002 }
2003
2004 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js
2005 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
2006 CollapsiblePanelDataAttributes2["open"] = "data-open";
2007 CollapsiblePanelDataAttributes2["closed"] = "data-closed";
2008 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
2009 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
2010 return CollapsiblePanelDataAttributes2;
2011 })({});
2012
2013 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js
2014 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
2015 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
2016 return CollapsibleTriggerDataAttributes2;
2017 })({});
2018
2019 // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js
2020 var PANEL_OPEN_HOOK = {
2021 [CollapsiblePanelDataAttributes.open]: ""
2022 };
2023 var PANEL_CLOSED_HOOK = {
2024 [CollapsiblePanelDataAttributes.closed]: ""
2025 };
2026 var triggerOpenStateMapping = {
2027 open(value) {
2028 if (value) {
2029 return {
2030 [CollapsibleTriggerDataAttributes.panelOpen]: ""
2031 };
2032 }
2033 return null;
2034 }
2035 };
2036 var collapsibleOpenStateMapping = {
2037 open(value) {
2038 if (value) {
2039 return PANEL_OPEN_HOOK;
2040 }
2041 return PANEL_CLOSED_HOOK;
2042 }
2043 };
2044
2045 // node_modules/@base-ui/react/esm/use-button/useButton.js
2046 var React17 = __toESM(require_react(), 1);
2047
2048 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2049 function hasWindow() {
2050 return typeof window !== "undefined";
2051 }
2052 function getWindow(node) {
2053 var _node$ownerDocument;
2054 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2055 }
2056 function isHTMLElement(value) {
2057 if (!hasWindow()) {
2058 return false;
2059 }
2060 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2061 }
2062
2063 // node_modules/@base-ui/react/esm/composite/root/CompositeRootContext.js
2064 var React15 = __toESM(require_react(), 1);
2065 var CompositeRootContext = /* @__PURE__ */ React15.createContext(void 0);
2066 if (true) CompositeRootContext.displayName = "CompositeRootContext";
2067 function useCompositeRootContext(optional = false) {
2068 const context = React15.useContext(CompositeRootContext);
2069 if (context === void 0 && !optional) {
2070 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
2071 }
2072 return context;
2073 }
2074
2075 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js
2076 var React16 = __toESM(require_react(), 1);
2077 function useFocusableWhenDisabled(parameters) {
2078 const {
2079 focusableWhenDisabled,
2080 disabled: disabled2,
2081 composite = false,
2082 tabIndex: tabIndexProp = 0,
2083 isNativeButton
2084 } = parameters;
2085 const isFocusableComposite = composite && focusableWhenDisabled !== false;
2086 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
2087 const props = React16.useMemo(() => {
2088 const additionalProps = {
2089 // allow Tabbing away from focusableWhenDisabled elements
2090 onKeyDown(event) {
2091 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
2092 event.preventDefault();
2093 }
2094 }
2095 };
2096 if (!composite) {
2097 additionalProps.tabIndex = tabIndexProp;
2098 if (!isNativeButton && disabled2) {
2099 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
2100 }
2101 }
2102 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
2103 additionalProps["aria-disabled"] = disabled2;
2104 }
2105 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
2106 additionalProps.disabled = disabled2;
2107 }
2108 return additionalProps;
2109 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
2110 return {
2111 props
2112 };
2113 }
2114
2115 // node_modules/@base-ui/react/esm/use-button/useButton.js
2116 function useButton(parameters = {}) {
2117 const {
2118 disabled: disabled2 = false,
2119 focusableWhenDisabled,
2120 tabIndex = 0,
2121 native: isNativeButton = true,
2122 composite: compositeProp
2123 } = parameters;
2124 const elementRef = React17.useRef(null);
2125 const compositeRootContext = useCompositeRootContext(true);
2126 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2127 const {
2128 props: focusableWhenDisabledProps
2129 } = useFocusableWhenDisabled({
2130 focusableWhenDisabled,
2131 disabled: disabled2,
2132 composite: isCompositeItem,
2133 tabIndex,
2134 isNativeButton
2135 });
2136 if (true) {
2137 React17.useEffect(() => {
2138 if (!elementRef.current) {
2139 return;
2140 }
2141 const isButtonTag = isButtonElement(elementRef.current);
2142 if (isNativeButton) {
2143 if (!isButtonTag) {
2144 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2145 const message2 = "A component that acts as a button expected a native <button> because the `nativeButton` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the `render` prop, or set `nativeButton` to `false`.";
2146 error(`${message2}${ownerStackMessage}`);
2147 }
2148 } else if (isButtonTag) {
2149 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2150 const message2 = "A component that acts as a button expected a non-<button> because the `nativeButton` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set `nativeButton` to `true`.";
2151 error(`${message2}${ownerStackMessage}`);
2152 }
2153 }, [isNativeButton]);
2154 }
2155 const updateDisabled = React17.useCallback(() => {
2156 const element = elementRef.current;
2157 if (!isButtonElement(element)) {
2158 return;
2159 }
2160 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2161 element.disabled = false;
2162 }
2163 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2164 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2165 const getButtonProps = React17.useCallback((externalProps = {}) => {
2166 const {
2167 onClick: externalOnClick,
2168 onMouseDown: externalOnMouseDown,
2169 onKeyUp: externalOnKeyUp,
2170 onKeyDown: externalOnKeyDown,
2171 onPointerDown: externalOnPointerDown,
2172 ...otherExternalProps
2173 } = externalProps;
2174 const type = isNativeButton ? "button" : void 0;
2175 return mergeProps({
2176 type,
2177 onClick(event) {
2178 if (disabled2) {
2179 event.preventDefault();
2180 return;
2181 }
2182 externalOnClick?.(event);
2183 },
2184 onMouseDown(event) {
2185 if (!disabled2) {
2186 externalOnMouseDown?.(event);
2187 }
2188 },
2189 onKeyDown(event) {
2190 if (disabled2) {
2191 return;
2192 }
2193 makeEventPreventable(event);
2194 externalOnKeyDown?.(event);
2195 if (event.baseUIHandlerPrevented) {
2196 return;
2197 }
2198 const isCurrentTarget = event.target === event.currentTarget;
2199 const currentTarget = event.currentTarget;
2200 const isButton2 = isButtonElement(currentTarget);
2201 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2202 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2203 const isEnterKey = event.key === "Enter";
2204 const isSpaceKey = event.key === " ";
2205 const role = currentTarget.getAttribute("role");
2206 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2207 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2208 if (event.defaultPrevented && isTextNavigationRole) {
2209 return;
2210 }
2211 event.preventDefault();
2212 if (isLink || isNativeButton && isButton2) {
2213 currentTarget.click();
2214 event.preventBaseUIHandler();
2215 } else if (shouldClick) {
2216 externalOnClick?.(event);
2217 event.preventBaseUIHandler();
2218 }
2219 return;
2220 }
2221 if (shouldClick) {
2222 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2223 event.preventDefault();
2224 }
2225 if (!isNativeButton && isEnterKey) {
2226 externalOnClick?.(event);
2227 }
2228 }
2229 },
2230 onKeyUp(event) {
2231 if (disabled2) {
2232 return;
2233 }
2234 makeEventPreventable(event);
2235 externalOnKeyUp?.(event);
2236 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2237 event.preventDefault();
2238 return;
2239 }
2240 if (event.baseUIHandlerPrevented) {
2241 return;
2242 }
2243 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2244 externalOnClick?.(event);
2245 }
2246 },
2247 onPointerDown(event) {
2248 if (disabled2) {
2249 event.preventDefault();
2250 return;
2251 }
2252 externalOnPointerDown?.(event);
2253 }
2254 }, !isNativeButton ? {
2255 role: "button"
2256 } : void 0, focusableWhenDisabledProps, otherExternalProps);
2257 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2258 const buttonRef = useStableCallback((element) => {
2259 elementRef.current = element;
2260 updateDisabled();
2261 });
2262 return {
2263 getButtonProps,
2264 buttonRef
2265 };
2266 }
2267 function isButtonElement(elem) {
2268 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2269 }
2270 function isValidLinkElement(elem) {
2271 return Boolean(elem?.tagName === "A" && elem?.href);
2272 }
2273
2274 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2275 var React18 = __toESM(require_react(), 1);
2276
2277 // node_modules/@base-ui/utils/esm/addEventListener.js
2278 function addEventListener(target, type, listener, options) {
2279 target.addEventListener(type, listener, options);
2280 return () => {
2281 target.removeEventListener(type, listener, options);
2282 };
2283 }
2284
2285 // node_modules/@base-ui/react/esm/accordion/root/AccordionRootDataAttributes.js
2286 var AccordionRootDataAttributes = /* @__PURE__ */ (function(AccordionRootDataAttributes2) {
2287 AccordionRootDataAttributes2["disabled"] = "data-disabled";
2288 AccordionRootDataAttributes2["orientation"] = "data-orientation";
2289 return AccordionRootDataAttributes2;
2290 })({});
2291
2292 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2293 function useCollapsiblePanel(parameters) {
2294 const {
2295 abortControllerRef,
2296 animationTypeRef,
2297 externalRef,
2298 height,
2299 hiddenUntilFound,
2300 keepMounted,
2301 id: idParam,
2302 mounted,
2303 onOpenChange,
2304 open,
2305 panelRef,
2306 runOnceAnimationsFinish,
2307 setDimensions,
2308 setMounted,
2309 setOpen,
2310 setVisible,
2311 transitionDimensionRef,
2312 visible,
2313 width
2314 } = parameters;
2315 const isBeforeMatchRef = React18.useRef(false);
2316 const latestAnimationNameRef = React18.useRef(null);
2317 const shouldCancelInitialOpenAnimationRef = React18.useRef(open);
2318 const shouldCancelInitialOpenTransitionRef = React18.useRef(open);
2319 const endingStyleFrame = useAnimationFrame();
2320 const hidden = React18.useMemo(() => {
2321 if (animationTypeRef.current === "css-animation") {
2322 return !visible;
2323 }
2324 return !open && !mounted;
2325 }, [open, mounted, visible, animationTypeRef]);
2326 const handlePanelRef = useStableCallback((element) => {
2327 if (!element) {
2328 return void 0;
2329 }
2330 if (animationTypeRef.current == null || transitionDimensionRef.current == null) {
2331 const panelStyles = getComputedStyle(element);
2332 const hasAnimation = panelStyles.animationName !== "none" && panelStyles.animationName !== "";
2333 const hasTransition = panelStyles.transitionDuration !== "0s" && panelStyles.transitionDuration !== "";
2334 if (hasAnimation && hasTransition) {
2335 if (true) {
2336 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
2337 }
2338 } else if (panelStyles.animationName === "none" && panelStyles.transitionDuration !== "0s") {
2339 animationTypeRef.current = "css-transition";
2340 } else if (panelStyles.animationName !== "none" && panelStyles.transitionDuration === "0s") {
2341 animationTypeRef.current = "css-animation";
2342 } else {
2343 animationTypeRef.current = "none";
2344 }
2345 if (element.getAttribute(AccordionRootDataAttributes.orientation) === "horizontal" || panelStyles.transitionProperty.indexOf("width") > -1) {
2346 transitionDimensionRef.current = "width";
2347 } else {
2348 transitionDimensionRef.current = "height";
2349 }
2350 }
2351 if (animationTypeRef.current !== "css-transition") {
2352 return void 0;
2353 }
2354 if (height === void 0 || width === void 0) {
2355 setDimensions({
2356 height: element.scrollHeight,
2357 width: element.scrollWidth
2358 });
2359 if (shouldCancelInitialOpenTransitionRef.current) {
2360 element.style.setProperty("transition-duration", "0s");
2361 }
2362 }
2363 let frame = -1;
2364 let nextFrame = -1;
2365 frame = AnimationFrame.request(() => {
2366 shouldCancelInitialOpenTransitionRef.current = false;
2367 nextFrame = AnimationFrame.request(() => {
2368 setTimeout(() => {
2369 element.style.removeProperty("transition-duration");
2370 });
2371 });
2372 });
2373 return () => {
2374 AnimationFrame.cancel(frame);
2375 AnimationFrame.cancel(nextFrame);
2376 };
2377 });
2378 const mergedPanelRef = useMergedRefs(externalRef, panelRef, handlePanelRef);
2379 useIsoLayoutEffect(() => {
2380 if (animationTypeRef.current !== "css-transition") {
2381 return void 0;
2382 }
2383 const panel = panelRef.current;
2384 if (!panel) {
2385 return void 0;
2386 }
2387 let resizeFrame = -1;
2388 if (abortControllerRef.current != null) {
2389 abortControllerRef.current.abort();
2390 abortControllerRef.current = null;
2391 }
2392 if (open) {
2393 const originalLayoutStyles = {
2394 "justify-content": panel.style.justifyContent,
2395 "align-items": panel.style.alignItems,
2396 "align-content": panel.style.alignContent,
2397 "justify-items": panel.style.justifyItems
2398 };
2399 Object.keys(originalLayoutStyles).forEach((key) => {
2400 panel.style.setProperty(key, "initial", "important");
2401 });
2402 if (!shouldCancelInitialOpenTransitionRef.current && !keepMounted) {
2403 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, "");
2404 }
2405 setDimensions({
2406 height: panel.scrollHeight,
2407 width: panel.scrollWidth
2408 });
2409 resizeFrame = AnimationFrame.request(() => {
2410 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
2411 if (value === "") {
2412 panel.style.removeProperty(key);
2413 } else {
2414 panel.style.setProperty(key, value);
2415 }
2416 });
2417 });
2418 } else {
2419 if (panel.scrollHeight === 0 && panel.scrollWidth === 0) {
2420 return void 0;
2421 }
2422 setDimensions({
2423 height: panel.scrollHeight,
2424 width: panel.scrollWidth
2425 });
2426 const abortController = new AbortController();
2427 abortControllerRef.current = abortController;
2428 const signal = abortController.signal;
2429 let attributeObserver = null;
2430 const endingStyleAttribute = CollapsiblePanelDataAttributes.endingStyle;
2431 attributeObserver = new MutationObserver((mutationList) => {
2432 const hasEndingStyle = mutationList.some((mutation) => mutation.type === "attributes" && mutation.attributeName === endingStyleAttribute);
2433 if (hasEndingStyle) {
2434 attributeObserver?.disconnect();
2435 attributeObserver = null;
2436 runOnceAnimationsFinish(() => {
2437 setDimensions({
2438 height: 0,
2439 width: 0
2440 });
2441 panel.style.removeProperty("content-visibility");
2442 setMounted(false);
2443 if (abortControllerRef.current === abortController) {
2444 abortControllerRef.current = null;
2445 }
2446 }, signal);
2447 }
2448 });
2449 attributeObserver.observe(panel, {
2450 attributes: true,
2451 attributeFilter: [endingStyleAttribute]
2452 });
2453 return () => {
2454 attributeObserver?.disconnect();
2455 endingStyleFrame.cancel();
2456 if (abortControllerRef.current === abortController) {
2457 abortController.abort();
2458 abortControllerRef.current = null;
2459 }
2460 };
2461 }
2462 return () => {
2463 AnimationFrame.cancel(resizeFrame);
2464 };
2465 }, [abortControllerRef, animationTypeRef, endingStyleFrame, hiddenUntilFound, keepMounted, mounted, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted]);
2466 useIsoLayoutEffect(() => {
2467 if (animationTypeRef.current !== "css-animation") {
2468 return;
2469 }
2470 const panel = panelRef.current;
2471 if (!panel) {
2472 return;
2473 }
2474 latestAnimationNameRef.current = panel.style.animationName || latestAnimationNameRef.current;
2475 panel.style.setProperty("animation-name", "none");
2476 setDimensions({
2477 height: panel.scrollHeight,
2478 width: panel.scrollWidth
2479 });
2480 if (!shouldCancelInitialOpenAnimationRef.current && !isBeforeMatchRef.current) {
2481 panel.style.removeProperty("animation-name");
2482 }
2483 if (open) {
2484 if (abortControllerRef.current != null) {
2485 abortControllerRef.current.abort();
2486 abortControllerRef.current = null;
2487 }
2488 setMounted(true);
2489 setVisible(true);
2490 } else {
2491 abortControllerRef.current = new AbortController();
2492 runOnceAnimationsFinish(() => {
2493 setMounted(false);
2494 setVisible(false);
2495 abortControllerRef.current = null;
2496 }, abortControllerRef.current.signal);
2497 }
2498 }, [abortControllerRef, animationTypeRef, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted, setVisible, visible]);
2499 useOnMount(() => {
2500 const frame = AnimationFrame.request(() => {
2501 shouldCancelInitialOpenAnimationRef.current = false;
2502 });
2503 return () => AnimationFrame.cancel(frame);
2504 });
2505 useIsoLayoutEffect(() => {
2506 if (!hiddenUntilFound) {
2507 return void 0;
2508 }
2509 const panel = panelRef.current;
2510 if (!panel) {
2511 return void 0;
2512 }
2513 let frame = -1;
2514 let nextFrame = -1;
2515 if (open && isBeforeMatchRef.current) {
2516 panel.style.transitionDuration = "0s";
2517 setDimensions({
2518 height: panel.scrollHeight,
2519 width: panel.scrollWidth
2520 });
2521 frame = AnimationFrame.request(() => {
2522 isBeforeMatchRef.current = false;
2523 nextFrame = AnimationFrame.request(() => {
2524 setTimeout(() => {
2525 panel.style.removeProperty("transition-duration");
2526 });
2527 });
2528 });
2529 }
2530 return () => {
2531 AnimationFrame.cancel(frame);
2532 AnimationFrame.cancel(nextFrame);
2533 };
2534 }, [hiddenUntilFound, open, panelRef, setDimensions]);
2535 useIsoLayoutEffect(() => {
2536 const panel = panelRef.current;
2537 if (panel && hiddenUntilFound && hidden) {
2538 panel.setAttribute("hidden", "until-found");
2539 if (animationTypeRef.current === "css-transition") {
2540 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, "");
2541 }
2542 }
2543 }, [hiddenUntilFound, hidden, animationTypeRef, panelRef]);
2544 React18.useEffect(function registerBeforeMatchListener() {
2545 const panel = panelRef.current;
2546 if (!panel) {
2547 return void 0;
2548 }
2549 function handleBeforeMatch(event) {
2550 isBeforeMatchRef.current = true;
2551 setOpen(true);
2552 onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event));
2553 }
2554 return addEventListener(panel, "beforematch", handleBeforeMatch);
2555 }, [onOpenChange, panelRef, setOpen]);
2556 return React18.useMemo(() => ({
2557 props: {
2558 hidden,
2559 id: idParam,
2560 ref: mergedPanelRef
2561 }
2562 }), [hidden, idParam, mergedPanelRef]);
2563 }
2564
2565 // node_modules/@base-ui/react/esm/utils/useOpenChangeComplete.js
2566 var React19 = __toESM(require_react(), 1);
2567 function useOpenChangeComplete(parameters) {
2568 const {
2569 enabled = true,
2570 open,
2571 ref,
2572 onComplete: onCompleteParam
2573 } = parameters;
2574 const onComplete = useStableCallback(onCompleteParam);
2575 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2576 React19.useEffect(() => {
2577 if (!enabled) {
2578 return void 0;
2579 }
2580 const abortController = new AbortController();
2581 runOnceAnimationsFinish(onComplete, abortController.signal);
2582 return () => {
2583 abortController.abort();
2584 };
2585 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2586 }
2587
2588 // node_modules/@base-ui/react/esm/collapsible/index.parts.js
2589 var index_parts_exports = {};
2590 __export(index_parts_exports, {
2591 Panel: () => CollapsiblePanel,
2592 Root: () => CollapsibleRoot,
2593 Trigger: () => CollapsibleTrigger
2594 });
2595
2596 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
2597 var React20 = __toESM(require_react(), 1);
2598
2599 // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js
2600 var collapsibleStateAttributesMapping = {
2601 ...collapsibleOpenStateMapping,
2602 ...transitionStatusMapping
2603 };
2604
2605 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
2606 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2607 var CollapsibleRoot = /* @__PURE__ */ React20.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
2608 const {
2609 render: render4,
2610 className,
2611 defaultOpen = false,
2612 disabled: disabled2 = false,
2613 onOpenChange: onOpenChangeProp,
2614 open,
2615 style,
2616 ...elementProps
2617 } = componentProps;
2618 const onOpenChange = useStableCallback(onOpenChangeProp);
2619 const collapsible = useCollapsibleRoot({
2620 open,
2621 defaultOpen,
2622 onOpenChange,
2623 disabled: disabled2
2624 });
2625 const state = React20.useMemo(() => ({
2626 open: collapsible.open,
2627 disabled: collapsible.disabled,
2628 transitionStatus: collapsible.transitionStatus
2629 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
2630 const contextValue = React20.useMemo(() => ({
2631 ...collapsible,
2632 onOpenChange,
2633 state
2634 }), [collapsible, onOpenChange, state]);
2635 const element = useRenderElement("div", componentProps, {
2636 state,
2637 ref: forwardedRef,
2638 props: elementProps,
2639 stateAttributesMapping: collapsibleStateAttributesMapping
2640 });
2641 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CollapsibleRootContext.Provider, {
2642 value: contextValue,
2643 children: element
2644 });
2645 });
2646 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
2647
2648 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js
2649 var React21 = __toESM(require_react(), 1);
2650 var stateAttributesMapping = {
2651 ...triggerOpenStateMapping,
2652 ...transitionStatusMapping
2653 };
2654 var CollapsibleTrigger = /* @__PURE__ */ React21.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
2655 const {
2656 panelId,
2657 open,
2658 handleTrigger,
2659 state,
2660 disabled: contextDisabled
2661 } = useCollapsibleRootContext();
2662 const {
2663 className,
2664 disabled: disabled2 = contextDisabled,
2665 id,
2666 render: render4,
2667 nativeButton = true,
2668 style,
2669 ...elementProps
2670 } = componentProps;
2671 const {
2672 getButtonProps,
2673 buttonRef
2674 } = useButton({
2675 disabled: disabled2,
2676 focusableWhenDisabled: true,
2677 native: nativeButton
2678 });
2679 const props = React21.useMemo(() => ({
2680 "aria-controls": open ? panelId : void 0,
2681 "aria-expanded": open,
2682 onClick: handleTrigger
2683 }), [panelId, open, handleTrigger]);
2684 const element = useRenderElement("button", componentProps, {
2685 state,
2686 ref: [forwardedRef, buttonRef],
2687 props: [props, elementProps, getButtonProps],
2688 stateAttributesMapping
2689 });
2690 return element;
2691 });
2692 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
2693
2694 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
2695 var React22 = __toESM(require_react(), 1);
2696
2697 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js
2698 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
2699 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
2700 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
2701 return CollapsiblePanelCssVars2;
2702 })({});
2703
2704 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
2705 var CollapsiblePanel = /* @__PURE__ */ React22.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
2706 const {
2707 className,
2708 hiddenUntilFound: hiddenUntilFoundProp,
2709 keepMounted: keepMountedProp,
2710 render: render4,
2711 id: idProp,
2712 style,
2713 ...elementProps
2714 } = componentProps;
2715 if (true) {
2716 useIsoLayoutEffect(() => {
2717 if (hiddenUntilFoundProp && keepMountedProp === false) {
2718 warn("The `keepMounted={false}` prop on a Collapsible will be ignored when using `hiddenUntilFound` since it requires the Panel to remain mounted even when closed.");
2719 }
2720 }, [hiddenUntilFoundProp, keepMountedProp]);
2721 }
2722 const {
2723 abortControllerRef,
2724 animationTypeRef,
2725 height,
2726 mounted,
2727 onOpenChange,
2728 open,
2729 panelId,
2730 panelRef,
2731 runOnceAnimationsFinish,
2732 setDimensions,
2733 setHiddenUntilFound,
2734 setKeepMounted,
2735 setMounted,
2736 setPanelIdState,
2737 setOpen,
2738 setVisible,
2739 state,
2740 transitionDimensionRef,
2741 visible,
2742 width,
2743 transitionStatus
2744 } = useCollapsibleRootContext();
2745 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
2746 const keepMounted = keepMountedProp ?? false;
2747 useIsoLayoutEffect(() => {
2748 if (idProp) {
2749 setPanelIdState(idProp);
2750 return () => {
2751 setPanelIdState(void 0);
2752 };
2753 }
2754 return void 0;
2755 }, [idProp, setPanelIdState]);
2756 useIsoLayoutEffect(() => {
2757 setHiddenUntilFound(hiddenUntilFound);
2758 }, [setHiddenUntilFound, hiddenUntilFound]);
2759 useIsoLayoutEffect(() => {
2760 setKeepMounted(keepMounted);
2761 }, [setKeepMounted, keepMounted]);
2762 const {
2763 props
2764 } = useCollapsiblePanel({
2765 abortControllerRef,
2766 animationTypeRef,
2767 externalRef: forwardedRef,
2768 height,
2769 hiddenUntilFound,
2770 id: panelId,
2771 keepMounted,
2772 mounted,
2773 onOpenChange,
2774 open,
2775 panelRef,
2776 runOnceAnimationsFinish,
2777 setDimensions,
2778 setMounted,
2779 setOpen,
2780 setVisible,
2781 transitionDimensionRef,
2782 visible,
2783 width
2784 });
2785 useOpenChangeComplete({
2786 open: open && transitionStatus === "idle",
2787 ref: panelRef,
2788 onComplete() {
2789 if (!open) {
2790 return;
2791 }
2792 setDimensions({
2793 height: void 0,
2794 width: void 0
2795 });
2796 }
2797 });
2798 const panelState = React22.useMemo(() => ({
2799 ...state,
2800 transitionStatus
2801 }), [state, transitionStatus]);
2802 const element = useRenderElement("div", componentProps, {
2803 state: panelState,
2804 ref: [forwardedRef, panelRef],
2805 props: [props, {
2806 style: {
2807 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
2808 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
2809 }
2810 }, elementProps],
2811 stateAttributesMapping: collapsibleStateAttributesMapping
2812 });
2813 const shouldRender = keepMounted || hiddenUntilFound || mounted;
2814 if (!shouldRender) {
2815 return null;
2816 }
2817 return element;
2818 });
2819 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
2820
2821 // node_modules/@base-ui/react/esm/use-render/useRender.js
2822 function useRender(params) {
2823 return useRenderElement(params.defaultTagName ?? "div", params, params);
2824 }
2825
2826 // packages/ui/build-module/text/text.mjs
2827 var import_element2 = __toESM(require_element(), 1);
2828 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='4130d64bea']")) {
2829 const style = document.createElement("style");
2830 style.setAttribute("data-wp-hash", "4130d64bea");
2831 style.appendChild(document.createTextNode('@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)}}'));
2832 document.head.appendChild(style);
2833 }
2834 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" };
2835 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='1fb29d3a3c']")) {
2836 const style = document.createElement("style");
2837 style.setAttribute("data-wp-hash", "1fb29d3a3c");
2838 style.appendChild(document.createTextNode("._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)}"));
2839 document.head.appendChild(style);
2840 }
2841 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" };
2842 var Text = (0, import_element2.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
2843 const element = useRender({
2844 render: render4,
2845 defaultTagName: "span",
2846 ref,
2847 props: mergeProps(props, {
2848 className: clsx_default(
2849 style_default.text,
2850 variant.startsWith("heading-") && global_css_defense_default.heading,
2851 variant.startsWith("body-") && global_css_defense_default.p,
2852 style_default[variant],
2853 className
2854 )
2855 })
2856 });
2857 return element;
2858 });
2859
2860 // packages/ui/build-module/badge/badge.mjs
2861 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2862 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='d6a685e1aa']")) {
2863 const style = document.createElement("style");
2864 style.setAttribute("data-wp-hash", "d6a685e1aa");
2865 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-bg-surface-error,#f6e6e3);color:var(--wpds-color-fg-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-bg-surface-warning,#fde6be);color:var(--wpds-color-fg-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-bg-surface-caution,#fee995);color:var(--wpds-color-fg-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-bg-surface-success,#c6f7cd);color:var(--wpds-color-fg-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-bg-surface-info,#deebfa);color:var(--wpds-color-fg-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-fg-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}"));
2866 document.head.appendChild(style);
2867 }
2868 var style_default2 = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" };
2869 var Badge = (0, import_element3.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
2870 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2871 Text,
2872 {
2873 ref,
2874 className: clsx_default(
2875 style_default2.badge,
2876 style_default2[`is-${intent}-intent`],
2877 className
2878 ),
2879 ...props,
2880 variant: "body-sm"
2881 }
2882 );
2883 });
2884
2885 // packages/ui/build-module/icon/icon.mjs
2886 var import_element4 = __toESM(require_element(), 1);
2887 var import_primitives = __toESM(require_primitives(), 1);
2888 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2889 var Icon = (0, import_element4.forwardRef)(function Icon2({ icon, size = 24, ...restProps }, ref) {
2890 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2891 import_primitives.SVG,
2892 {
2893 ref,
2894 fill: "currentColor",
2895 ...icon.props,
2896 ...restProps,
2897 width: size,
2898 height: size
2899 }
2900 );
2901 });
2902
2903 // packages/ui/build-module/card/index.mjs
2904 var card_exports = {};
2905 __export(card_exports, {
2906 Content: () => Content,
2907 FullBleed: () => FullBleed,
2908 Header: () => Header,
2909 Root: () => Root,
2910 Title: () => Title
2911 });
2912
2913 // packages/ui/build-module/card/root.mjs
2914 var import_element5 = __toESM(require_element(), 1);
2915 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='e3ae230cea']")) {
2916 const style = document.createElement("style");
2917 style.setAttribute("data-wp-hash", "e3ae230cea");
2918 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}"));
2919 document.head.appendChild(style);
2920 }
2921 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
2922 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
2923 const style = document.createElement("style");
2924 style.setAttribute("data-wp-hash", "14f5e9ddeb");
2925 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
2926 document.head.appendChild(style);
2927 }
2928 var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
2929 var Root = (0, import_element5.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
2930 const mergedClassName = clsx_default(style_default3.root, resets_default["box-sizing"]);
2931 const element = useRender({
2932 defaultTagName: "div",
2933 render: render4,
2934 ref,
2935 props: mergeProps({ className: mergedClassName }, restProps)
2936 });
2937 return element;
2938 });
2939
2940 // packages/ui/build-module/card/header.mjs
2941 var import_element6 = __toESM(require_element(), 1);
2942 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
2943 const style = document.createElement("style");
2944 style.setAttribute("data-wp-hash", "14f5e9ddeb");
2945 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
2946 document.head.appendChild(style);
2947 }
2948 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
2949 var Header = (0, import_element6.forwardRef)(
2950 function CardHeader({ render: render4, ...props }, ref) {
2951 const element = useRender({
2952 defaultTagName: "div",
2953 render: render4,
2954 ref,
2955 props: mergeProps({ className: style_default4.header }, props)
2956 });
2957 return element;
2958 }
2959 );
2960
2961 // packages/ui/build-module/card/content.mjs
2962 var import_element7 = __toESM(require_element(), 1);
2963 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
2964 const style = document.createElement("style");
2965 style.setAttribute("data-wp-hash", "14f5e9ddeb");
2966 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
2967 document.head.appendChild(style);
2968 }
2969 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
2970 var Content = (0, import_element7.forwardRef)(
2971 function CardContent({ render: render4, ...props }, ref) {
2972 const element = useRender({
2973 defaultTagName: "div",
2974 render: render4,
2975 ref,
2976 props: mergeProps({ className: style_default5.content }, props)
2977 });
2978 return element;
2979 }
2980 );
2981
2982 // packages/ui/build-module/card/full-bleed.mjs
2983 var import_element8 = __toESM(require_element(), 1);
2984 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
2985 const style = document.createElement("style");
2986 style.setAttribute("data-wp-hash", "14f5e9ddeb");
2987 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
2988 document.head.appendChild(style);
2989 }
2990 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
2991 var FullBleed = (0, import_element8.forwardRef)(
2992 function CardFullBleed({ render: render4, ...props }, ref) {
2993 const element = useRender({
2994 defaultTagName: "div",
2995 render: render4,
2996 ref,
2997 props: mergeProps(
2998 { className: style_default6.fullbleed },
2999 props
3000 )
3001 });
3002 return element;
3003 }
3004 );
3005
3006 // packages/ui/build-module/card/title.mjs
3007 var import_element9 = __toESM(require_element(), 1);
3008 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
3009 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {});
3010 var Title = (0, import_element9.forwardRef)(
3011 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
3012 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3013 Text,
3014 {
3015 ref,
3016 variant: "heading-lg",
3017 render: render4,
3018 ...props,
3019 children
3020 }
3021 );
3022 }
3023 );
3024
3025 // packages/ui/build-module/collapsible/panel.mjs
3026 var import_element10 = __toESM(require_element(), 1);
3027 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
3028 var Panel = (0, import_element10.forwardRef)(
3029 function CollapsiblePanel3(props, forwardedRef) {
3030 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
3031 }
3032 );
3033
3034 // packages/ui/build-module/collapsible/root.mjs
3035 var import_element11 = __toESM(require_element(), 1);
3036 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
3037 var Root2 = (0, import_element11.forwardRef)(
3038 function CollapsibleRoot3(props, forwardedRef) {
3039 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
3040 }
3041 );
3042
3043 // packages/ui/build-module/collapsible/trigger.mjs
3044 var import_element12 = __toESM(require_element(), 1);
3045 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
3046 var Trigger = (0, import_element12.forwardRef)(
3047 function CollapsibleTrigger3(props, forwardedRef) {
3048 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
3049 }
3050 );
3051
3052 // packages/ui/build-module/collapsible-card/index.mjs
3053 var collapsible_card_exports = {};
3054 __export(collapsible_card_exports, {
3055 Content: () => Content2,
3056 Header: () => Header2,
3057 HeaderDescription: () => HeaderDescription,
3058 Root: () => Root3
3059 });
3060
3061 // packages/ui/build-module/collapsible-card/root.mjs
3062 var import_element13 = __toESM(require_element(), 1);
3063 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
3064 var Root3 = (0, import_element13.forwardRef)(
3065 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
3066 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3067 Root2,
3068 {
3069 ref,
3070 render: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Root, { render: render4 }),
3071 ...restProps
3072 }
3073 );
3074 }
3075 );
3076
3077 // packages/ui/build-module/collapsible-card/header.mjs
3078 var import_element15 = __toESM(require_element(), 1);
3079
3080 // packages/icons/build-module/library/arrow-down.mjs
3081 var import_primitives2 = __toESM(require_primitives(), 1);
3082 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
3083 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives2.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
3084
3085 // packages/icons/build-module/library/arrow-left.mjs
3086 var import_primitives3 = __toESM(require_primitives(), 1);
3087 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
3088 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
3089
3090 // packages/icons/build-module/library/arrow-right.mjs
3091 var import_primitives4 = __toESM(require_primitives(), 1);
3092 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
3093 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
3094
3095 // packages/icons/build-module/library/arrow-up.mjs
3096 var import_primitives5 = __toESM(require_primitives(), 1);
3097 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
3098 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
3099
3100 // packages/icons/build-module/library/block-default.mjs
3101 var import_primitives6 = __toESM(require_primitives(), 1);
3102 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
3103 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives6.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) });
3104
3105 // packages/icons/build-module/library/block-table.mjs
3106 var import_primitives7 = __toESM(require_primitives(), 1);
3107 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
3108 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives7.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" }) });
3109
3110 // packages/icons/build-module/library/category.mjs
3111 var import_primitives8 = __toESM(require_primitives(), 1);
3112 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
3113 var category_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives8.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" }) });
3114
3115 // packages/icons/build-module/library/check.mjs
3116 var import_primitives9 = __toESM(require_primitives(), 1);
3117 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
3118 var check_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives9.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
3119
3120 // packages/icons/build-module/library/chevron-down.mjs
3121 var import_primitives10 = __toESM(require_primitives(), 1);
3122 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
3123 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives10.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
3124
3125 // packages/icons/build-module/library/chevron-left.mjs
3126 var import_primitives11 = __toESM(require_primitives(), 1);
3127 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
3128 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives11.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
3129
3130 // packages/icons/build-module/library/chevron-right.mjs
3131 var import_primitives12 = __toESM(require_primitives(), 1);
3132 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
3133 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives12.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
3134
3135 // packages/icons/build-module/library/close-small.mjs
3136 var import_primitives13 = __toESM(require_primitives(), 1);
3137 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
3138 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives13.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" }) });
3139
3140 // packages/icons/build-module/library/cog.mjs
3141 var import_primitives14 = __toESM(require_primitives(), 1);
3142 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
3143 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives14.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" }) });
3144
3145 // packages/icons/build-module/library/envelope.mjs
3146 var import_primitives15 = __toESM(require_primitives(), 1);
3147 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
3148 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives15.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" }) });
3149
3150 // packages/icons/build-module/library/error.mjs
3151 var import_primitives16 = __toESM(require_primitives(), 1);
3152 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
3153 var error_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives16.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" }) });
3154
3155 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
3156 var import_primitives17 = __toESM(require_primitives(), 1);
3157 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
3158 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives17.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) });
3159
3160 // packages/icons/build-module/library/format-list-bullets.mjs
3161 var import_primitives18 = __toESM(require_primitives(), 1);
3162 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
3163 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives18.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
3164
3165 // packages/icons/build-module/library/funnel.mjs
3166 var import_primitives19 = __toESM(require_primitives(), 1);
3167 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
3168 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives19.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
3169
3170 // packages/icons/build-module/library/link.mjs
3171 var import_primitives20 = __toESM(require_primitives(), 1);
3172 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
3173 var link_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives20.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) });
3174
3175 // packages/icons/build-module/library/mobile.mjs
3176 var import_primitives21 = __toESM(require_primitives(), 1);
3177 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3178 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives21.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) });
3179
3180 // packages/icons/build-module/library/more-vertical.mjs
3181 var import_primitives22 = __toESM(require_primitives(), 1);
3182 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3183 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
3184
3185 // packages/icons/build-module/library/next.mjs
3186 var import_primitives23 = __toESM(require_primitives(), 1);
3187 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3188 var next_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives23.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });
3189
3190 // packages/icons/build-module/library/pencil.mjs
3191 var import_primitives24 = __toESM(require_primitives(), 1);
3192 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3193 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives24.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
3194
3195 // packages/icons/build-module/library/previous.mjs
3196 var import_primitives25 = __toESM(require_primitives(), 1);
3197 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3198 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives25.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) });
3199
3200 // packages/icons/build-module/library/scheduled.mjs
3201 var import_primitives26 = __toESM(require_primitives(), 1);
3202 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3203 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives26.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) });
3204
3205 // packages/icons/build-module/library/search.mjs
3206 var import_primitives27 = __toESM(require_primitives(), 1);
3207 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
3208 var search_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives27.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) });
3209
3210 // packages/icons/build-module/library/seen.mjs
3211 var import_primitives28 = __toESM(require_primitives(), 1);
3212 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3213 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives28.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) });
3214
3215 // packages/icons/build-module/library/unseen.mjs
3216 var import_primitives29 = __toESM(require_primitives(), 1);
3217 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3218 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives29.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) });
3219
3220 // packages/ui/build-module/collapsible-card/context.mjs
3221 var import_element14 = __toESM(require_element(), 1);
3222 var HeaderDescriptionIdContext = (0, import_element14.createContext)({
3223 setDescriptionId: () => {
3224 }
3225 });
3226
3227 // packages/ui/build-module/collapsible-card/header.mjs
3228 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
3229 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='718ddb3557']")) {
3230 const style = document.createElement("style");
3231 style.setAttribute("data-wp-hash", "718ddb3557");
3232 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"));
3233 document.head.appendChild(style);
3234 }
3235 var style_default7 = { "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
3236 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='2a5ab8f3a7']")) {
3237 const style = document.createElement("style");
3238 style.setAttribute("data-wp-hash", "2a5ab8f3a7");
3239 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}"));
3240 document.head.appendChild(style);
3241 }
3242 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
3243 var Header2 = (0, import_element15.forwardRef)(
3244 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
3245 const [descriptionId, setDescriptionId] = (0, import_element15.useState)();
3246 const contextValue = (0, import_element15.useMemo)(
3247 () => ({ setDescriptionId }),
3248 [setDescriptionId]
3249 );
3250 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
3251 Trigger,
3252 {
3253 className: clsx_default(style_default7.header, className),
3254 render: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3255 Header,
3256 {
3257 ref,
3258 render: render4,
3259 ...restProps
3260 }
3261 ),
3262 nativeButton: false,
3263 "aria-describedby": descriptionId,
3264 children: [
3265 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: style_default7["header-content"], children }),
3266 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3267 "div",
3268 {
3269 className: clsx_default(
3270 style_default7["header-trigger-positioner"]
3271 ),
3272 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3273 "div",
3274 {
3275 className: clsx_default(
3276 style_default7["header-trigger-wrapper"],
3277 // While the interactive trigger element is the whole header,
3278 // the focus ring will be displayed only on the icon to visually
3279 // emulate it being the button.
3280 focus_default["outset-ring--focus-parent-visible"]
3281 ),
3282 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3283 Icon,
3284 {
3285 icon: chevron_down_default,
3286 className: style_default7["header-trigger"]
3287 }
3288 )
3289 }
3290 )
3291 }
3292 )
3293 ]
3294 }
3295 ) });
3296 }
3297 );
3298
3299 // packages/ui/build-module/collapsible-card/header-description.mjs
3300 var import_element16 = __toESM(require_element(), 1);
3301 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
3302 var HeaderDescription = (0, import_element16.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
3303 const descriptionId = (0, import_element16.useId)();
3304 const { setDescriptionId } = (0, import_element16.useContext)(HeaderDescriptionIdContext);
3305 (0, import_element16.useEffect)(() => {
3306 setDescriptionId(descriptionId);
3307 return () => setDescriptionId(void 0);
3308 }, [descriptionId, setDescriptionId]);
3309 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3310 "div",
3311 {
3312 ref,
3313 id: descriptionId,
3314 "aria-hidden": "true",
3315 className,
3316 ...restProps,
3317 children
3318 }
3319 );
3320 });
3321
3322 // packages/ui/build-module/collapsible-card/content.mjs
3323 var import_element17 = __toESM(require_element(), 1);
3324 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
3325 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='718ddb3557']")) {
3326 const style = document.createElement("style");
3327 style.setAttribute("data-wp-hash", "718ddb3557");
3328 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"));
3329 document.head.appendChild(style);
3330 }
3331 var style_default8 = { "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
3332 var Content2 = (0, import_element17.forwardRef)(
3333 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
3334 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3335 Panel,
3336 {
3337 ref,
3338 className: clsx_default(style_default8.content, className),
3339 hiddenUntilFound,
3340 ...restProps,
3341 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3342 Content,
3343 {
3344 className: style_default8["content-inner"],
3345 render: render4,
3346 children
3347 }
3348 )
3349 }
3350 );
3351 }
3352 );
3353
3354 // packages/ui/build-module/stack/stack.mjs
3355 var import_element18 = __toESM(require_element(), 1);
3356 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b51ff41489']")) {
3357 const style = document.createElement("style");
3358 style.setAttribute("data-wp-hash", "b51ff41489");
3359 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"));
3360 document.head.appendChild(style);
3361 }
3362 var style_default9 = { "stack": "_19ce0419607e1896__stack" };
3363 var gapTokens = {
3364 xs: "var(--wpds-dimension-gap-xs, 4px)",
3365 sm: "var(--wpds-dimension-gap-sm, 8px)",
3366 md: "var(--wpds-dimension-gap-md, 12px)",
3367 lg: "var(--wpds-dimension-gap-lg, 16px)",
3368 xl: "var(--wpds-dimension-gap-xl, 24px)",
3369 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
3370 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
3371 };
3372 var Stack = (0, import_element18.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
3373 const style = {
3374 gap: gap && gapTokens[gap],
3375 alignItems: align,
3376 justifyContent: justify,
3377 flexDirection: direction,
3378 flexWrap: wrap
3379 };
3380 const element = useRender({
3381 render: render4,
3382 ref,
3383 props: mergeProps(props, { style, className: style_default9.stack })
3384 });
3385 return element;
3386 });
3387
3388 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
3389 var import_components = __toESM(require_components(), 1);
3390 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");
3391
3392 // packages/admin-ui/build-module/page/header.mjs
3393 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
3394 function Header3({
3395 headingLevel = 2,
3396 breadcrumbs,
3397 badges,
3398 title,
3399 subTitle,
3400 actions: actions2,
3401 showSidebarToggle = true
3402 }) {
3403 const HeadingTag = `h${headingLevel}`;
3404 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
3405 Stack,
3406 {
3407 direction: "column",
3408 className: "admin-ui-page__header",
3409 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", {}),
3410 children: [
3411 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Stack, { direction: "row", justify: "space-between", gap: "sm", children: [
3412 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
3413 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3414 SidebarToggleSlot,
3415 {
3416 bubblesVirtually: true,
3417 className: "admin-ui-page__sidebar-toggle-slot"
3418 }
3419 ),
3420 title && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(HeadingTag, { className: "admin-ui-page__header-title", children: title }),
3421 breadcrumbs,
3422 badges
3423 ] }),
3424 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3425 Stack,
3426 {
3427 direction: "row",
3428 gap: "sm",
3429 style: { width: "auto", flexShrink: 0 },
3430 className: "admin-ui-page__header-actions",
3431 align: "center",
3432 children: actions2
3433 }
3434 )
3435 ] }),
3436 subTitle && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "admin-ui-page__header-subtitle", children: subTitle })
3437 ]
3438 }
3439 );
3440 }
3441
3442 // packages/admin-ui/build-module/page/index.mjs
3443 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
3444 function Page({
3445 headingLevel,
3446 breadcrumbs,
3447 badges,
3448 title,
3449 subTitle,
3450 children,
3451 className,
3452 actions: actions2,
3453 ariaLabel,
3454 hasPadding = false,
3455 showSidebarToggle = true
3456 }) {
3457 const classes = clsx_default("admin-ui-page", className);
3458 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
3459 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
3460 (title || breadcrumbs || badges || actions2) && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
3461 Header3,
3462 {
3463 headingLevel,
3464 breadcrumbs,
3465 badges,
3466 title,
3467 subTitle,
3468 actions: actions2,
3469 showSidebarToggle
3470 }
3471 ),
3472 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "admin-ui-page__content has-padding", children }) : children
3473 ] });
3474 }
3475 Page.SidebarToggleFill = SidebarToggleFill;
3476 var page_default = Page;
3477
3478 // routes/guidelines/stage.tsx
3479 var import_i18n56 = __toESM(require_i18n());
3480 var import_element93 = __toESM(require_element());
3481 var import_components60 = __toESM(require_components());
3482
3483 // routes/guidelines/style.scss
3484 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='15b2061f96']")) {
3485 const style = document.createElement("style");
3486 style.setAttribute("data-wp-hash", "15b2061f96");
3487 style.appendChild(document.createTextNode(".guidelines__content{border-radius:8px;margin-top:0;padding:24px}.guidelines__list{display:flex;flex-direction:column;gap:16px;list-style:none;margin:0;padding:0}.guidelines__list-item{margin:0 auto;width:min(680px,100%)}.guidelines__loading{align-items:center;display:flex;justify-content:center;margin-top:16px}.guidelines__revision-history{display:flex;flex-direction:column;gap:16px;padding:24px}.guidelines__revision-history .dataviews-wrapper{margin-left:-24px;margin-right:-24px}.guidelines__revision-history-back{align-self:flex-start;color:#1e1e1e;font-weight:500;margin-left:-16px}.guidelines__error-description{margin:8px 0 0}.guidelines__revision-description{padding-left:8px}.guidelines__restore-modal-actions{margin-top:24px}"));
3488 document.head.appendChild(style);
3489 }
3490
3491 // routes/guidelines/components/guideline-accordion.tsx
3492 var import_components2 = __toESM(require_components());
3493 var import_i18n = __toESM(require_i18n());
3494 var import_element19 = __toESM(require_element());
3495
3496 // routes/guidelines/components/guideline-accordion.scss
3497 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b78bad87f0']")) {
3498 const style = document.createElement("style");
3499 style.setAttribute("data-wp-hash", "b78bad87f0");
3500 style.appendChild(document.createTextNode(".guidelines__accordion{padding:16px 24px}.guidelines__accordion-trigger{background:none;border:none;cursor:pointer;display:block;height:auto;margin:0;padding:0;text-align:left;width:100%}.guidelines__accordion-trigger:focus{box-shadow:none!important}.guidelines__accordion-trigger:focus-visible{box-shadow:0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color,#3858e9)!important}.guidelines__accordion-chevron-up{transform:rotate(180deg);transition:transform .3s ease-in-out}.guidelines__accordion-chevron-down{transform:rotate(0deg);transition:transform .3s ease-in-out}.guidelines__accordion-header{color:#1e1e1e;padding-top:4px}.guidelines__accordion-description{color:#757575;padding-bottom:4px}.guidelines__accordion-form{margin-top:24px}"));
3501 document.head.appendChild(style);
3502 }
3503
3504 // routes/guidelines/components/guideline-accordion.tsx
3505 function GuidelineAccordion({
3506 title,
3507 description,
3508 children,
3509 contentId,
3510 headingId,
3511 descriptionId
3512 }) {
3513 const [isOpen, setIsOpen] = (0, import_element19.useState)(false);
3514 return /* @__PURE__ */ React.createElement(import_components2.Card, { className: "guidelines__accordion" }, /* @__PURE__ */ React.createElement(
3515 import_components2.Button,
3516 {
3517 className: "guidelines__accordion-trigger",
3518 onClick: () => setIsOpen(!isOpen),
3519 "aria-expanded": isOpen,
3520 "aria-controls": contentId,
3521 "aria-describedby": descriptionId,
3522 "aria-label": isOpen ? (0, import_i18n.sprintf)(
3523 /* translators: %s: Guideline title */
3524 (0, import_i18n.__)("Collapse %s guidelines"),
3525 title
3526 ) : (0, import_i18n.sprintf)(
3527 /* translators: %s: Guideline title */
3528 (0, import_i18n.__)("Expand %s guidelines"),
3529 title
3530 )
3531 },
3532 /* @__PURE__ */ React.createElement(import_components2.__experimentalHStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(import_components2.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement(
3533 import_components2.__experimentalHeading,
3534 {
3535 id: headingId,
3536 className: "guidelines__accordion-header",
3537 level: 2,
3538 size: 15,
3539 weight: 400
3540 },
3541 title
3542 ), /* @__PURE__ */ React.createElement(
3543 import_components2.__experimentalText,
3544 {
3545 id: descriptionId,
3546 className: "guidelines__accordion-description",
3547 size: 13,
3548 weight: 400,
3549 variant: "muted"
3550 },
3551 description
3552 )), /* @__PURE__ */ React.createElement(
3553 import_components2.Icon,
3554 {
3555 icon: chevron_down_default,
3556 className: isOpen ? "guidelines__accordion-chevron-up" : "guidelines__accordion-chevron-down"
3557 }
3558 ))
3559 ), /* @__PURE__ */ React.createElement("div", { hidden: !isOpen }, children));
3560 }
3561
3562 // routes/guidelines/components/guideline-accordion-form.tsx
3563 var import_components54 = __toESM(require_components());
3564
3565 // packages/dataviews/build-module/dataviews/index.mjs
3566 var import_element75 = __toESM(require_element(), 1);
3567 var import_compose12 = __toESM(require_compose(), 1);
3568
3569 // packages/dataviews/build-module/components/dataviews-context/index.mjs
3570 var import_element20 = __toESM(require_element(), 1);
3571
3572 // packages/dataviews/build-module/constants.mjs
3573 var import_i18n2 = __toESM(require_i18n(), 1);
3574 var OPERATOR_IS_ANY = "isAny";
3575 var OPERATOR_IS_NONE = "isNone";
3576 var OPERATOR_IS_ALL = "isAll";
3577 var OPERATOR_IS_NOT_ALL = "isNotAll";
3578 var OPERATOR_BETWEEN = "between";
3579 var OPERATOR_IN_THE_PAST = "inThePast";
3580 var OPERATOR_OVER = "over";
3581 var OPERATOR_IS = "is";
3582 var OPERATOR_IS_NOT = "isNot";
3583 var OPERATOR_LESS_THAN = "lessThan";
3584 var OPERATOR_GREATER_THAN = "greaterThan";
3585 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
3586 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
3587 var OPERATOR_BEFORE = "before";
3588 var OPERATOR_AFTER = "after";
3589 var OPERATOR_BEFORE_INC = "beforeInc";
3590 var OPERATOR_AFTER_INC = "afterInc";
3591 var OPERATOR_CONTAINS = "contains";
3592 var OPERATOR_NOT_CONTAINS = "notContains";
3593 var OPERATOR_STARTS_WITH = "startsWith";
3594 var OPERATOR_ON = "on";
3595 var OPERATOR_NOT_ON = "notOn";
3596 var SORTING_DIRECTIONS = ["asc", "desc"];
3597 var sortArrows = { asc: "\u2191", desc: "\u2193" };
3598 var sortValues = { asc: "ascending", desc: "descending" };
3599 var sortLabels = {
3600 asc: (0, import_i18n2.__)("Sort ascending"),
3601 desc: (0, import_i18n2.__)("Sort descending")
3602 };
3603 var sortIcons = {
3604 asc: arrow_up_default,
3605 desc: arrow_down_default
3606 };
3607 var LAYOUT_TABLE = "table";
3608 var LAYOUT_GRID = "grid";
3609 var LAYOUT_LIST = "list";
3610 var LAYOUT_ACTIVITY = "activity";
3611 var LAYOUT_PICKER_GRID = "pickerGrid";
3612 var LAYOUT_PICKER_TABLE = "pickerTable";
3613
3614 // packages/dataviews/build-module/components/dataviews-context/index.mjs
3615 var DataViewsContext = (0, import_element20.createContext)({
3616 view: { type: LAYOUT_TABLE },
3617 onChangeView: () => {
3618 },
3619 fields: [],
3620 data: [],
3621 paginationInfo: {
3622 totalItems: 0,
3623 totalPages: 0
3624 },
3625 selection: [],
3626 onChangeSelection: () => {
3627 },
3628 setOpenedFilter: () => {
3629 },
3630 openedFilter: null,
3631 getItemId: (item) => item.id,
3632 isItemClickable: () => true,
3633 renderItemLink: void 0,
3634 containerWidth: 0,
3635 containerRef: (0, import_element20.createRef)(),
3636 resizeObserverRef: () => {
3637 },
3638 defaultLayouts: { list: {}, grid: {}, table: {} },
3639 filters: [],
3640 isShowingFilter: false,
3641 setIsShowingFilter: () => {
3642 },
3643 hasInitiallyLoaded: false,
3644 config: {
3645 perPageSizes: []
3646 },
3647 intersectionObserver: null
3648 });
3649 DataViewsContext.displayName = "DataViewsContext";
3650 var dataviews_context_default = DataViewsContext;
3651
3652 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
3653 var import_i18n22 = __toESM(require_i18n(), 1);
3654
3655 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
3656 var import_i18n10 = __toESM(require_i18n(), 1);
3657 var import_components8 = __toESM(require_components(), 1);
3658 var import_element28 = __toESM(require_element(), 1);
3659 var import_keycodes = __toESM(require_keycodes(), 1);
3660
3661 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
3662 var import_components3 = __toESM(require_components(), 1);
3663 var import_i18n3 = __toESM(require_i18n(), 1);
3664 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
3665 function DataViewsSelectionCheckbox({
3666 selection,
3667 onChangeSelection,
3668 item,
3669 getItemId,
3670 titleField,
3671 disabled: disabled2,
3672 ...extraProps
3673 }) {
3674 const id = getItemId(item);
3675 const isInSelectionArray = selection.includes(id);
3676 const checked = !disabled2 && isInSelectionArray;
3677 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
3678 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3679 import_components3.CheckboxControl,
3680 {
3681 className: "dataviews-selection-checkbox",
3682 "aria-label": selectionLabel,
3683 "aria-disabled": disabled2,
3684 checked,
3685 onChange: () => {
3686 if (disabled2) {
3687 return;
3688 }
3689 onChangeSelection(
3690 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
3691 );
3692 },
3693 ...extraProps
3694 }
3695 );
3696 }
3697
3698 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
3699 var import_components4 = __toESM(require_components(), 1);
3700 var import_i18n4 = __toESM(require_i18n(), 1);
3701 var import_element21 = __toESM(require_element(), 1);
3702 var import_data = __toESM(require_data(), 1);
3703 var import_compose = __toESM(require_compose(), 1);
3704
3705 // packages/dataviews/build-module/lock-unlock.mjs
3706 var import_private_apis = __toESM(require_private_apis(), 1);
3707 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
3708 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
3709 "@wordpress/dataviews"
3710 );
3711
3712 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
3713 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
3714 var { Menu, kebabCase } = unlock(import_components4.privateApis);
3715 function ButtonTrigger({
3716 action,
3717 onClick,
3718 items,
3719 variant
3720 }) {
3721 const label = typeof action.label === "string" ? action.label : action.label(items);
3722 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3723 import_components4.Button,
3724 {
3725 disabled: !!action.disabled,
3726 accessibleWhenDisabled: true,
3727 size: "compact",
3728 variant,
3729 onClick,
3730 children: label
3731 }
3732 );
3733 }
3734 function MenuItemTrigger({
3735 action,
3736 onClick,
3737 items
3738 }) {
3739 const label = typeof action.label === "string" ? action.label : action.label(items);
3740 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.ItemLabel, { children: label }) });
3741 }
3742 function ActionModal({
3743 action,
3744 items,
3745 closeModal
3746 }) {
3747 const label = typeof action.label === "string" ? action.label : action.label(items);
3748 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
3749 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3750 import_components4.Modal,
3751 {
3752 title: modalHeader || label,
3753 __experimentalHideHeader: !!action.hideModalHeader,
3754 onRequestClose: closeModal,
3755 focusOnMount: action.modalFocusOnMount ?? true,
3756 size: action.modalSize || "medium",
3757 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
3758 action.id
3759 )}`,
3760 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(action.RenderModal, { items, closeModal })
3761 }
3762 );
3763 }
3764 function ActionsMenuGroup({
3765 actions: actions2,
3766 item,
3767 registry,
3768 setActiveModalAction
3769 }) {
3770 const { primaryActions, regularActions } = (0, import_element21.useMemo)(() => {
3771 return actions2.reduce(
3772 (acc, action) => {
3773 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
3774 return acc;
3775 },
3776 {
3777 primaryActions: [],
3778 regularActions: []
3779 }
3780 );
3781 }, [actions2]);
3782 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3783 MenuItemTrigger,
3784 {
3785 action,
3786 onClick: () => {
3787 if ("RenderModal" in action) {
3788 setActiveModalAction(action);
3789 return;
3790 }
3791 action.callback([item], { registry });
3792 },
3793 items: [item]
3794 },
3795 action.id
3796 ));
3797 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Menu.Group, { children: [
3798 renderActionGroup(primaryActions),
3799 renderActionGroup(regularActions)
3800 ] });
3801 }
3802 function ItemActions({
3803 item,
3804 actions: actions2,
3805 isCompact
3806 }) {
3807 const registry = (0, import_data.useRegistry)();
3808 const { primaryActions, eligibleActions } = (0, import_element21.useMemo)(() => {
3809 const _eligibleActions = actions2.filter(
3810 (action) => !action.isEligible || action.isEligible(item)
3811 );
3812 const _primaryActions = _eligibleActions.filter(
3813 (action) => action.isPrimary
3814 );
3815 return {
3816 primaryActions: _primaryActions,
3817 eligibleActions: _eligibleActions
3818 };
3819 }, [actions2, item]);
3820 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
3821 if (isCompact) {
3822 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3823 CompactItemActions,
3824 {
3825 item,
3826 actions: eligibleActions,
3827 isSmall: true,
3828 registry
3829 }
3830 );
3831 }
3832 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
3833 Stack,
3834 {
3835 direction: "row",
3836 justify: "flex-end",
3837 className: "dataviews-item-actions",
3838 style: {
3839 flexShrink: 0,
3840 width: "auto"
3841 },
3842 children: [
3843 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3844 PrimaryActions,
3845 {
3846 item,
3847 actions: primaryActions,
3848 registry
3849 }
3850 ),
3851 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
3852 // there if there are any actions at all.
3853 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3854 CompactItemActions,
3855 {
3856 item,
3857 actions: eligibleActions,
3858 registry
3859 }
3860 )
3861 ]
3862 }
3863 );
3864 }
3865 function CompactItemActions({
3866 item,
3867 actions: actions2,
3868 isSmall,
3869 registry
3870 }) {
3871 const [activeModalAction, setActiveModalAction] = (0, import_element21.useState)(
3872 null
3873 );
3874 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
3875 /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Menu, { placement: "bottom-end", children: [
3876 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3877 Menu.TriggerButton,
3878 {
3879 render: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3880 import_components4.Button,
3881 {
3882 size: isSmall ? "small" : "compact",
3883 icon: more_vertical_default,
3884 label: (0, import_i18n4.__)("Actions"),
3885 accessibleWhenDisabled: true,
3886 disabled: !actions2.length,
3887 className: "dataviews-all-actions-button"
3888 }
3889 )
3890 }
3891 ),
3892 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3893 ActionsMenuGroup,
3894 {
3895 actions: actions2,
3896 item,
3897 registry,
3898 setActiveModalAction
3899 }
3900 ) })
3901 ] }),
3902 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3903 ActionModal,
3904 {
3905 action: activeModalAction,
3906 items: [item],
3907 closeModal: () => setActiveModalAction(null)
3908 }
3909 )
3910 ] });
3911 }
3912 function PrimaryActions({
3913 item,
3914 actions: actions2,
3915 registry,
3916 buttonVariant
3917 }) {
3918 const [activeModalAction, setActiveModalAction] = (0, import_element21.useState)(null);
3919 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
3920 if (isMobileViewport) {
3921 return null;
3922 }
3923 if (!Array.isArray(actions2) || actions2.length === 0) {
3924 return null;
3925 }
3926 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
3927 actions2.map((action) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3928 ButtonTrigger,
3929 {
3930 action,
3931 onClick: () => {
3932 if ("RenderModal" in action) {
3933 setActiveModalAction(action);
3934 return;
3935 }
3936 action.callback([item], { registry });
3937 },
3938 items: [item],
3939 variant: buttonVariant
3940 },
3941 action.id
3942 )),
3943 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3944 ActionModal,
3945 {
3946 action: activeModalAction,
3947 items: [item],
3948 closeModal: () => setActiveModalAction(null)
3949 }
3950 )
3951 ] });
3952 }
3953
3954 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
3955 var import_components5 = __toESM(require_components(), 1);
3956 var import_i18n6 = __toESM(require_i18n(), 1);
3957 var import_element22 = __toESM(require_element(), 1);
3958 var import_data2 = __toESM(require_data(), 1);
3959 var import_compose2 = __toESM(require_compose(), 1);
3960
3961 // packages/dataviews/build-module/utils/get-footer-message.mjs
3962 var import_i18n5 = __toESM(require_i18n(), 1);
3963 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
3964 if (selectionCount > 0) {
3965 return (0, import_i18n5.sprintf)(
3966 /* translators: %d: number of items. */
3967 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
3968 selectionCount
3969 );
3970 }
3971 if (onlyTotalCount || totalItems <= itemsCount) {
3972 return (0, import_i18n5.sprintf)(
3973 /* translators: %d: number of items. */
3974 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
3975 totalItems
3976 );
3977 }
3978 return (0, import_i18n5.sprintf)(
3979 /* translators: %1$d: number of items. %2$d: total number of items. */
3980 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
3981 itemsCount,
3982 totalItems
3983 );
3984 }
3985
3986 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
3987 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
3988 function ActionWithModal({
3989 action,
3990 items,
3991 ActionTriggerComponent
3992 }) {
3993 const [isModalOpen, setIsModalOpen] = (0, import_element22.useState)(false);
3994 const actionTriggerProps = {
3995 action,
3996 onClick: () => {
3997 setIsModalOpen(true);
3998 },
3999 items
4000 };
4001 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4002 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
4003 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4004 ActionModal,
4005 {
4006 action,
4007 items,
4008 closeModal: () => setIsModalOpen(false)
4009 }
4010 )
4011 ] });
4012 }
4013 function useHasAPossibleBulkAction(actions2, item) {
4014 return (0, import_element22.useMemo)(() => {
4015 return actions2.some((action) => {
4016 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
4017 });
4018 }, [actions2, item]);
4019 }
4020 function useSomeItemHasAPossibleBulkAction(actions2, data) {
4021 return (0, import_element22.useMemo)(() => {
4022 return data.some((item) => {
4023 return actions2.some((action) => {
4024 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
4025 });
4026 });
4027 }, [actions2, data]);
4028 }
4029 function BulkSelectionCheckbox({
4030 selection,
4031 onChangeSelection,
4032 data,
4033 actions: actions2,
4034 getItemId,
4035 disableSelectAll = false
4036 }) {
4037 const selectableItems = (0, import_element22.useMemo)(() => {
4038 return data.filter((item) => {
4039 return actions2.some(
4040 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
4041 );
4042 });
4043 }, [data, actions2]);
4044 const selectedItems = data.filter(
4045 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
4046 );
4047 const hasSelection = selection.length > 0;
4048 const areAllSelected = selectedItems.length === selectableItems.length;
4049 if (disableSelectAll) {
4050 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4051 import_components5.CheckboxControl,
4052 {
4053 className: "dataviews-view-table-selection-checkbox",
4054 checked: hasSelection,
4055 disabled: !hasSelection,
4056 onChange: () => {
4057 onChangeSelection([]);
4058 },
4059 "aria-label": (0, import_i18n6.__)("Deselect all")
4060 }
4061 );
4062 }
4063 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4064 import_components5.CheckboxControl,
4065 {
4066 className: "dataviews-view-table-selection-checkbox",
4067 checked: areAllSelected,
4068 indeterminate: !areAllSelected && !!selectedItems.length,
4069 onChange: () => {
4070 if (areAllSelected) {
4071 onChangeSelection([]);
4072 } else {
4073 onChangeSelection(
4074 selectableItems.map((item) => getItemId(item))
4075 );
4076 }
4077 },
4078 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
4079 }
4080 );
4081 }
4082 function ActionTrigger({
4083 action,
4084 onClick,
4085 isBusy,
4086 items
4087 }) {
4088 const label = typeof action.label === "string" ? action.label : action.label(items);
4089 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
4090 if (isMobile) {
4091 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4092 import_components5.Button,
4093 {
4094 disabled: isBusy,
4095 accessibleWhenDisabled: true,
4096 label,
4097 icon: action.icon,
4098 size: "compact",
4099 onClick,
4100 isBusy
4101 }
4102 );
4103 }
4104 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4105 import_components5.Button,
4106 {
4107 disabled: isBusy,
4108 accessibleWhenDisabled: true,
4109 size: "compact",
4110 onClick,
4111 isBusy,
4112 children: label
4113 }
4114 );
4115 }
4116 var EMPTY_ARRAY2 = [];
4117 function ActionButton({
4118 action,
4119 selectedItems,
4120 actionInProgress,
4121 setActionInProgress
4122 }) {
4123 const registry = (0, import_data2.useRegistry)();
4124 const selectedEligibleItems = (0, import_element22.useMemo)(() => {
4125 return selectedItems.filter((item) => {
4126 return !action.isEligible || action.isEligible(item);
4127 });
4128 }, [action, selectedItems]);
4129 if ("RenderModal" in action) {
4130 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4131 ActionWithModal,
4132 {
4133 action,
4134 items: selectedEligibleItems,
4135 ActionTriggerComponent: ActionTrigger
4136 },
4137 action.id
4138 );
4139 }
4140 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4141 ActionTrigger,
4142 {
4143 action,
4144 onClick: async () => {
4145 setActionInProgress(action.id);
4146 await action.callback(selectedItems, {
4147 registry
4148 });
4149 setActionInProgress(null);
4150 },
4151 items: selectedEligibleItems,
4152 isBusy: actionInProgress === action.id
4153 },
4154 action.id
4155 );
4156 }
4157 function renderFooterContent(data, actions2, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
4158 const message2 = getFooterMessage(
4159 selection.length,
4160 data.length,
4161 paginationInfo.totalItems,
4162 isInfiniteScroll
4163 );
4164 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4165 Stack,
4166 {
4167 direction: "row",
4168 className: "dataviews-bulk-actions-footer__container",
4169 gap: "md",
4170 align: "center",
4171 children: [
4172 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4173 BulkSelectionCheckbox,
4174 {
4175 selection,
4176 onChangeSelection,
4177 data,
4178 actions: actions2,
4179 getItemId,
4180 disableSelectAll: isInfiniteScroll
4181 }
4182 ),
4183 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
4184 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4185 Stack,
4186 {
4187 direction: "row",
4188 className: "dataviews-bulk-actions-footer__action-buttons",
4189 gap: "xs",
4190 children: [
4191 actionsToShow.map((action) => {
4192 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4193 ActionButton,
4194 {
4195 action,
4196 selectedItems,
4197 actionInProgress,
4198 setActionInProgress
4199 },
4200 action.id
4201 );
4202 }),
4203 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4204 import_components5.Button,
4205 {
4206 icon: close_small_default,
4207 showTooltip: true,
4208 tooltipPosition: "top",
4209 size: "compact",
4210 label: (0, import_i18n6.__)("Cancel"),
4211 disabled: !!actionInProgress,
4212 accessibleWhenDisabled: false,
4213 onClick: () => {
4214 onChangeSelection(EMPTY_ARRAY2);
4215 }
4216 }
4217 )
4218 ]
4219 }
4220 )
4221 ]
4222 }
4223 );
4224 }
4225 function FooterContent({
4226 selection,
4227 actions: actions2,
4228 onChangeSelection,
4229 data,
4230 getItemId,
4231 isInfiniteScroll,
4232 paginationInfo
4233 }) {
4234 const [actionInProgress, setActionInProgress] = (0, import_element22.useState)(
4235 null
4236 );
4237 const footerContentRef = (0, import_element22.useRef)(void 0);
4238 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
4239 const bulkActions = (0, import_element22.useMemo)(
4240 () => actions2.filter((action) => action.supportsBulk),
4241 [actions2]
4242 );
4243 const selectableItems = (0, import_element22.useMemo)(() => {
4244 return data.filter((item) => {
4245 return bulkActions.some(
4246 (action) => !action.isEligible || action.isEligible(item)
4247 );
4248 });
4249 }, [data, bulkActions]);
4250 const selectedItems = (0, import_element22.useMemo)(() => {
4251 return data.filter(
4252 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
4253 );
4254 }, [selection, data, getItemId, selectableItems]);
4255 const actionsToShow = (0, import_element22.useMemo)(
4256 () => actions2.filter((action) => {
4257 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
4258 (item) => !action.isEligible || action.isEligible(item)
4259 );
4260 }),
4261 [actions2, selectedItems, isMobile]
4262 );
4263 if (!actionInProgress) {
4264 if (footerContentRef.current) {
4265 footerContentRef.current = void 0;
4266 }
4267 return renderFooterContent(
4268 data,
4269 actions2,
4270 getItemId,
4271 isInfiniteScroll,
4272 selection,
4273 actionsToShow,
4274 selectedItems,
4275 actionInProgress,
4276 setActionInProgress,
4277 onChangeSelection,
4278 paginationInfo
4279 );
4280 } else if (!footerContentRef.current) {
4281 footerContentRef.current = renderFooterContent(
4282 data,
4283 actions2,
4284 getItemId,
4285 isInfiniteScroll,
4286 selection,
4287 actionsToShow,
4288 selectedItems,
4289 actionInProgress,
4290 setActionInProgress,
4291 onChangeSelection,
4292 paginationInfo
4293 );
4294 }
4295 return footerContentRef.current;
4296 }
4297 function BulkActionsFooter() {
4298 const {
4299 data,
4300 selection,
4301 actions: actions2 = EMPTY_ARRAY2,
4302 onChangeSelection,
4303 getItemId,
4304 paginationInfo,
4305 view
4306 } = (0, import_element22.useContext)(dataviews_context_default);
4307 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4308 FooterContent,
4309 {
4310 selection,
4311 onChangeSelection,
4312 data,
4313 actions: actions2,
4314 getItemId,
4315 isInfiniteScroll: !!view.infiniteScrollEnabled,
4316 paginationInfo
4317 }
4318 );
4319 }
4320
4321 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
4322 var import_i18n7 = __toESM(require_i18n(), 1);
4323 var import_components6 = __toESM(require_components(), 1);
4324 var import_element23 = __toESM(require_element(), 1);
4325
4326 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
4327 function getHideableFields(view, fields2) {
4328 const togglableFields = [
4329 view?.titleField,
4330 view?.mediaField,
4331 view?.descriptionField
4332 ].filter(Boolean);
4333 return fields2.filter(
4334 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
4335 );
4336 }
4337
4338 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
4339 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
4340 var { Menu: Menu2 } = unlock(import_components6.privateApis);
4341 function WithMenuSeparators({ children }) {
4342 return import_element23.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_element23.Fragment, { children: [
4343 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Separator, {}),
4344 child
4345 ] }, i2));
4346 }
4347 var _HeaderMenu = (0, import_element23.forwardRef)(function HeaderMenu({
4348 fieldId,
4349 view,
4350 fields: fields2,
4351 onChangeView,
4352 onHide,
4353 setOpenedFilter,
4354 canMove = true,
4355 canInsertLeft = true,
4356 canInsertRight = true
4357 }, ref) {
4358 const visibleFieldIds = view.fields ?? [];
4359 const index = visibleFieldIds?.indexOf(fieldId);
4360 const isSorted = view.sort?.field === fieldId;
4361 let isHidable = false;
4362 let isSortable = false;
4363 let canAddFilter = false;
4364 let operators = [];
4365 const field = fields2.find((f2) => f2.id === fieldId);
4366 const { setIsShowingFilter } = (0, import_element23.useContext)(dataviews_context_default);
4367 if (!field) {
4368 return null;
4369 }
4370 isHidable = field.enableHiding !== false;
4371 isSortable = field.enableSorting !== false;
4372 const header = field.header;
4373 operators = !!field.filterBy && field.filterBy?.operators || [];
4374 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
4375 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
4376 return header;
4377 }
4378 const hiddenFields = getHideableFields(view, fields2).filter(
4379 (f2) => !visibleFieldIds.includes(f2.id)
4380 );
4381 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
4382 const isRtl = (0, import_i18n7.isRTL)();
4383 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
4384 /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4385 Menu2.TriggerButton,
4386 {
4387 render: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4388 import_components6.Button,
4389 {
4390 size: "compact",
4391 className: "dataviews-view-table-header-button",
4392 ref,
4393 variant: "tertiary"
4394 }
4395 ),
4396 children: [
4397 header,
4398 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
4399 ]
4400 }
4401 ),
4402 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(WithMenuSeparators, { children: [
4403 isSortable && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
4404 (direction) => {
4405 const isChecked = view.sort && isSorted && view.sort.direction === direction;
4406 const value = `${fieldId}-${direction}`;
4407 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4408 Menu2.RadioItem,
4409 {
4410 name: "view-table-sorting",
4411 value,
4412 checked: isChecked,
4413 onChange: () => {
4414 onChangeView({
4415 ...view,
4416 sort: {
4417 field: fieldId,
4418 direction
4419 },
4420 showLevels: false
4421 });
4422 },
4423 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
4424 },
4425 value
4426 );
4427 }
4428 ) }),
4429 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4430 Menu2.Item,
4431 {
4432 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: funnel_default }),
4433 onClick: () => {
4434 setOpenedFilter(fieldId);
4435 setIsShowingFilter(true);
4436 onChangeView({
4437 ...view,
4438 page: 1,
4439 filters: [
4440 ...view.filters || [],
4441 {
4442 field: fieldId,
4443 value: void 0,
4444 operator: operators[0]
4445 }
4446 ]
4447 });
4448 },
4449 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
4450 }
4451 ) }),
4452 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2.Group, { children: [
4453 canMove && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4454 Menu2.Item,
4455 {
4456 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: arrow_left_default }),
4457 disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
4458 onClick: () => {
4459 const targetIndex = isRtl ? index + 1 : index - 1;
4460 const newFields = [
4461 ...visibleFieldIds
4462 ];
4463 newFields.splice(index, 1);
4464 newFields.splice(
4465 targetIndex,
4466 0,
4467 fieldId
4468 );
4469 onChangeView({
4470 ...view,
4471 fields: newFields
4472 });
4473 },
4474 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
4475 }
4476 ),
4477 canMove && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4478 Menu2.Item,
4479 {
4480 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: arrow_right_default }),
4481 disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
4482 onClick: () => {
4483 const targetIndex = isRtl ? index - 1 : index + 1;
4484 const newFields = [
4485 ...visibleFieldIds
4486 ];
4487 newFields.splice(index, 1);
4488 newFields.splice(
4489 targetIndex,
4490 0,
4491 fieldId
4492 );
4493 onChangeView({
4494 ...view,
4495 fields: newFields
4496 });
4497 },
4498 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
4499 }
4500 ),
4501 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
4502 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
4503 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
4504 const insertIndex = isRtl ? index + 1 : index;
4505 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4506 Menu2.Item,
4507 {
4508 onClick: () => {
4509 onChangeView({
4510 ...view,
4511 fields: [
4512 ...visibleFieldIds.slice(
4513 0,
4514 insertIndex
4515 ),
4516 hiddenField.id,
4517 ...visibleFieldIds.slice(
4518 insertIndex
4519 )
4520 ]
4521 });
4522 },
4523 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
4524 },
4525 hiddenField.id
4526 );
4527 }) })
4528 ] }),
4529 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
4530 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
4531 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
4532 const insertIndex = isRtl ? index : index + 1;
4533 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4534 Menu2.Item,
4535 {
4536 onClick: () => {
4537 onChangeView({
4538 ...view,
4539 fields: [
4540 ...visibleFieldIds.slice(
4541 0,
4542 insertIndex
4543 ),
4544 hiddenField.id,
4545 ...visibleFieldIds.slice(
4546 insertIndex
4547 )
4548 ]
4549 });
4550 },
4551 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
4552 },
4553 hiddenField.id
4554 );
4555 }) })
4556 ] }),
4557 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4558 Menu2.Item,
4559 {
4560 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: unseen_default }),
4561 onClick: () => {
4562 onHide(field);
4563 onChangeView({
4564 ...view,
4565 fields: visibleFieldIds.filter(
4566 (id) => id !== fieldId
4567 )
4568 });
4569 },
4570 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
4571 }
4572 )
4573 ] })
4574 ] }) })
4575 ] });
4576 });
4577 var ColumnHeaderMenu = _HeaderMenu;
4578 var column_header_menu_default = ColumnHeaderMenu;
4579
4580 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
4581 var import_element24 = __toESM(require_element(), 1);
4582 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
4583 function getClickableItemProps({
4584 item,
4585 isItemClickable,
4586 onClickItem,
4587 className
4588 }) {
4589 if (!isItemClickable(item) || !onClickItem) {
4590 return { className };
4591 }
4592 return {
4593 className: className ? `${className} ${className}--clickable` : void 0,
4594 role: "button",
4595 tabIndex: 0,
4596 onClick: (event) => {
4597 event.stopPropagation();
4598 onClickItem(item);
4599 },
4600 onKeyDown: (event) => {
4601 if (event.key === "Enter" || event.key === "" || event.key === " ") {
4602 event.stopPropagation();
4603 onClickItem(item);
4604 }
4605 }
4606 };
4607 }
4608 function ItemClickWrapper({
4609 item,
4610 isItemClickable,
4611 onClickItem,
4612 renderItemLink,
4613 className,
4614 children,
4615 ...extraProps
4616 }) {
4617 if (!isItemClickable(item)) {
4618 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, ...extraProps, children });
4619 }
4620 if (renderItemLink) {
4621 const renderedElement = renderItemLink({
4622 item,
4623 className: `${className} ${className}--clickable`,
4624 ...extraProps,
4625 children
4626 });
4627 return (0, import_element24.cloneElement)(renderedElement, {
4628 onClick: (event) => {
4629 event.stopPropagation();
4630 if (renderedElement.props.onClick) {
4631 renderedElement.props.onClick(event);
4632 }
4633 },
4634 onKeyDown: (event) => {
4635 if (event.key === "Enter" || event.key === "" || event.key === " ") {
4636 event.stopPropagation();
4637 if (renderedElement.props.onKeyDown) {
4638 renderedElement.props.onKeyDown(event);
4639 }
4640 }
4641 }
4642 });
4643 }
4644 const clickProps = getClickableItemProps({
4645 item,
4646 isItemClickable,
4647 onClickItem,
4648 className
4649 });
4650 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { ...clickProps, ...extraProps, children });
4651 }
4652
4653 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
4654 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
4655 function ColumnPrimary({
4656 item,
4657 level,
4658 titleField,
4659 mediaField,
4660 descriptionField,
4661 onClickItem,
4662 renderItemLink,
4663 isItemClickable
4664 }) {
4665 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
4666 mediaField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
4667 ItemClickWrapper,
4668 {
4669 item,
4670 isItemClickable,
4671 onClickItem,
4672 renderItemLink,
4673 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
4674 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
4675 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
4676 mediaField.render,
4677 {
4678 item,
4679 field: mediaField,
4680 config: { sizes: "32px" }
4681 }
4682 )
4683 }
4684 ),
4685 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
4686 Stack,
4687 {
4688 direction: "column",
4689 align: "flex-start",
4690 className: "dataviews-view-table__primary-column-content",
4691 children: [
4692 titleField && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
4693 ItemClickWrapper,
4694 {
4695 item,
4696 isItemClickable,
4697 onClickItem,
4698 renderItemLink,
4699 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
4700 children: [
4701 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("span", { className: "dataviews-view-table__level", children: [
4702 Array(level).fill("\u2014").join(" "),
4703 "\xA0"
4704 ] }),
4705 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(titleField.render, { item, field: titleField })
4706 ]
4707 }
4708 ),
4709 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
4710 descriptionField.render,
4711 {
4712 item,
4713 field: descriptionField
4714 }
4715 )
4716 ]
4717 }
4718 )
4719 ] });
4720 }
4721 var column_primary_default = ColumnPrimary;
4722
4723 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
4724 var import_element25 = __toESM(require_element(), 1);
4725 var import_i18n8 = __toESM(require_i18n(), 1);
4726 var isScrolledToEnd = (element) => {
4727 if ((0, import_i18n8.isRTL)()) {
4728 const scrollLeft = Math.abs(element.scrollLeft);
4729 return scrollLeft <= 1;
4730 }
4731 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
4732 };
4733 function useScrollState({
4734 scrollContainerRef,
4735 enabledHorizontal = false
4736 }) {
4737 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element25.useState)(false);
4738 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element25.useState)(false);
4739 const handleScroll = (0, import_element25.useCallback)(() => {
4740 const scrollContainer = scrollContainerRef.current;
4741 if (!scrollContainer) {
4742 return;
4743 }
4744 if (enabledHorizontal) {
4745 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
4746 }
4747 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
4748 }, [scrollContainerRef, enabledHorizontal]);
4749 (0, import_element25.useEffect)(() => {
4750 if (typeof window === "undefined" || !scrollContainerRef.current) {
4751 return () => {
4752 };
4753 }
4754 const scrollContainer = scrollContainerRef.current;
4755 handleScroll();
4756 scrollContainer.addEventListener("scroll", handleScroll);
4757 window.addEventListener("resize", handleScroll);
4758 return () => {
4759 scrollContainer.removeEventListener("scroll", handleScroll);
4760 window.removeEventListener("resize", handleScroll);
4761 };
4762 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
4763 return { isHorizontalScrollEnd, isVerticallyScrolled };
4764 }
4765
4766 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
4767 function getDataByGroup(data, groupByField) {
4768 return data.reduce((groups, item) => {
4769 const groupName = groupByField.getValue({ item });
4770 if (!groups.has(groupName)) {
4771 groups.set(groupName, []);
4772 }
4773 groups.get(groupName)?.push(item);
4774 return groups;
4775 }, /* @__PURE__ */ new Map());
4776 }
4777
4778 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
4779 var import_components7 = __toESM(require_components(), 1);
4780 var import_i18n9 = __toESM(require_i18n(), 1);
4781 var import_element26 = __toESM(require_element(), 1);
4782 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
4783 function FieldItem({
4784 field,
4785 isVisible: isVisible2,
4786 onToggleVisibility
4787 }) {
4788 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components7.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
4789 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components7.Icon, { icon: check_default }) }),
4790 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
4791 ] }) });
4792 }
4793 function isDefined(item) {
4794 return !!item;
4795 }
4796 function PropertiesSection({
4797 showLabel = true
4798 }) {
4799 const { view, fields: fields2, onChangeView } = (0, import_element26.useContext)(dataviews_context_default);
4800 const regularFields = getHideableFields(view, fields2);
4801 if (!regularFields?.length) {
4802 return null;
4803 }
4804 const titleField = fields2.find((f2) => f2.id === view.titleField);
4805 const previewField = fields2.find((f2) => f2.id === view.mediaField);
4806 const descriptionField = fields2.find(
4807 (f2) => f2.id === view.descriptionField
4808 );
4809 const lockedFields = [
4810 {
4811 field: titleField,
4812 isVisibleFlag: "showTitle"
4813 },
4814 {
4815 field: previewField,
4816 isVisibleFlag: "showMedia"
4817 },
4818 {
4819 field: descriptionField,
4820 isVisibleFlag: "showDescription"
4821 }
4822 ].filter(({ field }) => isDefined(field));
4823 const visibleFieldIds = view.fields ?? [];
4824 const visibleRegularFieldsCount = regularFields.filter(
4825 (f2) => visibleFieldIds.includes(f2.id)
4826 ).length;
4827 const visibleLockedFields = lockedFields.filter(
4828 ({ isVisibleFlag }) => (
4829 // @ts-expect-error
4830 view[isVisibleFlag] ?? true
4831 )
4832 );
4833 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
4834 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
4835 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
4836 showLabel && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
4837 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4838 Stack,
4839 {
4840 direction: "column",
4841 className: "dataviews-view-config__properties",
4842 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
4843 lockedFields.map(({ field, isVisibleFlag }) => {
4844 const isVisible2 = view[isVisibleFlag] ?? true;
4845 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
4846 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4847 FieldItem,
4848 {
4849 field: fieldToRender,
4850 isVisible: isVisible2,
4851 onToggleVisibility: () => {
4852 onChangeView({
4853 ...view,
4854 [isVisibleFlag]: !isVisible2
4855 });
4856 }
4857 },
4858 field.id
4859 );
4860 }),
4861 regularFields.map((field) => {
4862 const isVisible2 = visibleFieldIds.includes(field.id);
4863 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
4864 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4865 FieldItem,
4866 {
4867 field: fieldToRender,
4868 isVisible: isVisible2,
4869 onToggleVisibility: () => {
4870 onChangeView({
4871 ...view,
4872 fields: isVisible2 ? visibleFieldIds.filter(
4873 (fieldId) => fieldId !== field.id
4874 ) : [...visibleFieldIds, field.id]
4875 });
4876 }
4877 },
4878 field.id
4879 );
4880 })
4881 ] })
4882 }
4883 )
4884 ] });
4885 }
4886
4887 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
4888 var import_element27 = __toESM(require_element(), 1);
4889 function useDelayedLoading(isLoading, options = { delay: 400 }) {
4890 const [showLoader, setShowLoader] = (0, import_element27.useState)(false);
4891 (0, import_element27.useEffect)(() => {
4892 if (!isLoading) {
4893 return;
4894 }
4895 const timeout = setTimeout(() => {
4896 setShowLoader(true);
4897 }, options.delay);
4898 return () => {
4899 clearTimeout(timeout);
4900 setShowLoader(false);
4901 };
4902 }, [isLoading, options.delay]);
4903 return showLoader;
4904 }
4905
4906 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
4907 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
4908 function getEffectiveAlign(explicitAlign, fieldType) {
4909 if (explicitAlign) {
4910 return explicitAlign;
4911 }
4912 if (fieldType === "integer" || fieldType === "number") {
4913 return "end";
4914 }
4915 return void 0;
4916 }
4917 function TableColumnField({
4918 item,
4919 fields: fields2,
4920 column,
4921 align
4922 }) {
4923 const field = fields2.find((f2) => f2.id === column);
4924 if (!field) {
4925 return null;
4926 }
4927 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
4928 "dataviews-view-table__cell-align-end": align === "end",
4929 "dataviews-view-table__cell-align-center": align === "center"
4930 });
4931 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(field.render, { item, field }) });
4932 }
4933 function TableRow({
4934 hasBulkActions,
4935 item,
4936 level,
4937 actions: actions2,
4938 fields: fields2,
4939 id,
4940 view,
4941 titleField,
4942 mediaField,
4943 descriptionField,
4944 selection,
4945 getItemId,
4946 isItemClickable,
4947 onClickItem,
4948 renderItemLink,
4949 onChangeSelection,
4950 isActionsColumnSticky,
4951 posinset
4952 }) {
4953 const { paginationInfo } = (0, import_element28.useContext)(dataviews_context_default);
4954 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions2, item);
4955 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
4956 const {
4957 showTitle = true,
4958 showMedia = true,
4959 showDescription = true,
4960 infiniteScrollEnabled
4961 } = view;
4962 const isTouchDeviceRef = (0, import_element28.useRef)(false);
4963 const columns = view.fields ?? [];
4964 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
4965 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
4966 "tr",
4967 {
4968 className: clsx_default("dataviews-view-table__row", {
4969 "is-selected": hasPossibleBulkAction && isSelected2,
4970 "has-bulk-actions": hasPossibleBulkAction
4971 }),
4972 onTouchStart: () => {
4973 isTouchDeviceRef.current = true;
4974 },
4975 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
4976 "aria-posinset": posinset,
4977 role: infiniteScrollEnabled ? "article" : void 0,
4978 onMouseDown: (event) => {
4979 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
4980 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
4981 event?.preventDefault();
4982 }
4983 },
4984 onClick: (event) => {
4985 if (!hasPossibleBulkAction) {
4986 return;
4987 }
4988 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
4989 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
4990 onChangeSelection(
4991 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
4992 );
4993 }
4994 },
4995 children: [
4996 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4997 DataViewsSelectionCheckbox,
4998 {
4999 item,
5000 selection,
5001 onChangeSelection,
5002 getItemId,
5003 titleField,
5004 disabled: !hasPossibleBulkAction
5005 }
5006 ) }) }),
5007 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5008 column_primary_default,
5009 {
5010 item,
5011 level,
5012 titleField: showTitle ? titleField : void 0,
5013 mediaField: showMedia ? mediaField : void 0,
5014 descriptionField: showDescription ? descriptionField : void 0,
5015 isItemClickable,
5016 onClickItem,
5017 renderItemLink
5018 }
5019 ) }),
5020 columns.map((column) => {
5021 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5022 const field = fields2.find((f2) => f2.id === column);
5023 const effectiveAlign = getEffectiveAlign(align, field?.type);
5024 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5025 "td",
5026 {
5027 style: {
5028 width,
5029 maxWidth,
5030 minWidth
5031 },
5032 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5033 TableColumnField,
5034 {
5035 fields: fields2,
5036 item,
5037 column,
5038 align: effectiveAlign
5039 }
5040 )
5041 },
5042 column
5043 );
5044 }),
5045 !!actions2?.length && // Disable reason: we are not making the element interactive,
5046 // but preventing any click events from bubbling up to the
5047 // table row. This allows us to add a click handler to the row
5048 // itself (to toggle row selection) without erroneously
5049 // intercepting click events from ItemActions.
5050 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5051 "td",
5052 {
5053 className: clsx_default("dataviews-view-table__actions-column", {
5054 "dataviews-view-table__actions-column--sticky": true,
5055 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
5056 }),
5057 onClick: (e2) => e2.stopPropagation(),
5058 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ItemActions, { item, actions: actions2 })
5059 }
5060 )
5061 ]
5062 }
5063 );
5064 }
5065 function ViewTable({
5066 actions: actions2,
5067 data,
5068 fields: fields2,
5069 getItemId,
5070 getItemLevel,
5071 isLoading = false,
5072 onChangeView,
5073 onChangeSelection,
5074 selection,
5075 setOpenedFilter,
5076 onClickItem,
5077 isItemClickable,
5078 renderItemLink,
5079 view,
5080 className,
5081 empty
5082 }) {
5083 const { containerRef } = (0, import_element28.useContext)(dataviews_context_default);
5084 const isDelayedLoading = useDelayedLoading(isLoading);
5085 const headerMenuRefs = (0, import_element28.useRef)(/* @__PURE__ */ new Map());
5086 const headerMenuToFocusRef = (0, import_element28.useRef)(void 0);
5087 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element28.useState)();
5088 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element28.useState)(null);
5089 (0, import_element28.useEffect)(() => {
5090 if (headerMenuToFocusRef.current) {
5091 headerMenuToFocusRef.current.focus();
5092 headerMenuToFocusRef.current = void 0;
5093 }
5094 });
5095 const tableNoticeId = (0, import_element28.useId)();
5096 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
5097 scrollContainerRef: containerRef,
5098 enabledHorizontal: !!actions2?.length
5099 });
5100 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data);
5101 if (nextHeaderMenuToFocus) {
5102 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
5103 setNextHeaderMenuToFocus(void 0);
5104 return;
5105 }
5106 const onHide = (field) => {
5107 const hidden = headerMenuRefs.current.get(field.id);
5108 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
5109 setNextHeaderMenuToFocus(fallback?.node);
5110 };
5111 const handleHeaderContextMenu = (event) => {
5112 event.preventDefault();
5113 event.stopPropagation();
5114 const virtualAnchor = {
5115 getBoundingClientRect: () => ({
5116 x: event.clientX,
5117 y: event.clientY,
5118 top: event.clientY,
5119 left: event.clientX,
5120 right: event.clientX,
5121 bottom: event.clientY,
5122 width: 0,
5123 height: 0,
5124 toJSON: () => ({})
5125 })
5126 };
5127 window.requestAnimationFrame(() => {
5128 setContextMenuAnchor(virtualAnchor);
5129 });
5130 };
5131 const hasData = !!data?.length;
5132 const titleField = fields2.find((field) => field.id === view.titleField);
5133 const mediaField = fields2.find((field) => field.id === view.mediaField);
5134 const descriptionField = fields2.find(
5135 (field) => field.id === view.descriptionField
5136 );
5137 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
5138 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5139 const { showTitle = true, showMedia = true, showDescription = true } = view;
5140 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
5141 const columns = view.fields ?? [];
5142 const headerMenuRef = (column, index) => (node) => {
5143 if (node) {
5144 headerMenuRefs.current.set(column, {
5145 node,
5146 fallback: columns[index > 0 ? index - 1 : 1]
5147 });
5148 } else {
5149 headerMenuRefs.current.delete(column);
5150 }
5151 };
5152 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5153 const isRtl = (0, import_i18n10.isRTL)();
5154 if (!hasData) {
5155 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5156 "div",
5157 {
5158 className: clsx_default("dataviews-no-results", {
5159 "is-refreshing": isDelayedLoading
5160 }),
5161 id: tableNoticeId,
5162 children: empty
5163 }
5164 );
5165 }
5166 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
5167 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
5168 "table",
5169 {
5170 className: clsx_default("dataviews-view-table", className, {
5171 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5172 view.layout.density
5173 ),
5174 "has-bulk-actions": hasBulkActions,
5175 "is-refreshing": !isInfiniteScroll && isDelayedLoading
5176 }),
5177 "aria-busy": isLoading,
5178 "aria-describedby": tableNoticeId,
5179 role: isInfiniteScroll ? "feed" : void 0,
5180 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
5181 children: [
5182 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("colgroup", { children: [
5183 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
5184 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
5185 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5186 "col",
5187 {
5188 className: clsx_default(
5189 `dataviews-view-table__col-${column}`,
5190 {
5191 "dataviews-view-table__col-expand": !hasPrimaryColumn && index === columns.length - 1
5192 }
5193 )
5194 },
5195 `col-${column}`
5196 )),
5197 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-actions" })
5198 ] }),
5199 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5200 import_components8.Popover,
5201 {
5202 anchor: contextMenuAnchor,
5203 onClose: () => setContextMenuAnchor(null),
5204 placement: "bottom-start",
5205 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(PropertiesSection, { showLabel: false })
5206 }
5207 ),
5208 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5209 "thead",
5210 {
5211 className: clsx_default({
5212 "dataviews-view-table__thead--stuck": isVerticallyScrolled
5213 }),
5214 onContextMenu: handleHeaderContextMenu,
5215 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("tr", { className: "dataviews-view-table__row", children: [
5216 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5217 "th",
5218 {
5219 className: "dataviews-view-table__checkbox-column",
5220 scope: "col",
5221 onContextMenu: handleHeaderContextMenu,
5222 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5223 BulkSelectionCheckbox,
5224 {
5225 selection,
5226 onChangeSelection,
5227 data,
5228 actions: actions2,
5229 getItemId
5230 }
5231 )
5232 }
5233 ),
5234 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5235 column_header_menu_default,
5236 {
5237 ref: headerMenuRef(
5238 titleField.id,
5239 0
5240 ),
5241 fieldId: titleField.id,
5242 view,
5243 fields: fields2,
5244 onChangeView,
5245 onHide,
5246 setOpenedFilter,
5247 canMove: false,
5248 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
5249 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
5250 }
5251 ) }),
5252 columns.map((column, index) => {
5253 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5254 const field = fields2.find(
5255 (f2) => f2.id === column
5256 );
5257 const effectiveAlign = getEffectiveAlign(
5258 align,
5259 field?.type
5260 );
5261 const canInsertOrMove = view.layout?.enableMoving ?? true;
5262 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5263 "th",
5264 {
5265 style: {
5266 width,
5267 maxWidth,
5268 minWidth,
5269 textAlign: effectiveAlign
5270 },
5271 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
5272 scope: "col",
5273 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5274 column_header_menu_default,
5275 {
5276 ref: headerMenuRef(column, index),
5277 fieldId: column,
5278 view,
5279 fields: fields2,
5280 onChangeView,
5281 onHide,
5282 setOpenedFilter,
5283 canMove: canInsertOrMove,
5284 canInsertLeft: canInsertOrMove,
5285 canInsertRight: canInsertOrMove
5286 }
5287 )
5288 },
5289 column
5290 );
5291 }),
5292 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5293 "th",
5294 {
5295 className: clsx_default(
5296 "dataviews-view-table__actions-column",
5297 {
5298 "dataviews-view-table__actions-column--sticky": true,
5299 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
5300 }
5301 ),
5302 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
5303 }
5304 )
5305 ] })
5306 }
5307 ),
5308 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
5309 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("tbody", { children: [
5310 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5311 "td",
5312 {
5313 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions2?.length ? 1 : 0),
5314 className: "dataviews-view-table__group-header-cell",
5315 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
5316 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5317 (0, import_i18n10.__)("%1$s: %2$s"),
5318 groupField.label,
5319 groupName
5320 )
5321 }
5322 ) }),
5323 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5324 TableRow,
5325 {
5326 item,
5327 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
5328 hasBulkActions,
5329 actions: actions2,
5330 fields: fields2,
5331 id: getItemId(item) || index.toString(),
5332 view,
5333 titleField,
5334 mediaField,
5335 descriptionField,
5336 selection,
5337 getItemId,
5338 onChangeSelection,
5339 onClickItem,
5340 renderItemLink,
5341 isItemClickable,
5342 isActionsColumnSticky: !isHorizontalScrollEnd
5343 },
5344 getItemId(item)
5345 ))
5346 ] }, `group-${groupName}`)
5347 ) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5348 TableRow,
5349 {
5350 item,
5351 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
5352 hasBulkActions,
5353 actions: actions2,
5354 fields: fields2,
5355 id: getItemId(item) || index.toString(),
5356 view,
5357 titleField,
5358 mediaField,
5359 descriptionField,
5360 selection,
5361 getItemId,
5362 onChangeSelection,
5363 onClickItem,
5364 renderItemLink,
5365 isItemClickable,
5366 isActionsColumnSticky: !isHorizontalScrollEnd,
5367 posinset: isInfiniteScroll ? index + 1 : void 0
5368 },
5369 getItemId(item)
5370 )) })
5371 ]
5372 }
5373 ),
5374 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components8.Spinner, {}) }) })
5375 ] });
5376 }
5377 var table_default = ViewTable;
5378
5379 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
5380 var import_components11 = __toESM(require_components(), 1);
5381 var import_i18n13 = __toESM(require_i18n(), 1);
5382
5383 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
5384 var import_components10 = __toESM(require_components(), 1);
5385 var import_i18n12 = __toESM(require_i18n(), 1);
5386 var import_compose3 = __toESM(require_compose(), 1);
5387 var import_keycodes2 = __toESM(require_keycodes(), 1);
5388 var import_element32 = __toESM(require_element(), 1);
5389
5390 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
5391 var import_components9 = __toESM(require_components(), 1);
5392 var import_i18n11 = __toESM(require_i18n(), 1);
5393 var import_element29 = __toESM(require_element(), 1);
5394 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
5395 var imageSizes = [
5396 {
5397 value: 120,
5398 breakpoint: 1
5399 },
5400 {
5401 value: 170,
5402 breakpoint: 1
5403 },
5404 {
5405 value: 230,
5406 breakpoint: 1
5407 },
5408 {
5409 value: 290,
5410 breakpoint: 1112
5411 // at minimum image width, 4 images display at this container size
5412 },
5413 {
5414 value: 350,
5415 breakpoint: 1636
5416 // at minimum image width, 6 images display at this container size
5417 },
5418 {
5419 value: 430,
5420 breakpoint: 588
5421 // at minimum image width, 2 images display at this container size
5422 }
5423 ];
5424 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
5425 function useGridColumns() {
5426 const context = (0, import_element29.useContext)(dataviews_context_default);
5427 const view = context.view;
5428 return (0, import_element29.useMemo)(() => {
5429 const containerWidth = context.containerWidth;
5430 const gap = 32;
5431 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
5432 const columns = Math.floor(
5433 (containerWidth + gap) / (previewSize + gap)
5434 );
5435 return Math.max(1, columns);
5436 }, [context.containerWidth, view.layout?.previewSize]);
5437 }
5438
5439 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
5440 var import_element30 = __toESM(require_element(), 1);
5441 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
5442 var GridItems = (0, import_element30.forwardRef)(({ className, previewSize, ...props }, ref) => {
5443 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
5444 "div",
5445 {
5446 ref,
5447 className: clsx_default("dataviews-view-grid-items", className),
5448 style: {
5449 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
5450 },
5451 ...props
5452 }
5453 );
5454 });
5455
5456 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
5457 var import_element31 = __toESM(require_element(), 1);
5458 function useIntersectionObserver(elementRef, posinset) {
5459 const { intersectionObserver } = (0, import_element31.useContext)(dataviews_context_default);
5460 (0, import_element31.useEffect)(() => {
5461 const element = elementRef.current;
5462 if (!element || posinset === void 0 || !intersectionObserver) {
5463 return;
5464 }
5465 intersectionObserver.observe(element);
5466 return () => {
5467 intersectionObserver.unobserve(element);
5468 };
5469 }, [elementRef, intersectionObserver, posinset]);
5470 }
5471 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
5472 const hasData = !!data?.length;
5473 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
5474 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
5475 }
5476
5477 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
5478 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
5479 var { Badge: Badge3 } = unlock(import_components10.privateApis);
5480 function chunk(array, size) {
5481 const chunks = [];
5482 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) {
5483 chunks.push(array.slice(i2, i2 + size));
5484 }
5485 return chunks;
5486 }
5487 var GridItem = (0, import_element32.forwardRef)(
5488 function GridItem2({
5489 view,
5490 selection,
5491 onChangeSelection,
5492 onClickItem,
5493 isItemClickable,
5494 renderItemLink,
5495 getItemId,
5496 item,
5497 actions: actions2,
5498 mediaField,
5499 titleField,
5500 descriptionField,
5501 regularFields,
5502 badgeFields,
5503 hasBulkActions,
5504 config,
5505 posinset,
5506 setsize,
5507 ...props
5508 }, forwardedRef) {
5509 const {
5510 showTitle = true,
5511 showMedia = true,
5512 showDescription = true
5513 } = view;
5514 const hasBulkAction = useHasAPossibleBulkAction(actions2, item);
5515 const id = getItemId(item);
5516 const elementRef = (0, import_element32.useRef)(null);
5517 const setRefs = (0, import_element32.useCallback)(
5518 (node) => {
5519 elementRef.current = node;
5520 if (typeof forwardedRef === "function") {
5521 forwardedRef(node);
5522 } else if (forwardedRef) {
5523 forwardedRef.current = node;
5524 }
5525 },
5526 [forwardedRef]
5527 );
5528 useIntersectionObserver(elementRef, posinset);
5529 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
5530 const isSelected2 = selection.includes(id);
5531 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
5532 const rendersMediaField = showMedia && mediaField?.render;
5533 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5534 mediaField.render,
5535 {
5536 item,
5537 field: mediaField,
5538 config
5539 }
5540 ) : mediaPlaceholder;
5541 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField }) : null;
5542 let mediaA11yProps;
5543 let titleA11yProps;
5544 if (isItemClickable(item) && onClickItem) {
5545 if (renderedTitleField) {
5546 mediaA11yProps = {
5547 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
5548 };
5549 titleA11yProps = {
5550 id: `dataviews-view-grid__title-field-${instanceId}`
5551 };
5552 } else {
5553 mediaA11yProps = {
5554 "aria-label": (0, import_i18n12.__)("Navigate to item")
5555 };
5556 }
5557 }
5558 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
5559 Stack,
5560 {
5561 direction: "column",
5562 ...props,
5563 ref: setRefs,
5564 "aria-setsize": setsize,
5565 "aria-posinset": posinset,
5566 className: clsx_default(
5567 props.className,
5568 "dataviews-view-grid__row__gridcell",
5569 "dataviews-view-grid__card",
5570 {
5571 "is-selected": hasBulkAction && isSelected2
5572 }
5573 ),
5574 onClickCapture: (event) => {
5575 props.onClickCapture?.(event);
5576 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
5577 event.stopPropagation();
5578 event.preventDefault();
5579 if (!hasBulkAction) {
5580 return;
5581 }
5582 onChangeSelection(
5583 isSelected2 ? selection.filter(
5584 (itemId) => id !== itemId
5585 ) : [...selection, id]
5586 );
5587 }
5588 },
5589 children: [
5590 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5591 ItemClickWrapper,
5592 {
5593 item,
5594 isItemClickable,
5595 onClickItem,
5596 renderItemLink,
5597 className: clsx_default("dataviews-view-grid__media", {
5598 "dataviews-view-grid__media--placeholder": !rendersMediaField
5599 }),
5600 ...mediaA11yProps,
5601 children: renderedMediaField
5602 }
5603 ),
5604 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5605 DataViewsSelectionCheckbox,
5606 {
5607 item,
5608 selection,
5609 onChangeSelection,
5610 getItemId,
5611 titleField,
5612 disabled: !hasBulkAction
5613 }
5614 ),
5615 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5616 ItemActions,
5617 {
5618 item,
5619 actions: actions2,
5620 isCompact: true
5621 }
5622 ) }),
5623 showTitle && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5624 ItemClickWrapper,
5625 {
5626 item,
5627 isItemClickable,
5628 onClickItem,
5629 renderItemLink,
5630 className: "dataviews-view-grid__title-field dataviews-title-field",
5631 ...titleA11yProps,
5632 title: titleField?.getValueFormatted({
5633 item,
5634 field: titleField
5635 }) || void 0,
5636 children: renderedTitleField
5637 }
5638 ) }),
5639 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", gap: "xs", children: [
5640 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5641 descriptionField.render,
5642 {
5643 item,
5644 field: descriptionField
5645 }
5646 ),
5647 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5648 Stack,
5649 {
5650 direction: "row",
5651 className: "dataviews-view-grid__badge-fields",
5652 gap: "sm",
5653 wrap: "wrap",
5654 align: "top",
5655 justify: "flex-start",
5656 children: badgeFields.map((field) => {
5657 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5658 Badge3,
5659 {
5660 className: "dataviews-view-grid__field-value",
5661 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5662 field.render,
5663 {
5664 item,
5665 field
5666 }
5667 )
5668 },
5669 field.id
5670 );
5671 })
5672 }
5673 ),
5674 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5675 Stack,
5676 {
5677 direction: "column",
5678 className: "dataviews-view-grid__fields",
5679 gap: "xs",
5680 children: regularFields.map((field) => {
5681 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5682 import_components10.Flex,
5683 {
5684 className: "dataviews-view-grid__field",
5685 gap: 1,
5686 justify: "flex-start",
5687 expanded: true,
5688 style: { height: "auto" },
5689 direction: "row",
5690 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
5691 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components10.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components10.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }),
5692 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5693 import_components10.FlexItem,
5694 {
5695 className: "dataviews-view-grid__field-value",
5696 style: { maxHeight: "none" },
5697 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5698 field.render,
5699 {
5700 item,
5701 field
5702 }
5703 )
5704 }
5705 )
5706 ] })
5707 },
5708 field.id
5709 );
5710 })
5711 }
5712 )
5713 ] })
5714 ]
5715 }
5716 );
5717 }
5718 );
5719 function CompositeGrid({
5720 data,
5721 isInfiniteScroll,
5722 className,
5723 inert,
5724 isLoading,
5725 view,
5726 fields: fields2,
5727 selection,
5728 onChangeSelection,
5729 onClickItem,
5730 isItemClickable,
5731 renderItemLink,
5732 getItemId,
5733 actions: actions2
5734 }) {
5735 const { paginationInfo, resizeObserverRef } = (0, import_element32.useContext)(dataviews_context_default);
5736 const gridColumns = useGridColumns();
5737 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data);
5738 const titleField = fields2.find(
5739 (field) => field.id === view?.titleField
5740 );
5741 const mediaField = fields2.find(
5742 (field) => field.id === view?.mediaField
5743 );
5744 const descriptionField = fields2.find(
5745 (field) => field.id === view?.descriptionField
5746 );
5747 const otherFields = view.fields ?? [];
5748 const { regularFields, badgeFields } = otherFields.reduce(
5749 (accumulator, fieldId) => {
5750 const field = fields2.find((f2) => f2.id === fieldId);
5751 if (!field) {
5752 return accumulator;
5753 }
5754 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
5755 accumulator[key].push(field);
5756 return accumulator;
5757 },
5758 { regularFields: [], badgeFields: [] }
5759 );
5760 const size = "900px";
5761 const totalRows = Math.ceil(data.length / gridColumns);
5762 const placeholdersNeeded = usePlaceholdersNeeded(
5763 data,
5764 isInfiniteScroll,
5765 gridColumns
5766 );
5767 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, {
5768 // Render infinite scroll layout (no rows, feed semantics)
5769 children: [
5770 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
5771 import_components10.Composite,
5772 {
5773 render: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5774 GridItems,
5775 {
5776 className: clsx_default(
5777 "dataviews-view-grid-infinite-scroll",
5778 className,
5779 {
5780 [`has-${view.layout?.density}-density`]: view.layout?.density && [
5781 "compact",
5782 "comfortable"
5783 ].includes(view.layout.density)
5784 }
5785 ),
5786 previewSize: view.layout?.previewSize,
5787 "aria-busy": isLoading,
5788 ref: resizeObserverRef
5789 }
5790 ),
5791 role: "feed",
5792 focusWrap: true,
5793 inert,
5794 children: [
5795 Array.from({ length: placeholdersNeeded }).map(
5796 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5797 import_components10.Composite.Item,
5798 {
5799 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5800 Stack,
5801 {
5802 ...props,
5803 direction: "column",
5804 role: "article",
5805 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
5806 }
5807 ),
5808 "aria-hidden": true,
5809 tabIndex: -1
5810 },
5811 `placeholder-${index}`
5812 )
5813 ),
5814 data.map((item) => {
5815 const itemId = getItemId(item);
5816 const stablePosition = item.position;
5817 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5818 import_components10.Composite.Item,
5819 {
5820 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5821 GridItem,
5822 {
5823 ...props,
5824 id: itemId,
5825 role: "article",
5826 view,
5827 selection,
5828 onChangeSelection,
5829 onClickItem,
5830 isItemClickable,
5831 renderItemLink,
5832 getItemId,
5833 item,
5834 actions: actions2,
5835 mediaField,
5836 titleField,
5837 descriptionField,
5838 regularFields,
5839 badgeFields,
5840 hasBulkActions,
5841 posinset: stablePosition,
5842 setsize: paginationInfo.totalItems,
5843 config: {
5844 sizes: size
5845 }
5846 }
5847 )
5848 },
5849 itemId
5850 );
5851 })
5852 ]
5853 }
5854 ),
5855 // Render standard grid layout (with rows, grid semantics)
5856 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5857 import_components10.Composite,
5858 {
5859 role: "grid",
5860 className: clsx_default("dataviews-view-grid", className, {
5861 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5862 view.layout.density
5863 )
5864 }),
5865 focusWrap: true,
5866 "aria-busy": isLoading,
5867 "aria-rowcount": totalRows,
5868 ref: resizeObserverRef,
5869 inert,
5870 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5871 import_components10.Composite.Row,
5872 {
5873 render: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5874 "div",
5875 {
5876 role: "row",
5877 "aria-rowindex": i2 + 1,
5878 "aria-label": (0, import_i18n12.sprintf)(
5879 /* translators: %d: The row number in the grid */
5880 (0, import_i18n12.__)("Row %d"),
5881 i2 + 1
5882 ),
5883 className: "dataviews-view-grid__row",
5884 style: {
5885 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
5886 }
5887 }
5888 ),
5889 children: row.map((item) => {
5890 const itemId = getItemId(item);
5891 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5892 import_components10.Composite.Item,
5893 {
5894 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5895 GridItem,
5896 {
5897 ...props,
5898 id: itemId,
5899 role: "gridcell",
5900 view,
5901 selection,
5902 onChangeSelection,
5903 onClickItem,
5904 isItemClickable,
5905 renderItemLink,
5906 getItemId,
5907 item,
5908 actions: actions2,
5909 mediaField,
5910 titleField,
5911 descriptionField,
5912 regularFields,
5913 badgeFields,
5914 hasBulkActions,
5915 config: {
5916 sizes: size
5917 }
5918 }
5919 )
5920 },
5921 itemId
5922 );
5923 })
5924 },
5925 i2
5926 ))
5927 }
5928 )
5929 ]
5930 });
5931 }
5932
5933 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
5934 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
5935 function ViewGrid({
5936 actions: actions2,
5937 data,
5938 fields: fields2,
5939 getItemId,
5940 isLoading,
5941 onChangeSelection,
5942 onClickItem,
5943 isItemClickable,
5944 renderItemLink,
5945 selection,
5946 view,
5947 className,
5948 empty
5949 }) {
5950 const isDelayedLoading = useDelayedLoading(!!isLoading);
5951 const hasData = !!data?.length;
5952 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
5953 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5954 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5955 if (!hasData) {
5956 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
5957 "div",
5958 {
5959 className: clsx_default("dataviews-no-results", {
5960 "is-refreshing": isDelayedLoading
5961 }),
5962 children: empty
5963 }
5964 );
5965 }
5966 const gridProps = {
5967 className: clsx_default(className, {
5968 "is-refreshing": !isInfiniteScroll && isDelayedLoading
5969 }),
5970 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
5971 isLoading,
5972 view,
5973 fields: fields2,
5974 selection,
5975 onChangeSelection,
5976 onClickItem,
5977 isItemClickable,
5978 renderItemLink,
5979 getItemId,
5980 actions: actions2
5981 };
5982 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, {
5983 // Render multiple groups.
5984 children: [
5985 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
5986 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
5987 Stack,
5988 {
5989 direction: "column",
5990 gap: "sm",
5991 children: [
5992 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
5993 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5994 (0, import_i18n13.__)("%1$s: %2$s"),
5995 groupField.label,
5996 groupName
5997 ) }),
5998 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
5999 CompositeGrid,
6000 {
6001 ...gridProps,
6002 data: groupItems,
6003 isInfiniteScroll: false
6004 }
6005 )
6006 ]
6007 },
6008 groupName
6009 )
6010 ) }),
6011 // Render a single grid with all data.
6012 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
6013 CompositeGrid,
6014 {
6015 ...gridProps,
6016 data,
6017 isInfiniteScroll: !!isInfiniteScroll
6018 }
6019 ),
6020 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components11.Spinner, {}) })
6021 ]
6022 });
6023 }
6024 var grid_default = ViewGrid;
6025
6026 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
6027 var import_compose4 = __toESM(require_compose(), 1);
6028 var import_components12 = __toESM(require_components(), 1);
6029 var import_element33 = __toESM(require_element(), 1);
6030 var import_i18n14 = __toESM(require_i18n(), 1);
6031 var import_data3 = __toESM(require_data(), 1);
6032 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
6033 var { Menu: Menu3 } = unlock(import_components12.privateApis);
6034 function generateItemWrapperCompositeId(idPrefix) {
6035 return `${idPrefix}-item-wrapper`;
6036 }
6037 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
6038 return `${idPrefix}-primary-action-${primaryActionId}`;
6039 }
6040 function generateDropdownTriggerCompositeId(idPrefix) {
6041 return `${idPrefix}-dropdown`;
6042 }
6043 function PrimaryActionGridCell({
6044 idPrefix,
6045 primaryAction,
6046 item
6047 }) {
6048 const registry = (0, import_data3.useRegistry)();
6049 const [isModalOpen, setIsModalOpen] = (0, import_element33.useState)(false);
6050 const compositeItemId = generatePrimaryActionCompositeId(
6051 idPrefix,
6052 primaryAction.id
6053 );
6054 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
6055 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6056 import_components12.Composite.Item,
6057 {
6058 id: compositeItemId,
6059 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6060 import_components12.Button,
6061 {
6062 disabled: !!primaryAction.disabled,
6063 accessibleWhenDisabled: true,
6064 text: label,
6065 size: "small",
6066 onClick: () => setIsModalOpen(true)
6067 }
6068 ),
6069 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6070 ActionModal,
6071 {
6072 action: primaryAction,
6073 items: [item],
6074 closeModal: () => setIsModalOpen(false)
6075 }
6076 )
6077 }
6078 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6079 import_components12.Composite.Item,
6080 {
6081 id: compositeItemId,
6082 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6083 import_components12.Button,
6084 {
6085 disabled: !!primaryAction.disabled,
6086 accessibleWhenDisabled: true,
6087 size: "small",
6088 onClick: () => {
6089 primaryAction.callback([item], { registry });
6090 },
6091 children: label
6092 }
6093 )
6094 }
6095 ) }, primaryAction.id);
6096 }
6097 function ListItem({
6098 view,
6099 actions: actions2,
6100 idPrefix,
6101 isSelected: isSelected2,
6102 item,
6103 titleField,
6104 mediaField,
6105 descriptionField,
6106 onSelect,
6107 otherFields,
6108 onDropdownTriggerKeyDown,
6109 posinset
6110 }) {
6111 const {
6112 showTitle = true,
6113 showMedia = true,
6114 showDescription = true,
6115 infiniteScrollEnabled
6116 } = view;
6117 const itemRef = (0, import_element33.useRef)(null);
6118 const labelId = `${idPrefix}-label`;
6119 const descriptionId = `${idPrefix}-description`;
6120 const registry = (0, import_data3.useRegistry)();
6121 const [isHovered, setIsHovered] = (0, import_element33.useState)(false);
6122 const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)(
6123 null
6124 );
6125 const handleHover = ({ type }) => {
6126 const isHover = type === "mouseenter";
6127 setIsHovered(isHover);
6128 };
6129 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
6130 (0, import_element33.useEffect)(() => {
6131 if (isSelected2) {
6132 itemRef.current?.scrollIntoView({
6133 behavior: "auto",
6134 block: "nearest",
6135 inline: "nearest"
6136 });
6137 }
6138 }, [isSelected2]);
6139 const { primaryAction, eligibleActions } = (0, import_element33.useMemo)(() => {
6140 const _eligibleActions = actions2.filter(
6141 (action) => !action.isEligible || action.isEligible(item)
6142 );
6143 const _primaryActions = _eligibleActions.filter(
6144 (action) => action.isPrimary
6145 );
6146 return {
6147 primaryAction: _primaryActions[0],
6148 eligibleActions: _eligibleActions
6149 };
6150 }, [actions2, item]);
6151 const hasOnlyOnePrimaryAction = primaryAction && actions2.length === 1;
6152 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6153 mediaField.render,
6154 {
6155 item,
6156 field: mediaField,
6157 config: { sizes: "52px" }
6158 }
6159 ) }) : null;
6160 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(titleField.render, { item, field: titleField }) : null;
6161 const renderDescription = showDescription && descriptionField?.render;
6162 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
6163 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6164 Stack,
6165 {
6166 direction: "row",
6167 gap: "md",
6168 className: "dataviews-view-list__item-actions",
6169 children: [
6170 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6171 PrimaryActionGridCell,
6172 {
6173 idPrefix,
6174 primaryAction,
6175 item
6176 }
6177 ),
6178 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { role: "gridcell", children: [
6179 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Menu3, { placement: "bottom-end", children: [
6180 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6181 Menu3.TriggerButton,
6182 {
6183 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6184 import_components12.Composite.Item,
6185 {
6186 id: generateDropdownTriggerCompositeId(
6187 idPrefix
6188 ),
6189 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6190 import_components12.Button,
6191 {
6192 size: "small",
6193 icon: more_vertical_default,
6194 label: (0, import_i18n14.__)("Actions"),
6195 accessibleWhenDisabled: true,
6196 disabled: !actions2.length,
6197 onKeyDown: onDropdownTriggerKeyDown
6198 }
6199 )
6200 }
6201 )
6202 }
6203 ),
6204 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6205 ActionsMenuGroup,
6206 {
6207 actions: eligibleActions,
6208 item,
6209 registry,
6210 setActiveModalAction
6211 }
6212 ) })
6213 ] }),
6214 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6215 ActionModal,
6216 {
6217 action: activeModalAction,
6218 items: [item],
6219 closeModal: () => setActiveModalAction(null)
6220 }
6221 )
6222 ] })
6223 ]
6224 }
6225 );
6226 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6227 import_components12.Composite.Row,
6228 {
6229 ref: itemRef,
6230 render: (
6231 /* aria-posinset breaks Composite.Row if passed to it directly. */
6232 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6233 "div",
6234 {
6235 "aria-posinset": posinset,
6236 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
6237 }
6238 )
6239 ),
6240 role: infiniteScrollEnabled ? "article" : "row",
6241 className: clsx_default({
6242 "is-selected": isSelected2,
6243 "is-hovered": isHovered
6244 }),
6245 onMouseEnter: handleHover,
6246 onMouseLeave: handleHover,
6247 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6248 Stack,
6249 {
6250 direction: "row",
6251 className: "dataviews-view-list__item-wrapper",
6252 children: [
6253 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6254 import_components12.Composite.Item,
6255 {
6256 id: generateItemWrapperCompositeId(idPrefix),
6257 "aria-pressed": isSelected2,
6258 "aria-labelledby": labelId,
6259 "aria-describedby": descriptionId,
6260 className: "dataviews-view-list__item",
6261 onClick: () => onSelect(item)
6262 }
6263 ) }),
6264 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6265 Stack,
6266 {
6267 direction: "row",
6268 gap: "md",
6269 justify: "start",
6270 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
6271 style: { flex: 1, minWidth: 0 },
6272 children: [
6273 renderedMediaField,
6274 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6275 Stack,
6276 {
6277 direction: "column",
6278 gap: "xs",
6279 className: "dataviews-view-list__field-wrapper",
6280 children: [
6281 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Stack, { direction: "row", align: "center", children: [
6282 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6283 "div",
6284 {
6285 className: "dataviews-title-field dataviews-view-list__title-field",
6286 id: labelId,
6287 children: renderedTitleField
6288 }
6289 ),
6290 usedActions
6291 ] }),
6292 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6293 descriptionField.render,
6294 {
6295 item,
6296 field: descriptionField
6297 }
6298 ) }),
6299 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6300 "div",
6301 {
6302 className: "dataviews-view-list__fields",
6303 id: descriptionId,
6304 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6305 "div",
6306 {
6307 className: "dataviews-view-list__field",
6308 children: [
6309 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6310 import_components12.VisuallyHidden,
6311 {
6312 as: "span",
6313 className: "dataviews-view-list__field-label",
6314 children: field.label
6315 }
6316 ),
6317 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6318 field.render,
6319 {
6320 item,
6321 field
6322 }
6323 ) })
6324 ]
6325 },
6326 field.id
6327 ))
6328 }
6329 )
6330 ]
6331 }
6332 )
6333 ]
6334 }
6335 )
6336 ]
6337 }
6338 )
6339 }
6340 );
6341 }
6342 function isDefined2(item) {
6343 return !!item;
6344 }
6345 function ViewList(props) {
6346 const {
6347 actions: actions2,
6348 data,
6349 fields: fields2,
6350 getItemId,
6351 isLoading,
6352 onChangeSelection,
6353 selection,
6354 view,
6355 className,
6356 empty
6357 } = props;
6358 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
6359 const isDelayedLoading = useDelayedLoading(!!isLoading);
6360 const selectedItem = data?.findLast(
6361 (item) => selection.includes(getItemId(item))
6362 );
6363 const titleField = fields2.find((field) => field.id === view.titleField);
6364 const mediaField = fields2.find((field) => field.id === view.mediaField);
6365 const descriptionField = fields2.find(
6366 (field) => field.id === view.descriptionField
6367 );
6368 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined2);
6369 const onSelect = (item) => onChangeSelection([getItemId(item)]);
6370 const generateCompositeItemIdPrefix = (0, import_element33.useCallback)(
6371 (item) => `${baseId}-${getItemId(item)}`,
6372 [baseId, getItemId]
6373 );
6374 const isActiveCompositeItem = (0, import_element33.useCallback)(
6375 (item, idToCheck) => {
6376 return idToCheck.startsWith(
6377 generateCompositeItemIdPrefix(item)
6378 );
6379 },
6380 [generateCompositeItemIdPrefix]
6381 );
6382 const [activeCompositeId, setActiveCompositeId] = (0, import_element33.useState)(void 0);
6383 const compositeRef = (0, import_element33.useRef)(null);
6384 (0, import_element33.useEffect)(() => {
6385 if (selectedItem) {
6386 setActiveCompositeId(
6387 generateItemWrapperCompositeId(
6388 generateCompositeItemIdPrefix(selectedItem)
6389 )
6390 );
6391 }
6392 }, [selectedItem, generateCompositeItemIdPrefix]);
6393 const activeItemIndex = data.findIndex(
6394 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
6395 );
6396 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
6397 const isActiveIdInList = activeItemIndex !== -1;
6398 const selectCompositeItem = (0, import_element33.useCallback)(
6399 (targetIndex, generateCompositeId) => {
6400 const clampedIndex = Math.min(
6401 data.length - 1,
6402 Math.max(0, targetIndex)
6403 );
6404 if (!data[clampedIndex]) {
6405 return;
6406 }
6407 const itemIdPrefix = generateCompositeItemIdPrefix(
6408 data[clampedIndex]
6409 );
6410 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
6411 setActiveCompositeId(targetCompositeItemId);
6412 if (compositeRef.current?.contains(
6413 compositeRef.current.ownerDocument.activeElement
6414 )) {
6415 document.getElementById(targetCompositeItemId)?.focus();
6416 }
6417 },
6418 [data, generateCompositeItemIdPrefix]
6419 );
6420 (0, import_element33.useEffect)(() => {
6421 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
6422 if (!isActiveIdInList && wasActiveIdInList) {
6423 selectCompositeItem(
6424 previousActiveItemIndex,
6425 generateItemWrapperCompositeId
6426 );
6427 }
6428 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
6429 const onDropdownTriggerKeyDown = (0, import_element33.useCallback)(
6430 (event) => {
6431 if (event.key === "ArrowDown") {
6432 event.preventDefault();
6433 selectCompositeItem(
6434 activeItemIndex + 1,
6435 generateDropdownTriggerCompositeId
6436 );
6437 }
6438 if (event.key === "ArrowUp") {
6439 event.preventDefault();
6440 selectCompositeItem(
6441 activeItemIndex - 1,
6442 generateDropdownTriggerCompositeId
6443 );
6444 }
6445 },
6446 [selectCompositeItem, activeItemIndex]
6447 );
6448 const hasData = !!data?.length;
6449 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
6450 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
6451 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
6452 if (!hasData) {
6453 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6454 "div",
6455 {
6456 className: clsx_default("dataviews-no-results", {
6457 "is-refreshing": isDelayedLoading
6458 }),
6459 children: empty
6460 }
6461 );
6462 }
6463 if (hasData && groupField && dataByGroup) {
6464 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6465 import_components12.Composite,
6466 {
6467 ref: compositeRef,
6468 id: `${baseId}`,
6469 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", {}),
6470 className: "dataviews-view-list__group",
6471 role: "grid",
6472 activeId: activeCompositeId,
6473 setActiveId: setActiveCompositeId,
6474 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6475 Stack,
6476 {
6477 direction: "column",
6478 gap: "lg",
6479 className: clsx_default("dataviews-view-list", className),
6480 children: Array.from(dataByGroup.entries()).map(
6481 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6482 Stack,
6483 {
6484 direction: "column",
6485 gap: "sm",
6486 children: [
6487 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
6488 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
6489 (0, import_i18n14.__)("%1$s: %2$s"),
6490 groupField.label,
6491 groupName
6492 ) }),
6493 groupItems.map((item) => {
6494 const id = generateCompositeItemIdPrefix(item);
6495 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6496 ListItem,
6497 {
6498 view,
6499 idPrefix: id,
6500 actions: actions2,
6501 item,
6502 isSelected: item === selectedItem,
6503 onSelect,
6504 mediaField,
6505 titleField,
6506 descriptionField,
6507 otherFields,
6508 onDropdownTriggerKeyDown
6509 },
6510 id
6511 );
6512 })
6513 ]
6514 },
6515 groupName
6516 )
6517 )
6518 }
6519 )
6520 }
6521 );
6522 }
6523 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
6524 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6525 import_components12.Composite,
6526 {
6527 ref: compositeRef,
6528 id: baseId,
6529 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", {}),
6530 className: clsx_default("dataviews-view-list", className, {
6531 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
6532 view.layout.density
6533 ),
6534 "is-refreshing": !isInfiniteScroll && isDelayedLoading
6535 }),
6536 role: view.infiniteScrollEnabled ? "feed" : "grid",
6537 activeId: activeCompositeId,
6538 setActiveId: setActiveCompositeId,
6539 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
6540 children: data.map((item, index) => {
6541 const id = generateCompositeItemIdPrefix(item);
6542 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6543 ListItem,
6544 {
6545 view,
6546 idPrefix: id,
6547 actions: actions2,
6548 item,
6549 isSelected: item === selectedItem,
6550 onSelect,
6551 mediaField,
6552 titleField,
6553 descriptionField,
6554 otherFields,
6555 onDropdownTriggerKeyDown,
6556 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
6557 },
6558 id
6559 );
6560 })
6561 }
6562 ),
6563 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components12.Spinner, {}) })
6564 ] });
6565 }
6566
6567 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
6568 var import_components14 = __toESM(require_components(), 1);
6569
6570 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
6571 var import_i18n15 = __toESM(require_i18n(), 1);
6572 var import_element34 = __toESM(require_element(), 1);
6573 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
6574 function ActivityGroup({
6575 groupName,
6576 groupData,
6577 groupField,
6578 showLabel = true,
6579 children
6580 }) {
6581 const groupHeader = showLabel ? (0, import_element34.createInterpolateElement)(
6582 // translators: %s: The label of the field e.g. "Status".
6583 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
6584 {
6585 groupName: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6586 groupField.render,
6587 {
6588 item: groupData[0],
6589 field: groupField
6590 }
6591 )
6592 }
6593 ) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(groupField.render, { item: groupData[0], field: groupField });
6594 return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
6595 Stack,
6596 {
6597 direction: "column",
6598 className: "dataviews-view-activity__group",
6599 children: [
6600 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
6601 children
6602 ]
6603 },
6604 groupName
6605 );
6606 }
6607
6608 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
6609 var import_components13 = __toESM(require_components(), 1);
6610 var import_element35 = __toESM(require_element(), 1);
6611 var import_data4 = __toESM(require_data(), 1);
6612 var import_compose5 = __toESM(require_compose(), 1);
6613 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
6614 function ActivityItem(props) {
6615 const {
6616 view,
6617 actions: actions2,
6618 item,
6619 titleField,
6620 mediaField,
6621 descriptionField,
6622 otherFields,
6623 posinset,
6624 onClickItem,
6625 renderItemLink,
6626 isItemClickable
6627 } = props;
6628 const {
6629 showTitle = true,
6630 showMedia = true,
6631 showDescription = true,
6632 infiniteScrollEnabled
6633 } = view;
6634 const itemRef = (0, import_element35.useRef)(null);
6635 const registry = (0, import_data4.useRegistry)();
6636 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
6637 const { primaryActions, eligibleActions } = (0, import_element35.useMemo)(() => {
6638 const _eligibleActions = actions2.filter(
6639 (action) => !action.isEligible || action.isEligible(item)
6640 );
6641 const _primaryActions = _eligibleActions.filter(
6642 (action) => action.isPrimary
6643 );
6644 return {
6645 primaryActions: _primaryActions,
6646 eligibleActions: _eligibleActions
6647 };
6648 }, [actions2, item]);
6649 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
6650 const density = view.layout?.density ?? "balanced";
6651 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6652 mediaField.render,
6653 {
6654 item,
6655 field: mediaField,
6656 config: {
6657 sizes: density === "comfortable" ? "32px" : "24px"
6658 }
6659 }
6660 ) : null;
6661 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6662 "span",
6663 {
6664 className: "dataviews-view-activity__item-bullet",
6665 "aria-hidden": "true"
6666 }
6667 ) });
6668 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null;
6669 const verticalGap = (0, import_element35.useMemo)(() => {
6670 switch (density) {
6671 case "comfortable":
6672 return "md";
6673 default:
6674 return "sm";
6675 }
6676 }, [density]);
6677 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6678 "div",
6679 {
6680 ref: itemRef,
6681 role: infiniteScrollEnabled ? "article" : void 0,
6682 "aria-posinset": posinset,
6683 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
6684 className: clsx_default(
6685 "dataviews-view-activity__item",
6686 density === "compact" && "is-compact",
6687 density === "balanced" && "is-balanced",
6688 density === "comfortable" && "is-comfortable"
6689 ),
6690 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
6691 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6692 Stack,
6693 {
6694 direction: "column",
6695 gap: "xs",
6696 align: "center",
6697 className: "dataviews-view-activity__item-type",
6698 children: renderedMediaField
6699 }
6700 ),
6701 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
6702 Stack,
6703 {
6704 direction: "column",
6705 gap: verticalGap,
6706 align: "flex-start",
6707 className: "dataviews-view-activity__item-content",
6708 children: [
6709 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6710 ItemClickWrapper,
6711 {
6712 item,
6713 isItemClickable,
6714 onClickItem,
6715 renderItemLink,
6716 className: "dataviews-view-activity__item-title",
6717 children: renderedTitleField
6718 }
6719 ),
6720 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6721 descriptionField.render,
6722 {
6723 item,
6724 field: descriptionField
6725 }
6726 ) }),
6727 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
6728 "div",
6729 {
6730 className: "dataviews-view-activity__item-field",
6731 children: [
6732 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6733 import_components13.VisuallyHidden,
6734 {
6735 as: "span",
6736 className: "dataviews-view-activity__item-field-label",
6737 children: field.label
6738 }
6739 ),
6740 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6741 field.render,
6742 {
6743 item,
6744 field
6745 }
6746 ) })
6747 ]
6748 },
6749 field.id
6750 )) }),
6751 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6752 PrimaryActions,
6753 {
6754 item,
6755 actions: primaryActions,
6756 registry,
6757 buttonVariant: "secondary"
6758 }
6759 )
6760 ]
6761 }
6762 ),
6763 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
6764 // there if there are any actions at all.
6765 isMobileViewport && // At the same time, only show the menu if there are actions to show.
6766 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6767 ItemActions,
6768 {
6769 item,
6770 actions: eligibleActions,
6771 isCompact: true
6772 }
6773 ) })
6774 ] })
6775 }
6776 );
6777 }
6778 var activity_item_default = ActivityItem;
6779
6780 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
6781 var import_react8 = __toESM(require_react(), 1);
6782 function isDefined3(item) {
6783 return !!item;
6784 }
6785 function ActivityItems(props) {
6786 const { data, fields: fields2, getItemId, view } = props;
6787 const titleField = fields2.find((field) => field.id === view.titleField);
6788 const mediaField = fields2.find((field) => field.id === view.mediaField);
6789 const descriptionField = fields2.find(
6790 (field) => field.id === view.descriptionField
6791 );
6792 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined3);
6793 return data.map((item, index) => {
6794 return /* @__PURE__ */ (0, import_react8.createElement)(
6795 activity_item_default,
6796 {
6797 ...props,
6798 key: getItemId(item),
6799 item,
6800 mediaField,
6801 titleField,
6802 descriptionField,
6803 otherFields,
6804 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
6805 }
6806 );
6807 });
6808 }
6809
6810 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
6811 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
6812 function ViewActivity(props) {
6813 const { empty, data, fields: fields2, isLoading, view, className } = props;
6814 const isDelayedLoading = useDelayedLoading(!!isLoading);
6815 const hasData = !!data?.length;
6816 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
6817 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
6818 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
6819 if (!hasData) {
6820 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6821 "div",
6822 {
6823 className: clsx_default("dataviews-no-results", {
6824 "is-refreshing": isDelayedLoading
6825 }),
6826 children: empty
6827 }
6828 );
6829 }
6830 const isInert = !isInfiniteScroll && !!isLoading;
6831 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
6832 "is-refreshing": !isInfiniteScroll && isDelayedLoading
6833 });
6834 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
6835 if (hasData && groupField && dataByGroup) {
6836 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6837 Stack,
6838 {
6839 direction: "column",
6840 gap: "sm",
6841 className: wrapperClassName,
6842 inert: isInert ? "true" : void 0,
6843 children: groupedEntries.map(
6844 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6845 ActivityGroup,
6846 {
6847 groupName,
6848 groupData,
6849 groupField,
6850 showLabel: view.groupBy?.showLabel !== false,
6851 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6852 ActivityItems,
6853 {
6854 ...props,
6855 data: groupData
6856 }
6857 )
6858 },
6859 groupName
6860 )
6861 )
6862 }
6863 );
6864 }
6865 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
6866 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6867 "div",
6868 {
6869 className: wrapperClassName,
6870 role: view.infiniteScrollEnabled ? "feed" : void 0,
6871 inert: isInert ? "true" : void 0,
6872 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ActivityItems, { ...props })
6873 }
6874 ),
6875 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) })
6876 ] });
6877 }
6878
6879 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
6880 var import_components17 = __toESM(require_components(), 1);
6881 var import_i18n18 = __toESM(require_i18n(), 1);
6882 var import_compose6 = __toESM(require_compose(), 1);
6883 var import_element38 = __toESM(require_element(), 1);
6884
6885 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
6886 var import_components16 = __toESM(require_components(), 1);
6887 var import_data5 = __toESM(require_data(), 1);
6888 var import_element37 = __toESM(require_element(), 1);
6889 var import_i18n17 = __toESM(require_i18n(), 1);
6890
6891 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
6892 var import_components15 = __toESM(require_components(), 1);
6893 var import_element36 = __toESM(require_element(), 1);
6894 var import_i18n16 = __toESM(require_i18n(), 1);
6895 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
6896 function DataViewsPagination() {
6897 const {
6898 view,
6899 onChangeView,
6900 paginationInfo: { totalItems = 0, totalPages }
6901 } = (0, import_element36.useContext)(dataviews_context_default);
6902 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
6903 return null;
6904 }
6905 const currentPage = view.page ?? 1;
6906 const pageSelectOptions = Array.from(Array(totalPages)).map(
6907 (_, i2) => {
6908 const page = i2 + 1;
6909 return {
6910 value: page.toString(),
6911 label: page.toString(),
6912 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
6913 // translators: 1: current page number. 2: total number of pages.
6914 (0, import_i18n16.__)("Page %1$d of %2$d"),
6915 currentPage,
6916 totalPages
6917 ) : page.toString()
6918 };
6919 }
6920 );
6921 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
6922 Stack,
6923 {
6924 direction: "row",
6925 className: "dataviews-pagination",
6926 justify: "end",
6927 align: "center",
6928 gap: "xl",
6929 children: [
6930 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
6931 Stack,
6932 {
6933 direction: "row",
6934 justify: "flex-start",
6935 align: "center",
6936 gap: "xs",
6937 className: "dataviews-pagination__page-select",
6938 children: (0, import_element36.createInterpolateElement)(
6939 (0, import_i18n16.sprintf)(
6940 // translators: 1: Current page number, 2: Total number of pages.
6941 (0, import_i18n16._x)(
6942 "<div>Page</div>%1$s<div>of %2$d</div>",
6943 "paging"
6944 ),
6945 "<CurrentPage />",
6946 totalPages
6947 ),
6948 {
6949 div: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { "aria-hidden": true }),
6950 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
6951 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
6952 import_components15.SelectControl,
6953 {
6954 "aria-label": (0, import_i18n16.__)("Current page"),
6955 value: currentPage.toString(),
6956 options: pageSelectOptions,
6957 onChange: (newValue) => {
6958 onChangeView({
6959 ...view,
6960 page: +newValue
6961 });
6962 },
6963 size: "small",
6964 variant: "minimal"
6965 }
6966 )
6967 }
6968 )
6969 }
6970 ),
6971 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
6972 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
6973 import_components15.Button,
6974 {
6975 onClick: () => onChangeView({
6976 ...view,
6977 page: currentPage - 1
6978 }),
6979 disabled: currentPage === 1,
6980 accessibleWhenDisabled: true,
6981 label: (0, import_i18n16.__)("Previous page"),
6982 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
6983 showTooltip: true,
6984 size: "compact",
6985 tooltipPosition: "top"
6986 }
6987 ),
6988 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
6989 import_components15.Button,
6990 {
6991 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
6992 disabled: currentPage >= totalPages,
6993 accessibleWhenDisabled: true,
6994 label: (0, import_i18n16.__)("Next page"),
6995 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
6996 showTooltip: true,
6997 size: "compact",
6998 tooltipPosition: "top"
6999 }
7000 )
7001 ] })
7002 ]
7003 }
7004 );
7005 }
7006 var dataviews_pagination_default = (0, import_element36.memo)(DataViewsPagination);
7007
7008 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
7009 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
7010 function useIsMultiselectPicker(actions2) {
7011 return (0, import_element37.useMemo)(() => {
7012 return actions2?.every((action) => action.supportsBulk);
7013 }, [actions2]);
7014 }
7015
7016 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
7017 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
7018 var { Badge: Badge4 } = unlock(import_components17.privateApis);
7019 function GridItem3({
7020 view,
7021 multiselect,
7022 selection,
7023 onChangeSelection,
7024 getItemId,
7025 item,
7026 mediaField,
7027 titleField,
7028 descriptionField,
7029 regularFields,
7030 badgeFields,
7031 config,
7032 posinset,
7033 setsize
7034 }) {
7035 const { showTitle = true, showMedia = true, showDescription = true } = view;
7036 const id = getItemId(item);
7037 const elementRef = (0, import_element38.useRef)(null);
7038 const isSelected2 = selection.includes(id);
7039 useIntersectionObserver(elementRef, posinset);
7040 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7041 mediaField.render,
7042 {
7043 item,
7044 field: mediaField,
7045 config
7046 }
7047 ) : null;
7048 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null;
7049 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
7050 import_components17.Composite.Item,
7051 {
7052 ref: elementRef,
7053 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
7054 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Stack, { direction: "column", children, ...props }),
7055 role: "option",
7056 "aria-posinset": posinset,
7057 "aria-setsize": setsize,
7058 className: clsx_default("dataviews-view-picker-grid__card", {
7059 "is-selected": isSelected2
7060 }),
7061 "aria-selected": isSelected2,
7062 onClick: () => {
7063 if (isSelected2) {
7064 onChangeSelection(
7065 selection.filter((itemId) => id !== itemId)
7066 );
7067 } else {
7068 const newSelection = multiselect ? [...selection, id] : [id];
7069 onChangeSelection(newSelection);
7070 }
7071 },
7072 children: [
7073 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
7074 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7075 DataViewsSelectionCheckbox,
7076 {
7077 item,
7078 selection,
7079 onChangeSelection,
7080 getItemId,
7081 titleField,
7082 disabled: false,
7083 "aria-hidden": true,
7084 tabIndex: -1
7085 }
7086 ),
7087 showTitle && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7088 Stack,
7089 {
7090 direction: "row",
7091 justify: "space-between",
7092 className: "dataviews-view-picker-grid__title-actions",
7093 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
7094 }
7095 ),
7096 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "column", gap: "xs", children: [
7097 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7098 descriptionField.render,
7099 {
7100 item,
7101 field: descriptionField
7102 }
7103 ),
7104 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7105 Stack,
7106 {
7107 direction: "row",
7108 className: "dataviews-view-picker-grid__badge-fields",
7109 gap: "sm",
7110 wrap: "wrap",
7111 align: "top",
7112 justify: "flex-start",
7113 children: badgeFields.map((field) => {
7114 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7115 Badge4,
7116 {
7117 className: "dataviews-view-picker-grid__field-value",
7118 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7119 field.render,
7120 {
7121 item,
7122 field
7123 }
7124 )
7125 },
7126 field.id
7127 );
7128 })
7129 }
7130 ),
7131 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7132 Stack,
7133 {
7134 direction: "column",
7135 className: "dataviews-view-picker-grid__fields",
7136 gap: "xs",
7137 children: regularFields.map((field) => {
7138 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7139 import_components17.Flex,
7140 {
7141 className: "dataviews-view-picker-grid__field",
7142 gap: 1,
7143 justify: "flex-start",
7144 expanded: true,
7145 style: { height: "auto" },
7146 direction: "row",
7147 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
7148 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components17.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
7149 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7150 import_components17.FlexItem,
7151 {
7152 className: "dataviews-view-picker-grid__field-value",
7153 style: { maxHeight: "none" },
7154 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7155 field.render,
7156 {
7157 item,
7158 field
7159 }
7160 )
7161 }
7162 )
7163 ] })
7164 },
7165 field.id
7166 );
7167 })
7168 }
7169 )
7170 ] })
7171 ]
7172 },
7173 id
7174 );
7175 }
7176 function GridGroup({
7177 groupName,
7178 groupField,
7179 showLabel = true,
7180 children
7181 }) {
7182 const headerId = (0, import_compose6.useInstanceId)(
7183 GridGroup,
7184 "dataviews-view-picker-grid-group__header"
7185 );
7186 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
7187 Stack,
7188 {
7189 direction: "column",
7190 gap: "sm",
7191 role: "group",
7192 "aria-labelledby": headerId,
7193 children: [
7194 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7195 "h3",
7196 {
7197 className: "dataviews-view-picker-grid-group__header",
7198 id: headerId,
7199 children: showLabel ? (0, import_i18n18.sprintf)(
7200 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
7201 (0, import_i18n18.__)("%1$s: %2$s"),
7202 groupField.label,
7203 groupName
7204 ) : groupName
7205 }
7206 ),
7207 children
7208 ]
7209 },
7210 groupName
7211 );
7212 }
7213 function ViewPickerGrid({
7214 actions: actions2,
7215 data,
7216 fields: fields2,
7217 getItemId,
7218 isLoading,
7219 onChangeSelection,
7220 selection,
7221 view,
7222 className,
7223 empty
7224 }) {
7225 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element38.useContext)(dataviews_context_default);
7226 const titleField = fields2.find(
7227 (field) => field.id === view?.titleField
7228 );
7229 const mediaField = fields2.find(
7230 (field) => field.id === view?.mediaField
7231 );
7232 const descriptionField = fields2.find(
7233 (field) => field.id === view?.descriptionField
7234 );
7235 const otherFields = view.fields ?? [];
7236 const { regularFields, badgeFields } = otherFields.reduce(
7237 (accumulator, fieldId) => {
7238 const field = fields2.find((f2) => f2.id === fieldId);
7239 if (!field) {
7240 return accumulator;
7241 }
7242 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
7243 accumulator[key].push(field);
7244 return accumulator;
7245 },
7246 { regularFields: [], badgeFields: [] }
7247 );
7248 const hasData = !!data?.length;
7249 const usedPreviewSize = view.layout?.previewSize;
7250 const isMultiselect = useIsMultiselectPicker(actions2);
7251 const size = "900px";
7252 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
7253 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
7254 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
7255 const currentPage = view?.page ?? 1;
7256 const perPage = view?.perPage ?? 0;
7257 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
7258 const gridColumns = useGridColumns();
7259 const placeholdersNeeded = usePlaceholdersNeeded(
7260 data,
7261 isInfiniteScroll,
7262 gridColumns
7263 );
7264 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, {
7265 // Render multiple groups.
7266 children: [
7267 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7268 import_components17.Composite,
7269 {
7270 virtualFocus: true,
7271 orientation: "horizontal",
7272 role: "listbox",
7273 "aria-multiselectable": isMultiselect,
7274 className: clsx_default(
7275 "dataviews-view-picker-grid",
7276 className,
7277 {
7278 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
7279 view.layout.density
7280 )
7281 }
7282 ),
7283 "aria-label": itemListLabel,
7284 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7285 Stack,
7286 {
7287 direction: "column",
7288 gap: "lg",
7289 children,
7290 ...props
7291 }
7292 ),
7293 children: Array.from(dataByGroup.entries()).map(
7294 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7295 GridGroup,
7296 {
7297 groupName,
7298 groupField,
7299 showLabel: view.groupBy?.showLabel !== false,
7300 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7301 GridItems,
7302 {
7303 previewSize: usedPreviewSize,
7304 style: {
7305 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
7306 },
7307 "aria-busy": isLoading,
7308 ref: resizeObserverRef,
7309 children: groupItems.map((item) => {
7310 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
7311 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7312 GridItem3,
7313 {
7314 view,
7315 multiselect: isMultiselect,
7316 selection,
7317 onChangeSelection,
7318 getItemId,
7319 item,
7320 mediaField,
7321 titleField,
7322 descriptionField,
7323 regularFields,
7324 badgeFields,
7325 config: {
7326 sizes: size
7327 },
7328 posinset: posInSet,
7329 setsize: setSize
7330 },
7331 getItemId(item)
7332 );
7333 })
7334 }
7335 )
7336 },
7337 groupName
7338 )
7339 )
7340 }
7341 ),
7342 // Render a single grid with all data.
7343 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
7344 import_components17.Composite,
7345 {
7346 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7347 GridItems,
7348 {
7349 className: clsx_default(
7350 "dataviews-view-picker-grid",
7351 className,
7352 {
7353 [`has-${view.layout?.density}-density`]: view.layout?.density && [
7354 "compact",
7355 "comfortable"
7356 ].includes(view.layout.density)
7357 }
7358 ),
7359 previewSize: usedPreviewSize,
7360 "aria-busy": isLoading,
7361 ref: resizeObserverRef
7362 }
7363 ),
7364 virtualFocus: true,
7365 orientation: "horizontal",
7366 role: "listbox",
7367 "aria-multiselectable": isMultiselect,
7368 "aria-label": itemListLabel,
7369 children: [
7370 Array.from({ length: placeholdersNeeded }).map(
7371 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7372 import_components17.Composite.Item,
7373 {
7374 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7375 Stack,
7376 {
7377 direction: "column",
7378 children,
7379 ...props
7380 }
7381 ),
7382 role: "option",
7383 "aria-hidden": true,
7384 tabIndex: -1,
7385 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
7386 },
7387 `placeholder-${index}`
7388 )
7389 ),
7390 data.map((item) => {
7391 const posinset = item.position;
7392 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7393 GridItem3,
7394 {
7395 view,
7396 multiselect: isMultiselect,
7397 selection,
7398 onChangeSelection,
7399 getItemId,
7400 item,
7401 mediaField,
7402 titleField,
7403 descriptionField,
7404 regularFields,
7405 badgeFields,
7406 config: {
7407 sizes: size
7408 },
7409 posinset,
7410 setsize: setSize
7411 },
7412 getItemId(item)
7413 );
7414 })
7415 ]
7416 }
7417 ),
7418 // Render empty state.
7419 !hasData && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7420 "div",
7421 {
7422 className: clsx_default({
7423 "dataviews-loading": isLoading,
7424 "dataviews-no-results": !isLoading
7425 }),
7426 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components17.Spinner, {}) }) : empty
7427 }
7428 ),
7429 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components17.Spinner, {}) })
7430 ]
7431 });
7432 }
7433 var picker_grid_default = ViewPickerGrid;
7434
7435 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
7436 var import_i18n19 = __toESM(require_i18n(), 1);
7437 var import_components18 = __toESM(require_components(), 1);
7438 var import_element39 = __toESM(require_element(), 1);
7439 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
7440 function TableColumnField2({
7441 item,
7442 fields: fields2,
7443 column,
7444 align
7445 }) {
7446 const field = fields2.find((f2) => f2.id === column);
7447 if (!field) {
7448 return null;
7449 }
7450 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
7451 "dataviews-view-table__cell-align-end": align === "end",
7452 "dataviews-view-table__cell-align-center": align === "center"
7453 });
7454 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(field.render, { item, field }) });
7455 }
7456 function TableRow2({
7457 item,
7458 fields: fields2,
7459 id,
7460 view,
7461 titleField,
7462 mediaField,
7463 descriptionField,
7464 selection,
7465 getItemId,
7466 onChangeSelection,
7467 multiselect,
7468 posinset
7469 }) {
7470 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
7471 const isSelected2 = selection.includes(id);
7472 const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
7473 const elementRef = (0, import_element39.useRef)(null);
7474 useIntersectionObserver(elementRef, posinset);
7475 const {
7476 showTitle = true,
7477 showMedia = true,
7478 showDescription = true,
7479 infiniteScrollEnabled
7480 } = view;
7481 const handleMouseEnter = () => {
7482 setIsHovered(true);
7483 };
7484 const handleMouseLeave = () => {
7485 setIsHovered(false);
7486 };
7487 const columns = view.fields ?? [];
7488 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
7489 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7490 import_components18.Composite.Item,
7491 {
7492 ref: elementRef,
7493 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7494 "tr",
7495 {
7496 className: clsx_default("dataviews-view-table__row", {
7497 "is-selected": isSelected2,
7498 "is-hovered": isHovered
7499 }),
7500 onMouseEnter: handleMouseEnter,
7501 onMouseLeave: handleMouseLeave,
7502 children,
7503 ...props
7504 }
7505 ),
7506 "aria-selected": isSelected2,
7507 "aria-setsize": paginationInfo.totalItems || void 0,
7508 "aria-posinset": posinset,
7509 role: infiniteScrollEnabled ? "article" : "option",
7510 onClick: () => {
7511 if (isSelected2) {
7512 onChangeSelection(
7513 selection.filter((itemId) => id !== itemId)
7514 );
7515 } else {
7516 const newSelection = multiselect ? [...selection, id] : [id];
7517 onChangeSelection(newSelection);
7518 }
7519 },
7520 children: [
7521 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7522 "td",
7523 {
7524 className: "dataviews-view-table__checkbox-column",
7525 role: "presentation",
7526 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7527 DataViewsSelectionCheckbox,
7528 {
7529 item,
7530 selection,
7531 onChangeSelection,
7532 getItemId,
7533 titleField,
7534 disabled: false,
7535 "aria-hidden": true,
7536 tabIndex: -1
7537 }
7538 ) })
7539 }
7540 ),
7541 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7542 "td",
7543 {
7544 role: "presentation",
7545 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7546 column_primary_default,
7547 {
7548 item,
7549 titleField: showTitle ? titleField : void 0,
7550 mediaField: showMedia ? mediaField : void 0,
7551 descriptionField: showDescription ? descriptionField : void 0,
7552 isItemClickable: () => false
7553 }
7554 )
7555 }
7556 ),
7557 columns.map((column) => {
7558 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
7559 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7560 "td",
7561 {
7562 style: {
7563 width,
7564 maxWidth,
7565 minWidth
7566 },
7567 role: "presentation",
7568 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7569 TableColumnField2,
7570 {
7571 fields: fields2,
7572 item,
7573 column,
7574 align
7575 }
7576 )
7577 },
7578 column
7579 );
7580 })
7581 ]
7582 },
7583 id
7584 );
7585 }
7586 function ViewPickerTable({
7587 actions: actions2,
7588 data,
7589 fields: fields2,
7590 getItemId,
7591 isLoading = false,
7592 onChangeView,
7593 onChangeSelection,
7594 selection,
7595 setOpenedFilter,
7596 view,
7597 className,
7598 empty
7599 }) {
7600 const headerMenuRefs = (0, import_element39.useRef)(/* @__PURE__ */ new Map());
7601 const headerMenuToFocusRef = (0, import_element39.useRef)(void 0);
7602 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element39.useState)();
7603 const isMultiselect = useIsMultiselectPicker(actions2) ?? false;
7604 (0, import_element39.useEffect)(() => {
7605 if (headerMenuToFocusRef.current) {
7606 headerMenuToFocusRef.current.focus();
7607 headerMenuToFocusRef.current = void 0;
7608 }
7609 });
7610 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
7611 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
7612 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
7613 const tableNoticeId = (0, import_element39.useId)();
7614 if (nextHeaderMenuToFocus) {
7615 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
7616 setNextHeaderMenuToFocus(void 0);
7617 return;
7618 }
7619 const onHide = (field) => {
7620 const hidden = headerMenuRefs.current.get(field.id);
7621 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
7622 setNextHeaderMenuToFocus(fallback?.node);
7623 };
7624 const hasData = !!data?.length;
7625 const titleField = fields2.find((field) => field.id === view.titleField);
7626 const mediaField = fields2.find((field) => field.id === view.mediaField);
7627 const descriptionField = fields2.find(
7628 (field) => field.id === view.descriptionField
7629 );
7630 const { showTitle = true, showMedia = true, showDescription = true } = view;
7631 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
7632 const columns = view.fields ?? [];
7633 const headerMenuRef = (column, index) => (node) => {
7634 if (node) {
7635 headerMenuRefs.current.set(column, {
7636 node,
7637 fallback: columns[index > 0 ? index - 1 : 1]
7638 });
7639 } else {
7640 headerMenuRefs.current.delete(column);
7641 }
7642 };
7643 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
7644 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7645 "table",
7646 {
7647 className: clsx_default(
7648 "dataviews-view-table",
7649 "dataviews-view-picker-table",
7650 className,
7651 {
7652 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
7653 view.layout.density
7654 )
7655 }
7656 ),
7657 "aria-busy": isLoading,
7658 "aria-describedby": tableNoticeId,
7659 role: isInfiniteScroll ? "feed" : "listbox",
7660 children: [
7661 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7662 "tr",
7663 {
7664 className: "dataviews-view-table__row",
7665 role: "presentation",
7666 children: [
7667 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7668 BulkSelectionCheckbox,
7669 {
7670 selection,
7671 onChangeSelection,
7672 data,
7673 actions: actions2,
7674 getItemId,
7675 disableSelectAll: isInfiniteScroll
7676 }
7677 ) }),
7678 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7679 column_header_menu_default,
7680 {
7681 ref: headerMenuRef(
7682 titleField.id,
7683 0
7684 ),
7685 fieldId: titleField.id,
7686 view,
7687 fields: fields2,
7688 onChangeView,
7689 onHide,
7690 setOpenedFilter,
7691 canMove: false
7692 }
7693 ) }),
7694 columns.map((column, index) => {
7695 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
7696 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7697 "th",
7698 {
7699 style: {
7700 width,
7701 maxWidth,
7702 minWidth,
7703 textAlign: align
7704 },
7705 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
7706 scope: "col",
7707 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7708 column_header_menu_default,
7709 {
7710 ref: headerMenuRef(column, index),
7711 fieldId: column,
7712 view,
7713 fields: fields2,
7714 onChangeView,
7715 onHide,
7716 setOpenedFilter,
7717 canMove: view.layout?.enableMoving ?? true
7718 }
7719 )
7720 },
7721 column
7722 );
7723 })
7724 ]
7725 }
7726 ) }),
7727 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
7728 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7729 import_components18.Composite,
7730 {
7731 virtualFocus: true,
7732 orientation: "vertical",
7733 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("tbody", { role: "group" }),
7734 children: [
7735 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7736 "tr",
7737 {
7738 className: "dataviews-view-table__group-header-row",
7739 role: "presentation",
7740 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7741 "td",
7742 {
7743 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
7744 className: "dataviews-view-table__group-header-cell",
7745 role: "presentation",
7746 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
7747 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
7748 (0, import_i18n19.__)("%1$s: %2$s"),
7749 groupField.label,
7750 groupName
7751 )
7752 }
7753 )
7754 }
7755 ),
7756 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7757 TableRow2,
7758 {
7759 item,
7760 fields: fields2,
7761 id: getItemId(item) || index.toString(),
7762 view,
7763 titleField,
7764 mediaField,
7765 descriptionField,
7766 selection,
7767 getItemId,
7768 onChangeSelection,
7769 multiselect: isMultiselect
7770 },
7771 getItemId(item)
7772 ))
7773 ]
7774 },
7775 `group-${groupName}`
7776 )
7777 ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7778 import_components18.Composite,
7779 {
7780 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("tbody", { role: "presentation" }),
7781 virtualFocus: true,
7782 orientation: "vertical",
7783 children: hasData && data.map((item, index) => {
7784 const itemId = getItemId(item);
7785 const posinset = item.position;
7786 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7787 TableRow2,
7788 {
7789 item,
7790 fields: fields2,
7791 id: itemId || index.toString(),
7792 view,
7793 titleField,
7794 mediaField,
7795 descriptionField,
7796 selection,
7797 getItemId,
7798 onChangeSelection,
7799 multiselect: isMultiselect,
7800 posinset
7801 },
7802 itemId
7803 );
7804 })
7805 }
7806 )
7807 ]
7808 }
7809 ),
7810 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7811 "div",
7812 {
7813 className: clsx_default({
7814 "dataviews-loading": isLoading,
7815 "dataviews-no-results": !hasData && !isLoading
7816 }),
7817 id: tableNoticeId,
7818 children: [
7819 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components18.Spinner, {}) }) : empty),
7820 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components18.Spinner, {}) })
7821 ]
7822 }
7823 )
7824 ] });
7825 }
7826 var picker_table_default = ViewPickerTable;
7827
7828 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
7829 var import_components19 = __toESM(require_components(), 1);
7830 var import_i18n20 = __toESM(require_i18n(), 1);
7831 var import_element40 = __toESM(require_element(), 1);
7832 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
7833 function DensityPicker() {
7834 const context = (0, import_element40.useContext)(dataviews_context_default);
7835 const view = context.view;
7836 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
7837 import_components19.__experimentalToggleGroupControl,
7838 {
7839 size: "__unstable-large",
7840 label: (0, import_i18n20.__)("Density"),
7841 value: view.layout?.density || "balanced",
7842 onChange: (value) => {
7843 context.onChangeView({
7844 ...view,
7845 layout: {
7846 ...view.layout,
7847 density: value
7848 }
7849 });
7850 },
7851 isBlock: true,
7852 children: [
7853 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
7854 import_components19.__experimentalToggleGroupControlOption,
7855 {
7856 value: "comfortable",
7857 label: (0, import_i18n20._x)(
7858 "Comfortable",
7859 "Density option for DataView layout"
7860 )
7861 },
7862 "comfortable"
7863 ),
7864 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
7865 import_components19.__experimentalToggleGroupControlOption,
7866 {
7867 value: "balanced",
7868 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
7869 },
7870 "balanced"
7871 ),
7872 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
7873 import_components19.__experimentalToggleGroupControlOption,
7874 {
7875 value: "compact",
7876 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
7877 },
7878 "compact"
7879 )
7880 ]
7881 }
7882 );
7883 }
7884
7885 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
7886 var import_components20 = __toESM(require_components(), 1);
7887 var import_i18n21 = __toESM(require_i18n(), 1);
7888 var import_element41 = __toESM(require_element(), 1);
7889 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
7890 var imageSizes2 = [
7891 {
7892 value: 120,
7893 breakpoint: 1
7894 },
7895 {
7896 value: 170,
7897 breakpoint: 1
7898 },
7899 {
7900 value: 230,
7901 breakpoint: 1
7902 },
7903 {
7904 value: 290,
7905 breakpoint: 1112
7906 // at minimum image width, 4 images display at this container size
7907 },
7908 {
7909 value: 350,
7910 breakpoint: 1636
7911 // at minimum image width, 6 images display at this container size
7912 },
7913 {
7914 value: 430,
7915 breakpoint: 588
7916 // at minimum image width, 2 images display at this container size
7917 }
7918 ];
7919 function PreviewSizePicker() {
7920 const context = (0, import_element41.useContext)(dataviews_context_default);
7921 const view = context.view;
7922 const breakValues = imageSizes2.filter((size) => {
7923 return context.containerWidth >= size.breakpoint;
7924 });
7925 const layoutPreviewSize = view.layout?.previewSize ?? 230;
7926 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
7927 const marks = breakValues.map((size, index) => {
7928 return {
7929 value: index
7930 };
7931 });
7932 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
7933 import_components20.RangeControl,
7934 {
7935 __next40pxDefaultSize: true,
7936 showTooltip: false,
7937 label: (0, import_i18n21.__)("Preview size"),
7938 value: previewSizeToUse,
7939 min: 0,
7940 max: breakValues.length - 1,
7941 withInputField: false,
7942 onChange: (value = 0) => {
7943 context.onChangeView({
7944 ...view,
7945 layout: {
7946 ...view.layout,
7947 previewSize: breakValues[value].value
7948 }
7949 });
7950 },
7951 step: 1,
7952 marks
7953 }
7954 );
7955 }
7956
7957 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
7958 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
7959 function GridConfigOptions() {
7960 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
7961 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(DensityPicker, {}),
7962 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PreviewSizePicker, {})
7963 ] });
7964 }
7965
7966 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
7967 var VIEW_LAYOUTS = [
7968 {
7969 type: LAYOUT_TABLE,
7970 label: (0, import_i18n22.__)("Table"),
7971 component: table_default,
7972 icon: block_table_default,
7973 viewConfigOptions: DensityPicker
7974 },
7975 {
7976 type: LAYOUT_GRID,
7977 label: (0, import_i18n22.__)("Grid"),
7978 component: grid_default,
7979 icon: category_default,
7980 viewConfigOptions: GridConfigOptions
7981 },
7982 {
7983 type: LAYOUT_LIST,
7984 label: (0, import_i18n22.__)("List"),
7985 component: ViewList,
7986 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
7987 viewConfigOptions: DensityPicker
7988 },
7989 {
7990 type: LAYOUT_ACTIVITY,
7991 label: (0, import_i18n22.__)("Activity"),
7992 component: ViewActivity,
7993 icon: scheduled_default,
7994 viewConfigOptions: DensityPicker
7995 },
7996 {
7997 type: LAYOUT_PICKER_GRID,
7998 label: (0, import_i18n22.__)("Grid"),
7999 component: picker_grid_default,
8000 icon: category_default,
8001 viewConfigOptions: GridConfigOptions,
8002 isPicker: true
8003 },
8004 {
8005 type: LAYOUT_PICKER_TABLE,
8006 label: (0, import_i18n22.__)("Table"),
8007 component: picker_table_default,
8008 icon: block_table_default,
8009 viewConfigOptions: DensityPicker,
8010 isPicker: true
8011 }
8012 ];
8013
8014 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
8015 var import_element49 = __toESM(require_element(), 1);
8016
8017 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
8018 var import_components23 = __toESM(require_components(), 1);
8019 var import_i18n25 = __toESM(require_i18n(), 1);
8020 var import_element46 = __toESM(require_element(), 1);
8021
8022 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
8023 function noop2(..._) {
8024 }
8025 function applyState(argument, currentValue) {
8026 if (isUpdater(argument)) {
8027 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
8028 return argument(value);
8029 }
8030 return argument;
8031 }
8032 function isUpdater(argument) {
8033 return typeof argument === "function";
8034 }
8035 function isLazyValue(value) {
8036 return typeof value === "function";
8037 }
8038 function hasOwnProperty(object, prop) {
8039 if (typeof Object.hasOwn === "function") {
8040 return Object.hasOwn(object, prop);
8041 }
8042 return Object.prototype.hasOwnProperty.call(object, prop);
8043 }
8044 function chain(...fns) {
8045 return (...args) => {
8046 for (const fn of fns) {
8047 if (typeof fn === "function") {
8048 fn(...args);
8049 }
8050 }
8051 };
8052 }
8053 function normalizeString(str) {
8054 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
8055 }
8056 function omit(object, keys) {
8057 const result = { ...object };
8058 for (const key of keys) {
8059 if (hasOwnProperty(result, key)) {
8060 delete result[key];
8061 }
8062 }
8063 return result;
8064 }
8065 function pick(object, paths) {
8066 const result = {};
8067 for (const key of paths) {
8068 if (hasOwnProperty(object, key)) {
8069 result[key] = object[key];
8070 }
8071 }
8072 return result;
8073 }
8074 function identity(value) {
8075 return value;
8076 }
8077 function invariant(condition, message2) {
8078 if (condition) return;
8079 if (typeof message2 !== "string") throw new Error("Invariant failed");
8080 throw new Error(message2);
8081 }
8082 function getKeys(obj) {
8083 return Object.keys(obj);
8084 }
8085 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
8086 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
8087 if (result == null) return false;
8088 return !result;
8089 }
8090 function disabledFromProps(props) {
8091 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
8092 }
8093 function removeUndefinedValues(obj) {
8094 const result = {};
8095 for (const key in obj) {
8096 if (obj[key] !== void 0) {
8097 result[key] = obj[key];
8098 }
8099 }
8100 return result;
8101 }
8102 function defaultValue(...values) {
8103 for (const value of values) {
8104 if (value !== void 0) return value;
8105 }
8106 return void 0;
8107 }
8108
8109 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
8110 var import_react9 = __toESM(require_react(), 1);
8111 function setRef(ref, value) {
8112 if (typeof ref === "function") {
8113 ref(value);
8114 } else if (ref) {
8115 ref.current = value;
8116 }
8117 }
8118 function isValidElementWithRef(element) {
8119 if (!element) return false;
8120 if (!(0, import_react9.isValidElement)(element)) return false;
8121 if ("ref" in element.props) return true;
8122 if ("ref" in element) return true;
8123 return false;
8124 }
8125 function getRefProperty(element) {
8126 if (!isValidElementWithRef(element)) return null;
8127 const props = { ...element.props };
8128 return props.ref || element.ref;
8129 }
8130 function mergeProps2(base, overrides) {
8131 const props = { ...base };
8132 for (const key in overrides) {
8133 if (!hasOwnProperty(overrides, key)) continue;
8134 if (key === "className") {
8135 const prop = "className";
8136 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
8137 continue;
8138 }
8139 if (key === "style") {
8140 const prop = "style";
8141 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
8142 continue;
8143 }
8144 const overrideValue = overrides[key];
8145 if (typeof overrideValue === "function" && key.startsWith("on")) {
8146 const baseValue = base[key];
8147 if (typeof baseValue === "function") {
8148 props[key] = (...args) => {
8149 overrideValue(...args);
8150 baseValue(...args);
8151 };
8152 continue;
8153 }
8154 }
8155 props[key] = overrideValue;
8156 }
8157 return props;
8158 }
8159
8160 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
8161 var canUseDOM = checkIsBrowser();
8162 function checkIsBrowser() {
8163 var _a;
8164 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
8165 }
8166 function getDocument(node) {
8167 if (!node) return document;
8168 if ("self" in node) return node.document;
8169 return node.ownerDocument || document;
8170 }
8171 function getActiveElement(node, activeDescendant = false) {
8172 var _a;
8173 const { activeElement } = getDocument(node);
8174 if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
8175 return null;
8176 }
8177 if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
8178 return getActiveElement(
8179 activeElement.contentDocument.body,
8180 activeDescendant
8181 );
8182 }
8183 if (activeDescendant) {
8184 const id = activeElement.getAttribute("aria-activedescendant");
8185 if (id) {
8186 const element = getDocument(activeElement).getElementById(id);
8187 if (element) {
8188 return element;
8189 }
8190 }
8191 }
8192 return activeElement;
8193 }
8194 function contains(parent, child) {
8195 return parent === child || parent.contains(child);
8196 }
8197 function isFrame(element) {
8198 return element.tagName === "IFRAME";
8199 }
8200 function isButton(element) {
8201 const tagName = element.tagName.toLowerCase();
8202 if (tagName === "button") return true;
8203 if (tagName === "input" && element.type) {
8204 return buttonInputTypes.indexOf(element.type) !== -1;
8205 }
8206 return false;
8207 }
8208 var buttonInputTypes = [
8209 "button",
8210 "color",
8211 "file",
8212 "image",
8213 "reset",
8214 "submit"
8215 ];
8216 function isVisible(element) {
8217 if (typeof element.checkVisibility === "function") {
8218 return element.checkVisibility();
8219 }
8220 const htmlElement = element;
8221 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
8222 }
8223 function isTextField(element) {
8224 try {
8225 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
8226 const isTextArea = element.tagName === "TEXTAREA";
8227 return isTextInput || isTextArea || false;
8228 } catch (_error) {
8229 return false;
8230 }
8231 }
8232 function isTextbox(element) {
8233 return element.isContentEditable || isTextField(element);
8234 }
8235 function getTextboxValue(element) {
8236 if (isTextField(element)) {
8237 return element.value;
8238 }
8239 if (element.isContentEditable) {
8240 const range = getDocument(element).createRange();
8241 range.selectNodeContents(element);
8242 return range.toString();
8243 }
8244 return "";
8245 }
8246 function getTextboxSelection(element) {
8247 let start = 0;
8248 let end = 0;
8249 if (isTextField(element)) {
8250 start = element.selectionStart || 0;
8251 end = element.selectionEnd || 0;
8252 } else if (element.isContentEditable) {
8253 const selection = getDocument(element).getSelection();
8254 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
8255 const range = selection.getRangeAt(0);
8256 const nextRange = range.cloneRange();
8257 nextRange.selectNodeContents(element);
8258 nextRange.setEnd(range.startContainer, range.startOffset);
8259 start = nextRange.toString().length;
8260 nextRange.setEnd(range.endContainer, range.endOffset);
8261 end = nextRange.toString().length;
8262 }
8263 }
8264 return { start, end };
8265 }
8266 function getPopupRole(element, fallback) {
8267 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
8268 const role = element == null ? void 0 : element.getAttribute("role");
8269 if (role && allowedPopupRoles.indexOf(role) !== -1) {
8270 return role;
8271 }
8272 return fallback;
8273 }
8274 function getScrollingElement(element) {
8275 if (!element) return null;
8276 const isScrollableOverflow = (overflow) => {
8277 if (overflow === "auto") return true;
8278 if (overflow === "scroll") return true;
8279 return false;
8280 };
8281 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
8282 const { overflowY } = getComputedStyle(element);
8283 if (isScrollableOverflow(overflowY)) return element;
8284 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
8285 const { overflowX } = getComputedStyle(element);
8286 if (isScrollableOverflow(overflowX)) return element;
8287 }
8288 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
8289 }
8290 function setSelectionRange(element, ...args) {
8291 if (/text|search|password|tel|url/i.test(element.type)) {
8292 element.setSelectionRange(...args);
8293 }
8294 }
8295 function sortBasedOnDOMPosition(items, getElement) {
8296 const pairs = items.map((item, index) => [index, item]);
8297 let isOrderDifferent = false;
8298 pairs.sort(([indexA, a2], [indexB, b2]) => {
8299 const elementA = getElement(a2);
8300 const elementB = getElement(b2);
8301 if (elementA === elementB) return 0;
8302 if (!elementA || !elementB) return 0;
8303 if (isElementPreceding(elementA, elementB)) {
8304 if (indexA > indexB) {
8305 isOrderDifferent = true;
8306 }
8307 return -1;
8308 }
8309 if (indexA < indexB) {
8310 isOrderDifferent = true;
8311 }
8312 return 1;
8313 });
8314 if (isOrderDifferent) {
8315 return pairs.map(([_, item]) => item);
8316 }
8317 return items;
8318 }
8319 function isElementPreceding(a2, b2) {
8320 return Boolean(
8321 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
8322 );
8323 }
8324
8325 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
8326 function isTouchDevice() {
8327 return canUseDOM && !!navigator.maxTouchPoints;
8328 }
8329 function isApple() {
8330 if (!canUseDOM) return false;
8331 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
8332 }
8333 function isSafari() {
8334 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
8335 }
8336 function isFirefox() {
8337 return canUseDOM && /firefox\//i.test(navigator.userAgent);
8338 }
8339
8340 // node_modules/@ariakit/core/esm/utils/events.js
8341 function isPortalEvent(event) {
8342 return Boolean(
8343 event.currentTarget && !contains(event.currentTarget, event.target)
8344 );
8345 }
8346 function isSelfTarget(event) {
8347 return event.target === event.currentTarget;
8348 }
8349 function isOpeningInNewTab(event) {
8350 const element = event.currentTarget;
8351 if (!element) return false;
8352 const isAppleDevice = isApple();
8353 if (isAppleDevice && !event.metaKey) return false;
8354 if (!isAppleDevice && !event.ctrlKey) return false;
8355 const tagName = element.tagName.toLowerCase();
8356 if (tagName === "a") return true;
8357 if (tagName === "button" && element.type === "submit") return true;
8358 if (tagName === "input" && element.type === "submit") return true;
8359 return false;
8360 }
8361 function isDownloading(event) {
8362 const element = event.currentTarget;
8363 if (!element) return false;
8364 const tagName = element.tagName.toLowerCase();
8365 if (!event.altKey) return false;
8366 if (tagName === "a") return true;
8367 if (tagName === "button" && element.type === "submit") return true;
8368 if (tagName === "input" && element.type === "submit") return true;
8369 return false;
8370 }
8371 function fireBlurEvent(element, eventInit) {
8372 const event = new FocusEvent("blur", eventInit);
8373 const defaultAllowed = element.dispatchEvent(event);
8374 const bubbleInit = { ...eventInit, bubbles: true };
8375 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
8376 return defaultAllowed;
8377 }
8378 function fireKeyboardEvent(element, type, eventInit) {
8379 const event = new KeyboardEvent(type, eventInit);
8380 return element.dispatchEvent(event);
8381 }
8382 function fireClickEvent(element, eventInit) {
8383 const event = new MouseEvent("click", eventInit);
8384 return element.dispatchEvent(event);
8385 }
8386 function isFocusEventOutside(event, container) {
8387 const containerElement = container || event.currentTarget;
8388 const relatedTarget = event.relatedTarget;
8389 return !relatedTarget || !contains(containerElement, relatedTarget);
8390 }
8391 function queueBeforeEvent(element, type, callback, timeout) {
8392 const createTimer = (callback2) => {
8393 if (timeout) {
8394 const timerId2 = setTimeout(callback2, timeout);
8395 return () => clearTimeout(timerId2);
8396 }
8397 const timerId = requestAnimationFrame(callback2);
8398 return () => cancelAnimationFrame(timerId);
8399 };
8400 const cancelTimer = createTimer(() => {
8401 element.removeEventListener(type, callSync, true);
8402 callback();
8403 });
8404 const callSync = () => {
8405 cancelTimer();
8406 callback();
8407 };
8408 element.addEventListener(type, callSync, { once: true, capture: true });
8409 return cancelTimer;
8410 }
8411 function addGlobalEventListener(type, listener, options, scope = window) {
8412 const children = [];
8413 try {
8414 scope.document.addEventListener(type, listener, options);
8415 for (const frame of Array.from(scope.frames)) {
8416 children.push(addGlobalEventListener(type, listener, options, frame));
8417 }
8418 } catch (e2) {
8419 }
8420 const removeEventListener = () => {
8421 try {
8422 scope.document.removeEventListener(type, listener, options);
8423 } catch (e2) {
8424 }
8425 for (const remove of children) {
8426 remove();
8427 }
8428 };
8429 return removeEventListener;
8430 }
8431
8432 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
8433 var React23 = __toESM(require_react(), 1);
8434 var import_react10 = __toESM(require_react(), 1);
8435 var _React = { ...React23 };
8436 var useReactId = _React.useId;
8437 var useReactDeferredValue = _React.useDeferredValue;
8438 var useReactInsertionEffect = _React.useInsertionEffect;
8439 var useSafeLayoutEffect = canUseDOM ? import_react10.useLayoutEffect : import_react10.useEffect;
8440 function useInitialValue(value) {
8441 const [initialValue] = (0, import_react10.useState)(value);
8442 return initialValue;
8443 }
8444 function useLiveRef(value) {
8445 const ref = (0, import_react10.useRef)(value);
8446 useSafeLayoutEffect(() => {
8447 ref.current = value;
8448 });
8449 return ref;
8450 }
8451 function useEvent(callback) {
8452 const ref = (0, import_react10.useRef)(() => {
8453 throw new Error("Cannot call an event handler while rendering.");
8454 });
8455 if (useReactInsertionEffect) {
8456 useReactInsertionEffect(() => {
8457 ref.current = callback;
8458 });
8459 } else {
8460 ref.current = callback;
8461 }
8462 return (0, import_react10.useCallback)((...args) => {
8463 var _a;
8464 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
8465 }, []);
8466 }
8467 function useTransactionState(callback) {
8468 const [state, setState] = (0, import_react10.useState)(null);
8469 useSafeLayoutEffect(() => {
8470 if (state == null) return;
8471 if (!callback) return;
8472 let prevState = null;
8473 callback((prev) => {
8474 prevState = prev;
8475 return state;
8476 });
8477 return () => {
8478 callback(prevState);
8479 };
8480 }, [state, callback]);
8481 return [state, setState];
8482 }
8483 function useMergeRefs(...refs) {
8484 return (0, import_react10.useMemo)(() => {
8485 if (!refs.some(Boolean)) return;
8486 return (value) => {
8487 for (const ref of refs) {
8488 setRef(ref, value);
8489 }
8490 };
8491 }, refs);
8492 }
8493 function useId5(defaultId) {
8494 if (useReactId) {
8495 const reactId = useReactId();
8496 if (defaultId) return defaultId;
8497 return reactId;
8498 }
8499 const [id, setId] = (0, import_react10.useState)(defaultId);
8500 useSafeLayoutEffect(() => {
8501 if (defaultId || id) return;
8502 const random = Math.random().toString(36).slice(2, 8);
8503 setId(`id-${random}`);
8504 }, [defaultId, id]);
8505 return defaultId || id;
8506 }
8507 function useTagName(refOrElement, type) {
8508 const stringOrUndefined = (type2) => {
8509 if (typeof type2 !== "string") return;
8510 return type2;
8511 };
8512 const [tagName, setTagName] = (0, import_react10.useState)(() => stringOrUndefined(type));
8513 useSafeLayoutEffect(() => {
8514 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
8515 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
8516 }, [refOrElement, type]);
8517 return tagName;
8518 }
8519 function useAttribute(refOrElement, attributeName, defaultValue2) {
8520 const initialValue = useInitialValue(defaultValue2);
8521 const [attribute, setAttribute] = (0, import_react10.useState)(initialValue);
8522 (0, import_react10.useEffect)(() => {
8523 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
8524 if (!element) return;
8525 const callback = () => {
8526 const value = element.getAttribute(attributeName);
8527 setAttribute(value == null ? initialValue : value);
8528 };
8529 const observer = new MutationObserver(callback);
8530 observer.observe(element, { attributeFilter: [attributeName] });
8531 callback();
8532 return () => observer.disconnect();
8533 }, [refOrElement, attributeName, initialValue]);
8534 return attribute;
8535 }
8536 function useUpdateEffect(effect, deps) {
8537 const mounted = (0, import_react10.useRef)(false);
8538 (0, import_react10.useEffect)(() => {
8539 if (mounted.current) {
8540 return effect();
8541 }
8542 mounted.current = true;
8543 }, deps);
8544 (0, import_react10.useEffect)(
8545 () => () => {
8546 mounted.current = false;
8547 },
8548 []
8549 );
8550 }
8551 function useUpdateLayoutEffect(effect, deps) {
8552 const mounted = (0, import_react10.useRef)(false);
8553 useSafeLayoutEffect(() => {
8554 if (mounted.current) {
8555 return effect();
8556 }
8557 mounted.current = true;
8558 }, deps);
8559 useSafeLayoutEffect(
8560 () => () => {
8561 mounted.current = false;
8562 },
8563 []
8564 );
8565 }
8566 function useForceUpdate() {
8567 return (0, import_react10.useReducer)(() => [], []);
8568 }
8569 function useBooleanEvent(booleanOrCallback) {
8570 return useEvent(
8571 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
8572 );
8573 }
8574 function useWrapElement(props, callback, deps = []) {
8575 const wrapElement = (0, import_react10.useCallback)(
8576 (element) => {
8577 if (props.wrapElement) {
8578 element = props.wrapElement(element);
8579 }
8580 return callback(element);
8581 },
8582 [...deps, props.wrapElement]
8583 );
8584 return { ...props, wrapElement };
8585 }
8586 function useMetadataProps(props, key, value) {
8587 const parent = props.onLoadedMetadataCapture;
8588 const onLoadedMetadataCapture = (0, import_react10.useMemo)(() => {
8589 return Object.assign(() => {
8590 }, { ...parent, [key]: value });
8591 }, [parent, key, value]);
8592 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
8593 }
8594 var hasInstalledGlobalEventListeners = false;
8595 function useIsMouseMoving() {
8596 (0, import_react10.useEffect)(() => {
8597 if (hasInstalledGlobalEventListeners) return;
8598 addGlobalEventListener("mousemove", setMouseMoving, true);
8599 addGlobalEventListener("mousedown", resetMouseMoving, true);
8600 addGlobalEventListener("mouseup", resetMouseMoving, true);
8601 addGlobalEventListener("keydown", resetMouseMoving, true);
8602 addGlobalEventListener("scroll", resetMouseMoving, true);
8603 hasInstalledGlobalEventListeners = true;
8604 }, []);
8605 const isMouseMoving = useEvent(() => mouseMoving);
8606 return isMouseMoving;
8607 }
8608 var mouseMoving = false;
8609 var previousScreenX = 0;
8610 var previousScreenY = 0;
8611 function hasMouseMovement(event) {
8612 const movementX = event.movementX || event.screenX - previousScreenX;
8613 const movementY = event.movementY || event.screenY - previousScreenY;
8614 previousScreenX = event.screenX;
8615 previousScreenY = event.screenY;
8616 return movementX || movementY || false;
8617 }
8618 function setMouseMoving(event) {
8619 if (!hasMouseMovement(event)) return;
8620 mouseMoving = true;
8621 }
8622 function resetMouseMoving() {
8623 mouseMoving = false;
8624 }
8625
8626 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
8627 var React24 = __toESM(require_react(), 1);
8628 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
8629 function forwardRef25(render4) {
8630 const Role = React24.forwardRef(
8631 // @ts-ignore Incompatible with React 19 types. Ignore for now.
8632 (props, ref) => render4({ ...props, ref })
8633 );
8634 Role.displayName = render4.displayName || render4.name;
8635 return Role;
8636 }
8637 function memo22(Component, propsAreEqual) {
8638 return React24.memo(Component, propsAreEqual);
8639 }
8640 function createElement3(Type, props) {
8641 const { wrapElement, render: render4, ...rest } = props;
8642 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
8643 let element;
8644 if (React24.isValidElement(render4)) {
8645 const renderProps = {
8646 // @ts-ignore Incompatible with React 19 types. Ignore for now.
8647 ...render4.props,
8648 ref: mergedRef
8649 };
8650 element = React24.cloneElement(render4, mergeProps2(rest, renderProps));
8651 } else if (render4) {
8652 element = render4(rest);
8653 } else {
8654 element = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Type, { ...rest });
8655 }
8656 if (wrapElement) {
8657 return wrapElement(element);
8658 }
8659 return element;
8660 }
8661 function createHook(useProps) {
8662 const useRole = (props = {}) => {
8663 return useProps(props);
8664 };
8665 useRole.displayName = useProps.name;
8666 return useRole;
8667 }
8668 function createStoreContext(providers = [], scopedProviders = []) {
8669 const context = React24.createContext(void 0);
8670 const scopedContext = React24.createContext(void 0);
8671 const useContext210 = () => React24.useContext(context);
8672 const useScopedContext = (onlyScoped = false) => {
8673 const scoped = React24.useContext(scopedContext);
8674 const store2 = useContext210();
8675 if (onlyScoped) return scoped;
8676 return scoped || store2;
8677 };
8678 const useProviderContext = () => {
8679 const scoped = React24.useContext(scopedContext);
8680 const store2 = useContext210();
8681 if (scoped && scoped === store2) return;
8682 return store2;
8683 };
8684 const ContextProvider = (props) => {
8685 return providers.reduceRight(
8686 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Provider, { ...props, children }),
8687 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(context.Provider, { ...props })
8688 );
8689 };
8690 const ScopedContextProvider = (props) => {
8691 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
8692 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Provider, { ...props, children }),
8693 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(scopedContext.Provider, { ...props })
8694 ) });
8695 };
8696 return {
8697 context,
8698 scopedContext,
8699 useContext: useContext210,
8700 useScopedContext,
8701 useProviderContext,
8702 ContextProvider,
8703 ScopedContextProvider
8704 };
8705 }
8706
8707 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
8708 var ctx = createStoreContext();
8709 var useCollectionContext = ctx.useContext;
8710 var useCollectionScopedContext = ctx.useScopedContext;
8711 var useCollectionProviderContext = ctx.useProviderContext;
8712 var CollectionContextProvider = ctx.ContextProvider;
8713 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
8714
8715 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
8716 var import_react11 = __toESM(require_react(), 1);
8717 var ctx2 = createStoreContext(
8718 [CollectionContextProvider],
8719 [CollectionScopedContextProvider]
8720 );
8721 var useCompositeContext = ctx2.useContext;
8722 var useCompositeScopedContext = ctx2.useScopedContext;
8723 var useCompositeProviderContext = ctx2.useProviderContext;
8724 var CompositeContextProvider = ctx2.ContextProvider;
8725 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
8726 var CompositeItemContext = (0, import_react11.createContext)(
8727 void 0
8728 );
8729 var CompositeRowContext = (0, import_react11.createContext)(
8730 void 0
8731 );
8732
8733 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
8734 function findFirstEnabledItem(items, excludeId) {
8735 return items.find((item) => {
8736 if (excludeId) {
8737 return !item.disabled && item.id !== excludeId;
8738 }
8739 return !item.disabled;
8740 });
8741 }
8742 function getEnabledItem(store2, id) {
8743 if (!id) return null;
8744 return store2.item(id) || null;
8745 }
8746 function groupItemsByRows(items) {
8747 const rows = [];
8748 for (const item of items) {
8749 const row = rows.find((currentRow) => {
8750 var _a;
8751 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
8752 });
8753 if (row) {
8754 row.push(item);
8755 } else {
8756 rows.push([item]);
8757 }
8758 }
8759 return rows;
8760 }
8761 function selectTextField(element, collapseToEnd = false) {
8762 if (isTextField(element)) {
8763 element.setSelectionRange(
8764 collapseToEnd ? element.value.length : 0,
8765 element.value.length
8766 );
8767 } else if (element.isContentEditable) {
8768 const selection = getDocument(element).getSelection();
8769 selection == null ? void 0 : selection.selectAllChildren(element);
8770 if (collapseToEnd) {
8771 selection == null ? void 0 : selection.collapseToEnd();
8772 }
8773 }
8774 }
8775 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
8776 function focusSilently(element) {
8777 element[FOCUS_SILENTLY] = true;
8778 element.focus({ preventScroll: true });
8779 }
8780 function silentlyFocused(element) {
8781 const isSilentlyFocused = element[FOCUS_SILENTLY];
8782 delete element[FOCUS_SILENTLY];
8783 return isSilentlyFocused;
8784 }
8785 function isItem(store2, element, exclude) {
8786 if (!element) return false;
8787 if (element === exclude) return false;
8788 const item = store2.item(element.id);
8789 if (!item) return false;
8790 if (exclude && item.element === exclude) return false;
8791 return true;
8792 }
8793
8794 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
8795 var import_react12 = __toESM(require_react(), 1);
8796 var TagName = "div";
8797 var useCollectionItem = createHook(
8798 function useCollectionItem2({
8799 store: store2,
8800 shouldRegisterItem = true,
8801 getItem = identity,
8802 // @ts-expect-error This prop may come from a collection renderer.
8803 element,
8804 ...props
8805 }) {
8806 const context = useCollectionContext();
8807 store2 = store2 || context;
8808 const id = useId5(props.id);
8809 const ref = (0, import_react12.useRef)(element);
8810 (0, import_react12.useEffect)(() => {
8811 const element2 = ref.current;
8812 if (!id) return;
8813 if (!element2) return;
8814 if (!shouldRegisterItem) return;
8815 const item = getItem({ id, element: element2 });
8816 return store2 == null ? void 0 : store2.renderItem(item);
8817 }, [id, shouldRegisterItem, getItem, store2]);
8818 props = {
8819 ...props,
8820 ref: useMergeRefs(ref, props.ref)
8821 };
8822 return removeUndefinedValues(props);
8823 }
8824 );
8825 var CollectionItem = forwardRef25(function CollectionItem2(props) {
8826 const htmlProps = useCollectionItem(props);
8827 return createElement3(TagName, htmlProps);
8828 });
8829
8830 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
8831 var import_react13 = __toESM(require_react(), 1);
8832 var FocusableContext = (0, import_react13.createContext)(true);
8833
8834 // node_modules/@ariakit/core/esm/utils/focus.js
8835 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'])";
8836 function isFocusable(element) {
8837 if (!element.matches(selector)) return false;
8838 if (!isVisible(element)) return false;
8839 if (element.closest("[inert]")) return false;
8840 return true;
8841 }
8842 function getClosestFocusable(element) {
8843 while (element && !isFocusable(element)) {
8844 element = element.closest(selector);
8845 }
8846 return element || null;
8847 }
8848 function hasFocus(element) {
8849 const activeElement = getActiveElement(element);
8850 if (!activeElement) return false;
8851 if (activeElement === element) return true;
8852 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
8853 if (!activeDescendant) return false;
8854 return activeDescendant === element.id;
8855 }
8856 function hasFocusWithin(element) {
8857 const activeElement = getActiveElement(element);
8858 if (!activeElement) return false;
8859 if (contains(element, activeElement)) return true;
8860 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
8861 if (!activeDescendant) return false;
8862 if (!("id" in element)) return false;
8863 if (activeDescendant === element.id) return true;
8864 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
8865 }
8866 function focusIfNeeded(element) {
8867 if (!hasFocusWithin(element) && isFocusable(element)) {
8868 element.focus();
8869 }
8870 }
8871 function focusIntoView(element, options) {
8872 if (!("scrollIntoView" in element)) {
8873 element.focus();
8874 } else {
8875 element.focus({ preventScroll: true });
8876 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
8877 }
8878 }
8879
8880 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
8881 var import_react14 = __toESM(require_react(), 1);
8882 var TagName2 = "div";
8883 var isSafariBrowser = isSafari();
8884 var alwaysFocusVisibleInputTypes = [
8885 "text",
8886 "search",
8887 "url",
8888 "tel",
8889 "email",
8890 "password",
8891 "number",
8892 "date",
8893 "month",
8894 "week",
8895 "time",
8896 "datetime",
8897 "datetime-local"
8898 ];
8899 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
8900 function markSafariFocusAncestor(element, value) {
8901 if (!element) return;
8902 element[safariFocusAncestorSymbol] = value;
8903 }
8904 function isAlwaysFocusVisible(element) {
8905 const { tagName, readOnly, type } = element;
8906 if (tagName === "TEXTAREA" && !readOnly) return true;
8907 if (tagName === "SELECT" && !readOnly) return true;
8908 if (tagName === "INPUT" && !readOnly) {
8909 return alwaysFocusVisibleInputTypes.includes(type);
8910 }
8911 if (element.isContentEditable) return true;
8912 const role = element.getAttribute("role");
8913 if (role === "combobox" && element.dataset.name) {
8914 return true;
8915 }
8916 return false;
8917 }
8918 function getLabels(element) {
8919 if ("labels" in element) {
8920 return element.labels;
8921 }
8922 return null;
8923 }
8924 function isNativeCheckboxOrRadio(element) {
8925 const tagName = element.tagName.toLowerCase();
8926 if (tagName === "input" && element.type) {
8927 return element.type === "radio" || element.type === "checkbox";
8928 }
8929 return false;
8930 }
8931 function isNativeTabbable(tagName) {
8932 if (!tagName) return true;
8933 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
8934 }
8935 function supportsDisabledAttribute(tagName) {
8936 if (!tagName) return true;
8937 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
8938 }
8939 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
8940 if (!focusable) {
8941 return tabIndexProp;
8942 }
8943 if (trulyDisabled) {
8944 if (nativeTabbable && !supportsDisabled) {
8945 return -1;
8946 }
8947 return;
8948 }
8949 if (nativeTabbable) {
8950 return tabIndexProp;
8951 }
8952 return tabIndexProp || 0;
8953 }
8954 function useDisableEvent(onEvent, disabled2) {
8955 return useEvent((event) => {
8956 onEvent == null ? void 0 : onEvent(event);
8957 if (event.defaultPrevented) return;
8958 if (disabled2) {
8959 event.stopPropagation();
8960 event.preventDefault();
8961 }
8962 });
8963 }
8964 var hasInstalledGlobalEventListeners2 = false;
8965 var isKeyboardModality = true;
8966 function onGlobalMouseDown(event) {
8967 const target = event.target;
8968 if (target && "hasAttribute" in target) {
8969 if (!target.hasAttribute("data-focus-visible")) {
8970 isKeyboardModality = false;
8971 }
8972 }
8973 }
8974 function onGlobalKeyDown(event) {
8975 if (event.metaKey) return;
8976 if (event.ctrlKey) return;
8977 if (event.altKey) return;
8978 isKeyboardModality = true;
8979 }
8980 var useFocusable = createHook(
8981 function useFocusable2({
8982 focusable = true,
8983 accessibleWhenDisabled,
8984 autoFocus,
8985 onFocusVisible,
8986 ...props
8987 }) {
8988 const ref = (0, import_react14.useRef)(null);
8989 (0, import_react14.useEffect)(() => {
8990 if (!focusable) return;
8991 if (hasInstalledGlobalEventListeners2) return;
8992 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
8993 addGlobalEventListener("keydown", onGlobalKeyDown, true);
8994 hasInstalledGlobalEventListeners2 = true;
8995 }, [focusable]);
8996 if (isSafariBrowser) {
8997 (0, import_react14.useEffect)(() => {
8998 if (!focusable) return;
8999 const element = ref.current;
9000 if (!element) return;
9001 if (!isNativeCheckboxOrRadio(element)) return;
9002 const labels = getLabels(element);
9003 if (!labels) return;
9004 const onMouseUp = () => queueMicrotask(() => element.focus());
9005 for (const label of labels) {
9006 label.addEventListener("mouseup", onMouseUp);
9007 }
9008 return () => {
9009 for (const label of labels) {
9010 label.removeEventListener("mouseup", onMouseUp);
9011 }
9012 };
9013 }, [focusable]);
9014 }
9015 const disabled2 = focusable && disabledFromProps(props);
9016 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
9017 const [focusVisible, setFocusVisible] = (0, import_react14.useState)(false);
9018 (0, import_react14.useEffect)(() => {
9019 if (!focusable) return;
9020 if (trulyDisabled && focusVisible) {
9021 setFocusVisible(false);
9022 }
9023 }, [focusable, trulyDisabled, focusVisible]);
9024 (0, import_react14.useEffect)(() => {
9025 if (!focusable) return;
9026 if (!focusVisible) return;
9027 const element = ref.current;
9028 if (!element) return;
9029 if (typeof IntersectionObserver === "undefined") return;
9030 const observer = new IntersectionObserver(() => {
9031 if (!isFocusable(element)) {
9032 setFocusVisible(false);
9033 }
9034 });
9035 observer.observe(element);
9036 return () => observer.disconnect();
9037 }, [focusable, focusVisible]);
9038 const onKeyPressCapture = useDisableEvent(
9039 props.onKeyPressCapture,
9040 disabled2
9041 );
9042 const onMouseDownCapture = useDisableEvent(
9043 props.onMouseDownCapture,
9044 disabled2
9045 );
9046 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
9047 const onMouseDownProp = props.onMouseDown;
9048 const onMouseDown = useEvent((event) => {
9049 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
9050 if (event.defaultPrevented) return;
9051 if (!focusable) return;
9052 const element = event.currentTarget;
9053 if (!isSafariBrowser) return;
9054 if (isPortalEvent(event)) return;
9055 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
9056 let receivedFocus = false;
9057 const onFocus = () => {
9058 receivedFocus = true;
9059 };
9060 const options = { capture: true, once: true };
9061 element.addEventListener("focusin", onFocus, options);
9062 const focusableContainer = getClosestFocusable(element.parentElement);
9063 markSafariFocusAncestor(focusableContainer, true);
9064 queueBeforeEvent(element, "mouseup", () => {
9065 element.removeEventListener("focusin", onFocus, true);
9066 markSafariFocusAncestor(focusableContainer, false);
9067 if (receivedFocus) return;
9068 focusIfNeeded(element);
9069 });
9070 });
9071 const handleFocusVisible = (event, currentTarget) => {
9072 if (currentTarget) {
9073 event.currentTarget = currentTarget;
9074 }
9075 if (!focusable) return;
9076 const element = event.currentTarget;
9077 if (!element) return;
9078 if (!hasFocus(element)) return;
9079 onFocusVisible == null ? void 0 : onFocusVisible(event);
9080 if (event.defaultPrevented) return;
9081 element.dataset.focusVisible = "true";
9082 setFocusVisible(true);
9083 };
9084 const onKeyDownCaptureProp = props.onKeyDownCapture;
9085 const onKeyDownCapture = useEvent((event) => {
9086 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
9087 if (event.defaultPrevented) return;
9088 if (!focusable) return;
9089 if (focusVisible) return;
9090 if (event.metaKey) return;
9091 if (event.altKey) return;
9092 if (event.ctrlKey) return;
9093 if (!isSelfTarget(event)) return;
9094 const element = event.currentTarget;
9095 const applyFocusVisible = () => handleFocusVisible(event, element);
9096 queueBeforeEvent(element, "focusout", applyFocusVisible);
9097 });
9098 const onFocusCaptureProp = props.onFocusCapture;
9099 const onFocusCapture = useEvent((event) => {
9100 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
9101 if (event.defaultPrevented) return;
9102 if (!focusable) return;
9103 if (!isSelfTarget(event)) {
9104 setFocusVisible(false);
9105 return;
9106 }
9107 const element = event.currentTarget;
9108 const applyFocusVisible = () => handleFocusVisible(event, element);
9109 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
9110 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
9111 } else {
9112 setFocusVisible(false);
9113 }
9114 });
9115 const onBlurProp = props.onBlur;
9116 const onBlur = useEvent((event) => {
9117 onBlurProp == null ? void 0 : onBlurProp(event);
9118 if (!focusable) return;
9119 if (!isFocusEventOutside(event)) return;
9120 event.currentTarget.removeAttribute("data-focus-visible");
9121 setFocusVisible(false);
9122 });
9123 const autoFocusOnShow = (0, import_react14.useContext)(FocusableContext);
9124 const autoFocusRef = useEvent((element) => {
9125 if (!focusable) return;
9126 if (!autoFocus) return;
9127 if (!element) return;
9128 if (!autoFocusOnShow) return;
9129 queueMicrotask(() => {
9130 if (hasFocus(element)) return;
9131 if (!isFocusable(element)) return;
9132 element.focus();
9133 });
9134 });
9135 const tagName = useTagName(ref);
9136 const nativeTabbable = focusable && isNativeTabbable(tagName);
9137 const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
9138 const styleProp = props.style;
9139 const style = (0, import_react14.useMemo)(() => {
9140 if (trulyDisabled) {
9141 return { pointerEvents: "none", ...styleProp };
9142 }
9143 return styleProp;
9144 }, [trulyDisabled, styleProp]);
9145 props = {
9146 "data-focus-visible": focusable && focusVisible || void 0,
9147 "data-autofocus": autoFocus || void 0,
9148 "aria-disabled": disabled2 || void 0,
9149 ...props,
9150 ref: useMergeRefs(ref, autoFocusRef, props.ref),
9151 style,
9152 tabIndex: getTabIndex(
9153 focusable,
9154 trulyDisabled,
9155 nativeTabbable,
9156 supportsDisabled,
9157 props.tabIndex
9158 ),
9159 disabled: supportsDisabled && trulyDisabled ? true : void 0,
9160 // TODO: Test Focusable contentEditable.
9161 contentEditable: disabled2 ? void 0 : props.contentEditable,
9162 onKeyPressCapture,
9163 onClickCapture,
9164 onMouseDownCapture,
9165 onMouseDown,
9166 onKeyDownCapture,
9167 onFocusCapture,
9168 onBlur
9169 };
9170 return removeUndefinedValues(props);
9171 }
9172 );
9173 var Focusable = forwardRef25(function Focusable2(props) {
9174 const htmlProps = useFocusable(props);
9175 return createElement3(TagName2, htmlProps);
9176 });
9177
9178 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
9179 var import_react15 = __toESM(require_react(), 1);
9180 var TagName3 = "button";
9181 function isNativeClick(event) {
9182 if (!event.isTrusted) return false;
9183 const element = event.currentTarget;
9184 if (event.key === "Enter") {
9185 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
9186 }
9187 if (event.key === " ") {
9188 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
9189 }
9190 return false;
9191 }
9192 var symbol = /* @__PURE__ */ Symbol("command");
9193 var useCommand = createHook(
9194 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
9195 const ref = (0, import_react15.useRef)(null);
9196 const [isNativeButton, setIsNativeButton] = (0, import_react15.useState)(false);
9197 (0, import_react15.useEffect)(() => {
9198 if (!ref.current) return;
9199 setIsNativeButton(isButton(ref.current));
9200 }, []);
9201 const [active, setActive] = (0, import_react15.useState)(false);
9202 const activeRef = (0, import_react15.useRef)(false);
9203 const disabled2 = disabledFromProps(props);
9204 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
9205 const onKeyDownProp = props.onKeyDown;
9206 const onKeyDown = useEvent((event) => {
9207 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9208 const element = event.currentTarget;
9209 if (event.defaultPrevented) return;
9210 if (isDuplicate) return;
9211 if (disabled2) return;
9212 if (!isSelfTarget(event)) return;
9213 if (isTextField(element)) return;
9214 if (element.isContentEditable) return;
9215 const isEnter = clickOnEnter && event.key === "Enter";
9216 const isSpace = clickOnSpace && event.key === " ";
9217 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
9218 const shouldPreventSpace = event.key === " " && !clickOnSpace;
9219 if (shouldPreventEnter || shouldPreventSpace) {
9220 event.preventDefault();
9221 return;
9222 }
9223 if (isEnter || isSpace) {
9224 const nativeClick = isNativeClick(event);
9225 if (isEnter) {
9226 if (!nativeClick) {
9227 event.preventDefault();
9228 const { view, ...eventInit } = event;
9229 const click = () => fireClickEvent(element, eventInit);
9230 if (isFirefox()) {
9231 queueBeforeEvent(element, "keyup", click);
9232 } else {
9233 queueMicrotask(click);
9234 }
9235 }
9236 } else if (isSpace) {
9237 activeRef.current = true;
9238 if (!nativeClick) {
9239 event.preventDefault();
9240 setActive(true);
9241 }
9242 }
9243 }
9244 });
9245 const onKeyUpProp = props.onKeyUp;
9246 const onKeyUp = useEvent((event) => {
9247 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
9248 if (event.defaultPrevented) return;
9249 if (isDuplicate) return;
9250 if (disabled2) return;
9251 if (event.metaKey) return;
9252 const isSpace = clickOnSpace && event.key === " ";
9253 if (activeRef.current && isSpace) {
9254 activeRef.current = false;
9255 if (!isNativeClick(event)) {
9256 event.preventDefault();
9257 setActive(false);
9258 const element = event.currentTarget;
9259 const { view, ...eventInit } = event;
9260 queueMicrotask(() => fireClickEvent(element, eventInit));
9261 }
9262 }
9263 });
9264 props = {
9265 "data-active": active || void 0,
9266 type: isNativeButton ? "button" : void 0,
9267 ...metadataProps,
9268 ...props,
9269 ref: useMergeRefs(ref, props.ref),
9270 onKeyDown,
9271 onKeyUp
9272 };
9273 props = useFocusable(props);
9274 return props;
9275 }
9276 );
9277 var Command = forwardRef25(function Command2(props) {
9278 const htmlProps = useCommand(props);
9279 return createElement3(TagName3, htmlProps);
9280 });
9281
9282 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
9283 function getInternal(store2, key) {
9284 const internals = store2.__unstableInternals;
9285 invariant(internals, "Invalid store");
9286 return internals[key];
9287 }
9288 function createStore(initialState, ...stores) {
9289 let state = initialState;
9290 let prevStateBatch = state;
9291 let lastUpdate = /* @__PURE__ */ Symbol();
9292 let destroy = noop2;
9293 const instances = /* @__PURE__ */ new Set();
9294 const updatedKeys = /* @__PURE__ */ new Set();
9295 const setups = /* @__PURE__ */ new Set();
9296 const listeners = /* @__PURE__ */ new Set();
9297 const batchListeners = /* @__PURE__ */ new Set();
9298 const disposables = /* @__PURE__ */ new WeakMap();
9299 const listenerKeys = /* @__PURE__ */ new WeakMap();
9300 const storeSetup = (callback) => {
9301 setups.add(callback);
9302 return () => setups.delete(callback);
9303 };
9304 const storeInit = () => {
9305 const initialized = instances.size;
9306 const instance = /* @__PURE__ */ Symbol();
9307 instances.add(instance);
9308 const maybeDestroy = () => {
9309 instances.delete(instance);
9310 if (instances.size) return;
9311 destroy();
9312 };
9313 if (initialized) return maybeDestroy;
9314 const desyncs = getKeys(state).map(
9315 (key) => chain(
9316 ...stores.map((store2) => {
9317 var _a;
9318 const storeState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
9319 if (!storeState) return;
9320 if (!hasOwnProperty(storeState, key)) return;
9321 return sync(store2, [key], (state2) => {
9322 setState(
9323 key,
9324 state2[key],
9325 // @ts-expect-error - Not public API. This is just to prevent
9326 // infinite loops.
9327 true
9328 );
9329 });
9330 })
9331 )
9332 );
9333 const teardowns = [];
9334 for (const setup2 of setups) {
9335 teardowns.push(setup2());
9336 }
9337 const cleanups = stores.map(init);
9338 destroy = chain(...desyncs, ...teardowns, ...cleanups);
9339 return maybeDestroy;
9340 };
9341 const sub = (keys, listener, set3 = listeners) => {
9342 set3.add(listener);
9343 listenerKeys.set(listener, keys);
9344 return () => {
9345 var _a;
9346 (_a = disposables.get(listener)) == null ? void 0 : _a();
9347 disposables.delete(listener);
9348 listenerKeys.delete(listener);
9349 set3.delete(listener);
9350 };
9351 };
9352 const storeSubscribe = (keys, listener) => sub(keys, listener);
9353 const storeSync = (keys, listener) => {
9354 disposables.set(listener, listener(state, state));
9355 return sub(keys, listener);
9356 };
9357 const storeBatch = (keys, listener) => {
9358 disposables.set(listener, listener(state, prevStateBatch));
9359 return sub(keys, listener, batchListeners);
9360 };
9361 const storePick = (keys) => createStore(pick(state, keys), finalStore);
9362 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
9363 const getState = () => state;
9364 const setState = (key, value, fromStores = false) => {
9365 var _a;
9366 if (!hasOwnProperty(state, key)) return;
9367 const nextValue = applyState(value, state[key]);
9368 if (nextValue === state[key]) return;
9369 if (!fromStores) {
9370 for (const store2 of stores) {
9371 (_a = store2 == null ? void 0 : store2.setState) == null ? void 0 : _a.call(store2, key, nextValue);
9372 }
9373 }
9374 const prevState = state;
9375 state = { ...state, [key]: nextValue };
9376 const thisUpdate = /* @__PURE__ */ Symbol();
9377 lastUpdate = thisUpdate;
9378 updatedKeys.add(key);
9379 const run = (listener, prev, uKeys) => {
9380 var _a2;
9381 const keys = listenerKeys.get(listener);
9382 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
9383 if (!keys || keys.some(updated)) {
9384 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
9385 disposables.set(listener, listener(state, prev));
9386 }
9387 };
9388 for (const listener of listeners) {
9389 run(listener, prevState);
9390 }
9391 queueMicrotask(() => {
9392 if (lastUpdate !== thisUpdate) return;
9393 const snapshot = state;
9394 for (const listener of batchListeners) {
9395 run(listener, prevStateBatch, updatedKeys);
9396 }
9397 prevStateBatch = snapshot;
9398 updatedKeys.clear();
9399 });
9400 };
9401 const finalStore = {
9402 getState,
9403 setState,
9404 __unstableInternals: {
9405 setup: storeSetup,
9406 init: storeInit,
9407 subscribe: storeSubscribe,
9408 sync: storeSync,
9409 batch: storeBatch,
9410 pick: storePick,
9411 omit: storeOmit
9412 }
9413 };
9414 return finalStore;
9415 }
9416 function setup(store2, ...args) {
9417 if (!store2) return;
9418 return getInternal(store2, "setup")(...args);
9419 }
9420 function init(store2, ...args) {
9421 if (!store2) return;
9422 return getInternal(store2, "init")(...args);
9423 }
9424 function subscribe(store2, ...args) {
9425 if (!store2) return;
9426 return getInternal(store2, "subscribe")(...args);
9427 }
9428 function sync(store2, ...args) {
9429 if (!store2) return;
9430 return getInternal(store2, "sync")(...args);
9431 }
9432 function batch(store2, ...args) {
9433 if (!store2) return;
9434 return getInternal(store2, "batch")(...args);
9435 }
9436 function omit2(store2, ...args) {
9437 if (!store2) return;
9438 return getInternal(store2, "omit")(...args);
9439 }
9440 function pick2(store2, ...args) {
9441 if (!store2) return;
9442 return getInternal(store2, "pick")(...args);
9443 }
9444 function mergeStore(...stores) {
9445 var _a;
9446 const initialState = {};
9447 for (const store22 of stores) {
9448 const nextState = (_a = store22 == null ? void 0 : store22.getState) == null ? void 0 : _a.call(store22);
9449 if (nextState) {
9450 Object.assign(initialState, nextState);
9451 }
9452 }
9453 const store2 = createStore(initialState, ...stores);
9454 return Object.assign({}, ...stores, store2);
9455 }
9456 function throwOnConflictingProps(props, store2) {
9457 if (false) return;
9458 if (!store2) return;
9459 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
9460 var _a;
9461 const stateKey = key.replace("default", "");
9462 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
9463 });
9464 if (!defaultKeys.length) return;
9465 const storeState = store2.getState();
9466 const conflictingProps = defaultKeys.filter(
9467 (key) => hasOwnProperty(storeState, key)
9468 );
9469 if (!conflictingProps.length) return;
9470 throw new Error(
9471 `Passing a store prop in conjunction with a default state is not supported.
9472
9473 const store = useSelectStore();
9474 <SelectProvider store={store} defaultValue="Apple" />
9475 ^ ^
9476
9477 Instead, pass the default state to the topmost store:
9478
9479 const store = useSelectStore({ defaultValue: "Apple" });
9480 <SelectProvider store={store} />
9481
9482 See https://github.com/ariakit/ariakit/pull/2745 for more details.
9483
9484 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
9485 `
9486 );
9487 }
9488
9489 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
9490 var React25 = __toESM(require_react(), 1);
9491 var import_shim = __toESM(require_shim(), 1);
9492 var { useSyncExternalStore } = import_shim.default;
9493 var noopSubscribe = () => () => {
9494 };
9495 function useStoreState(store2, keyOrSelector = identity) {
9496 const storeSubscribe = React25.useCallback(
9497 (callback) => {
9498 if (!store2) return noopSubscribe();
9499 return subscribe(store2, null, callback);
9500 },
9501 [store2]
9502 );
9503 const getSnapshot = () => {
9504 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
9505 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
9506 const state = store2 == null ? void 0 : store2.getState();
9507 if (selector2) return selector2(state);
9508 if (!state) return;
9509 if (!key) return;
9510 if (!hasOwnProperty(state, key)) return;
9511 return state[key];
9512 };
9513 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
9514 }
9515 function useStoreStateObject(store2, object) {
9516 const objRef = React25.useRef(
9517 {}
9518 );
9519 const storeSubscribe = React25.useCallback(
9520 (callback) => {
9521 if (!store2) return noopSubscribe();
9522 return subscribe(store2, null, callback);
9523 },
9524 [store2]
9525 );
9526 const getSnapshot = () => {
9527 const state = store2 == null ? void 0 : store2.getState();
9528 let updated = false;
9529 const obj = objRef.current;
9530 for (const prop in object) {
9531 const keyOrSelector = object[prop];
9532 if (typeof keyOrSelector === "function") {
9533 const value = keyOrSelector(state);
9534 if (value !== obj[prop]) {
9535 obj[prop] = value;
9536 updated = true;
9537 }
9538 }
9539 if (typeof keyOrSelector === "string") {
9540 if (!state) continue;
9541 if (!hasOwnProperty(state, keyOrSelector)) continue;
9542 const value = state[keyOrSelector];
9543 if (value !== obj[prop]) {
9544 obj[prop] = value;
9545 updated = true;
9546 }
9547 }
9548 }
9549 if (updated) {
9550 objRef.current = { ...obj };
9551 }
9552 return objRef.current;
9553 };
9554 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
9555 }
9556 function useStoreProps(store2, props, key, setKey) {
9557 const value = hasOwnProperty(props, key) ? props[key] : void 0;
9558 const setValue = setKey ? props[setKey] : void 0;
9559 const propsRef = useLiveRef({ value, setValue });
9560 useSafeLayoutEffect(() => {
9561 return sync(store2, [key], (state, prev) => {
9562 const { value: value2, setValue: setValue2 } = propsRef.current;
9563 if (!setValue2) return;
9564 if (state[key] === prev[key]) return;
9565 if (state[key] === value2) return;
9566 setValue2(state[key]);
9567 });
9568 }, [store2, key]);
9569 useSafeLayoutEffect(() => {
9570 if (value === void 0) return;
9571 store2.setState(key, value);
9572 return batch(store2, [key], () => {
9573 if (value === void 0) return;
9574 store2.setState(key, value);
9575 });
9576 });
9577 }
9578 function useStore(createStore2, props) {
9579 const [store2, setStore] = React25.useState(() => createStore2(props));
9580 useSafeLayoutEffect(() => init(store2), [store2]);
9581 const useState210 = React25.useCallback(
9582 (keyOrSelector) => useStoreState(store2, keyOrSelector),
9583 [store2]
9584 );
9585 const memoizedStore = React25.useMemo(
9586 () => ({ ...store2, useState: useState210 }),
9587 [store2, useState210]
9588 );
9589 const updateStore = useEvent(() => {
9590 setStore((store22) => createStore2({ ...props, ...store22.getState() }));
9591 });
9592 return [memoizedStore, updateStore];
9593 }
9594
9595 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
9596 var import_react16 = __toESM(require_react(), 1);
9597 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
9598 var TagName4 = "button";
9599 function isEditableElement(element) {
9600 if (isTextbox(element)) return true;
9601 return element.tagName === "INPUT" && !isButton(element);
9602 }
9603 function getNextPageOffset(scrollingElement, pageUp = false) {
9604 const height = scrollingElement.clientHeight;
9605 const { top } = scrollingElement.getBoundingClientRect();
9606 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
9607 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
9608 if (scrollingElement.tagName === "HTML") {
9609 return pageOffset + scrollingElement.scrollTop;
9610 }
9611 return pageOffset;
9612 }
9613 function getItemOffset(itemElement, pageUp = false) {
9614 const { top } = itemElement.getBoundingClientRect();
9615 if (pageUp) {
9616 return top + itemElement.clientHeight;
9617 }
9618 return top;
9619 }
9620 function findNextPageItemId(element, store2, next, pageUp = false) {
9621 var _a;
9622 if (!store2) return;
9623 if (!next) return;
9624 const { renderedItems } = store2.getState();
9625 const scrollingElement = getScrollingElement(element);
9626 if (!scrollingElement) return;
9627 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
9628 let id;
9629 let prevDifference;
9630 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
9631 const previousId = id;
9632 id = next(i2);
9633 if (!id) break;
9634 if (id === previousId) continue;
9635 const itemElement = (_a = getEnabledItem(store2, id)) == null ? void 0 : _a.element;
9636 if (!itemElement) continue;
9637 const itemOffset = getItemOffset(itemElement, pageUp);
9638 const difference = itemOffset - nextPageOffset;
9639 const absDifference = Math.abs(difference);
9640 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
9641 if (prevDifference !== void 0 && prevDifference < absDifference) {
9642 id = previousId;
9643 }
9644 break;
9645 }
9646 prevDifference = absDifference;
9647 }
9648 return id;
9649 }
9650 function targetIsAnotherItem(event, store2) {
9651 if (isSelfTarget(event)) return false;
9652 return isItem(store2, event.target);
9653 }
9654 var useCompositeItem = createHook(
9655 function useCompositeItem2({
9656 store: store2,
9657 rowId: rowIdProp,
9658 preventScrollOnKeyDown = false,
9659 moveOnKeyPress = true,
9660 tabbable = false,
9661 getItem: getItemProp,
9662 "aria-setsize": ariaSetSizeProp,
9663 "aria-posinset": ariaPosInSetProp,
9664 ...props
9665 }) {
9666 const context = useCompositeContext();
9667 store2 = store2 || context;
9668 const id = useId5(props.id);
9669 const ref = (0, import_react16.useRef)(null);
9670 const row = (0, import_react16.useContext)(CompositeRowContext);
9671 const disabled2 = disabledFromProps(props);
9672 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
9673 const {
9674 rowId,
9675 baseElement,
9676 isActiveItem,
9677 ariaSetSize,
9678 ariaPosInSet,
9679 isTabbable
9680 } = useStoreStateObject(store2, {
9681 rowId(state) {
9682 if (rowIdProp) return rowIdProp;
9683 if (!state) return;
9684 if (!(row == null ? void 0 : row.baseElement)) return;
9685 if (row.baseElement !== state.baseElement) return;
9686 return row.id;
9687 },
9688 baseElement(state) {
9689 return (state == null ? void 0 : state.baseElement) || void 0;
9690 },
9691 isActiveItem(state) {
9692 return !!state && state.activeId === id;
9693 },
9694 ariaSetSize(state) {
9695 if (ariaSetSizeProp != null) return ariaSetSizeProp;
9696 if (!state) return;
9697 if (!(row == null ? void 0 : row.ariaSetSize)) return;
9698 if (row.baseElement !== state.baseElement) return;
9699 return row.ariaSetSize;
9700 },
9701 ariaPosInSet(state) {
9702 if (ariaPosInSetProp != null) return ariaPosInSetProp;
9703 if (!state) return;
9704 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
9705 if (row.baseElement !== state.baseElement) return;
9706 const itemsInRow = state.renderedItems.filter(
9707 (item) => item.rowId === rowId
9708 );
9709 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
9710 },
9711 isTabbable(state) {
9712 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
9713 if (state.virtualFocus) return false;
9714 if (tabbable) return true;
9715 if (state.activeId === null) return false;
9716 const item = store2 == null ? void 0 : store2.item(state.activeId);
9717 if (item == null ? void 0 : item.disabled) return true;
9718 if (!(item == null ? void 0 : item.element)) return true;
9719 return state.activeId === id;
9720 }
9721 });
9722 const getItem = (0, import_react16.useCallback)(
9723 (item) => {
9724 var _a;
9725 const nextItem = {
9726 ...item,
9727 id: id || item.id,
9728 rowId,
9729 disabled: !!trulyDisabled,
9730 children: (_a = item.element) == null ? void 0 : _a.textContent
9731 };
9732 if (getItemProp) {
9733 return getItemProp(nextItem);
9734 }
9735 return nextItem;
9736 },
9737 [id, rowId, trulyDisabled, getItemProp]
9738 );
9739 const onFocusProp = props.onFocus;
9740 const hasFocusedComposite = (0, import_react16.useRef)(false);
9741 const onFocus = useEvent((event) => {
9742 onFocusProp == null ? void 0 : onFocusProp(event);
9743 if (event.defaultPrevented) return;
9744 if (isPortalEvent(event)) return;
9745 if (!id) return;
9746 if (!store2) return;
9747 if (targetIsAnotherItem(event, store2)) return;
9748 const { virtualFocus, baseElement: baseElement2 } = store2.getState();
9749 store2.setActiveId(id);
9750 if (isTextbox(event.currentTarget)) {
9751 selectTextField(event.currentTarget);
9752 }
9753 if (!virtualFocus) return;
9754 if (!isSelfTarget(event)) return;
9755 if (isEditableElement(event.currentTarget)) return;
9756 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
9757 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
9758 event.currentTarget.scrollIntoView({
9759 block: "nearest",
9760 inline: "nearest"
9761 });
9762 }
9763 hasFocusedComposite.current = true;
9764 const fromComposite = event.relatedTarget === baseElement2 || isItem(store2, event.relatedTarget);
9765 if (fromComposite) {
9766 focusSilently(baseElement2);
9767 } else {
9768 baseElement2.focus();
9769 }
9770 });
9771 const onBlurCaptureProp = props.onBlurCapture;
9772 const onBlurCapture = useEvent((event) => {
9773 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
9774 if (event.defaultPrevented) return;
9775 const state = store2 == null ? void 0 : store2.getState();
9776 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
9777 hasFocusedComposite.current = false;
9778 event.preventDefault();
9779 event.stopPropagation();
9780 }
9781 });
9782 const onKeyDownProp = props.onKeyDown;
9783 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
9784 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
9785 const onKeyDown = useEvent((event) => {
9786 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9787 if (event.defaultPrevented) return;
9788 if (!isSelfTarget(event)) return;
9789 if (!store2) return;
9790 const { currentTarget } = event;
9791 const state = store2.getState();
9792 const item = store2.item(id);
9793 const isGrid2 = !!(item == null ? void 0 : item.rowId);
9794 const isVertical = state.orientation !== "horizontal";
9795 const isHorizontal = state.orientation !== "vertical";
9796 const canHomeEnd = () => {
9797 if (isGrid2) return true;
9798 if (isHorizontal) return true;
9799 if (!state.baseElement) return true;
9800 if (!isTextField(state.baseElement)) return true;
9801 return false;
9802 };
9803 const keyMap = {
9804 ArrowUp: (isGrid2 || isVertical) && store2.up,
9805 ArrowRight: (isGrid2 || isHorizontal) && store2.next,
9806 ArrowDown: (isGrid2 || isVertical) && store2.down,
9807 ArrowLeft: (isGrid2 || isHorizontal) && store2.previous,
9808 Home: () => {
9809 if (!canHomeEnd()) return;
9810 if (!isGrid2 || event.ctrlKey) {
9811 return store2 == null ? void 0 : store2.first();
9812 }
9813 return store2 == null ? void 0 : store2.previous(-1);
9814 },
9815 End: () => {
9816 if (!canHomeEnd()) return;
9817 if (!isGrid2 || event.ctrlKey) {
9818 return store2 == null ? void 0 : store2.last();
9819 }
9820 return store2 == null ? void 0 : store2.next(-1);
9821 },
9822 PageUp: () => {
9823 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.up, true);
9824 },
9825 PageDown: () => {
9826 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.down);
9827 }
9828 };
9829 const action = keyMap[event.key];
9830 if (action) {
9831 if (isTextbox(currentTarget)) {
9832 const selection = getTextboxSelection(currentTarget);
9833 const isLeft = isHorizontal && event.key === "ArrowLeft";
9834 const isRight = isHorizontal && event.key === "ArrowRight";
9835 const isUp = isVertical && event.key === "ArrowUp";
9836 const isDown = isVertical && event.key === "ArrowDown";
9837 if (isRight || isDown) {
9838 const { length: valueLength } = getTextboxValue(currentTarget);
9839 if (selection.end !== valueLength) return;
9840 } else if ((isLeft || isUp) && selection.start !== 0) return;
9841 }
9842 const nextId = action();
9843 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
9844 if (!moveOnKeyPressProp(event)) return;
9845 event.preventDefault();
9846 store2.move(nextId);
9847 }
9848 }
9849 });
9850 const providerValue = (0, import_react16.useMemo)(
9851 () => ({ id, baseElement }),
9852 [id, baseElement]
9853 );
9854 props = useWrapElement(
9855 props,
9856 (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
9857 [providerValue]
9858 );
9859 props = {
9860 id,
9861 "data-active-item": isActiveItem || void 0,
9862 ...props,
9863 ref: useMergeRefs(ref, props.ref),
9864 tabIndex: isTabbable ? props.tabIndex : -1,
9865 onFocus,
9866 onBlurCapture,
9867 onKeyDown
9868 };
9869 props = useCommand(props);
9870 props = useCollectionItem({
9871 store: store2,
9872 ...props,
9873 getItem,
9874 shouldRegisterItem: id ? props.shouldRegisterItem : false
9875 });
9876 return removeUndefinedValues({
9877 ...props,
9878 "aria-setsize": ariaSetSize,
9879 "aria-posinset": ariaPosInSet
9880 });
9881 }
9882 );
9883 var CompositeItem = memo22(
9884 forwardRef25(function CompositeItem2(props) {
9885 const htmlProps = useCompositeItem(props);
9886 return createElement3(TagName4, htmlProps);
9887 })
9888 );
9889
9890 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
9891 function toArray(arg) {
9892 if (Array.isArray(arg)) {
9893 return arg;
9894 }
9895 return typeof arg !== "undefined" ? [arg] : [];
9896 }
9897 function flatten2DArray(array) {
9898 const flattened = [];
9899 for (const row of array) {
9900 flattened.push(...row);
9901 }
9902 return flattened;
9903 }
9904 function reverseArray(array) {
9905 return array.slice().reverse();
9906 }
9907
9908 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
9909 var import_react17 = __toESM(require_react(), 1);
9910 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
9911 var TagName5 = "div";
9912 function isGrid(items) {
9913 return items.some((item) => !!item.rowId);
9914 }
9915 function isPrintableKey(event) {
9916 const target = event.target;
9917 if (target && !isTextField(target)) return false;
9918 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
9919 }
9920 function isModifierKey(event) {
9921 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
9922 }
9923 function useKeyboardEventProxy(store2, onKeyboardEvent, previousElementRef) {
9924 return useEvent((event) => {
9925 var _a;
9926 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
9927 if (event.defaultPrevented) return;
9928 if (event.isPropagationStopped()) return;
9929 if (!isSelfTarget(event)) return;
9930 if (isModifierKey(event)) return;
9931 if (isPrintableKey(event)) return;
9932 const state = store2.getState();
9933 const activeElement = (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.element;
9934 if (!activeElement) return;
9935 const { view, ...eventInit } = event;
9936 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
9937 if (activeElement !== previousElement) {
9938 activeElement.focus();
9939 }
9940 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
9941 event.preventDefault();
9942 }
9943 if (event.currentTarget.contains(activeElement)) {
9944 event.stopPropagation();
9945 }
9946 });
9947 }
9948 function findFirstEnabledItemInTheLastRow(items) {
9949 return findFirstEnabledItem(
9950 flatten2DArray(reverseArray(groupItemsByRows(items)))
9951 );
9952 }
9953 function useScheduleFocus(store2) {
9954 const [scheduled, setScheduled] = (0, import_react17.useState)(false);
9955 const schedule = (0, import_react17.useCallback)(() => setScheduled(true), []);
9956 const activeItem = store2.useState(
9957 (state) => getEnabledItem(store2, state.activeId)
9958 );
9959 (0, import_react17.useEffect)(() => {
9960 const activeElement = activeItem == null ? void 0 : activeItem.element;
9961 if (!scheduled) return;
9962 if (!activeElement) return;
9963 setScheduled(false);
9964 activeElement.focus({ preventScroll: true });
9965 }, [activeItem, scheduled]);
9966 return schedule;
9967 }
9968 var useComposite = createHook(
9969 function useComposite2({
9970 store: store2,
9971 composite = true,
9972 focusOnMove = composite,
9973 moveOnKeyPress = true,
9974 ...props
9975 }) {
9976 const context = useCompositeProviderContext();
9977 store2 = store2 || context;
9978 invariant(
9979 store2,
9980 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
9981 );
9982 const ref = (0, import_react17.useRef)(null);
9983 const previousElementRef = (0, import_react17.useRef)(null);
9984 const scheduleFocus = useScheduleFocus(store2);
9985 const moves = store2.useState("moves");
9986 const [, setBaseElement] = useTransactionState(
9987 composite ? store2.setBaseElement : null
9988 );
9989 (0, import_react17.useEffect)(() => {
9990 var _a;
9991 if (!store2) return;
9992 if (!moves) return;
9993 if (!composite) return;
9994 if (!focusOnMove) return;
9995 const { activeId: activeId2 } = store2.getState();
9996 const itemElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element;
9997 if (!itemElement) return;
9998 focusIntoView(itemElement);
9999 }, [store2, moves, composite, focusOnMove]);
10000 useSafeLayoutEffect(() => {
10001 if (!store2) return;
10002 if (!moves) return;
10003 if (!composite) return;
10004 const { baseElement, activeId: activeId2 } = store2.getState();
10005 const isSelfAcive = activeId2 === null;
10006 if (!isSelfAcive) return;
10007 if (!baseElement) return;
10008 const previousElement = previousElementRef.current;
10009 previousElementRef.current = null;
10010 if (previousElement) {
10011 fireBlurEvent(previousElement, { relatedTarget: baseElement });
10012 }
10013 if (!hasFocus(baseElement)) {
10014 baseElement.focus();
10015 }
10016 }, [store2, moves, composite]);
10017 const activeId = store2.useState("activeId");
10018 const virtualFocus = store2.useState("virtualFocus");
10019 useSafeLayoutEffect(() => {
10020 var _a;
10021 if (!store2) return;
10022 if (!composite) return;
10023 if (!virtualFocus) return;
10024 const previousElement = previousElementRef.current;
10025 previousElementRef.current = null;
10026 if (!previousElement) return;
10027 const activeElement = (_a = getEnabledItem(store2, activeId)) == null ? void 0 : _a.element;
10028 const relatedTarget = activeElement || getActiveElement(previousElement);
10029 if (relatedTarget === previousElement) return;
10030 fireBlurEvent(previousElement, { relatedTarget });
10031 }, [store2, activeId, virtualFocus, composite]);
10032 const onKeyDownCapture = useKeyboardEventProxy(
10033 store2,
10034 props.onKeyDownCapture,
10035 previousElementRef
10036 );
10037 const onKeyUpCapture = useKeyboardEventProxy(
10038 store2,
10039 props.onKeyUpCapture,
10040 previousElementRef
10041 );
10042 const onFocusCaptureProp = props.onFocusCapture;
10043 const onFocusCapture = useEvent((event) => {
10044 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
10045 if (event.defaultPrevented) return;
10046 if (!store2) return;
10047 const { virtualFocus: virtualFocus2 } = store2.getState();
10048 if (!virtualFocus2) return;
10049 const previousActiveElement = event.relatedTarget;
10050 const isSilentlyFocused = silentlyFocused(event.currentTarget);
10051 if (isSelfTarget(event) && isSilentlyFocused) {
10052 event.stopPropagation();
10053 previousElementRef.current = previousActiveElement;
10054 }
10055 });
10056 const onFocusProp = props.onFocus;
10057 const onFocus = useEvent((event) => {
10058 onFocusProp == null ? void 0 : onFocusProp(event);
10059 if (event.defaultPrevented) return;
10060 if (!composite) return;
10061 if (!store2) return;
10062 const { relatedTarget } = event;
10063 const { virtualFocus: virtualFocus2 } = store2.getState();
10064 if (virtualFocus2) {
10065 if (isSelfTarget(event) && !isItem(store2, relatedTarget)) {
10066 queueMicrotask(scheduleFocus);
10067 }
10068 } else if (isSelfTarget(event)) {
10069 store2.setActiveId(null);
10070 }
10071 });
10072 const onBlurCaptureProp = props.onBlurCapture;
10073 const onBlurCapture = useEvent((event) => {
10074 var _a;
10075 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
10076 if (event.defaultPrevented) return;
10077 if (!store2) return;
10078 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store2.getState();
10079 if (!virtualFocus2) return;
10080 const activeElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element;
10081 const nextActiveElement = event.relatedTarget;
10082 const nextActiveElementIsItem = isItem(store2, nextActiveElement);
10083 const previousElement = previousElementRef.current;
10084 previousElementRef.current = null;
10085 if (isSelfTarget(event) && nextActiveElementIsItem) {
10086 if (nextActiveElement === activeElement) {
10087 if (previousElement && previousElement !== nextActiveElement) {
10088 fireBlurEvent(previousElement, event);
10089 }
10090 } else if (activeElement) {
10091 fireBlurEvent(activeElement, event);
10092 } else if (previousElement) {
10093 fireBlurEvent(previousElement, event);
10094 }
10095 event.stopPropagation();
10096 } else {
10097 const targetIsItem = isItem(store2, event.target);
10098 if (!targetIsItem && activeElement) {
10099 fireBlurEvent(activeElement, event);
10100 }
10101 }
10102 });
10103 const onKeyDownProp = props.onKeyDown;
10104 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
10105 const onKeyDown = useEvent((event) => {
10106 var _a;
10107 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
10108 if (event.nativeEvent.isComposing) return;
10109 if (event.defaultPrevented) return;
10110 if (!store2) return;
10111 if (!isSelfTarget(event)) return;
10112 const { orientation, renderedItems, activeId: activeId2 } = store2.getState();
10113 const activeItem = getEnabledItem(store2, activeId2);
10114 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
10115 const isVertical = orientation !== "horizontal";
10116 const isHorizontal = orientation !== "vertical";
10117 const grid = isGrid(renderedItems);
10118 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
10119 if (isHorizontalKey && isTextField(event.currentTarget)) return;
10120 const up = () => {
10121 if (grid) {
10122 const item = findFirstEnabledItemInTheLastRow(renderedItems);
10123 return item == null ? void 0 : item.id;
10124 }
10125 return store2 == null ? void 0 : store2.last();
10126 };
10127 const keyMap = {
10128 ArrowUp: (grid || isVertical) && up,
10129 ArrowRight: (grid || isHorizontal) && store2.first,
10130 ArrowDown: (grid || isVertical) && store2.first,
10131 ArrowLeft: (grid || isHorizontal) && store2.last,
10132 Home: store2.first,
10133 End: store2.last,
10134 PageUp: store2.first,
10135 PageDown: store2.last
10136 };
10137 const action = keyMap[event.key];
10138 if (action) {
10139 const id = action();
10140 if (id !== void 0) {
10141 if (!moveOnKeyPressProp(event)) return;
10142 event.preventDefault();
10143 store2.move(id);
10144 }
10145 }
10146 });
10147 props = useWrapElement(
10148 props,
10149 (element) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CompositeContextProvider, { value: store2, children: element }),
10150 [store2]
10151 );
10152 const activeDescendant = store2.useState((state) => {
10153 var _a;
10154 if (!store2) return;
10155 if (!composite) return;
10156 if (!state.virtualFocus) return;
10157 return (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.id;
10158 });
10159 props = {
10160 "aria-activedescendant": activeDescendant,
10161 ...props,
10162 ref: useMergeRefs(ref, setBaseElement, props.ref),
10163 onKeyDownCapture,
10164 onKeyUpCapture,
10165 onFocusCapture,
10166 onFocus,
10167 onBlurCapture,
10168 onKeyDown
10169 };
10170 const focusable = store2.useState(
10171 (state) => composite && (state.virtualFocus || state.activeId === null)
10172 );
10173 props = useFocusable({ focusable, ...props });
10174 return props;
10175 }
10176 );
10177 var Composite5 = forwardRef25(function Composite22(props) {
10178 const htmlProps = useComposite(props);
10179 return createElement3(TagName5, htmlProps);
10180 });
10181
10182 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
10183 var ctx3 = createStoreContext();
10184 var useDisclosureContext = ctx3.useContext;
10185 var useDisclosureScopedContext = ctx3.useScopedContext;
10186 var useDisclosureProviderContext = ctx3.useProviderContext;
10187 var DisclosureContextProvider = ctx3.ContextProvider;
10188 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
10189
10190 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
10191 var import_react18 = __toESM(require_react(), 1);
10192 var ctx4 = createStoreContext(
10193 [DisclosureContextProvider],
10194 [DisclosureScopedContextProvider]
10195 );
10196 var useDialogContext = ctx4.useContext;
10197 var useDialogScopedContext = ctx4.useScopedContext;
10198 var useDialogProviderContext = ctx4.useProviderContext;
10199 var DialogContextProvider = ctx4.ContextProvider;
10200 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
10201 var DialogHeadingContext = (0, import_react18.createContext)(void 0);
10202 var DialogDescriptionContext = (0, import_react18.createContext)(void 0);
10203
10204 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
10205 var import_react19 = __toESM(require_react(), 1);
10206 var import_react_dom = __toESM(require_react_dom(), 1);
10207 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
10208 var TagName6 = "div";
10209 function afterTimeout(timeoutMs, cb) {
10210 const timeoutId = setTimeout(cb, timeoutMs);
10211 return () => clearTimeout(timeoutId);
10212 }
10213 function afterPaint2(cb) {
10214 let raf = requestAnimationFrame(() => {
10215 raf = requestAnimationFrame(cb);
10216 });
10217 return () => cancelAnimationFrame(raf);
10218 }
10219 function parseCSSTime(...times) {
10220 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
10221 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
10222 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
10223 if (currentTime > longestTime) return currentTime;
10224 return longestTime;
10225 }, 0);
10226 }
10227 function isHidden(mounted, hidden, alwaysVisible) {
10228 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
10229 }
10230 var useDisclosureContent = createHook(function useDisclosureContent2({ store: store2, alwaysVisible, ...props }) {
10231 const context = useDisclosureProviderContext();
10232 store2 = store2 || context;
10233 invariant(
10234 store2,
10235 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
10236 );
10237 const ref = (0, import_react19.useRef)(null);
10238 const id = useId5(props.id);
10239 const [transition, setTransition] = (0, import_react19.useState)(null);
10240 const open = store2.useState("open");
10241 const mounted = store2.useState("mounted");
10242 const animated = store2.useState("animated");
10243 const contentElement = store2.useState("contentElement");
10244 const otherElement = useStoreState(store2.disclosure, "contentElement");
10245 useSafeLayoutEffect(() => {
10246 if (!ref.current) return;
10247 store2 == null ? void 0 : store2.setContentElement(ref.current);
10248 }, [store2]);
10249 useSafeLayoutEffect(() => {
10250 let previousAnimated;
10251 store2 == null ? void 0 : store2.setState("animated", (animated2) => {
10252 previousAnimated = animated2;
10253 return true;
10254 });
10255 return () => {
10256 if (previousAnimated === void 0) return;
10257 store2 == null ? void 0 : store2.setState("animated", previousAnimated);
10258 };
10259 }, [store2]);
10260 useSafeLayoutEffect(() => {
10261 if (!animated) return;
10262 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
10263 setTransition(null);
10264 return;
10265 }
10266 return afterPaint2(() => {
10267 setTransition(open ? "enter" : mounted ? "leave" : null);
10268 });
10269 }, [animated, contentElement, open, mounted]);
10270 useSafeLayoutEffect(() => {
10271 if (!store2) return;
10272 if (!animated) return;
10273 if (!transition) return;
10274 if (!contentElement) return;
10275 const stopAnimation = () => store2 == null ? void 0 : store2.setState("animating", false);
10276 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation);
10277 if (transition === "leave" && open) return;
10278 if (transition === "enter" && !open) return;
10279 if (typeof animated === "number") {
10280 const timeout2 = animated;
10281 return afterTimeout(timeout2, stopAnimationSync);
10282 }
10283 const {
10284 transitionDuration,
10285 animationDuration,
10286 transitionDelay,
10287 animationDelay
10288 } = getComputedStyle(contentElement);
10289 const {
10290 transitionDuration: transitionDuration2 = "0",
10291 animationDuration: animationDuration2 = "0",
10292 transitionDelay: transitionDelay2 = "0",
10293 animationDelay: animationDelay2 = "0"
10294 } = otherElement ? getComputedStyle(otherElement) : {};
10295 const delay = parseCSSTime(
10296 transitionDelay,
10297 animationDelay,
10298 transitionDelay2,
10299 animationDelay2
10300 );
10301 const duration = parseCSSTime(
10302 transitionDuration,
10303 animationDuration,
10304 transitionDuration2,
10305 animationDuration2
10306 );
10307 const timeout = delay + duration;
10308 if (!timeout) {
10309 if (transition === "enter") {
10310 store2.setState("animated", false);
10311 }
10312 stopAnimation();
10313 return;
10314 }
10315 const frameRate = 1e3 / 60;
10316 const maxTimeout = Math.max(timeout - frameRate, 0);
10317 return afterTimeout(maxTimeout, stopAnimationSync);
10318 }, [store2, animated, contentElement, otherElement, open, transition]);
10319 props = useWrapElement(
10320 props,
10321 (element) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DialogScopedContextProvider, { value: store2, children: element }),
10322 [store2]
10323 );
10324 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
10325 const styleProp = props.style;
10326 const style = (0, import_react19.useMemo)(() => {
10327 if (hidden) {
10328 return { ...styleProp, display: "none" };
10329 }
10330 return styleProp;
10331 }, [hidden, styleProp]);
10332 props = {
10333 id,
10334 "data-open": open || void 0,
10335 "data-enter": transition === "enter" || void 0,
10336 "data-leave": transition === "leave" || void 0,
10337 hidden,
10338 ...props,
10339 ref: useMergeRefs(id ? store2.setContentElement : null, ref, props.ref),
10340 style
10341 };
10342 return removeUndefinedValues(props);
10343 });
10344 var DisclosureContentImpl = forwardRef25(function DisclosureContentImpl2(props) {
10345 const htmlProps = useDisclosureContent(props);
10346 return createElement3(TagName6, htmlProps);
10347 });
10348 var DisclosureContent = forwardRef25(function DisclosureContent2({
10349 unmountOnHide,
10350 ...props
10351 }) {
10352 const context = useDisclosureProviderContext();
10353 const store2 = props.store || context;
10354 const mounted = useStoreState(
10355 store2,
10356 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
10357 );
10358 if (mounted === false) return null;
10359 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DisclosureContentImpl, { ...props });
10360 });
10361
10362 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
10363 function createDisclosureStore(props = {}) {
10364 const store2 = mergeStore(
10365 props.store,
10366 omit2(props.disclosure, ["contentElement", "disclosureElement"])
10367 );
10368 throwOnConflictingProps(props, store2);
10369 const syncState = store2 == null ? void 0 : store2.getState();
10370 const open = defaultValue(
10371 props.open,
10372 syncState == null ? void 0 : syncState.open,
10373 props.defaultOpen,
10374 false
10375 );
10376 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
10377 const initialState = {
10378 open,
10379 animated,
10380 animating: !!animated && open,
10381 mounted: open,
10382 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
10383 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
10384 };
10385 const disclosure = createStore(initialState, store2);
10386 setup(
10387 disclosure,
10388 () => sync(disclosure, ["animated", "animating"], (state) => {
10389 if (state.animated) return;
10390 disclosure.setState("animating", false);
10391 })
10392 );
10393 setup(
10394 disclosure,
10395 () => subscribe(disclosure, ["open"], () => {
10396 if (!disclosure.getState().animated) return;
10397 disclosure.setState("animating", true);
10398 })
10399 );
10400 setup(
10401 disclosure,
10402 () => sync(disclosure, ["open", "animating"], (state) => {
10403 disclosure.setState("mounted", state.open || state.animating);
10404 })
10405 );
10406 return {
10407 ...disclosure,
10408 disclosure: props.disclosure,
10409 setOpen: (value) => disclosure.setState("open", value),
10410 show: () => disclosure.setState("open", true),
10411 hide: () => disclosure.setState("open", false),
10412 toggle: () => disclosure.setState("open", (open2) => !open2),
10413 stopAnimation: () => disclosure.setState("animating", false),
10414 setContentElement: (value) => disclosure.setState("contentElement", value),
10415 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
10416 };
10417 }
10418
10419 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
10420 function useDisclosureStoreProps(store2, update2, props) {
10421 useUpdateEffect(update2, [props.store, props.disclosure]);
10422 useStoreProps(store2, props, "open", "setOpen");
10423 useStoreProps(store2, props, "mounted", "setMounted");
10424 useStoreProps(store2, props, "animated");
10425 return Object.assign(store2, { disclosure: props.disclosure });
10426 }
10427
10428 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
10429 var ctx5 = createStoreContext(
10430 [DialogContextProvider],
10431 [DialogScopedContextProvider]
10432 );
10433 var usePopoverContext = ctx5.useContext;
10434 var usePopoverScopedContext = ctx5.useScopedContext;
10435 var usePopoverProviderContext = ctx5.useProviderContext;
10436 var PopoverContextProvider = ctx5.ContextProvider;
10437 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
10438
10439 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
10440 function getCommonParent(items) {
10441 var _a;
10442 const firstItem = items.find((item) => !!item.element);
10443 const lastItem = [...items].reverse().find((item) => !!item.element);
10444 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
10445 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
10446 const parent = parentElement;
10447 if (lastItem && parent.contains(lastItem.element)) {
10448 return parentElement;
10449 }
10450 parentElement = parentElement.parentElement;
10451 }
10452 return getDocument(parentElement).body;
10453 }
10454 function getPrivateStore(store2) {
10455 return store2 == null ? void 0 : store2.__unstablePrivateStore;
10456 }
10457 function createCollectionStore(props = {}) {
10458 var _a;
10459 throwOnConflictingProps(props, props.store);
10460 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
10461 const items = defaultValue(
10462 props.items,
10463 syncState == null ? void 0 : syncState.items,
10464 props.defaultItems,
10465 []
10466 );
10467 const itemsMap = new Map(items.map((item) => [item.id, item]));
10468 const initialState = {
10469 items,
10470 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
10471 };
10472 const syncPrivateStore = getPrivateStore(props.store);
10473 const privateStore = createStore(
10474 { items, renderedItems: initialState.renderedItems },
10475 syncPrivateStore
10476 );
10477 const collection = createStore(initialState, props.store);
10478 const sortItems = (renderedItems) => {
10479 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
10480 privateStore.setState("renderedItems", sortedItems);
10481 collection.setState("renderedItems", sortedItems);
10482 };
10483 setup(collection, () => init(privateStore));
10484 setup(privateStore, () => {
10485 return batch(privateStore, ["items"], (state) => {
10486 collection.setState("items", state.items);
10487 });
10488 });
10489 setup(privateStore, () => {
10490 return batch(privateStore, ["renderedItems"], (state) => {
10491 let firstRun = true;
10492 let raf = requestAnimationFrame(() => {
10493 const { renderedItems } = collection.getState();
10494 if (state.renderedItems === renderedItems) return;
10495 sortItems(state.renderedItems);
10496 });
10497 if (typeof IntersectionObserver !== "function") {
10498 return () => cancelAnimationFrame(raf);
10499 }
10500 const ioCallback = () => {
10501 if (firstRun) {
10502 firstRun = false;
10503 return;
10504 }
10505 cancelAnimationFrame(raf);
10506 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
10507 };
10508 const root = getCommonParent(state.renderedItems);
10509 const observer = new IntersectionObserver(ioCallback, { root });
10510 for (const item of state.renderedItems) {
10511 if (!item.element) continue;
10512 observer.observe(item.element);
10513 }
10514 return () => {
10515 cancelAnimationFrame(raf);
10516 observer.disconnect();
10517 };
10518 });
10519 });
10520 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
10521 let prevItem;
10522 setItems((items2) => {
10523 const index = items2.findIndex(({ id }) => id === item.id);
10524 const nextItems = items2.slice();
10525 if (index !== -1) {
10526 prevItem = items2[index];
10527 const nextItem = { ...prevItem, ...item };
10528 nextItems[index] = nextItem;
10529 itemsMap.set(item.id, nextItem);
10530 } else {
10531 nextItems.push(item);
10532 itemsMap.set(item.id, item);
10533 }
10534 return nextItems;
10535 });
10536 const unmergeItem = () => {
10537 setItems((items2) => {
10538 if (!prevItem) {
10539 if (canDeleteFromMap) {
10540 itemsMap.delete(item.id);
10541 }
10542 return items2.filter(({ id }) => id !== item.id);
10543 }
10544 const index = items2.findIndex(({ id }) => id === item.id);
10545 if (index === -1) return items2;
10546 const nextItems = items2.slice();
10547 nextItems[index] = prevItem;
10548 itemsMap.set(item.id, prevItem);
10549 return nextItems;
10550 });
10551 };
10552 return unmergeItem;
10553 };
10554 const registerItem = (item) => mergeItem(
10555 item,
10556 (getItems) => privateStore.setState("items", getItems),
10557 true
10558 );
10559 return {
10560 ...collection,
10561 registerItem,
10562 renderItem: (item) => chain(
10563 registerItem(item),
10564 mergeItem(
10565 item,
10566 (getItems) => privateStore.setState("renderedItems", getItems)
10567 )
10568 ),
10569 item: (id) => {
10570 if (!id) return null;
10571 let item = itemsMap.get(id);
10572 if (!item) {
10573 const { items: items2 } = privateStore.getState();
10574 item = items2.find((item2) => item2.id === id);
10575 if (item) {
10576 itemsMap.set(id, item);
10577 }
10578 }
10579 return item || null;
10580 },
10581 // @ts-expect-error Internal
10582 __unstablePrivateStore: privateStore
10583 };
10584 }
10585
10586 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
10587 function useCollectionStoreProps(store2, update2, props) {
10588 useUpdateEffect(update2, [props.store]);
10589 useStoreProps(store2, props, "items", "setItems");
10590 return store2;
10591 }
10592
10593 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
10594 var NULL_ITEM = { id: null };
10595 function findFirstEnabledItem2(items, excludeId) {
10596 return items.find((item) => {
10597 if (excludeId) {
10598 return !item.disabled && item.id !== excludeId;
10599 }
10600 return !item.disabled;
10601 });
10602 }
10603 function getEnabledItems(items, excludeId) {
10604 return items.filter((item) => {
10605 if (excludeId) {
10606 return !item.disabled && item.id !== excludeId;
10607 }
10608 return !item.disabled;
10609 });
10610 }
10611 function getItemsInRow(items, rowId) {
10612 return items.filter((item) => item.rowId === rowId);
10613 }
10614 function flipItems(items, activeId, shouldInsertNullItem = false) {
10615 const index = items.findIndex((item) => item.id === activeId);
10616 return [
10617 ...items.slice(index + 1),
10618 ...shouldInsertNullItem ? [NULL_ITEM] : [],
10619 ...items.slice(0, index)
10620 ];
10621 }
10622 function groupItemsByRows2(items) {
10623 const rows = [];
10624 for (const item of items) {
10625 const row = rows.find((currentRow) => {
10626 var _a;
10627 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
10628 });
10629 if (row) {
10630 row.push(item);
10631 } else {
10632 rows.push([item]);
10633 }
10634 }
10635 return rows;
10636 }
10637 function getMaxRowLength(array) {
10638 let maxLength = 0;
10639 for (const { length } of array) {
10640 if (length > maxLength) {
10641 maxLength = length;
10642 }
10643 }
10644 return maxLength;
10645 }
10646 function createEmptyItem(rowId) {
10647 return {
10648 id: "__EMPTY_ITEM__",
10649 disabled: true,
10650 rowId
10651 };
10652 }
10653 function normalizeRows(rows, activeId, focusShift) {
10654 const maxLength = getMaxRowLength(rows);
10655 for (const row of rows) {
10656 for (let i2 = 0; i2 < maxLength; i2 += 1) {
10657 const item = row[i2];
10658 if (!item || focusShift && item.disabled) {
10659 const isFirst = i2 === 0;
10660 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
10661 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
10662 }
10663 }
10664 }
10665 return rows;
10666 }
10667 function verticalizeItems(items) {
10668 const rows = groupItemsByRows2(items);
10669 const maxLength = getMaxRowLength(rows);
10670 const verticalized = [];
10671 for (let i2 = 0; i2 < maxLength; i2 += 1) {
10672 for (const row of rows) {
10673 const item = row[i2];
10674 if (item) {
10675 verticalized.push({
10676 ...item,
10677 // If there's no rowId, it means that it's not a grid composite, but
10678 // a single row instead. So, instead of verticalizing it, that is,
10679 // assigning a different rowId based on the column index, we keep it
10680 // undefined so they will be part of the same row. This is useful
10681 // when using up/down on one-dimensional composites.
10682 rowId: item.rowId ? `${i2}` : void 0
10683 });
10684 }
10685 }
10686 }
10687 return verticalized;
10688 }
10689 function createCompositeStore(props = {}) {
10690 var _a;
10691 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
10692 const collection = createCollectionStore(props);
10693 const activeId = defaultValue(
10694 props.activeId,
10695 syncState == null ? void 0 : syncState.activeId,
10696 props.defaultActiveId
10697 );
10698 const initialState = {
10699 ...collection.getState(),
10700 id: defaultValue(
10701 props.id,
10702 syncState == null ? void 0 : syncState.id,
10703 `id-${Math.random().toString(36).slice(2, 8)}`
10704 ),
10705 activeId,
10706 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
10707 includesBaseElement: defaultValue(
10708 props.includesBaseElement,
10709 syncState == null ? void 0 : syncState.includesBaseElement,
10710 activeId === null
10711 ),
10712 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
10713 orientation: defaultValue(
10714 props.orientation,
10715 syncState == null ? void 0 : syncState.orientation,
10716 "both"
10717 ),
10718 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
10719 virtualFocus: defaultValue(
10720 props.virtualFocus,
10721 syncState == null ? void 0 : syncState.virtualFocus,
10722 false
10723 ),
10724 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
10725 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
10726 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
10727 };
10728 const composite = createStore(initialState, collection, props.store);
10729 setup(
10730 composite,
10731 () => sync(composite, ["renderedItems", "activeId"], (state) => {
10732 composite.setState("activeId", (activeId2) => {
10733 var _a2;
10734 if (activeId2 !== void 0) return activeId2;
10735 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
10736 });
10737 })
10738 );
10739 const getNextId = (direction = "next", options = {}) => {
10740 var _a2, _b;
10741 const defaultState = composite.getState();
10742 const {
10743 skip = 0,
10744 activeId: activeId2 = defaultState.activeId,
10745 focusShift = defaultState.focusShift,
10746 focusLoop = defaultState.focusLoop,
10747 focusWrap = defaultState.focusWrap,
10748 includesBaseElement = defaultState.includesBaseElement,
10749 renderedItems = defaultState.renderedItems,
10750 rtl = defaultState.rtl
10751 } = options;
10752 const isVerticalDirection = direction === "up" || direction === "down";
10753 const isNextDirection = direction === "next" || direction === "down";
10754 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
10755 const canShift = focusShift && !skip;
10756 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
10757 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
10758 );
10759 items = canReverse ? reverseArray(items) : items;
10760 items = isVerticalDirection ? verticalizeItems(items) : items;
10761 if (activeId2 == null) {
10762 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
10763 }
10764 const activeItem = items.find((item) => item.id === activeId2);
10765 if (!activeItem) {
10766 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
10767 }
10768 const isGrid2 = items.some((item) => item.rowId);
10769 const activeIndex = items.indexOf(activeItem);
10770 const nextItems = items.slice(activeIndex + 1);
10771 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
10772 if (skip) {
10773 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
10774 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
10775 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
10776 return nextItem2 == null ? void 0 : nextItem2.id;
10777 }
10778 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
10779 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
10780 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
10781 if (canLoop) {
10782 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
10783 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
10784 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
10785 return nextItem2 == null ? void 0 : nextItem2.id;
10786 }
10787 if (canWrap) {
10788 const nextItem2 = findFirstEnabledItem2(
10789 // We can use nextItems, which contains all the next items, including
10790 // items from other rows, to wrap between rows. However, if there is a
10791 // null item (the composite container), we'll only use the next items in
10792 // the row. So moving next from the last item will focus on the
10793 // composite container. On grid composites, horizontal navigation never
10794 // focuses on the composite container, only vertical.
10795 hasNullItem ? nextItemsInRow : nextItems,
10796 activeId2
10797 );
10798 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
10799 return nextId;
10800 }
10801 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
10802 if (!nextItem && hasNullItem) {
10803 return null;
10804 }
10805 return nextItem == null ? void 0 : nextItem.id;
10806 };
10807 return {
10808 ...collection,
10809 ...composite,
10810 setBaseElement: (element) => composite.setState("baseElement", element),
10811 setActiveId: (id) => composite.setState("activeId", id),
10812 move: (id) => {
10813 if (id === void 0) return;
10814 composite.setState("activeId", id);
10815 composite.setState("moves", (moves) => moves + 1);
10816 },
10817 first: () => {
10818 var _a2;
10819 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
10820 },
10821 last: () => {
10822 var _a2;
10823 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
10824 },
10825 next: (options) => {
10826 if (options !== void 0 && typeof options === "number") {
10827 options = { skip: options };
10828 }
10829 return getNextId("next", options);
10830 },
10831 previous: (options) => {
10832 if (options !== void 0 && typeof options === "number") {
10833 options = { skip: options };
10834 }
10835 return getNextId("previous", options);
10836 },
10837 down: (options) => {
10838 if (options !== void 0 && typeof options === "number") {
10839 options = { skip: options };
10840 }
10841 return getNextId("down", options);
10842 },
10843 up: (options) => {
10844 if (options !== void 0 && typeof options === "number") {
10845 options = { skip: options };
10846 }
10847 return getNextId("up", options);
10848 }
10849 };
10850 }
10851
10852 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
10853 function useCompositeStoreOptions(props) {
10854 const id = useId5(props.id);
10855 return { id, ...props };
10856 }
10857 function useCompositeStoreProps(store2, update2, props) {
10858 store2 = useCollectionStoreProps(store2, update2, props);
10859 useStoreProps(store2, props, "activeId", "setActiveId");
10860 useStoreProps(store2, props, "includesBaseElement");
10861 useStoreProps(store2, props, "virtualFocus");
10862 useStoreProps(store2, props, "orientation");
10863 useStoreProps(store2, props, "rtl");
10864 useStoreProps(store2, props, "focusLoop");
10865 useStoreProps(store2, props, "focusWrap");
10866 useStoreProps(store2, props, "focusShift");
10867 return store2;
10868 }
10869
10870 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
10871 var import_react20 = __toESM(require_react(), 1);
10872 var ComboboxListRoleContext = (0, import_react20.createContext)(
10873 void 0
10874 );
10875 var ctx6 = createStoreContext(
10876 [PopoverContextProvider, CompositeContextProvider],
10877 [PopoverScopedContextProvider, CompositeScopedContextProvider]
10878 );
10879 var useComboboxContext = ctx6.useContext;
10880 var useComboboxScopedContext = ctx6.useScopedContext;
10881 var useComboboxProviderContext = ctx6.useProviderContext;
10882 var ComboboxContextProvider = ctx6.ContextProvider;
10883 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
10884 var ComboboxItemValueContext = (0, import_react20.createContext)(
10885 void 0
10886 );
10887 var ComboboxItemCheckedContext = (0, import_react20.createContext)(false);
10888
10889 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
10890 function createDialogStore(props = {}) {
10891 return createDisclosureStore(props);
10892 }
10893
10894 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
10895 function useDialogStoreProps(store2, update2, props) {
10896 return useDisclosureStoreProps(store2, update2, props);
10897 }
10898
10899 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
10900 function createPopoverStore({
10901 popover: otherPopover,
10902 ...props
10903 } = {}) {
10904 const store2 = mergeStore(
10905 props.store,
10906 omit2(otherPopover, [
10907 "arrowElement",
10908 "anchorElement",
10909 "contentElement",
10910 "popoverElement",
10911 "disclosureElement"
10912 ])
10913 );
10914 throwOnConflictingProps(props, store2);
10915 const syncState = store2 == null ? void 0 : store2.getState();
10916 const dialog = createDialogStore({ ...props, store: store2 });
10917 const placement = defaultValue(
10918 props.placement,
10919 syncState == null ? void 0 : syncState.placement,
10920 "bottom"
10921 );
10922 const initialState = {
10923 ...dialog.getState(),
10924 placement,
10925 currentPlacement: placement,
10926 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
10927 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
10928 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
10929 rendered: /* @__PURE__ */ Symbol("rendered")
10930 };
10931 const popover = createStore(initialState, dialog, store2);
10932 return {
10933 ...dialog,
10934 ...popover,
10935 setAnchorElement: (element) => popover.setState("anchorElement", element),
10936 setPopoverElement: (element) => popover.setState("popoverElement", element),
10937 setArrowElement: (element) => popover.setState("arrowElement", element),
10938 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
10939 };
10940 }
10941
10942 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
10943 function usePopoverStoreProps(store2, update2, props) {
10944 useUpdateEffect(update2, [props.popover]);
10945 useStoreProps(store2, props, "placement");
10946 return useDialogStoreProps(store2, update2, props);
10947 }
10948
10949 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
10950 var TagName7 = "div";
10951 var usePopoverAnchor = createHook(
10952 function usePopoverAnchor2({ store: store2, ...props }) {
10953 const context = usePopoverProviderContext();
10954 store2 = store2 || context;
10955 props = {
10956 ...props,
10957 ref: useMergeRefs(store2 == null ? void 0 : store2.setAnchorElement, props.ref)
10958 };
10959 return props;
10960 }
10961 );
10962 var PopoverAnchor = forwardRef25(function PopoverAnchor2(props) {
10963 const htmlProps = usePopoverAnchor(props);
10964 return createElement3(TagName7, htmlProps);
10965 });
10966
10967 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
10968 var import_react21 = __toESM(require_react(), 1);
10969 var TagName8 = "div";
10970 function getMouseDestination(event) {
10971 const relatedTarget = event.relatedTarget;
10972 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
10973 return relatedTarget;
10974 }
10975 return null;
10976 }
10977 function hoveringInside(event) {
10978 const nextElement = getMouseDestination(event);
10979 if (!nextElement) return false;
10980 return contains(event.currentTarget, nextElement);
10981 }
10982 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
10983 function movingToAnotherItem(event) {
10984 let dest = getMouseDestination(event);
10985 if (!dest) return false;
10986 do {
10987 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
10988 dest = dest.parentElement;
10989 } while (dest);
10990 return false;
10991 }
10992 var useCompositeHover = createHook(
10993 function useCompositeHover2({
10994 store: store2,
10995 focusOnHover = true,
10996 blurOnHoverEnd = !!focusOnHover,
10997 ...props
10998 }) {
10999 const context = useCompositeContext();
11000 store2 = store2 || context;
11001 invariant(
11002 store2,
11003 "CompositeHover must be wrapped in a Composite component."
11004 );
11005 const isMouseMoving = useIsMouseMoving();
11006 const onMouseMoveProp = props.onMouseMove;
11007 const focusOnHoverProp = useBooleanEvent(focusOnHover);
11008 const onMouseMove = useEvent((event) => {
11009 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
11010 if (event.defaultPrevented) return;
11011 if (!isMouseMoving()) return;
11012 if (!focusOnHoverProp(event)) return;
11013 if (!hasFocusWithin(event.currentTarget)) {
11014 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
11015 if (baseElement && !hasFocus(baseElement)) {
11016 baseElement.focus();
11017 }
11018 }
11019 store2 == null ? void 0 : store2.setActiveId(event.currentTarget.id);
11020 });
11021 const onMouseLeaveProp = props.onMouseLeave;
11022 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
11023 const onMouseLeave = useEvent((event) => {
11024 var _a;
11025 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
11026 if (event.defaultPrevented) return;
11027 if (!isMouseMoving()) return;
11028 if (hoveringInside(event)) return;
11029 if (movingToAnotherItem(event)) return;
11030 if (!focusOnHoverProp(event)) return;
11031 if (!blurOnHoverEndProp(event)) return;
11032 store2 == null ? void 0 : store2.setActiveId(null);
11033 (_a = store2 == null ? void 0 : store2.getState().baseElement) == null ? void 0 : _a.focus();
11034 });
11035 const ref = (0, import_react21.useCallback)((element) => {
11036 if (!element) return;
11037 element[symbol2] = true;
11038 }, []);
11039 props = {
11040 ...props,
11041 ref: useMergeRefs(ref, props.ref),
11042 onMouseMove,
11043 onMouseLeave
11044 };
11045 return removeUndefinedValues(props);
11046 }
11047 );
11048 var CompositeHover = memo22(
11049 forwardRef25(function CompositeHover2(props) {
11050 const htmlProps = useCompositeHover(props);
11051 return createElement3(TagName8, htmlProps);
11052 })
11053 );
11054
11055 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
11056 var import_react22 = __toESM(require_react(), 1);
11057 var TagName9 = "input";
11058 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
11059 if (!autoSelect) return false;
11060 const firstItem = items.find((item) => !item.disabled && item.value);
11061 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
11062 }
11063 function hasCompletionString(value, activeValue) {
11064 if (!activeValue) return false;
11065 if (value == null) return false;
11066 value = normalizeString(value);
11067 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
11068 }
11069 function isInputEvent(event) {
11070 return event.type === "input";
11071 }
11072 function isAriaAutoCompleteValue(value) {
11073 return value === "inline" || value === "list" || value === "both" || value === "none";
11074 }
11075 function getDefaultAutoSelectId(items) {
11076 const item = items.find((item2) => {
11077 var _a;
11078 if (item2.disabled) return false;
11079 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
11080 });
11081 return item == null ? void 0 : item.id;
11082 }
11083 var useCombobox = createHook(
11084 function useCombobox2({
11085 store: store2,
11086 focusable = true,
11087 autoSelect: autoSelectProp = false,
11088 getAutoSelectId,
11089 setValueOnChange,
11090 showMinLength = 0,
11091 showOnChange,
11092 showOnMouseDown,
11093 showOnClick = showOnMouseDown,
11094 showOnKeyDown,
11095 showOnKeyPress = showOnKeyDown,
11096 blurActiveItemOnClick,
11097 setValueOnClick = true,
11098 moveOnKeyPress = true,
11099 autoComplete = "list",
11100 ...props
11101 }) {
11102 const context = useComboboxProviderContext();
11103 store2 = store2 || context;
11104 invariant(
11105 store2,
11106 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
11107 );
11108 const ref = (0, import_react22.useRef)(null);
11109 const [valueUpdated, forceValueUpdate] = useForceUpdate();
11110 const canAutoSelectRef = (0, import_react22.useRef)(false);
11111 const composingRef = (0, import_react22.useRef)(false);
11112 const autoSelect = store2.useState(
11113 (state) => state.virtualFocus && autoSelectProp
11114 );
11115 const inline = autoComplete === "inline" || autoComplete === "both";
11116 const [canInline, setCanInline] = (0, import_react22.useState)(inline);
11117 useUpdateLayoutEffect(() => {
11118 if (!inline) return;
11119 setCanInline(true);
11120 }, [inline]);
11121 const storeValue = store2.useState("value");
11122 const prevSelectedValueRef = (0, import_react22.useRef)(void 0);
11123 (0, import_react22.useEffect)(() => {
11124 return sync(store2, ["selectedValue", "activeId"], (_, prev) => {
11125 prevSelectedValueRef.current = prev.selectedValue;
11126 });
11127 }, []);
11128 const inlineActiveValue = store2.useState((state) => {
11129 var _a;
11130 if (!inline) return;
11131 if (!canInline) return;
11132 if (state.activeValue && Array.isArray(state.selectedValue)) {
11133 if (state.selectedValue.includes(state.activeValue)) return;
11134 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
11135 }
11136 return state.activeValue;
11137 });
11138 const items = store2.useState("renderedItems");
11139 const open = store2.useState("open");
11140 const contentElement = store2.useState("contentElement");
11141 const value = (0, import_react22.useMemo)(() => {
11142 if (!inline) return storeValue;
11143 if (!canInline) return storeValue;
11144 const firstItemAutoSelected = isFirstItemAutoSelected(
11145 items,
11146 inlineActiveValue,
11147 autoSelect
11148 );
11149 if (firstItemAutoSelected) {
11150 if (hasCompletionString(storeValue, inlineActiveValue)) {
11151 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
11152 return storeValue + slice;
11153 }
11154 return storeValue;
11155 }
11156 return inlineActiveValue || storeValue;
11157 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
11158 (0, import_react22.useEffect)(() => {
11159 const element = ref.current;
11160 if (!element) return;
11161 const onCompositeItemMove = () => setCanInline(true);
11162 element.addEventListener("combobox-item-move", onCompositeItemMove);
11163 return () => {
11164 element.removeEventListener("combobox-item-move", onCompositeItemMove);
11165 };
11166 }, []);
11167 (0, import_react22.useEffect)(() => {
11168 if (!inline) return;
11169 if (!canInline) return;
11170 if (!inlineActiveValue) return;
11171 const firstItemAutoSelected = isFirstItemAutoSelected(
11172 items,
11173 inlineActiveValue,
11174 autoSelect
11175 );
11176 if (!firstItemAutoSelected) return;
11177 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
11178 let cleanup = noop2;
11179 queueMicrotask(() => {
11180 const element = ref.current;
11181 if (!element) return;
11182 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
11183 const nextStart = storeValue.length;
11184 const nextEnd = inlineActiveValue.length;
11185 setSelectionRange(element, nextStart, nextEnd);
11186 cleanup = () => {
11187 if (!hasFocus(element)) return;
11188 const { start, end } = getTextboxSelection(element);
11189 if (start !== nextStart) return;
11190 if (end !== nextEnd) return;
11191 setSelectionRange(element, prevStart, prevEnd);
11192 };
11193 });
11194 return () => cleanup();
11195 }, [
11196 valueUpdated,
11197 inline,
11198 canInline,
11199 inlineActiveValue,
11200 items,
11201 autoSelect,
11202 storeValue
11203 ]);
11204 const scrollingElementRef = (0, import_react22.useRef)(null);
11205 const getAutoSelectIdProp = useEvent(getAutoSelectId);
11206 const autoSelectIdRef = (0, import_react22.useRef)(null);
11207 (0, import_react22.useEffect)(() => {
11208 if (!open) return;
11209 if (!contentElement) return;
11210 const scrollingElement = getScrollingElement(contentElement);
11211 if (!scrollingElement) return;
11212 scrollingElementRef.current = scrollingElement;
11213 const onUserScroll = () => {
11214 canAutoSelectRef.current = false;
11215 };
11216 const onScroll = () => {
11217 if (!store2) return;
11218 if (!canAutoSelectRef.current) return;
11219 const { activeId } = store2.getState();
11220 if (activeId === null) return;
11221 if (activeId === autoSelectIdRef.current) return;
11222 canAutoSelectRef.current = false;
11223 };
11224 const options = { passive: true, capture: true };
11225 scrollingElement.addEventListener("wheel", onUserScroll, options);
11226 scrollingElement.addEventListener("touchmove", onUserScroll, options);
11227 scrollingElement.addEventListener("scroll", onScroll, options);
11228 return () => {
11229 scrollingElement.removeEventListener("wheel", onUserScroll, true);
11230 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
11231 scrollingElement.removeEventListener("scroll", onScroll, true);
11232 };
11233 }, [open, contentElement, store2]);
11234 useSafeLayoutEffect(() => {
11235 if (!storeValue) return;
11236 if (composingRef.current) return;
11237 canAutoSelectRef.current = true;
11238 }, [storeValue]);
11239 useSafeLayoutEffect(() => {
11240 if (autoSelect !== "always" && open) return;
11241 canAutoSelectRef.current = open;
11242 }, [autoSelect, open]);
11243 const resetValueOnSelect = store2.useState("resetValueOnSelect");
11244 useUpdateEffect(() => {
11245 var _a, _b;
11246 const canAutoSelect = canAutoSelectRef.current;
11247 if (!store2) return;
11248 if (!open) return;
11249 if (!canAutoSelect && !resetValueOnSelect) return;
11250 const { baseElement, contentElement: contentElement2, activeId } = store2.getState();
11251 if (baseElement && !hasFocus(baseElement)) return;
11252 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
11253 const observer = new MutationObserver(forceValueUpdate);
11254 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
11255 return () => observer.disconnect();
11256 }
11257 if (autoSelect && canAutoSelect) {
11258 const userAutoSelectId = getAutoSelectIdProp(items);
11259 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store2.first();
11260 autoSelectIdRef.current = autoSelectId;
11261 store2.move(autoSelectId != null ? autoSelectId : null);
11262 } else {
11263 const element = (_b = store2.item(activeId || store2.first())) == null ? void 0 : _b.element;
11264 if (element && "scrollIntoView" in element) {
11265 element.scrollIntoView({ block: "nearest", inline: "nearest" });
11266 }
11267 }
11268 return;
11269 }, [
11270 store2,
11271 open,
11272 valueUpdated,
11273 storeValue,
11274 autoSelect,
11275 resetValueOnSelect,
11276 getAutoSelectIdProp,
11277 items
11278 ]);
11279 (0, import_react22.useEffect)(() => {
11280 if (!inline) return;
11281 const combobox = ref.current;
11282 if (!combobox) return;
11283 const elements = [combobox, contentElement].filter(
11284 (value2) => !!value2
11285 );
11286 const onBlur2 = (event) => {
11287 if (elements.every((el) => isFocusEventOutside(event, el))) {
11288 store2 == null ? void 0 : store2.setValue(value);
11289 }
11290 };
11291 for (const element of elements) {
11292 element.addEventListener("focusout", onBlur2);
11293 }
11294 return () => {
11295 for (const element of elements) {
11296 element.removeEventListener("focusout", onBlur2);
11297 }
11298 };
11299 }, [inline, contentElement, store2, value]);
11300 const canShow = (event) => {
11301 const currentTarget = event.currentTarget;
11302 return currentTarget.value.length >= showMinLength;
11303 };
11304 const onChangeProp = props.onChange;
11305 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
11306 const setValueOnChangeProp = useBooleanEvent(
11307 // If the combobox is combined with tags, the value will be set by the tag
11308 // input component.
11309 setValueOnChange != null ? setValueOnChange : !store2.tag
11310 );
11311 const onChange = useEvent((event) => {
11312 onChangeProp == null ? void 0 : onChangeProp(event);
11313 if (event.defaultPrevented) return;
11314 if (!store2) return;
11315 const currentTarget = event.currentTarget;
11316 const { value: value2, selectionStart, selectionEnd } = currentTarget;
11317 const nativeEvent = event.nativeEvent;
11318 canAutoSelectRef.current = true;
11319 if (isInputEvent(nativeEvent)) {
11320 if (nativeEvent.isComposing) {
11321 canAutoSelectRef.current = false;
11322 composingRef.current = true;
11323 }
11324 if (inline) {
11325 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
11326 const caretAtEnd = selectionStart === value2.length;
11327 setCanInline(textInserted && caretAtEnd);
11328 }
11329 }
11330 if (setValueOnChangeProp(event)) {
11331 const isSameValue = value2 === store2.getState().value;
11332 store2.setValue(value2);
11333 queueMicrotask(() => {
11334 setSelectionRange(currentTarget, selectionStart, selectionEnd);
11335 });
11336 if (inline && autoSelect && isSameValue) {
11337 forceValueUpdate();
11338 }
11339 }
11340 if (showOnChangeProp(event)) {
11341 store2.show();
11342 }
11343 if (!autoSelect || !canAutoSelectRef.current) {
11344 store2.setActiveId(null);
11345 }
11346 });
11347 const onCompositionEndProp = props.onCompositionEnd;
11348 const onCompositionEnd = useEvent((event) => {
11349 canAutoSelectRef.current = true;
11350 composingRef.current = false;
11351 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
11352 if (event.defaultPrevented) return;
11353 if (!autoSelect) return;
11354 forceValueUpdate();
11355 });
11356 const onMouseDownProp = props.onMouseDown;
11357 const blurActiveItemOnClickProp = useBooleanEvent(
11358 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store2 == null ? void 0 : store2.getState().includesBaseElement))
11359 );
11360 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
11361 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
11362 const onMouseDown = useEvent((event) => {
11363 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
11364 if (event.defaultPrevented) return;
11365 if (event.button) return;
11366 if (event.ctrlKey) return;
11367 if (!store2) return;
11368 if (blurActiveItemOnClickProp(event)) {
11369 store2.setActiveId(null);
11370 }
11371 if (setValueOnClickProp(event)) {
11372 store2.setValue(value);
11373 }
11374 if (showOnClickProp(event)) {
11375 queueBeforeEvent(event.currentTarget, "mouseup", store2.show);
11376 }
11377 });
11378 const onKeyDownProp = props.onKeyDown;
11379 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
11380 const onKeyDown = useEvent((event) => {
11381 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
11382 if (!event.repeat) {
11383 canAutoSelectRef.current = false;
11384 }
11385 if (event.defaultPrevented) return;
11386 if (event.ctrlKey) return;
11387 if (event.altKey) return;
11388 if (event.shiftKey) return;
11389 if (event.metaKey) return;
11390 if (!store2) return;
11391 const { open: open2 } = store2.getState();
11392 if (open2) return;
11393 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
11394 if (showOnKeyPressProp(event)) {
11395 event.preventDefault();
11396 store2.show();
11397 }
11398 }
11399 });
11400 const onBlurProp = props.onBlur;
11401 const onBlur = useEvent((event) => {
11402 canAutoSelectRef.current = false;
11403 onBlurProp == null ? void 0 : onBlurProp(event);
11404 if (event.defaultPrevented) return;
11405 });
11406 const id = useId5(props.id);
11407 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
11408 const isActiveItem = store2.useState((state) => state.activeId === null);
11409 props = {
11410 id,
11411 role: "combobox",
11412 "aria-autocomplete": ariaAutoComplete,
11413 "aria-haspopup": getPopupRole(contentElement, "listbox"),
11414 "aria-expanded": open,
11415 "aria-controls": contentElement == null ? void 0 : contentElement.id,
11416 "data-active-item": isActiveItem || void 0,
11417 value,
11418 ...props,
11419 ref: useMergeRefs(ref, props.ref),
11420 onChange,
11421 onCompositionEnd,
11422 onMouseDown,
11423 onKeyDown,
11424 onBlur
11425 };
11426 props = useComposite({
11427 store: store2,
11428 focusable,
11429 ...props,
11430 // Enable inline autocomplete when the user moves from the combobox input
11431 // to an item.
11432 moveOnKeyPress: (event) => {
11433 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
11434 if (inline) setCanInline(true);
11435 return true;
11436 }
11437 });
11438 props = usePopoverAnchor({ store: store2, ...props });
11439 return { autoComplete: "off", ...props };
11440 }
11441 );
11442 var Combobox = forwardRef25(function Combobox2(props) {
11443 const htmlProps = useCombobox(props);
11444 return createElement3(TagName9, htmlProps);
11445 });
11446
11447 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
11448 var import_react23 = __toESM(require_react(), 1);
11449 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
11450 var TagName10 = "div";
11451 function isSelected(storeValue, itemValue) {
11452 if (itemValue == null) return;
11453 if (storeValue == null) return false;
11454 if (Array.isArray(storeValue)) {
11455 return storeValue.includes(itemValue);
11456 }
11457 return storeValue === itemValue;
11458 }
11459 function getItemRole(popupRole) {
11460 var _a;
11461 const itemRoleByPopupRole = {
11462 menu: "menuitem",
11463 listbox: "option",
11464 tree: "treeitem"
11465 };
11466 const key = popupRole;
11467 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
11468 }
11469 var useComboboxItem = createHook(
11470 function useComboboxItem2({
11471 store: store2,
11472 value,
11473 hideOnClick,
11474 setValueOnClick,
11475 selectValueOnClick = true,
11476 resetValueOnSelect,
11477 focusOnHover = false,
11478 moveOnKeyPress = true,
11479 getItem: getItemProp,
11480 ...props
11481 }) {
11482 var _a;
11483 const context = useComboboxScopedContext();
11484 store2 = store2 || context;
11485 invariant(
11486 store2,
11487 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
11488 );
11489 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store2, {
11490 resetValueOnSelectState: "resetValueOnSelect",
11491 multiSelectable(state) {
11492 return Array.isArray(state.selectedValue);
11493 },
11494 selected(state) {
11495 return isSelected(state.selectedValue, value);
11496 }
11497 });
11498 const getItem = (0, import_react23.useCallback)(
11499 (item) => {
11500 const nextItem = { ...item, value };
11501 if (getItemProp) {
11502 return getItemProp(nextItem);
11503 }
11504 return nextItem;
11505 },
11506 [value, getItemProp]
11507 );
11508 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
11509 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
11510 const onClickProp = props.onClick;
11511 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
11512 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
11513 const resetValueOnSelectProp = useBooleanEvent(
11514 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
11515 );
11516 const hideOnClickProp = useBooleanEvent(hideOnClick);
11517 const onClick = useEvent((event) => {
11518 onClickProp == null ? void 0 : onClickProp(event);
11519 if (event.defaultPrevented) return;
11520 if (isDownloading(event)) return;
11521 if (isOpeningInNewTab(event)) return;
11522 if (value != null) {
11523 if (selectValueOnClickProp(event)) {
11524 if (resetValueOnSelectProp(event)) {
11525 store2 == null ? void 0 : store2.resetValue();
11526 }
11527 store2 == null ? void 0 : store2.setSelectedValue((prevValue) => {
11528 if (!Array.isArray(prevValue)) return value;
11529 if (prevValue.includes(value)) {
11530 return prevValue.filter((v2) => v2 !== value);
11531 }
11532 return [...prevValue, value];
11533 });
11534 }
11535 if (setValueOnClickProp(event)) {
11536 store2 == null ? void 0 : store2.setValue(value);
11537 }
11538 }
11539 if (hideOnClickProp(event)) {
11540 store2 == null ? void 0 : store2.hide();
11541 }
11542 });
11543 const onKeyDownProp = props.onKeyDown;
11544 const onKeyDown = useEvent((event) => {
11545 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
11546 if (event.defaultPrevented) return;
11547 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
11548 if (!baseElement) return;
11549 if (hasFocus(baseElement)) return;
11550 const printable = event.key.length === 1;
11551 if (printable || event.key === "Backspace" || event.key === "Delete") {
11552 queueMicrotask(() => baseElement.focus());
11553 if (isTextField(baseElement)) {
11554 store2 == null ? void 0 : store2.setValue(baseElement.value);
11555 }
11556 }
11557 });
11558 if (multiSelectable && selected != null) {
11559 props = {
11560 "aria-selected": selected,
11561 ...props
11562 };
11563 }
11564 props = useWrapElement(
11565 props,
11566 (element) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
11567 [value, selected]
11568 );
11569 const popupRole = (0, import_react23.useContext)(ComboboxListRoleContext);
11570 props = {
11571 role: getItemRole(popupRole),
11572 children: value,
11573 ...props,
11574 onClick,
11575 onKeyDown
11576 };
11577 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
11578 props = useCompositeItem({
11579 store: store2,
11580 ...props,
11581 getItem,
11582 // Dispatch a custom event on the combobox input when moving to an item
11583 // with the keyboard so the Combobox component can enable inline
11584 // autocompletion.
11585 moveOnKeyPress: (event) => {
11586 if (!moveOnKeyPressProp(event)) return false;
11587 const moveEvent = new Event("combobox-item-move");
11588 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
11589 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
11590 return true;
11591 }
11592 });
11593 props = useCompositeHover({ store: store2, focusOnHover, ...props });
11594 return props;
11595 }
11596 );
11597 var ComboboxItem = memo22(
11598 forwardRef25(function ComboboxItem2(props) {
11599 const htmlProps = useComboboxItem(props);
11600 return createElement3(TagName10, htmlProps);
11601 })
11602 );
11603
11604 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
11605 var import_react24 = __toESM(require_react(), 1);
11606 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
11607 var TagName11 = "span";
11608 function normalizeValue(value) {
11609 return normalizeString(value).toLowerCase();
11610 }
11611 function getOffsets(string, values) {
11612 const offsets = [];
11613 for (const value of values) {
11614 let pos = 0;
11615 const length = value.length;
11616 while (string.indexOf(value, pos) !== -1) {
11617 const index = string.indexOf(value, pos);
11618 if (index !== -1) {
11619 offsets.push([index, length]);
11620 }
11621 pos = index + 1;
11622 }
11623 }
11624 return offsets;
11625 }
11626 function filterOverlappingOffsets(offsets) {
11627 return offsets.filter(([offset, length], i2, arr) => {
11628 return !arr.some(
11629 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length
11630 );
11631 });
11632 }
11633 function sortOffsets(offsets) {
11634 return offsets.sort(([a2], [b2]) => a2 - b2);
11635 }
11636 function splitValue(itemValue, userValue) {
11637 if (!itemValue) return itemValue;
11638 if (!userValue) return itemValue;
11639 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
11640 const parts = [];
11641 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
11642 "span",
11643 {
11644 "data-autocomplete-value": autocomplete ? "" : void 0,
11645 "data-user-value": autocomplete ? void 0 : "",
11646 children: value
11647 },
11648 parts.length
11649 );
11650 const offsets = sortOffsets(
11651 filterOverlappingOffsets(
11652 // Convert userValues into a set to avoid duplicates
11653 getOffsets(normalizeValue(itemValue), new Set(userValues))
11654 )
11655 );
11656 if (!offsets.length) {
11657 parts.push(span(itemValue, true));
11658 return parts;
11659 }
11660 const [firstOffset] = offsets[0];
11661 const values = [
11662 itemValue.slice(0, firstOffset),
11663 ...offsets.flatMap(([offset, length], i2) => {
11664 var _a;
11665 const value = itemValue.slice(offset, offset + length);
11666 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
11667 const nextValue = itemValue.slice(offset + length, nextOffset);
11668 return [value, nextValue];
11669 })
11670 ];
11671 values.forEach((value, i2) => {
11672 if (!value) return;
11673 parts.push(span(value, i2 % 2 === 0));
11674 });
11675 return parts;
11676 }
11677 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store: store2, value, userValue, ...props }) {
11678 const context = useComboboxScopedContext();
11679 store2 = store2 || context;
11680 const itemContext = (0, import_react24.useContext)(ComboboxItemValueContext);
11681 const itemValue = value != null ? value : itemContext;
11682 const inputValue = useStoreState(store2, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
11683 const children = (0, import_react24.useMemo)(() => {
11684 if (!itemValue) return;
11685 if (!inputValue) return itemValue;
11686 return splitValue(itemValue, inputValue);
11687 }, [itemValue, inputValue]);
11688 props = {
11689 children,
11690 ...props
11691 };
11692 return removeUndefinedValues(props);
11693 });
11694 var ComboboxItemValue = forwardRef25(function ComboboxItemValue2(props) {
11695 const htmlProps = useComboboxItemValue(props);
11696 return createElement3(TagName11, htmlProps);
11697 });
11698
11699 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
11700 var TagName12 = "label";
11701 var useComboboxLabel = createHook(
11702 function useComboboxLabel2({ store: store2, ...props }) {
11703 const context = useComboboxProviderContext();
11704 store2 = store2 || context;
11705 invariant(
11706 store2,
11707 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
11708 );
11709 const comboboxId = store2.useState((state) => {
11710 var _a;
11711 return (_a = state.baseElement) == null ? void 0 : _a.id;
11712 });
11713 props = {
11714 htmlFor: comboboxId,
11715 ...props
11716 };
11717 return removeUndefinedValues(props);
11718 }
11719 );
11720 var ComboboxLabel = memo22(
11721 forwardRef25(function ComboboxLabel2(props) {
11722 const htmlProps = useComboboxLabel(props);
11723 return createElement3(TagName12, htmlProps);
11724 })
11725 );
11726
11727 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
11728 var import_react25 = __toESM(require_react(), 1);
11729 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
11730 var TagName13 = "div";
11731 var useComboboxList = createHook(
11732 function useComboboxList2({ store: store2, alwaysVisible, ...props }) {
11733 const scopedContext = useComboboxScopedContext(true);
11734 const context = useComboboxContext();
11735 store2 = store2 || context;
11736 const scopedContextSameStore = !!store2 && store2 === scopedContext;
11737 invariant(
11738 store2,
11739 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
11740 );
11741 const ref = (0, import_react25.useRef)(null);
11742 const id = useId5(props.id);
11743 const mounted = store2.useState("mounted");
11744 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
11745 const style = hidden ? { ...props.style, display: "none" } : props.style;
11746 const multiSelectable = store2.useState(
11747 (state) => Array.isArray(state.selectedValue)
11748 );
11749 const role = useAttribute(ref, "role", props.role);
11750 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
11751 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
11752 const [hasListboxInside, setHasListboxInside] = (0, import_react25.useState)(false);
11753 const contentElement = store2.useState("contentElement");
11754 useSafeLayoutEffect(() => {
11755 if (!mounted) return;
11756 const element = ref.current;
11757 if (!element) return;
11758 if (contentElement !== element) return;
11759 const callback = () => {
11760 setHasListboxInside(!!element.querySelector("[role='listbox']"));
11761 };
11762 const observer = new MutationObserver(callback);
11763 observer.observe(element, {
11764 subtree: true,
11765 childList: true,
11766 attributeFilter: ["role"]
11767 });
11768 callback();
11769 return () => observer.disconnect();
11770 }, [mounted, contentElement]);
11771 if (!hasListboxInside) {
11772 props = {
11773 role: "listbox",
11774 "aria-multiselectable": ariaMultiSelectable,
11775 ...props
11776 };
11777 }
11778 props = useWrapElement(
11779 props,
11780 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxScopedContextProvider, { value: store2, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
11781 [store2, role]
11782 );
11783 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store2.setContentElement : null;
11784 props = {
11785 id,
11786 hidden,
11787 ...props,
11788 ref: useMergeRefs(setContentElement, ref, props.ref),
11789 style
11790 };
11791 return removeUndefinedValues(props);
11792 }
11793 );
11794 var ComboboxList = forwardRef25(function ComboboxList2(props) {
11795 const htmlProps = useComboboxList(props);
11796 return createElement3(TagName13, htmlProps);
11797 });
11798
11799 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
11800 var import_react26 = __toESM(require_react(), 1);
11801 var TagValueContext = (0, import_react26.createContext)(null);
11802 var TagRemoveIdContext = (0, import_react26.createContext)(
11803 null
11804 );
11805 var ctx7 = createStoreContext(
11806 [CompositeContextProvider],
11807 [CompositeScopedContextProvider]
11808 );
11809 var useTagContext = ctx7.useContext;
11810 var useTagScopedContext = ctx7.useScopedContext;
11811 var useTagProviderContext = ctx7.useProviderContext;
11812 var TagContextProvider = ctx7.ContextProvider;
11813 var TagScopedContextProvider = ctx7.ScopedContextProvider;
11814
11815 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
11816 var isTouchSafari = isSafari() && isTouchDevice();
11817 function createComboboxStore({
11818 tag,
11819 ...props
11820 } = {}) {
11821 const store2 = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
11822 throwOnConflictingProps(props, store2);
11823 const tagState = tag == null ? void 0 : tag.getState();
11824 const syncState = store2 == null ? void 0 : store2.getState();
11825 const activeId = defaultValue(
11826 props.activeId,
11827 syncState == null ? void 0 : syncState.activeId,
11828 props.defaultActiveId,
11829 null
11830 );
11831 const composite = createCompositeStore({
11832 ...props,
11833 activeId,
11834 includesBaseElement: defaultValue(
11835 props.includesBaseElement,
11836 syncState == null ? void 0 : syncState.includesBaseElement,
11837 true
11838 ),
11839 orientation: defaultValue(
11840 props.orientation,
11841 syncState == null ? void 0 : syncState.orientation,
11842 "vertical"
11843 ),
11844 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
11845 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
11846 virtualFocus: defaultValue(
11847 props.virtualFocus,
11848 syncState == null ? void 0 : syncState.virtualFocus,
11849 true
11850 )
11851 });
11852 const popover = createPopoverStore({
11853 ...props,
11854 placement: defaultValue(
11855 props.placement,
11856 syncState == null ? void 0 : syncState.placement,
11857 "bottom-start"
11858 )
11859 });
11860 const value = defaultValue(
11861 props.value,
11862 syncState == null ? void 0 : syncState.value,
11863 props.defaultValue,
11864 ""
11865 );
11866 const selectedValue = defaultValue(
11867 props.selectedValue,
11868 syncState == null ? void 0 : syncState.selectedValue,
11869 tagState == null ? void 0 : tagState.values,
11870 props.defaultSelectedValue,
11871 ""
11872 );
11873 const multiSelectable = Array.isArray(selectedValue);
11874 const initialState = {
11875 ...composite.getState(),
11876 ...popover.getState(),
11877 value,
11878 selectedValue,
11879 resetValueOnSelect: defaultValue(
11880 props.resetValueOnSelect,
11881 syncState == null ? void 0 : syncState.resetValueOnSelect,
11882 multiSelectable
11883 ),
11884 resetValueOnHide: defaultValue(
11885 props.resetValueOnHide,
11886 syncState == null ? void 0 : syncState.resetValueOnHide,
11887 multiSelectable && !tag
11888 ),
11889 activeValue: syncState == null ? void 0 : syncState.activeValue
11890 };
11891 const combobox = createStore(initialState, composite, popover, store2);
11892 if (isTouchSafari) {
11893 setup(
11894 combobox,
11895 () => sync(combobox, ["virtualFocus"], () => {
11896 combobox.setState("virtualFocus", false);
11897 })
11898 );
11899 }
11900 setup(combobox, () => {
11901 if (!tag) return;
11902 return chain(
11903 sync(combobox, ["selectedValue"], (state) => {
11904 if (!Array.isArray(state.selectedValue)) return;
11905 tag.setValues(state.selectedValue);
11906 }),
11907 sync(tag, ["values"], (state) => {
11908 combobox.setState("selectedValue", state.values);
11909 })
11910 );
11911 });
11912 setup(
11913 combobox,
11914 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
11915 if (!state.resetValueOnHide) return;
11916 if (state.mounted) return;
11917 combobox.setState("value", value);
11918 })
11919 );
11920 setup(
11921 combobox,
11922 () => sync(combobox, ["open"], (state) => {
11923 if (state.open) return;
11924 combobox.setState("activeId", activeId);
11925 combobox.setState("moves", 0);
11926 })
11927 );
11928 setup(
11929 combobox,
11930 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
11931 if (state.moves === prevState.moves) {
11932 combobox.setState("activeValue", void 0);
11933 }
11934 })
11935 );
11936 setup(
11937 combobox,
11938 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
11939 if (state.moves === prev.moves) return;
11940 const { activeId: activeId2 } = combobox.getState();
11941 const activeItem = composite.item(activeId2);
11942 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
11943 })
11944 );
11945 return {
11946 ...popover,
11947 ...composite,
11948 ...combobox,
11949 tag,
11950 setValue: (value2) => combobox.setState("value", value2),
11951 resetValue: () => combobox.setState("value", initialState.value),
11952 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
11953 };
11954 }
11955
11956 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
11957 function useComboboxStoreOptions(props) {
11958 const tag = useTagContext();
11959 props = {
11960 ...props,
11961 tag: props.tag !== void 0 ? props.tag : tag
11962 };
11963 return useCompositeStoreOptions(props);
11964 }
11965 function useComboboxStoreProps(store2, update2, props) {
11966 useUpdateEffect(update2, [props.tag]);
11967 useStoreProps(store2, props, "value", "setValue");
11968 useStoreProps(store2, props, "selectedValue", "setSelectedValue");
11969 useStoreProps(store2, props, "resetValueOnHide");
11970 useStoreProps(store2, props, "resetValueOnSelect");
11971 return Object.assign(
11972 useCompositeStoreProps(
11973 usePopoverStoreProps(store2, update2, props),
11974 update2,
11975 props
11976 ),
11977 { tag: props.tag }
11978 );
11979 }
11980 function useComboboxStore(props = {}) {
11981 props = useComboboxStoreOptions(props);
11982 const [store2, update2] = useStore(createComboboxStore, props);
11983 return useComboboxStoreProps(store2, update2, props);
11984 }
11985
11986 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
11987 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
11988 function ComboboxProvider(props = {}) {
11989 const store2 = useComboboxStore(props);
11990 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ComboboxContextProvider, { value: store2, children: props.children });
11991 }
11992
11993 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
11994 var import_remove_accents = __toESM(require_remove_accents(), 1);
11995 var import_compose7 = __toESM(require_compose(), 1);
11996 var import_i18n23 = __toESM(require_i18n(), 1);
11997 var import_element43 = __toESM(require_element(), 1);
11998 var import_components21 = __toESM(require_components(), 1);
11999
12000 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
12001 var EMPTY_ARRAY3 = [];
12002 var getCurrentValue = (filterDefinition, currentFilter) => {
12003 if (filterDefinition.singleSelection) {
12004 return currentFilter?.value;
12005 }
12006 if (Array.isArray(currentFilter?.value)) {
12007 return currentFilter.value;
12008 }
12009 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
12010 return [currentFilter.value];
12011 }
12012 return EMPTY_ARRAY3;
12013 };
12014
12015 // packages/dataviews/build-module/hooks/use-elements.mjs
12016 var import_element42 = __toESM(require_element(), 1);
12017 var EMPTY_ARRAY4 = [];
12018 function useElements({
12019 elements,
12020 getElements
12021 }) {
12022 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
12023 const [records, setRecords] = (0, import_element42.useState)(staticElements);
12024 const [isLoading, setIsLoading] = (0, import_element42.useState)(false);
12025 (0, import_element42.useEffect)(() => {
12026 if (!getElements) {
12027 setRecords(staticElements);
12028 return;
12029 }
12030 let cancelled = false;
12031 setIsLoading(true);
12032 getElements().then((fetchedElements) => {
12033 if (!cancelled) {
12034 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
12035 setRecords(dynamicElements);
12036 }
12037 }).catch(() => {
12038 if (!cancelled) {
12039 setRecords(staticElements);
12040 }
12041 }).finally(() => {
12042 if (!cancelled) {
12043 setIsLoading(false);
12044 }
12045 });
12046 return () => {
12047 cancelled = true;
12048 };
12049 }, [getElements, staticElements]);
12050 return {
12051 elements: records,
12052 isLoading
12053 };
12054 }
12055
12056 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
12057 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
12058 function normalizeSearchInput(input = "") {
12059 return (0, import_remove_accents.default)(input.trim().toLowerCase());
12060 }
12061 var getNewValue = (filterDefinition, currentFilter, value) => {
12062 if (filterDefinition.singleSelection) {
12063 return value;
12064 }
12065 if (Array.isArray(currentFilter?.value)) {
12066 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
12067 }
12068 return [value];
12069 };
12070 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
12071 return `${prefix}-${filterElementValue}`;
12072 }
12073 var MultiSelectionOption = ({ selected }) => {
12074 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12075 "span",
12076 {
12077 className: clsx_default(
12078 "dataviews-filters__search-widget-listitem-multi-selection",
12079 { "is-selected": selected }
12080 ),
12081 children: selected && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components21.Icon, { icon: check_default })
12082 }
12083 );
12084 };
12085 var SingleSelectionOption = ({ selected }) => {
12086 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12087 "span",
12088 {
12089 className: clsx_default(
12090 "dataviews-filters__search-widget-listitem-single-selection",
12091 { "is-selected": selected }
12092 )
12093 }
12094 );
12095 };
12096 function ListBox({ view, filter, onChangeView }) {
12097 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
12098 const [activeCompositeId, setActiveCompositeId] = (0, import_element43.useState)(
12099 // When there are one or less operators, the first item is set as active
12100 // (by setting the initial `activeId` to `undefined`).
12101 // With 2 or more operators, the focus is moved on the operators control
12102 // (by setting the initial `activeId` to `null`), meaning that there won't
12103 // be an active item initially. Focus is then managed via the
12104 // `onFocusVisible` callback.
12105 filter.operators?.length === 1 ? void 0 : null
12106 );
12107 const currentFilter = view.filters?.find(
12108 (f2) => f2.field === filter.field
12109 );
12110 const currentValue = getCurrentValue(filter, currentFilter);
12111 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12112 import_components21.Composite,
12113 {
12114 virtualFocus: true,
12115 focusLoop: true,
12116 activeId: activeCompositeId,
12117 setActiveId: setActiveCompositeId,
12118 role: "listbox",
12119 className: "dataviews-filters__search-widget-listbox",
12120 "aria-label": (0, import_i18n23.sprintf)(
12121 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
12122 (0, import_i18n23.__)("List of: %1$s"),
12123 filter.name
12124 ),
12125 onFocusVisible: () => {
12126 if (!activeCompositeId && filter.elements.length) {
12127 setActiveCompositeId(
12128 generateFilterElementCompositeItemId(
12129 baseId,
12130 filter.elements[0].value
12131 )
12132 );
12133 }
12134 },
12135 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components21.Composite.Typeahead, {}),
12136 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12137 import_components21.Composite.Hover,
12138 {
12139 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12140 import_components21.Composite.Item,
12141 {
12142 id: generateFilterElementCompositeItemId(
12143 baseId,
12144 element.value
12145 ),
12146 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12147 "div",
12148 {
12149 "aria-label": element.label,
12150 role: "option",
12151 className: "dataviews-filters__search-widget-listitem"
12152 }
12153 ),
12154 onClick: () => {
12155 const newFilters = currentFilter ? [
12156 ...(view.filters ?? []).map(
12157 (_filter) => {
12158 if (_filter.field === filter.field) {
12159 return {
12160 ..._filter,
12161 operator: currentFilter.operator || filter.operators[0],
12162 value: getNewValue(
12163 filter,
12164 currentFilter,
12165 element.value
12166 )
12167 };
12168 }
12169 return _filter;
12170 }
12171 )
12172 ] : [
12173 ...view.filters ?? [],
12174 {
12175 field: filter.field,
12176 operator: filter.operators[0],
12177 value: getNewValue(
12178 filter,
12179 currentFilter,
12180 element.value
12181 )
12182 }
12183 ];
12184 onChangeView({
12185 ...view,
12186 page: 1,
12187 filters: newFilters
12188 });
12189 }
12190 }
12191 ),
12192 children: [
12193 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12194 SingleSelectionOption,
12195 {
12196 selected: currentValue === element.value
12197 }
12198 ),
12199 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12200 MultiSelectionOption,
12201 {
12202 selected: currentValue.includes(element.value)
12203 }
12204 ),
12205 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12206 "span",
12207 {
12208 className: "dataviews-filters__search-widget-listitem-value",
12209 title: element.label,
12210 children: element.label
12211 }
12212 )
12213 ]
12214 },
12215 element.value
12216 ))
12217 }
12218 );
12219 }
12220 function ComboboxList22({ view, filter, onChangeView }) {
12221 const [searchValue, setSearchValue] = (0, import_element43.useState)("");
12222 const deferredSearchValue = (0, import_element43.useDeferredValue)(searchValue);
12223 const currentFilter = view.filters?.find(
12224 (_filter) => _filter.field === filter.field
12225 );
12226 const currentValue = getCurrentValue(filter, currentFilter);
12227 const matches = (0, import_element43.useMemo)(() => {
12228 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
12229 return filter.elements.filter(
12230 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
12231 );
12232 }, [filter.elements, deferredSearchValue]);
12233 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12234 ComboboxProvider,
12235 {
12236 selectedValue: currentValue,
12237 setSelectedValue: (value) => {
12238 const newFilters = currentFilter ? [
12239 ...(view.filters ?? []).map((_filter) => {
12240 if (_filter.field === filter.field) {
12241 return {
12242 ..._filter,
12243 operator: currentFilter.operator || filter.operators[0],
12244 value
12245 };
12246 }
12247 return _filter;
12248 })
12249 ] : [
12250 ...view.filters ?? [],
12251 {
12252 field: filter.field,
12253 operator: filter.operators[0],
12254 value
12255 }
12256 ];
12257 onChangeView({
12258 ...view,
12259 page: 1,
12260 filters: newFilters
12261 });
12262 },
12263 setValue: setSearchValue,
12264 children: [
12265 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
12266 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12267 ComboboxLabel,
12268 {
12269 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components21.VisuallyHidden, { children: (0, import_i18n23.__)("Search items") }),
12270 children: (0, import_i18n23.__)("Search items")
12271 }
12272 ),
12273 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12274 Combobox,
12275 {
12276 autoSelect: "always",
12277 placeholder: (0, import_i18n23.__)("Search"),
12278 className: "dataviews-filters__search-widget-filter-combobox__input"
12279 }
12280 ),
12281 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components21.Icon, { icon: search_default }) })
12282 ] }),
12283 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12284 ComboboxList,
12285 {
12286 className: "dataviews-filters__search-widget-filter-combobox-list",
12287 alwaysVisible: true,
12288 children: [
12289 matches.map((element) => {
12290 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12291 ComboboxItem,
12292 {
12293 resetValueOnSelect: false,
12294 value: element.value,
12295 className: "dataviews-filters__search-widget-listitem",
12296 hideOnClick: false,
12297 setValueOnClick: false,
12298 focusOnHover: true,
12299 children: [
12300 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12301 SingleSelectionOption,
12302 {
12303 selected: currentValue === element.value
12304 }
12305 ),
12306 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12307 MultiSelectionOption,
12308 {
12309 selected: currentValue.includes(
12310 element.value
12311 )
12312 }
12313 ),
12314 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12315 "span",
12316 {
12317 className: "dataviews-filters__search-widget-listitem-value",
12318 title: element.label,
12319 children: [
12320 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12321 ComboboxItemValue,
12322 {
12323 className: "dataviews-filters__search-widget-filter-combobox-item-value",
12324 value: element.label
12325 }
12326 ),
12327 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
12328 ]
12329 }
12330 )
12331 ]
12332 },
12333 element.value
12334 );
12335 }),
12336 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
12337 ]
12338 }
12339 )
12340 ]
12341 }
12342 );
12343 }
12344 function SearchWidget(props) {
12345 const { elements, isLoading } = useElements({
12346 elements: props.filter.elements,
12347 getElements: props.filter.getElements
12348 });
12349 if (isLoading) {
12350 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components21.Spinner, {}) });
12351 }
12352 if (elements.length === 0) {
12353 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
12354 }
12355 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
12356 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
12357 }
12358
12359 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
12360 var import_es6 = __toESM(require_es6(), 1);
12361 var import_compose8 = __toESM(require_compose(), 1);
12362 var import_element44 = __toESM(require_element(), 1);
12363 var import_components22 = __toESM(require_components(), 1);
12364 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
12365 function InputWidget({
12366 filter,
12367 view,
12368 onChangeView,
12369 fields: fields2
12370 }) {
12371 const currentFilter = view.filters?.find(
12372 (f2) => f2.field === filter.field
12373 );
12374 const currentValue = getCurrentValue(filter, currentFilter);
12375 const field = (0, import_element44.useMemo)(() => {
12376 const currentField = fields2.find((f2) => f2.id === filter.field);
12377 if (currentField) {
12378 return {
12379 ...currentField,
12380 // Deactivate validation for filters.
12381 isValid: {},
12382 // Filter controls are always enabled.
12383 isDisabled: () => false,
12384 // Filter controls are always visible.
12385 isVisible: () => true,
12386 // Configure getValue/setValue as if Item was a plain object.
12387 getValue: ({ item }) => item[currentField.id],
12388 setValue: ({ value }) => ({
12389 [currentField.id]: value
12390 })
12391 };
12392 }
12393 return currentField;
12394 }, [fields2, filter.field]);
12395 const data = (0, import_element44.useMemo)(() => {
12396 return (view.filters ?? []).reduce(
12397 (acc, activeFilter) => {
12398 acc[activeFilter.field] = activeFilter.value;
12399 return acc;
12400 },
12401 {}
12402 );
12403 }, [view.filters]);
12404 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
12405 if (!field || !currentFilter) {
12406 return;
12407 }
12408 const nextValue = field.getValue({ item: updatedData });
12409 if ((0, import_es6.default)(nextValue, currentValue)) {
12410 return;
12411 }
12412 onChangeView({
12413 ...view,
12414 filters: (view.filters ?? []).map(
12415 (_filter) => _filter.field === filter.field ? {
12416 ..._filter,
12417 operator: currentFilter.operator || filter.operators[0],
12418 // Consider empty strings as undefined:
12419 //
12420 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
12421 // - empty string as value means "search empty string": returns only the records that have an empty string as value
12422 //
12423 // In practice, this means the filter will not be able to find an empty string as the value.
12424 value: nextValue === "" ? void 0 : nextValue
12425 } : _filter
12426 )
12427 });
12428 });
12429 if (!field || !field.Edit || !currentFilter) {
12430 return null;
12431 }
12432 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
12433 import_components22.Flex,
12434 {
12435 className: "dataviews-filters__user-input-widget",
12436 gap: 2.5,
12437 direction: "column",
12438 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
12439 field.Edit,
12440 {
12441 hideLabelFromVision: true,
12442 data,
12443 field,
12444 operator: currentFilter.operator,
12445 onChange: handleChange
12446 }
12447 )
12448 }
12449 );
12450 }
12451
12452 // packages/dataviews/node_modules/date-fns/constants.js
12453 var daysInYear = 365.2425;
12454 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
12455 var minTime = -maxTime;
12456 var millisecondsInWeek = 6048e5;
12457 var millisecondsInDay = 864e5;
12458 var secondsInHour = 3600;
12459 var secondsInDay = secondsInHour * 24;
12460 var secondsInWeek = secondsInDay * 7;
12461 var secondsInYear = secondsInDay * daysInYear;
12462 var secondsInMonth = secondsInYear / 12;
12463 var secondsInQuarter = secondsInMonth * 3;
12464 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
12465
12466 // packages/dataviews/node_modules/date-fns/constructFrom.js
12467 function constructFrom(date, value) {
12468 if (typeof date === "function") return date(value);
12469 if (date && typeof date === "object" && constructFromSymbol in date)
12470 return date[constructFromSymbol](value);
12471 if (date instanceof Date) return new date.constructor(value);
12472 return new Date(value);
12473 }
12474
12475 // packages/dataviews/node_modules/date-fns/toDate.js
12476 function toDate(argument, context) {
12477 return constructFrom(context || argument, argument);
12478 }
12479
12480 // packages/dataviews/node_modules/date-fns/addDays.js
12481 function addDays(date, amount, options) {
12482 const _date = toDate(date, options?.in);
12483 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
12484 if (!amount) return _date;
12485 _date.setDate(_date.getDate() + amount);
12486 return _date;
12487 }
12488
12489 // packages/dataviews/node_modules/date-fns/addMonths.js
12490 function addMonths(date, amount, options) {
12491 const _date = toDate(date, options?.in);
12492 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
12493 if (!amount) {
12494 return _date;
12495 }
12496 const dayOfMonth = _date.getDate();
12497 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
12498 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
12499 const daysInMonth = endOfDesiredMonth.getDate();
12500 if (dayOfMonth >= daysInMonth) {
12501 return endOfDesiredMonth;
12502 } else {
12503 _date.setFullYear(
12504 endOfDesiredMonth.getFullYear(),
12505 endOfDesiredMonth.getMonth(),
12506 dayOfMonth
12507 );
12508 return _date;
12509 }
12510 }
12511
12512 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
12513 var defaultOptions = {};
12514 function getDefaultOptions() {
12515 return defaultOptions;
12516 }
12517
12518 // packages/dataviews/node_modules/date-fns/startOfWeek.js
12519 function startOfWeek(date, options) {
12520 const defaultOptions2 = getDefaultOptions();
12521 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
12522 const _date = toDate(date, options?.in);
12523 const day = _date.getDay();
12524 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
12525 _date.setDate(_date.getDate() - diff);
12526 _date.setHours(0, 0, 0, 0);
12527 return _date;
12528 }
12529
12530 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
12531 function startOfISOWeek(date, options) {
12532 return startOfWeek(date, { ...options, weekStartsOn: 1 });
12533 }
12534
12535 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
12536 function getISOWeekYear(date, options) {
12537 const _date = toDate(date, options?.in);
12538 const year = _date.getFullYear();
12539 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
12540 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
12541 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
12542 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
12543 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
12544 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
12545 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
12546 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
12547 if (_date.getTime() >= startOfNextYear.getTime()) {
12548 return year + 1;
12549 } else if (_date.getTime() >= startOfThisYear.getTime()) {
12550 return year;
12551 } else {
12552 return year - 1;
12553 }
12554 }
12555
12556 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
12557 function getTimezoneOffsetInMilliseconds(date) {
12558 const _date = toDate(date);
12559 const utcDate = new Date(
12560 Date.UTC(
12561 _date.getFullYear(),
12562 _date.getMonth(),
12563 _date.getDate(),
12564 _date.getHours(),
12565 _date.getMinutes(),
12566 _date.getSeconds(),
12567 _date.getMilliseconds()
12568 )
12569 );
12570 utcDate.setUTCFullYear(_date.getFullYear());
12571 return +date - +utcDate;
12572 }
12573
12574 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
12575 function normalizeDates(context, ...dates) {
12576 const normalize = constructFrom.bind(
12577 null,
12578 context || dates.find((date) => typeof date === "object")
12579 );
12580 return dates.map(normalize);
12581 }
12582
12583 // packages/dataviews/node_modules/date-fns/startOfDay.js
12584 function startOfDay(date, options) {
12585 const _date = toDate(date, options?.in);
12586 _date.setHours(0, 0, 0, 0);
12587 return _date;
12588 }
12589
12590 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
12591 function differenceInCalendarDays(laterDate, earlierDate, options) {
12592 const [laterDate_, earlierDate_] = normalizeDates(
12593 options?.in,
12594 laterDate,
12595 earlierDate
12596 );
12597 const laterStartOfDay = startOfDay(laterDate_);
12598 const earlierStartOfDay = startOfDay(earlierDate_);
12599 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
12600 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
12601 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
12602 }
12603
12604 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
12605 function startOfISOWeekYear(date, options) {
12606 const year = getISOWeekYear(date, options);
12607 const fourthOfJanuary = constructFrom(options?.in || date, 0);
12608 fourthOfJanuary.setFullYear(year, 0, 4);
12609 fourthOfJanuary.setHours(0, 0, 0, 0);
12610 return startOfISOWeek(fourthOfJanuary);
12611 }
12612
12613 // packages/dataviews/node_modules/date-fns/addWeeks.js
12614 function addWeeks(date, amount, options) {
12615 return addDays(date, amount * 7, options);
12616 }
12617
12618 // packages/dataviews/node_modules/date-fns/addYears.js
12619 function addYears(date, amount, options) {
12620 return addMonths(date, amount * 12, options);
12621 }
12622
12623 // packages/dataviews/node_modules/date-fns/isDate.js
12624 function isDate(value) {
12625 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
12626 }
12627
12628 // packages/dataviews/node_modules/date-fns/isValid.js
12629 function isValid(date) {
12630 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
12631 }
12632
12633 // packages/dataviews/node_modules/date-fns/startOfMonth.js
12634 function startOfMonth(date, options) {
12635 const _date = toDate(date, options?.in);
12636 _date.setDate(1);
12637 _date.setHours(0, 0, 0, 0);
12638 return _date;
12639 }
12640
12641 // packages/dataviews/node_modules/date-fns/startOfYear.js
12642 function startOfYear(date, options) {
12643 const date_ = toDate(date, options?.in);
12644 date_.setFullYear(date_.getFullYear(), 0, 1);
12645 date_.setHours(0, 0, 0, 0);
12646 return date_;
12647 }
12648
12649 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
12650 var formatDistanceLocale = {
12651 lessThanXSeconds: {
12652 one: "less than a second",
12653 other: "less than {{count}} seconds"
12654 },
12655 xSeconds: {
12656 one: "1 second",
12657 other: "{{count}} seconds"
12658 },
12659 halfAMinute: "half a minute",
12660 lessThanXMinutes: {
12661 one: "less than a minute",
12662 other: "less than {{count}} minutes"
12663 },
12664 xMinutes: {
12665 one: "1 minute",
12666 other: "{{count}} minutes"
12667 },
12668 aboutXHours: {
12669 one: "about 1 hour",
12670 other: "about {{count}} hours"
12671 },
12672 xHours: {
12673 one: "1 hour",
12674 other: "{{count}} hours"
12675 },
12676 xDays: {
12677 one: "1 day",
12678 other: "{{count}} days"
12679 },
12680 aboutXWeeks: {
12681 one: "about 1 week",
12682 other: "about {{count}} weeks"
12683 },
12684 xWeeks: {
12685 one: "1 week",
12686 other: "{{count}} weeks"
12687 },
12688 aboutXMonths: {
12689 one: "about 1 month",
12690 other: "about {{count}} months"
12691 },
12692 xMonths: {
12693 one: "1 month",
12694 other: "{{count}} months"
12695 },
12696 aboutXYears: {
12697 one: "about 1 year",
12698 other: "about {{count}} years"
12699 },
12700 xYears: {
12701 one: "1 year",
12702 other: "{{count}} years"
12703 },
12704 overXYears: {
12705 one: "over 1 year",
12706 other: "over {{count}} years"
12707 },
12708 almostXYears: {
12709 one: "almost 1 year",
12710 other: "almost {{count}} years"
12711 }
12712 };
12713 var formatDistance = (token, count, options) => {
12714 let result;
12715 const tokenValue = formatDistanceLocale[token];
12716 if (typeof tokenValue === "string") {
12717 result = tokenValue;
12718 } else if (count === 1) {
12719 result = tokenValue.one;
12720 } else {
12721 result = tokenValue.other.replace("{{count}}", count.toString());
12722 }
12723 if (options?.addSuffix) {
12724 if (options.comparison && options.comparison > 0) {
12725 return "in " + result;
12726 } else {
12727 return result + " ago";
12728 }
12729 }
12730 return result;
12731 };
12732
12733 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
12734 function buildFormatLongFn(args) {
12735 return (options = {}) => {
12736 const width = options.width ? String(options.width) : args.defaultWidth;
12737 const format6 = args.formats[width] || args.formats[args.defaultWidth];
12738 return format6;
12739 };
12740 }
12741
12742 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
12743 var dateFormats = {
12744 full: "EEEE, MMMM do, y",
12745 long: "MMMM do, y",
12746 medium: "MMM d, y",
12747 short: "MM/dd/yyyy"
12748 };
12749 var timeFormats = {
12750 full: "h:mm:ss a zzzz",
12751 long: "h:mm:ss a z",
12752 medium: "h:mm:ss a",
12753 short: "h:mm a"
12754 };
12755 var dateTimeFormats = {
12756 full: "{{date}} 'at' {{time}}",
12757 long: "{{date}} 'at' {{time}}",
12758 medium: "{{date}}, {{time}}",
12759 short: "{{date}}, {{time}}"
12760 };
12761 var formatLong = {
12762 date: buildFormatLongFn({
12763 formats: dateFormats,
12764 defaultWidth: "full"
12765 }),
12766 time: buildFormatLongFn({
12767 formats: timeFormats,
12768 defaultWidth: "full"
12769 }),
12770 dateTime: buildFormatLongFn({
12771 formats: dateTimeFormats,
12772 defaultWidth: "full"
12773 })
12774 };
12775
12776 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
12777 var formatRelativeLocale = {
12778 lastWeek: "'last' eeee 'at' p",
12779 yesterday: "'yesterday at' p",
12780 today: "'today at' p",
12781 tomorrow: "'tomorrow at' p",
12782 nextWeek: "eeee 'at' p",
12783 other: "P"
12784 };
12785 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
12786
12787 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
12788 function buildLocalizeFn(args) {
12789 return (value, options) => {
12790 const context = options?.context ? String(options.context) : "standalone";
12791 let valuesArray;
12792 if (context === "formatting" && args.formattingValues) {
12793 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
12794 const width = options?.width ? String(options.width) : defaultWidth;
12795 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
12796 } else {
12797 const defaultWidth = args.defaultWidth;
12798 const width = options?.width ? String(options.width) : args.defaultWidth;
12799 valuesArray = args.values[width] || args.values[defaultWidth];
12800 }
12801 const index = args.argumentCallback ? args.argumentCallback(value) : value;
12802 return valuesArray[index];
12803 };
12804 }
12805
12806 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
12807 var eraValues = {
12808 narrow: ["B", "A"],
12809 abbreviated: ["BC", "AD"],
12810 wide: ["Before Christ", "Anno Domini"]
12811 };
12812 var quarterValues = {
12813 narrow: ["1", "2", "3", "4"],
12814 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
12815 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
12816 };
12817 var monthValues = {
12818 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
12819 abbreviated: [
12820 "Jan",
12821 "Feb",
12822 "Mar",
12823 "Apr",
12824 "May",
12825 "Jun",
12826 "Jul",
12827 "Aug",
12828 "Sep",
12829 "Oct",
12830 "Nov",
12831 "Dec"
12832 ],
12833 wide: [
12834 "January",
12835 "February",
12836 "March",
12837 "April",
12838 "May",
12839 "June",
12840 "July",
12841 "August",
12842 "September",
12843 "October",
12844 "November",
12845 "December"
12846 ]
12847 };
12848 var dayValues = {
12849 narrow: ["S", "M", "T", "W", "T", "F", "S"],
12850 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
12851 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
12852 wide: [
12853 "Sunday",
12854 "Monday",
12855 "Tuesday",
12856 "Wednesday",
12857 "Thursday",
12858 "Friday",
12859 "Saturday"
12860 ]
12861 };
12862 var dayPeriodValues = {
12863 narrow: {
12864 am: "a",
12865 pm: "p",
12866 midnight: "mi",
12867 noon: "n",
12868 morning: "morning",
12869 afternoon: "afternoon",
12870 evening: "evening",
12871 night: "night"
12872 },
12873 abbreviated: {
12874 am: "AM",
12875 pm: "PM",
12876 midnight: "midnight",
12877 noon: "noon",
12878 morning: "morning",
12879 afternoon: "afternoon",
12880 evening: "evening",
12881 night: "night"
12882 },
12883 wide: {
12884 am: "a.m.",
12885 pm: "p.m.",
12886 midnight: "midnight",
12887 noon: "noon",
12888 morning: "morning",
12889 afternoon: "afternoon",
12890 evening: "evening",
12891 night: "night"
12892 }
12893 };
12894 var formattingDayPeriodValues = {
12895 narrow: {
12896 am: "a",
12897 pm: "p",
12898 midnight: "mi",
12899 noon: "n",
12900 morning: "in the morning",
12901 afternoon: "in the afternoon",
12902 evening: "in the evening",
12903 night: "at night"
12904 },
12905 abbreviated: {
12906 am: "AM",
12907 pm: "PM",
12908 midnight: "midnight",
12909 noon: "noon",
12910 morning: "in the morning",
12911 afternoon: "in the afternoon",
12912 evening: "in the evening",
12913 night: "at night"
12914 },
12915 wide: {
12916 am: "a.m.",
12917 pm: "p.m.",
12918 midnight: "midnight",
12919 noon: "noon",
12920 morning: "in the morning",
12921 afternoon: "in the afternoon",
12922 evening: "in the evening",
12923 night: "at night"
12924 }
12925 };
12926 var ordinalNumber = (dirtyNumber, _options) => {
12927 const number = Number(dirtyNumber);
12928 const rem100 = number % 100;
12929 if (rem100 > 20 || rem100 < 10) {
12930 switch (rem100 % 10) {
12931 case 1:
12932 return number + "st";
12933 case 2:
12934 return number + "nd";
12935 case 3:
12936 return number + "rd";
12937 }
12938 }
12939 return number + "th";
12940 };
12941 var localize = {
12942 ordinalNumber,
12943 era: buildLocalizeFn({
12944 values: eraValues,
12945 defaultWidth: "wide"
12946 }),
12947 quarter: buildLocalizeFn({
12948 values: quarterValues,
12949 defaultWidth: "wide",
12950 argumentCallback: (quarter) => quarter - 1
12951 }),
12952 month: buildLocalizeFn({
12953 values: monthValues,
12954 defaultWidth: "wide"
12955 }),
12956 day: buildLocalizeFn({
12957 values: dayValues,
12958 defaultWidth: "wide"
12959 }),
12960 dayPeriod: buildLocalizeFn({
12961 values: dayPeriodValues,
12962 defaultWidth: "wide",
12963 formattingValues: formattingDayPeriodValues,
12964 defaultFormattingWidth: "wide"
12965 })
12966 };
12967
12968 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
12969 function buildMatchFn(args) {
12970 return (string, options = {}) => {
12971 const width = options.width;
12972 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
12973 const matchResult = string.match(matchPattern);
12974 if (!matchResult) {
12975 return null;
12976 }
12977 const matchedString = matchResult[0];
12978 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
12979 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
12980 // [TODO] -- I challenge you to fix the type
12981 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
12982 );
12983 let value;
12984 value = args.valueCallback ? args.valueCallback(key) : key;
12985 value = options.valueCallback ? (
12986 // [TODO] -- I challenge you to fix the type
12987 options.valueCallback(value)
12988 ) : value;
12989 const rest = string.slice(matchedString.length);
12990 return { value, rest };
12991 };
12992 }
12993 function findKey(object, predicate) {
12994 for (const key in object) {
12995 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
12996 return key;
12997 }
12998 }
12999 return void 0;
13000 }
13001 function findIndex(array, predicate) {
13002 for (let key = 0; key < array.length; key++) {
13003 if (predicate(array[key])) {
13004 return key;
13005 }
13006 }
13007 return void 0;
13008 }
13009
13010 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
13011 function buildMatchPatternFn(args) {
13012 return (string, options = {}) => {
13013 const matchResult = string.match(args.matchPattern);
13014 if (!matchResult) return null;
13015 const matchedString = matchResult[0];
13016 const parseResult = string.match(args.parsePattern);
13017 if (!parseResult) return null;
13018 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
13019 value = options.valueCallback ? options.valueCallback(value) : value;
13020 const rest = string.slice(matchedString.length);
13021 return { value, rest };
13022 };
13023 }
13024
13025 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
13026 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
13027 var parseOrdinalNumberPattern = /\d+/i;
13028 var matchEraPatterns = {
13029 narrow: /^(b|a)/i,
13030 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
13031 wide: /^(before christ|before common era|anno domini|common era)/i
13032 };
13033 var parseEraPatterns = {
13034 any: [/^b/i, /^(a|c)/i]
13035 };
13036 var matchQuarterPatterns = {
13037 narrow: /^[1234]/i,
13038 abbreviated: /^q[1234]/i,
13039 wide: /^[1234](th|st|nd|rd)? quarter/i
13040 };
13041 var parseQuarterPatterns = {
13042 any: [/1/i, /2/i, /3/i, /4/i]
13043 };
13044 var matchMonthPatterns = {
13045 narrow: /^[jfmasond]/i,
13046 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
13047 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
13048 };
13049 var parseMonthPatterns = {
13050 narrow: [
13051 /^j/i,
13052 /^f/i,
13053 /^m/i,
13054 /^a/i,
13055 /^m/i,
13056 /^j/i,
13057 /^j/i,
13058 /^a/i,
13059 /^s/i,
13060 /^o/i,
13061 /^n/i,
13062 /^d/i
13063 ],
13064 any: [
13065 /^ja/i,
13066 /^f/i,
13067 /^mar/i,
13068 /^ap/i,
13069 /^may/i,
13070 /^jun/i,
13071 /^jul/i,
13072 /^au/i,
13073 /^s/i,
13074 /^o/i,
13075 /^n/i,
13076 /^d/i
13077 ]
13078 };
13079 var matchDayPatterns = {
13080 narrow: /^[smtwf]/i,
13081 short: /^(su|mo|tu|we|th|fr|sa)/i,
13082 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
13083 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
13084 };
13085 var parseDayPatterns = {
13086 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
13087 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
13088 };
13089 var matchDayPeriodPatterns = {
13090 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
13091 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
13092 };
13093 var parseDayPeriodPatterns = {
13094 any: {
13095 am: /^a/i,
13096 pm: /^p/i,
13097 midnight: /^mi/i,
13098 noon: /^no/i,
13099 morning: /morning/i,
13100 afternoon: /afternoon/i,
13101 evening: /evening/i,
13102 night: /night/i
13103 }
13104 };
13105 var match = {
13106 ordinalNumber: buildMatchPatternFn({
13107 matchPattern: matchOrdinalNumberPattern,
13108 parsePattern: parseOrdinalNumberPattern,
13109 valueCallback: (value) => parseInt(value, 10)
13110 }),
13111 era: buildMatchFn({
13112 matchPatterns: matchEraPatterns,
13113 defaultMatchWidth: "wide",
13114 parsePatterns: parseEraPatterns,
13115 defaultParseWidth: "any"
13116 }),
13117 quarter: buildMatchFn({
13118 matchPatterns: matchQuarterPatterns,
13119 defaultMatchWidth: "wide",
13120 parsePatterns: parseQuarterPatterns,
13121 defaultParseWidth: "any",
13122 valueCallback: (index) => index + 1
13123 }),
13124 month: buildMatchFn({
13125 matchPatterns: matchMonthPatterns,
13126 defaultMatchWidth: "wide",
13127 parsePatterns: parseMonthPatterns,
13128 defaultParseWidth: "any"
13129 }),
13130 day: buildMatchFn({
13131 matchPatterns: matchDayPatterns,
13132 defaultMatchWidth: "wide",
13133 parsePatterns: parseDayPatterns,
13134 defaultParseWidth: "any"
13135 }),
13136 dayPeriod: buildMatchFn({
13137 matchPatterns: matchDayPeriodPatterns,
13138 defaultMatchWidth: "any",
13139 parsePatterns: parseDayPeriodPatterns,
13140 defaultParseWidth: "any"
13141 })
13142 };
13143
13144 // packages/dataviews/node_modules/date-fns/locale/en-US.js
13145 var enUS = {
13146 code: "en-US",
13147 formatDistance,
13148 formatLong,
13149 formatRelative,
13150 localize,
13151 match,
13152 options: {
13153 weekStartsOn: 0,
13154 firstWeekContainsDate: 1
13155 }
13156 };
13157
13158 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
13159 function getDayOfYear(date, options) {
13160 const _date = toDate(date, options?.in);
13161 const diff = differenceInCalendarDays(_date, startOfYear(_date));
13162 const dayOfYear = diff + 1;
13163 return dayOfYear;
13164 }
13165
13166 // packages/dataviews/node_modules/date-fns/getISOWeek.js
13167 function getISOWeek(date, options) {
13168 const _date = toDate(date, options?.in);
13169 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
13170 return Math.round(diff / millisecondsInWeek) + 1;
13171 }
13172
13173 // packages/dataviews/node_modules/date-fns/getWeekYear.js
13174 function getWeekYear(date, options) {
13175 const _date = toDate(date, options?.in);
13176 const year = _date.getFullYear();
13177 const defaultOptions2 = getDefaultOptions();
13178 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
13179 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
13180 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
13181 firstWeekOfNextYear.setHours(0, 0, 0, 0);
13182 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
13183 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
13184 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
13185 firstWeekOfThisYear.setHours(0, 0, 0, 0);
13186 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
13187 if (+_date >= +startOfNextYear) {
13188 return year + 1;
13189 } else if (+_date >= +startOfThisYear) {
13190 return year;
13191 } else {
13192 return year - 1;
13193 }
13194 }
13195
13196 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
13197 function startOfWeekYear(date, options) {
13198 const defaultOptions2 = getDefaultOptions();
13199 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
13200 const year = getWeekYear(date, options);
13201 const firstWeek = constructFrom(options?.in || date, 0);
13202 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
13203 firstWeek.setHours(0, 0, 0, 0);
13204 const _date = startOfWeek(firstWeek, options);
13205 return _date;
13206 }
13207
13208 // packages/dataviews/node_modules/date-fns/getWeek.js
13209 function getWeek(date, options) {
13210 const _date = toDate(date, options?.in);
13211 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
13212 return Math.round(diff / millisecondsInWeek) + 1;
13213 }
13214
13215 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
13216 function addLeadingZeros(number, targetLength) {
13217 const sign = number < 0 ? "-" : "";
13218 const output = Math.abs(number).toString().padStart(targetLength, "0");
13219 return sign + output;
13220 }
13221
13222 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
13223 var lightFormatters = {
13224 // Year
13225 y(date, token) {
13226 const signedYear = date.getFullYear();
13227 const year = signedYear > 0 ? signedYear : 1 - signedYear;
13228 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
13229 },
13230 // Month
13231 M(date, token) {
13232 const month = date.getMonth();
13233 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
13234 },
13235 // Day of the month
13236 d(date, token) {
13237 return addLeadingZeros(date.getDate(), token.length);
13238 },
13239 // AM or PM
13240 a(date, token) {
13241 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
13242 switch (token) {
13243 case "a":
13244 case "aa":
13245 return dayPeriodEnumValue.toUpperCase();
13246 case "aaa":
13247 return dayPeriodEnumValue;
13248 case "aaaaa":
13249 return dayPeriodEnumValue[0];
13250 case "aaaa":
13251 default:
13252 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
13253 }
13254 },
13255 // Hour [1-12]
13256 h(date, token) {
13257 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
13258 },
13259 // Hour [0-23]
13260 H(date, token) {
13261 return addLeadingZeros(date.getHours(), token.length);
13262 },
13263 // Minute
13264 m(date, token) {
13265 return addLeadingZeros(date.getMinutes(), token.length);
13266 },
13267 // Second
13268 s(date, token) {
13269 return addLeadingZeros(date.getSeconds(), token.length);
13270 },
13271 // Fraction of second
13272 S(date, token) {
13273 const numberOfDigits = token.length;
13274 const milliseconds = date.getMilliseconds();
13275 const fractionalSeconds = Math.trunc(
13276 milliseconds * Math.pow(10, numberOfDigits - 3)
13277 );
13278 return addLeadingZeros(fractionalSeconds, token.length);
13279 }
13280 };
13281
13282 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
13283 var dayPeriodEnum = {
13284 am: "am",
13285 pm: "pm",
13286 midnight: "midnight",
13287 noon: "noon",
13288 morning: "morning",
13289 afternoon: "afternoon",
13290 evening: "evening",
13291 night: "night"
13292 };
13293 var formatters = {
13294 // Era
13295 G: function(date, token, localize2) {
13296 const era = date.getFullYear() > 0 ? 1 : 0;
13297 switch (token) {
13298 // AD, BC
13299 case "G":
13300 case "GG":
13301 case "GGG":
13302 return localize2.era(era, { width: "abbreviated" });
13303 // A, B
13304 case "GGGGG":
13305 return localize2.era(era, { width: "narrow" });
13306 // Anno Domini, Before Christ
13307 case "GGGG":
13308 default:
13309 return localize2.era(era, { width: "wide" });
13310 }
13311 },
13312 // Year
13313 y: function(date, token, localize2) {
13314 if (token === "yo") {
13315 const signedYear = date.getFullYear();
13316 const year = signedYear > 0 ? signedYear : 1 - signedYear;
13317 return localize2.ordinalNumber(year, { unit: "year" });
13318 }
13319 return lightFormatters.y(date, token);
13320 },
13321 // Local week-numbering year
13322 Y: function(date, token, localize2, options) {
13323 const signedWeekYear = getWeekYear(date, options);
13324 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
13325 if (token === "YY") {
13326 const twoDigitYear = weekYear % 100;
13327 return addLeadingZeros(twoDigitYear, 2);
13328 }
13329 if (token === "Yo") {
13330 return localize2.ordinalNumber(weekYear, { unit: "year" });
13331 }
13332 return addLeadingZeros(weekYear, token.length);
13333 },
13334 // ISO week-numbering year
13335 R: function(date, token) {
13336 const isoWeekYear = getISOWeekYear(date);
13337 return addLeadingZeros(isoWeekYear, token.length);
13338 },
13339 // Extended year. This is a single number designating the year of this calendar system.
13340 // The main difference between `y` and `u` localizers are B.C. years:
13341 // | Year | `y` | `u` |
13342 // |------|-----|-----|
13343 // | AC 1 | 1 | 1 |
13344 // | BC 1 | 1 | 0 |
13345 // | BC 2 | 2 | -1 |
13346 // Also `yy` always returns the last two digits of a year,
13347 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
13348 u: function(date, token) {
13349 const year = date.getFullYear();
13350 return addLeadingZeros(year, token.length);
13351 },
13352 // Quarter
13353 Q: function(date, token, localize2) {
13354 const quarter = Math.ceil((date.getMonth() + 1) / 3);
13355 switch (token) {
13356 // 1, 2, 3, 4
13357 case "Q":
13358 return String(quarter);
13359 // 01, 02, 03, 04
13360 case "QQ":
13361 return addLeadingZeros(quarter, 2);
13362 // 1st, 2nd, 3rd, 4th
13363 case "Qo":
13364 return localize2.ordinalNumber(quarter, { unit: "quarter" });
13365 // Q1, Q2, Q3, Q4
13366 case "QQQ":
13367 return localize2.quarter(quarter, {
13368 width: "abbreviated",
13369 context: "formatting"
13370 });
13371 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
13372 case "QQQQQ":
13373 return localize2.quarter(quarter, {
13374 width: "narrow",
13375 context: "formatting"
13376 });
13377 // 1st quarter, 2nd quarter, ...
13378 case "QQQQ":
13379 default:
13380 return localize2.quarter(quarter, {
13381 width: "wide",
13382 context: "formatting"
13383 });
13384 }
13385 },
13386 // Stand-alone quarter
13387 q: function(date, token, localize2) {
13388 const quarter = Math.ceil((date.getMonth() + 1) / 3);
13389 switch (token) {
13390 // 1, 2, 3, 4
13391 case "q":
13392 return String(quarter);
13393 // 01, 02, 03, 04
13394 case "qq":
13395 return addLeadingZeros(quarter, 2);
13396 // 1st, 2nd, 3rd, 4th
13397 case "qo":
13398 return localize2.ordinalNumber(quarter, { unit: "quarter" });
13399 // Q1, Q2, Q3, Q4
13400 case "qqq":
13401 return localize2.quarter(quarter, {
13402 width: "abbreviated",
13403 context: "standalone"
13404 });
13405 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
13406 case "qqqqq":
13407 return localize2.quarter(quarter, {
13408 width: "narrow",
13409 context: "standalone"
13410 });
13411 // 1st quarter, 2nd quarter, ...
13412 case "qqqq":
13413 default:
13414 return localize2.quarter(quarter, {
13415 width: "wide",
13416 context: "standalone"
13417 });
13418 }
13419 },
13420 // Month
13421 M: function(date, token, localize2) {
13422 const month = date.getMonth();
13423 switch (token) {
13424 case "M":
13425 case "MM":
13426 return lightFormatters.M(date, token);
13427 // 1st, 2nd, ..., 12th
13428 case "Mo":
13429 return localize2.ordinalNumber(month + 1, { unit: "month" });
13430 // Jan, Feb, ..., Dec
13431 case "MMM":
13432 return localize2.month(month, {
13433 width: "abbreviated",
13434 context: "formatting"
13435 });
13436 // J, F, ..., D
13437 case "MMMMM":
13438 return localize2.month(month, {
13439 width: "narrow",
13440 context: "formatting"
13441 });
13442 // January, February, ..., December
13443 case "MMMM":
13444 default:
13445 return localize2.month(month, { width: "wide", context: "formatting" });
13446 }
13447 },
13448 // Stand-alone month
13449 L: function(date, token, localize2) {
13450 const month = date.getMonth();
13451 switch (token) {
13452 // 1, 2, ..., 12
13453 case "L":
13454 return String(month + 1);
13455 // 01, 02, ..., 12
13456 case "LL":
13457 return addLeadingZeros(month + 1, 2);
13458 // 1st, 2nd, ..., 12th
13459 case "Lo":
13460 return localize2.ordinalNumber(month + 1, { unit: "month" });
13461 // Jan, Feb, ..., Dec
13462 case "LLL":
13463 return localize2.month(month, {
13464 width: "abbreviated",
13465 context: "standalone"
13466 });
13467 // J, F, ..., D
13468 case "LLLLL":
13469 return localize2.month(month, {
13470 width: "narrow",
13471 context: "standalone"
13472 });
13473 // January, February, ..., December
13474 case "LLLL":
13475 default:
13476 return localize2.month(month, { width: "wide", context: "standalone" });
13477 }
13478 },
13479 // Local week of year
13480 w: function(date, token, localize2, options) {
13481 const week = getWeek(date, options);
13482 if (token === "wo") {
13483 return localize2.ordinalNumber(week, { unit: "week" });
13484 }
13485 return addLeadingZeros(week, token.length);
13486 },
13487 // ISO week of year
13488 I: function(date, token, localize2) {
13489 const isoWeek = getISOWeek(date);
13490 if (token === "Io") {
13491 return localize2.ordinalNumber(isoWeek, { unit: "week" });
13492 }
13493 return addLeadingZeros(isoWeek, token.length);
13494 },
13495 // Day of the month
13496 d: function(date, token, localize2) {
13497 if (token === "do") {
13498 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
13499 }
13500 return lightFormatters.d(date, token);
13501 },
13502 // Day of year
13503 D: function(date, token, localize2) {
13504 const dayOfYear = getDayOfYear(date);
13505 if (token === "Do") {
13506 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
13507 }
13508 return addLeadingZeros(dayOfYear, token.length);
13509 },
13510 // Day of week
13511 E: function(date, token, localize2) {
13512 const dayOfWeek = date.getDay();
13513 switch (token) {
13514 // Tue
13515 case "E":
13516 case "EE":
13517 case "EEE":
13518 return localize2.day(dayOfWeek, {
13519 width: "abbreviated",
13520 context: "formatting"
13521 });
13522 // T
13523 case "EEEEE":
13524 return localize2.day(dayOfWeek, {
13525 width: "narrow",
13526 context: "formatting"
13527 });
13528 // Tu
13529 case "EEEEEE":
13530 return localize2.day(dayOfWeek, {
13531 width: "short",
13532 context: "formatting"
13533 });
13534 // Tuesday
13535 case "EEEE":
13536 default:
13537 return localize2.day(dayOfWeek, {
13538 width: "wide",
13539 context: "formatting"
13540 });
13541 }
13542 },
13543 // Local day of week
13544 e: function(date, token, localize2, options) {
13545 const dayOfWeek = date.getDay();
13546 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
13547 switch (token) {
13548 // Numerical value (Nth day of week with current locale or weekStartsOn)
13549 case "e":
13550 return String(localDayOfWeek);
13551 // Padded numerical value
13552 case "ee":
13553 return addLeadingZeros(localDayOfWeek, 2);
13554 // 1st, 2nd, ..., 7th
13555 case "eo":
13556 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
13557 case "eee":
13558 return localize2.day(dayOfWeek, {
13559 width: "abbreviated",
13560 context: "formatting"
13561 });
13562 // T
13563 case "eeeee":
13564 return localize2.day(dayOfWeek, {
13565 width: "narrow",
13566 context: "formatting"
13567 });
13568 // Tu
13569 case "eeeeee":
13570 return localize2.day(dayOfWeek, {
13571 width: "short",
13572 context: "formatting"
13573 });
13574 // Tuesday
13575 case "eeee":
13576 default:
13577 return localize2.day(dayOfWeek, {
13578 width: "wide",
13579 context: "formatting"
13580 });
13581 }
13582 },
13583 // Stand-alone local day of week
13584 c: function(date, token, localize2, options) {
13585 const dayOfWeek = date.getDay();
13586 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
13587 switch (token) {
13588 // Numerical value (same as in `e`)
13589 case "c":
13590 return String(localDayOfWeek);
13591 // Padded numerical value
13592 case "cc":
13593 return addLeadingZeros(localDayOfWeek, token.length);
13594 // 1st, 2nd, ..., 7th
13595 case "co":
13596 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
13597 case "ccc":
13598 return localize2.day(dayOfWeek, {
13599 width: "abbreviated",
13600 context: "standalone"
13601 });
13602 // T
13603 case "ccccc":
13604 return localize2.day(dayOfWeek, {
13605 width: "narrow",
13606 context: "standalone"
13607 });
13608 // Tu
13609 case "cccccc":
13610 return localize2.day(dayOfWeek, {
13611 width: "short",
13612 context: "standalone"
13613 });
13614 // Tuesday
13615 case "cccc":
13616 default:
13617 return localize2.day(dayOfWeek, {
13618 width: "wide",
13619 context: "standalone"
13620 });
13621 }
13622 },
13623 // ISO day of week
13624 i: function(date, token, localize2) {
13625 const dayOfWeek = date.getDay();
13626 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
13627 switch (token) {
13628 // 2
13629 case "i":
13630 return String(isoDayOfWeek);
13631 // 02
13632 case "ii":
13633 return addLeadingZeros(isoDayOfWeek, token.length);
13634 // 2nd
13635 case "io":
13636 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
13637 // Tue
13638 case "iii":
13639 return localize2.day(dayOfWeek, {
13640 width: "abbreviated",
13641 context: "formatting"
13642 });
13643 // T
13644 case "iiiii":
13645 return localize2.day(dayOfWeek, {
13646 width: "narrow",
13647 context: "formatting"
13648 });
13649 // Tu
13650 case "iiiiii":
13651 return localize2.day(dayOfWeek, {
13652 width: "short",
13653 context: "formatting"
13654 });
13655 // Tuesday
13656 case "iiii":
13657 default:
13658 return localize2.day(dayOfWeek, {
13659 width: "wide",
13660 context: "formatting"
13661 });
13662 }
13663 },
13664 // AM or PM
13665 a: function(date, token, localize2) {
13666 const hours = date.getHours();
13667 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
13668 switch (token) {
13669 case "a":
13670 case "aa":
13671 return localize2.dayPeriod(dayPeriodEnumValue, {
13672 width: "abbreviated",
13673 context: "formatting"
13674 });
13675 case "aaa":
13676 return localize2.dayPeriod(dayPeriodEnumValue, {
13677 width: "abbreviated",
13678 context: "formatting"
13679 }).toLowerCase();
13680 case "aaaaa":
13681 return localize2.dayPeriod(dayPeriodEnumValue, {
13682 width: "narrow",
13683 context: "formatting"
13684 });
13685 case "aaaa":
13686 default:
13687 return localize2.dayPeriod(dayPeriodEnumValue, {
13688 width: "wide",
13689 context: "formatting"
13690 });
13691 }
13692 },
13693 // AM, PM, midnight, noon
13694 b: function(date, token, localize2) {
13695 const hours = date.getHours();
13696 let dayPeriodEnumValue;
13697 if (hours === 12) {
13698 dayPeriodEnumValue = dayPeriodEnum.noon;
13699 } else if (hours === 0) {
13700 dayPeriodEnumValue = dayPeriodEnum.midnight;
13701 } else {
13702 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
13703 }
13704 switch (token) {
13705 case "b":
13706 case "bb":
13707 return localize2.dayPeriod(dayPeriodEnumValue, {
13708 width: "abbreviated",
13709 context: "formatting"
13710 });
13711 case "bbb":
13712 return localize2.dayPeriod(dayPeriodEnumValue, {
13713 width: "abbreviated",
13714 context: "formatting"
13715 }).toLowerCase();
13716 case "bbbbb":
13717 return localize2.dayPeriod(dayPeriodEnumValue, {
13718 width: "narrow",
13719 context: "formatting"
13720 });
13721 case "bbbb":
13722 default:
13723 return localize2.dayPeriod(dayPeriodEnumValue, {
13724 width: "wide",
13725 context: "formatting"
13726 });
13727 }
13728 },
13729 // in the morning, in the afternoon, in the evening, at night
13730 B: function(date, token, localize2) {
13731 const hours = date.getHours();
13732 let dayPeriodEnumValue;
13733 if (hours >= 17) {
13734 dayPeriodEnumValue = dayPeriodEnum.evening;
13735 } else if (hours >= 12) {
13736 dayPeriodEnumValue = dayPeriodEnum.afternoon;
13737 } else if (hours >= 4) {
13738 dayPeriodEnumValue = dayPeriodEnum.morning;
13739 } else {
13740 dayPeriodEnumValue = dayPeriodEnum.night;
13741 }
13742 switch (token) {
13743 case "B":
13744 case "BB":
13745 case "BBB":
13746 return localize2.dayPeriod(dayPeriodEnumValue, {
13747 width: "abbreviated",
13748 context: "formatting"
13749 });
13750 case "BBBBB":
13751 return localize2.dayPeriod(dayPeriodEnumValue, {
13752 width: "narrow",
13753 context: "formatting"
13754 });
13755 case "BBBB":
13756 default:
13757 return localize2.dayPeriod(dayPeriodEnumValue, {
13758 width: "wide",
13759 context: "formatting"
13760 });
13761 }
13762 },
13763 // Hour [1-12]
13764 h: function(date, token, localize2) {
13765 if (token === "ho") {
13766 let hours = date.getHours() % 12;
13767 if (hours === 0) hours = 12;
13768 return localize2.ordinalNumber(hours, { unit: "hour" });
13769 }
13770 return lightFormatters.h(date, token);
13771 },
13772 // Hour [0-23]
13773 H: function(date, token, localize2) {
13774 if (token === "Ho") {
13775 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
13776 }
13777 return lightFormatters.H(date, token);
13778 },
13779 // Hour [0-11]
13780 K: function(date, token, localize2) {
13781 const hours = date.getHours() % 12;
13782 if (token === "Ko") {
13783 return localize2.ordinalNumber(hours, { unit: "hour" });
13784 }
13785 return addLeadingZeros(hours, token.length);
13786 },
13787 // Hour [1-24]
13788 k: function(date, token, localize2) {
13789 let hours = date.getHours();
13790 if (hours === 0) hours = 24;
13791 if (token === "ko") {
13792 return localize2.ordinalNumber(hours, { unit: "hour" });
13793 }
13794 return addLeadingZeros(hours, token.length);
13795 },
13796 // Minute
13797 m: function(date, token, localize2) {
13798 if (token === "mo") {
13799 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
13800 }
13801 return lightFormatters.m(date, token);
13802 },
13803 // Second
13804 s: function(date, token, localize2) {
13805 if (token === "so") {
13806 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
13807 }
13808 return lightFormatters.s(date, token);
13809 },
13810 // Fraction of second
13811 S: function(date, token) {
13812 return lightFormatters.S(date, token);
13813 },
13814 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
13815 X: function(date, token, _localize) {
13816 const timezoneOffset = date.getTimezoneOffset();
13817 if (timezoneOffset === 0) {
13818 return "Z";
13819 }
13820 switch (token) {
13821 // Hours and optional minutes
13822 case "X":
13823 return formatTimezoneWithOptionalMinutes(timezoneOffset);
13824 // Hours, minutes and optional seconds without `:` delimiter
13825 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
13826 // so this token always has the same output as `XX`
13827 case "XXXX":
13828 case "XX":
13829 return formatTimezone(timezoneOffset);
13830 // Hours, minutes and optional seconds with `:` delimiter
13831 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
13832 // so this token always has the same output as `XXX`
13833 case "XXXXX":
13834 case "XXX":
13835 // Hours and minutes with `:` delimiter
13836 default:
13837 return formatTimezone(timezoneOffset, ":");
13838 }
13839 },
13840 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
13841 x: function(date, token, _localize) {
13842 const timezoneOffset = date.getTimezoneOffset();
13843 switch (token) {
13844 // Hours and optional minutes
13845 case "x":
13846 return formatTimezoneWithOptionalMinutes(timezoneOffset);
13847 // Hours, minutes and optional seconds without `:` delimiter
13848 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
13849 // so this token always has the same output as `xx`
13850 case "xxxx":
13851 case "xx":
13852 return formatTimezone(timezoneOffset);
13853 // Hours, minutes and optional seconds with `:` delimiter
13854 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
13855 // so this token always has the same output as `xxx`
13856 case "xxxxx":
13857 case "xxx":
13858 // Hours and minutes with `:` delimiter
13859 default:
13860 return formatTimezone(timezoneOffset, ":");
13861 }
13862 },
13863 // Timezone (GMT)
13864 O: function(date, token, _localize) {
13865 const timezoneOffset = date.getTimezoneOffset();
13866 switch (token) {
13867 // Short
13868 case "O":
13869 case "OO":
13870 case "OOO":
13871 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
13872 // Long
13873 case "OOOO":
13874 default:
13875 return "GMT" + formatTimezone(timezoneOffset, ":");
13876 }
13877 },
13878 // Timezone (specific non-location)
13879 z: function(date, token, _localize) {
13880 const timezoneOffset = date.getTimezoneOffset();
13881 switch (token) {
13882 // Short
13883 case "z":
13884 case "zz":
13885 case "zzz":
13886 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
13887 // Long
13888 case "zzzz":
13889 default:
13890 return "GMT" + formatTimezone(timezoneOffset, ":");
13891 }
13892 },
13893 // Seconds timestamp
13894 t: function(date, token, _localize) {
13895 const timestamp = Math.trunc(+date / 1e3);
13896 return addLeadingZeros(timestamp, token.length);
13897 },
13898 // Milliseconds timestamp
13899 T: function(date, token, _localize) {
13900 return addLeadingZeros(+date, token.length);
13901 }
13902 };
13903 function formatTimezoneShort(offset, delimiter = "") {
13904 const sign = offset > 0 ? "-" : "+";
13905 const absOffset = Math.abs(offset);
13906 const hours = Math.trunc(absOffset / 60);
13907 const minutes = absOffset % 60;
13908 if (minutes === 0) {
13909 return sign + String(hours);
13910 }
13911 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
13912 }
13913 function formatTimezoneWithOptionalMinutes(offset, delimiter) {
13914 if (offset % 60 === 0) {
13915 const sign = offset > 0 ? "-" : "+";
13916 return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
13917 }
13918 return formatTimezone(offset, delimiter);
13919 }
13920 function formatTimezone(offset, delimiter = "") {
13921 const sign = offset > 0 ? "-" : "+";
13922 const absOffset = Math.abs(offset);
13923 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
13924 const minutes = addLeadingZeros(absOffset % 60, 2);
13925 return sign + hours + delimiter + minutes;
13926 }
13927
13928 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
13929 var dateLongFormatter = (pattern, formatLong2) => {
13930 switch (pattern) {
13931 case "P":
13932 return formatLong2.date({ width: "short" });
13933 case "PP":
13934 return formatLong2.date({ width: "medium" });
13935 case "PPP":
13936 return formatLong2.date({ width: "long" });
13937 case "PPPP":
13938 default:
13939 return formatLong2.date({ width: "full" });
13940 }
13941 };
13942 var timeLongFormatter = (pattern, formatLong2) => {
13943 switch (pattern) {
13944 case "p":
13945 return formatLong2.time({ width: "short" });
13946 case "pp":
13947 return formatLong2.time({ width: "medium" });
13948 case "ppp":
13949 return formatLong2.time({ width: "long" });
13950 case "pppp":
13951 default:
13952 return formatLong2.time({ width: "full" });
13953 }
13954 };
13955 var dateTimeLongFormatter = (pattern, formatLong2) => {
13956 const matchResult = pattern.match(/(P+)(p+)?/) || [];
13957 const datePattern = matchResult[1];
13958 const timePattern = matchResult[2];
13959 if (!timePattern) {
13960 return dateLongFormatter(pattern, formatLong2);
13961 }
13962 let dateTimeFormat;
13963 switch (datePattern) {
13964 case "P":
13965 dateTimeFormat = formatLong2.dateTime({ width: "short" });
13966 break;
13967 case "PP":
13968 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
13969 break;
13970 case "PPP":
13971 dateTimeFormat = formatLong2.dateTime({ width: "long" });
13972 break;
13973 case "PPPP":
13974 default:
13975 dateTimeFormat = formatLong2.dateTime({ width: "full" });
13976 break;
13977 }
13978 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
13979 };
13980 var longFormatters = {
13981 p: timeLongFormatter,
13982 P: dateTimeLongFormatter
13983 };
13984
13985 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
13986 var dayOfYearTokenRE = /^D+$/;
13987 var weekYearTokenRE = /^Y+$/;
13988 var throwTokens = ["D", "DD", "YY", "YYYY"];
13989 function isProtectedDayOfYearToken(token) {
13990 return dayOfYearTokenRE.test(token);
13991 }
13992 function isProtectedWeekYearToken(token) {
13993 return weekYearTokenRE.test(token);
13994 }
13995 function warnOrThrowProtectedError(token, format6, input) {
13996 const _message = message(token, format6, input);
13997 console.warn(_message);
13998 if (throwTokens.includes(token)) throw new RangeError(_message);
13999 }
14000 function message(token, format6, input) {
14001 const subject = token[0] === "Y" ? "years" : "days of the month";
14002 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`;
14003 }
14004
14005 // packages/dataviews/node_modules/date-fns/format.js
14006 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
14007 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
14008 var escapedStringRegExp = /^'([^]*?)'?$/;
14009 var doubleQuoteRegExp = /''/g;
14010 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
14011 function format(date, formatStr, options) {
14012 const defaultOptions2 = getDefaultOptions();
14013 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
14014 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
14015 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
14016 const originalDate = toDate(date, options?.in);
14017 if (!isValid(originalDate)) {
14018 throw new RangeError("Invalid time value");
14019 }
14020 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
14021 const firstCharacter = substring[0];
14022 if (firstCharacter === "p" || firstCharacter === "P") {
14023 const longFormatter = longFormatters[firstCharacter];
14024 return longFormatter(substring, locale.formatLong);
14025 }
14026 return substring;
14027 }).join("").match(formattingTokensRegExp).map((substring) => {
14028 if (substring === "''") {
14029 return { isToken: false, value: "'" };
14030 }
14031 const firstCharacter = substring[0];
14032 if (firstCharacter === "'") {
14033 return { isToken: false, value: cleanEscapedString(substring) };
14034 }
14035 if (formatters[firstCharacter]) {
14036 return { isToken: true, value: substring };
14037 }
14038 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
14039 throw new RangeError(
14040 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
14041 );
14042 }
14043 return { isToken: false, value: substring };
14044 });
14045 if (locale.localize.preprocessor) {
14046 parts = locale.localize.preprocessor(originalDate, parts);
14047 }
14048 const formatterOptions = {
14049 firstWeekContainsDate,
14050 weekStartsOn,
14051 locale
14052 };
14053 return parts.map((part) => {
14054 if (!part.isToken) return part.value;
14055 const token = part.value;
14056 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
14057 warnOrThrowProtectedError(token, formatStr, String(date));
14058 }
14059 const formatter = formatters[token[0]];
14060 return formatter(originalDate, token, locale.localize, formatterOptions);
14061 }).join("");
14062 }
14063 function cleanEscapedString(input) {
14064 const matched = input.match(escapedStringRegExp);
14065 if (!matched) {
14066 return input;
14067 }
14068 return matched[1].replace(doubleQuoteRegExp, "'");
14069 }
14070
14071 // packages/dataviews/node_modules/date-fns/subDays.js
14072 function subDays(date, amount, options) {
14073 return addDays(date, -amount, options);
14074 }
14075
14076 // packages/dataviews/node_modules/date-fns/subMonths.js
14077 function subMonths(date, amount, options) {
14078 return addMonths(date, -amount, options);
14079 }
14080
14081 // packages/dataviews/node_modules/date-fns/subWeeks.js
14082 function subWeeks(date, amount, options) {
14083 return addWeeks(date, -amount, options);
14084 }
14085
14086 // packages/dataviews/node_modules/date-fns/subYears.js
14087 function subYears(date, amount, options) {
14088 return addYears(date, -amount, options);
14089 }
14090
14091 // packages/dataviews/build-module/utils/operators.mjs
14092 var import_i18n24 = __toESM(require_i18n(), 1);
14093 var import_element45 = __toESM(require_element(), 1);
14094 var import_date = __toESM(require_date(), 1);
14095 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
14096 var filterTextWrappers = {
14097 Name: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
14098 Value: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
14099 };
14100 function getRelativeDate(value, unit) {
14101 switch (unit) {
14102 case "days":
14103 return subDays(/* @__PURE__ */ new Date(), value);
14104 case "weeks":
14105 return subWeeks(/* @__PURE__ */ new Date(), value);
14106 case "months":
14107 return subMonths(/* @__PURE__ */ new Date(), value);
14108 case "years":
14109 return subYears(/* @__PURE__ */ new Date(), value);
14110 default:
14111 return /* @__PURE__ */ new Date();
14112 }
14113 }
14114 var isNoneOperatorDefinition = {
14115 /* translators: DataViews operator name */
14116 label: (0, import_i18n24.__)("Is none of"),
14117 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14118 (0, import_i18n24.sprintf)(
14119 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
14120 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
14121 filter.name,
14122 activeElements.map((element) => element.label).join(", ")
14123 ),
14124 filterTextWrappers
14125 ),
14126 filter: ((item, field, filterValue) => {
14127 if (!filterValue?.length) {
14128 return true;
14129 }
14130 const fieldValue = field.getValue({ item });
14131 if (Array.isArray(fieldValue)) {
14132 return !filterValue.some(
14133 (fv) => fieldValue.includes(fv)
14134 );
14135 } else if (typeof fieldValue === "string") {
14136 return !filterValue.includes(fieldValue);
14137 }
14138 return false;
14139 }),
14140 selection: "multi"
14141 };
14142 var OPERATORS = [
14143 {
14144 name: OPERATOR_IS_ANY,
14145 /* translators: DataViews operator name */
14146 label: (0, import_i18n24.__)("Includes"),
14147 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14148 (0, import_i18n24.sprintf)(
14149 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
14150 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
14151 filter.name,
14152 activeElements.map((element) => element.label).join(", ")
14153 ),
14154 filterTextWrappers
14155 ),
14156 filter(item, field, filterValue) {
14157 if (!filterValue?.length) {
14158 return true;
14159 }
14160 const fieldValue = field.getValue({ item });
14161 if (Array.isArray(fieldValue)) {
14162 return filterValue.some(
14163 (fv) => fieldValue.includes(fv)
14164 );
14165 } else if (typeof fieldValue === "string") {
14166 return filterValue.includes(fieldValue);
14167 }
14168 return false;
14169 },
14170 selection: "multi"
14171 },
14172 {
14173 name: OPERATOR_IS_NONE,
14174 ...isNoneOperatorDefinition
14175 },
14176 {
14177 name: OPERATOR_IS_ALL,
14178 /* translators: DataViews operator name */
14179 label: (0, import_i18n24.__)("Includes all"),
14180 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14181 (0, import_i18n24.sprintf)(
14182 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
14183 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
14184 filter.name,
14185 activeElements.map((element) => element.label).join(", ")
14186 ),
14187 filterTextWrappers
14188 ),
14189 filter(item, field, filterValue) {
14190 if (!filterValue?.length) {
14191 return true;
14192 }
14193 return filterValue.every((value) => {
14194 return field.getValue({ item })?.includes(value);
14195 });
14196 },
14197 selection: "multi"
14198 },
14199 {
14200 name: OPERATOR_IS_NOT_ALL,
14201 ...isNoneOperatorDefinition
14202 },
14203 {
14204 name: OPERATOR_BETWEEN,
14205 /* translators: DataViews operator name */
14206 label: (0, import_i18n24.__)("Between (inc)"),
14207 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14208 (0, import_i18n24.sprintf)(
14209 /* 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". */
14210 (0, import_i18n24.__)(
14211 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
14212 ),
14213 filter.name,
14214 activeElements[0].label[0],
14215 activeElements[0].label[1]
14216 ),
14217 filterTextWrappers
14218 ),
14219 filter(item, field, filterValue) {
14220 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
14221 return true;
14222 }
14223 const fieldValue = field.getValue({ item });
14224 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
14225 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
14226 }
14227 return false;
14228 },
14229 selection: "custom"
14230 },
14231 {
14232 name: OPERATOR_IN_THE_PAST,
14233 /* translators: DataViews operator name */
14234 label: (0, import_i18n24.__)("In the past"),
14235 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14236 (0, import_i18n24.sprintf)(
14237 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
14238 (0, import_i18n24.__)(
14239 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
14240 ),
14241 filter.name,
14242 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
14243 ),
14244 filterTextWrappers
14245 ),
14246 filter(item, field, filterValue) {
14247 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
14248 return true;
14249 }
14250 const targetDate = getRelativeDate(
14251 filterValue.value,
14252 filterValue.unit
14253 );
14254 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
14255 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
14256 },
14257 selection: "custom"
14258 },
14259 {
14260 name: OPERATOR_OVER,
14261 /* translators: DataViews operator name */
14262 label: (0, import_i18n24.__)("Over"),
14263 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14264 (0, import_i18n24.sprintf)(
14265 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
14266 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
14267 filter.name,
14268 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
14269 ),
14270 filterTextWrappers
14271 ),
14272 filter(item, field, filterValue) {
14273 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
14274 return true;
14275 }
14276 const targetDate = getRelativeDate(
14277 filterValue.value,
14278 filterValue.unit
14279 );
14280 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
14281 return fieldValue < targetDate;
14282 },
14283 selection: "custom"
14284 },
14285 {
14286 name: OPERATOR_IS,
14287 /* translators: DataViews operator name */
14288 label: (0, import_i18n24.__)("Is"),
14289 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14290 (0, import_i18n24.sprintf)(
14291 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
14292 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
14293 filter.name,
14294 activeElements[0].label
14295 ),
14296 filterTextWrappers
14297 ),
14298 filter(item, field, filterValue) {
14299 return filterValue === field.getValue({ item }) || filterValue === void 0;
14300 },
14301 selection: "single"
14302 },
14303 {
14304 name: OPERATOR_IS_NOT,
14305 /* translators: DataViews operator name */
14306 label: (0, import_i18n24.__)("Is not"),
14307 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14308 (0, import_i18n24.sprintf)(
14309 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
14310 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
14311 filter.name,
14312 activeElements[0].label
14313 ),
14314 filterTextWrappers
14315 ),
14316 filter(item, field, filterValue) {
14317 return filterValue !== field.getValue({ item });
14318 },
14319 selection: "single"
14320 },
14321 {
14322 name: OPERATOR_LESS_THAN,
14323 /* translators: DataViews operator name */
14324 label: (0, import_i18n24.__)("Less than"),
14325 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14326 (0, import_i18n24.sprintf)(
14327 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
14328 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
14329 filter.name,
14330 activeElements[0].label
14331 ),
14332 filterTextWrappers
14333 ),
14334 filter(item, field, filterValue) {
14335 if (filterValue === void 0) {
14336 return true;
14337 }
14338 const fieldValue = field.getValue({ item });
14339 return fieldValue < filterValue;
14340 },
14341 selection: "single"
14342 },
14343 {
14344 name: OPERATOR_GREATER_THAN,
14345 /* translators: DataViews operator name */
14346 label: (0, import_i18n24.__)("Greater than"),
14347 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14348 (0, import_i18n24.sprintf)(
14349 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
14350 (0, import_i18n24.__)(
14351 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
14352 ),
14353 filter.name,
14354 activeElements[0].label
14355 ),
14356 filterTextWrappers
14357 ),
14358 filter(item, field, filterValue) {
14359 if (filterValue === void 0) {
14360 return true;
14361 }
14362 const fieldValue = field.getValue({ item });
14363 return fieldValue > filterValue;
14364 },
14365 selection: "single"
14366 },
14367 {
14368 name: OPERATOR_LESS_THAN_OR_EQUAL,
14369 /* translators: DataViews operator name */
14370 label: (0, import_i18n24.__)("Less than or equal"),
14371 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14372 (0, import_i18n24.sprintf)(
14373 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
14374 (0, import_i18n24.__)(
14375 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
14376 ),
14377 filter.name,
14378 activeElements[0].label
14379 ),
14380 filterTextWrappers
14381 ),
14382 filter(item, field, filterValue) {
14383 if (filterValue === void 0) {
14384 return true;
14385 }
14386 const fieldValue = field.getValue({ item });
14387 return fieldValue <= filterValue;
14388 },
14389 selection: "single"
14390 },
14391 {
14392 name: OPERATOR_GREATER_THAN_OR_EQUAL,
14393 /* translators: DataViews operator name */
14394 label: (0, import_i18n24.__)("Greater than or equal"),
14395 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14396 (0, import_i18n24.sprintf)(
14397 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
14398 (0, import_i18n24.__)(
14399 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
14400 ),
14401 filter.name,
14402 activeElements[0].label
14403 ),
14404 filterTextWrappers
14405 ),
14406 filter(item, field, filterValue) {
14407 if (filterValue === void 0) {
14408 return true;
14409 }
14410 const fieldValue = field.getValue({ item });
14411 return fieldValue >= filterValue;
14412 },
14413 selection: "single"
14414 },
14415 {
14416 name: OPERATOR_BEFORE,
14417 /* translators: DataViews operator name */
14418 label: (0, import_i18n24.__)("Before"),
14419 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14420 (0, import_i18n24.sprintf)(
14421 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
14422 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
14423 filter.name,
14424 activeElements[0].label
14425 ),
14426 filterTextWrappers
14427 ),
14428 filter(item, field, filterValue) {
14429 if (filterValue === void 0) {
14430 return true;
14431 }
14432 const filterDate = (0, import_date.getDate)(filterValue);
14433 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14434 return fieldDate < filterDate;
14435 },
14436 selection: "single"
14437 },
14438 {
14439 name: OPERATOR_AFTER,
14440 /* translators: DataViews operator name */
14441 label: (0, import_i18n24.__)("After"),
14442 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14443 (0, import_i18n24.sprintf)(
14444 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
14445 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
14446 filter.name,
14447 activeElements[0].label
14448 ),
14449 filterTextWrappers
14450 ),
14451 filter(item, field, filterValue) {
14452 if (filterValue === void 0) {
14453 return true;
14454 }
14455 const filterDate = (0, import_date.getDate)(filterValue);
14456 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14457 return fieldDate > filterDate;
14458 },
14459 selection: "single"
14460 },
14461 {
14462 name: OPERATOR_BEFORE_INC,
14463 /* translators: DataViews operator name */
14464 label: (0, import_i18n24.__)("Before (inc)"),
14465 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14466 (0, import_i18n24.sprintf)(
14467 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
14468 (0, import_i18n24.__)(
14469 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
14470 ),
14471 filter.name,
14472 activeElements[0].label
14473 ),
14474 filterTextWrappers
14475 ),
14476 filter(item, field, filterValue) {
14477 if (filterValue === void 0) {
14478 return true;
14479 }
14480 const filterDate = (0, import_date.getDate)(filterValue);
14481 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14482 return fieldDate <= filterDate;
14483 },
14484 selection: "single"
14485 },
14486 {
14487 name: OPERATOR_AFTER_INC,
14488 /* translators: DataViews operator name */
14489 label: (0, import_i18n24.__)("After (inc)"),
14490 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14491 (0, import_i18n24.sprintf)(
14492 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
14493 (0, import_i18n24.__)(
14494 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
14495 ),
14496 filter.name,
14497 activeElements[0].label
14498 ),
14499 filterTextWrappers
14500 ),
14501 filter(item, field, filterValue) {
14502 if (filterValue === void 0) {
14503 return true;
14504 }
14505 const filterDate = (0, import_date.getDate)(filterValue);
14506 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14507 return fieldDate >= filterDate;
14508 },
14509 selection: "single"
14510 },
14511 {
14512 name: OPERATOR_CONTAINS,
14513 /* translators: DataViews operator name */
14514 label: (0, import_i18n24.__)("Contains"),
14515 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14516 (0, import_i18n24.sprintf)(
14517 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
14518 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
14519 filter.name,
14520 activeElements[0].label
14521 ),
14522 filterTextWrappers
14523 ),
14524 filter(item, field, filterValue) {
14525 if (filterValue === void 0) {
14526 return true;
14527 }
14528 const fieldValue = field.getValue({ item });
14529 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
14530 },
14531 selection: "single"
14532 },
14533 {
14534 name: OPERATOR_NOT_CONTAINS,
14535 /* translators: DataViews operator name */
14536 label: (0, import_i18n24.__)("Doesn't contain"),
14537 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14538 (0, import_i18n24.sprintf)(
14539 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
14540 (0, import_i18n24.__)(
14541 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
14542 ),
14543 filter.name,
14544 activeElements[0].label
14545 ),
14546 filterTextWrappers
14547 ),
14548 filter(item, field, filterValue) {
14549 if (filterValue === void 0) {
14550 return true;
14551 }
14552 const fieldValue = field.getValue({ item });
14553 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
14554 },
14555 selection: "single"
14556 },
14557 {
14558 name: OPERATOR_STARTS_WITH,
14559 /* translators: DataViews operator name */
14560 label: (0, import_i18n24.__)("Starts with"),
14561 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14562 (0, import_i18n24.sprintf)(
14563 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
14564 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
14565 filter.name,
14566 activeElements[0].label
14567 ),
14568 filterTextWrappers
14569 ),
14570 filter(item, field, filterValue) {
14571 if (filterValue === void 0) {
14572 return true;
14573 }
14574 const fieldValue = field.getValue({ item });
14575 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
14576 },
14577 selection: "single"
14578 },
14579 {
14580 name: OPERATOR_ON,
14581 /* translators: DataViews operator name */
14582 label: (0, import_i18n24.__)("On"),
14583 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14584 (0, import_i18n24.sprintf)(
14585 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
14586 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
14587 filter.name,
14588 activeElements[0].label
14589 ),
14590 filterTextWrappers
14591 ),
14592 filter(item, field, filterValue) {
14593 if (filterValue === void 0) {
14594 return true;
14595 }
14596 const filterDate = (0, import_date.getDate)(filterValue);
14597 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14598 return filterDate.getTime() === fieldDate.getTime();
14599 },
14600 selection: "single"
14601 },
14602 {
14603 name: OPERATOR_NOT_ON,
14604 /* translators: DataViews operator name */
14605 label: (0, import_i18n24.__)("Not on"),
14606 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
14607 (0, import_i18n24.sprintf)(
14608 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
14609 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
14610 filter.name,
14611 activeElements[0].label
14612 ),
14613 filterTextWrappers
14614 ),
14615 filter(item, field, filterValue) {
14616 if (filterValue === void 0) {
14617 return true;
14618 }
14619 const filterDate = (0, import_date.getDate)(filterValue);
14620 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14621 return filterDate.getTime() !== fieldDate.getTime();
14622 },
14623 selection: "single"
14624 }
14625 ];
14626 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
14627 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
14628 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
14629 (op) => op.name === name
14630 );
14631 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
14632
14633 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14634 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
14635 var ENTER = "Enter";
14636 var SPACE = " ";
14637 var FilterText = ({
14638 activeElements,
14639 filterInView,
14640 filter
14641 }) => {
14642 if (activeElements === void 0 || activeElements.length === 0) {
14643 return filter.name;
14644 }
14645 const operator = getOperatorByName(filterInView?.operator);
14646 if (operator !== void 0) {
14647 return operator.filterText(filter, activeElements);
14648 }
14649 return (0, import_i18n25.sprintf)(
14650 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
14651 (0, import_i18n25.__)("Unknown status for %1$s"),
14652 filter.name
14653 );
14654 };
14655 function OperatorSelector({
14656 filter,
14657 view,
14658 onChangeView
14659 }) {
14660 const operatorOptions = filter.operators?.map((operator) => ({
14661 value: operator,
14662 label: getOperatorByName(operator)?.label || operator
14663 }));
14664 const currentFilter = view.filters?.find(
14665 (_filter) => _filter.field === filter.field
14666 );
14667 const value = currentFilter?.operator || filter.operators[0];
14668 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14669 Stack,
14670 {
14671 direction: "row",
14672 gap: "sm",
14673 justify: "flex-start",
14674 className: "dataviews-filters__summary-operators-container",
14675 align: "center",
14676 children: [
14677 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components23.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
14678 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14679 import_components23.SelectControl,
14680 {
14681 className: "dataviews-filters__summary-operators-filter-select",
14682 label: (0, import_i18n25.__)("Conditions"),
14683 value,
14684 options: operatorOptions,
14685 onChange: (newValue) => {
14686 const newOperator = newValue;
14687 const currentOperator = currentFilter?.operator;
14688 const newFilters = currentFilter ? [
14689 ...(view.filters ?? []).map(
14690 (_filter) => {
14691 if (_filter.field === filter.field) {
14692 const currentOpSelectionModel = getOperatorByName(
14693 currentOperator
14694 )?.selection;
14695 const newOpSelectionModel = getOperatorByName(
14696 newOperator
14697 )?.selection;
14698 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
14699 currentOpSelectionModel,
14700 newOpSelectionModel
14701 ].includes("custom");
14702 return {
14703 ..._filter,
14704 value: shouldResetValue ? void 0 : _filter.value,
14705 operator: newOperator
14706 };
14707 }
14708 return _filter;
14709 }
14710 )
14711 ] : [
14712 ...view.filters ?? [],
14713 {
14714 field: filter.field,
14715 operator: newOperator,
14716 value: void 0
14717 }
14718 ];
14719 onChangeView({
14720 ...view,
14721 page: 1,
14722 filters: newFilters
14723 });
14724 },
14725 size: "small",
14726 variant: "minimal",
14727 hideLabelFromVision: true
14728 }
14729 )
14730 ]
14731 }
14732 );
14733 }
14734 function Filter({
14735 addFilterRef,
14736 openedFilter,
14737 fields: fields2,
14738 ...commonProps
14739 }) {
14740 const toggleRef = (0, import_element46.useRef)(null);
14741 const { filter, view, onChangeView } = commonProps;
14742 const filterInView = view.filters?.find(
14743 (f2) => f2.field === filter.field
14744 );
14745 let activeElements = [];
14746 const field = (0, import_element46.useMemo)(() => {
14747 const currentField = fields2.find((f2) => f2.id === filter.field);
14748 if (currentField) {
14749 return {
14750 ...currentField,
14751 // Configure getValue as if Item was a plain object.
14752 // See related input-widget.tsx
14753 getValue: ({ item }) => item[currentField.id]
14754 };
14755 }
14756 return currentField;
14757 }, [fields2, filter.field]);
14758 const { elements } = useElements({
14759 elements: filter.elements,
14760 getElements: filter.getElements
14761 });
14762 if (elements.length > 0) {
14763 activeElements = elements.filter((element) => {
14764 if (filter.singleSelection) {
14765 return element.value === filterInView?.value;
14766 }
14767 return filterInView?.value?.includes(element.value);
14768 });
14769 } else if (Array.isArray(filterInView?.value)) {
14770 const label = filterInView.value.map((v2) => {
14771 const formattedValue = field?.getValueFormatted({
14772 item: { [field.id]: v2 },
14773 field
14774 });
14775 return formattedValue || String(v2);
14776 });
14777 activeElements = [
14778 {
14779 value: filterInView.value,
14780 // @ts-ignore
14781 label
14782 }
14783 ];
14784 } else if (typeof filterInView?.value === "object") {
14785 activeElements = [
14786 { value: filterInView.value, label: filterInView.value }
14787 ];
14788 } else if (filterInView?.value !== void 0) {
14789 const label = field !== void 0 ? field.getValueFormatted({
14790 item: { [field.id]: filterInView.value },
14791 field
14792 }) : String(filterInView.value);
14793 activeElements = [
14794 {
14795 value: filterInView.value,
14796 label
14797 }
14798 ];
14799 }
14800 const isPrimary = filter.isPrimary;
14801 const isLocked = filterInView?.isLocked;
14802 const hasValues = !isLocked && filterInView?.value !== void 0;
14803 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
14804 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14805 import_components23.Dropdown,
14806 {
14807 defaultOpen: openedFilter === filter.field,
14808 contentClassName: "dataviews-filters__summary-popover",
14809 popoverProps: { placement: "bottom-start", role: "dialog" },
14810 onClose: () => {
14811 toggleRef.current?.focus();
14812 },
14813 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
14814 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14815 import_components23.Tooltip,
14816 {
14817 text: (0, import_i18n25.sprintf)(
14818 /* translators: 1: Filter name. */
14819 (0, import_i18n25.__)("Filter by: %1$s"),
14820 filter.name.toLowerCase()
14821 ),
14822 placement: "top",
14823 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14824 "div",
14825 {
14826 className: clsx_default(
14827 "dataviews-filters__summary-chip",
14828 {
14829 "has-reset": canResetOrRemove,
14830 "has-values": hasValues,
14831 "is-not-clickable": isLocked
14832 }
14833 ),
14834 role: "button",
14835 tabIndex: isLocked ? -1 : 0,
14836 onClick: () => {
14837 if (!isLocked) {
14838 onToggle();
14839 }
14840 },
14841 onKeyDown: (event) => {
14842 if (!isLocked && [ENTER, SPACE].includes(event.key)) {
14843 onToggle();
14844 event.preventDefault();
14845 }
14846 },
14847 "aria-disabled": isLocked,
14848 "aria-pressed": isOpen,
14849 "aria-expanded": isOpen,
14850 ref: toggleRef,
14851 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14852 FilterText,
14853 {
14854 activeElements,
14855 filterInView,
14856 filter
14857 }
14858 )
14859 }
14860 )
14861 }
14862 ),
14863 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14864 import_components23.Tooltip,
14865 {
14866 text: isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove"),
14867 placement: "top",
14868 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14869 "button",
14870 {
14871 className: clsx_default(
14872 "dataviews-filters__summary-chip-remove",
14873 { "has-values": hasValues }
14874 ),
14875 onClick: () => {
14876 onChangeView({
14877 ...view,
14878 page: 1,
14879 filters: view.filters?.filter(
14880 (_filter) => _filter.field !== filter.field
14881 )
14882 });
14883 if (!isPrimary) {
14884 addFilterRef.current?.focus();
14885 } else {
14886 toggleRef.current?.focus();
14887 }
14888 },
14889 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components23.Icon, { icon: close_small_default })
14890 }
14891 )
14892 }
14893 )
14894 ] }),
14895 renderContent: () => {
14896 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
14897 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(OperatorSelector, { ...commonProps }),
14898 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14899 SearchWidget,
14900 {
14901 ...commonProps,
14902 filter: {
14903 ...commonProps.filter,
14904 elements
14905 }
14906 }
14907 ) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(InputWidget, { ...commonProps, fields: fields2 })
14908 ] });
14909 }
14910 }
14911 );
14912 }
14913
14914 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
14915 var import_components24 = __toESM(require_components(), 1);
14916 var import_i18n26 = __toESM(require_i18n(), 1);
14917 var import_element47 = __toESM(require_element(), 1);
14918 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
14919 var { Menu: Menu4 } = unlock(import_components24.privateApis);
14920 function AddFilterMenu({
14921 filters,
14922 view,
14923 onChangeView,
14924 setOpenedFilter,
14925 triggerProps
14926 }) {
14927 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
14928 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(Menu4, { children: [
14929 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.TriggerButton, { ...triggerProps }),
14930 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
14931 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
14932 Menu4.Item,
14933 {
14934 onClick: () => {
14935 setOpenedFilter(filter.field);
14936 onChangeView({
14937 ...view,
14938 page: 1,
14939 filters: [
14940 ...view.filters || [],
14941 {
14942 field: filter.field,
14943 value: void 0,
14944 operator: filter.operators[0]
14945 }
14946 ]
14947 });
14948 },
14949 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.ItemLabel, { children: filter.name })
14950 },
14951 filter.field
14952 );
14953 }) })
14954 ] });
14955 }
14956 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
14957 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
14958 return null;
14959 }
14960 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
14961 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
14962 AddFilterMenu,
14963 {
14964 triggerProps: {
14965 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
14966 import_components24.Button,
14967 {
14968 accessibleWhenDisabled: true,
14969 size: "compact",
14970 className: "dataviews-filters-button",
14971 variant: "tertiary",
14972 disabled: !inactiveFilters.length,
14973 ref
14974 }
14975 ),
14976 children: (0, import_i18n26.__)("Add filter")
14977 },
14978 ...{ filters, view, onChangeView, setOpenedFilter }
14979 }
14980 );
14981 }
14982 var add_filter_default = (0, import_element47.forwardRef)(AddFilter);
14983
14984 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
14985 var import_components25 = __toESM(require_components(), 1);
14986 var import_i18n27 = __toESM(require_i18n(), 1);
14987 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
14988 function ResetFilter({
14989 filters,
14990 view,
14991 onChangeView
14992 }) {
14993 const isPrimary = (field) => filters.some(
14994 (_filter) => _filter.field === field && _filter.isPrimary
14995 );
14996 const isDisabled = !view.search && !view.filters?.some(
14997 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
14998 );
14999 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15000 import_components25.Button,
15001 {
15002 disabled: isDisabled,
15003 accessibleWhenDisabled: true,
15004 size: "compact",
15005 variant: "tertiary",
15006 className: "dataviews-filters__reset-button",
15007 onClick: () => {
15008 onChangeView({
15009 ...view,
15010 page: 1,
15011 search: "",
15012 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
15013 });
15014 },
15015 children: (0, import_i18n27.__)("Reset")
15016 }
15017 );
15018 }
15019
15020 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
15021 var import_element48 = __toESM(require_element(), 1);
15022 function useFilters(fields2, view) {
15023 return (0, import_element48.useMemo)(() => {
15024 const filters = [];
15025 fields2.forEach((field) => {
15026 if (field.filterBy === false || !field.hasElements && !field.Edit) {
15027 return;
15028 }
15029 const operators = field.filterBy.operators;
15030 const isPrimary = !!field.filterBy?.isPrimary;
15031 const isLocked = view.filters?.some(
15032 (f2) => f2.field === field.id && !!f2.isLocked
15033 ) ?? false;
15034 filters.push({
15035 field: field.id,
15036 name: field.label,
15037 elements: field.elements,
15038 getElements: field.getElements,
15039 hasElements: field.hasElements,
15040 singleSelection: operators.some(
15041 (op) => isSingleSelectionOperator(op)
15042 ),
15043 operators,
15044 isVisible: isLocked || isPrimary || !!view.filters?.some(
15045 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
15046 ),
15047 isPrimary,
15048 isLocked
15049 });
15050 });
15051 filters.sort((a2, b2) => {
15052 if (a2.isLocked && !b2.isLocked) {
15053 return -1;
15054 }
15055 if (!a2.isLocked && b2.isLocked) {
15056 return 1;
15057 }
15058 if (a2.isPrimary && !b2.isPrimary) {
15059 return -1;
15060 }
15061 if (!a2.isPrimary && b2.isPrimary) {
15062 return 1;
15063 }
15064 return a2.name.localeCompare(b2.name);
15065 });
15066 return filters;
15067 }, [fields2, view]);
15068 }
15069 var use_filters_default = useFilters;
15070
15071 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15072 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
15073 function Filters({ className }) {
15074 const { fields: fields2, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element49.useContext)(dataviews_context_default);
15075 const addFilterRef = (0, import_element49.useRef)(null);
15076 const filters = use_filters_default(fields2, view);
15077 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15078 add_filter_default,
15079 {
15080 filters,
15081 view,
15082 onChangeView,
15083 ref: addFilterRef,
15084 setOpenedFilter
15085 },
15086 "add-filter"
15087 );
15088 const visibleFilters = filters.filter((filter) => filter.isVisible);
15089 if (visibleFilters.length === 0) {
15090 return null;
15091 }
15092 const filterComponents = [
15093 ...visibleFilters.map((filter) => {
15094 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15095 Filter,
15096 {
15097 filter,
15098 view,
15099 fields: fields2,
15100 onChangeView,
15101 addFilterRef,
15102 openedFilter
15103 },
15104 filter.field
15105 );
15106 }),
15107 addFilter
15108 ];
15109 filterComponents.push(
15110 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15111 ResetFilter,
15112 {
15113 filters,
15114 view,
15115 onChangeView
15116 },
15117 "reset-filters"
15118 )
15119 );
15120 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15121 Stack,
15122 {
15123 direction: "row",
15124 justify: "flex-start",
15125 gap: "sm",
15126 style: { width: "fit-content" },
15127 wrap: "wrap",
15128 className,
15129 children: filterComponents
15130 }
15131 );
15132 }
15133 var filters_default = (0, import_element49.memo)(Filters);
15134
15135 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
15136 var import_element50 = __toESM(require_element(), 1);
15137 var import_components26 = __toESM(require_components(), 1);
15138 var import_i18n28 = __toESM(require_i18n(), 1);
15139 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
15140 function FiltersToggle() {
15141 const {
15142 filters,
15143 view,
15144 onChangeView,
15145 setOpenedFilter,
15146 isShowingFilter,
15147 setIsShowingFilter
15148 } = (0, import_element50.useContext)(dataviews_context_default);
15149 const buttonRef = (0, import_element50.useRef)(null);
15150 const onChangeViewWithFilterVisibility = (0, import_element50.useCallback)(
15151 (_view) => {
15152 onChangeView(_view);
15153 setIsShowingFilter(true);
15154 },
15155 [onChangeView, setIsShowingFilter]
15156 );
15157 if (filters.length === 0) {
15158 return null;
15159 }
15160 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
15161 const addFilterButtonProps = {
15162 label: (0, import_i18n28.__)("Add filter"),
15163 "aria-expanded": false,
15164 isPressed: false
15165 };
15166 const toggleFiltersButtonProps = {
15167 label: (0, import_i18n28._x)("Filter", "verb"),
15168 "aria-expanded": isShowingFilter,
15169 isPressed: isShowingFilter,
15170 onClick: () => {
15171 if (!isShowingFilter) {
15172 setOpenedFilter(null);
15173 }
15174 setIsShowingFilter(!isShowingFilter);
15175 }
15176 };
15177 const hasPrimaryOrLockedFilters = filters.some(
15178 (filter) => filter.isPrimary || filter.isLocked
15179 );
15180 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15181 import_components26.Button,
15182 {
15183 ref: buttonRef,
15184 className: "dataviews-filters__visibility-toggle",
15185 size: "compact",
15186 icon: funnel_default,
15187 disabled: hasPrimaryOrLockedFilters,
15188 accessibleWhenDisabled: true,
15189 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
15190 }
15191 );
15192 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15193 AddFilterMenu,
15194 {
15195 filters,
15196 view,
15197 onChangeView: onChangeViewWithFilterVisibility,
15198 setOpenedFilter,
15199 triggerProps: { render: buttonComponent }
15200 }
15201 ) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15202 FilterVisibilityToggle,
15203 {
15204 buttonRef,
15205 filtersCount: view.filters?.length,
15206 children: buttonComponent
15207 }
15208 ) });
15209 }
15210 function FilterVisibilityToggle({
15211 buttonRef,
15212 filtersCount,
15213 children
15214 }) {
15215 (0, import_element50.useEffect)(
15216 () => () => {
15217 buttonRef.current?.focus();
15218 },
15219 [buttonRef]
15220 );
15221 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
15222 children,
15223 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
15224 ] });
15225 }
15226 var toggle_default = FiltersToggle;
15227
15228 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
15229 var import_element51 = __toESM(require_element(), 1);
15230 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
15231 function FiltersToggled(props) {
15232 const { isShowingFilter } = (0, import_element51.useContext)(dataviews_context_default);
15233 if (!isShowingFilter) {
15234 return null;
15235 }
15236 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(filters_default, { ...props });
15237 }
15238 var filters_toggled_default = FiltersToggled;
15239
15240 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
15241 var import_element52 = __toESM(require_element(), 1);
15242 var import_components27 = __toESM(require_components(), 1);
15243 var import_i18n29 = __toESM(require_i18n(), 1);
15244 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
15245 function DataViewsLayout({ className }) {
15246 const {
15247 actions: actions2 = [],
15248 data,
15249 fields: fields2,
15250 getItemId,
15251 getItemLevel,
15252 hasInitiallyLoaded,
15253 isLoading,
15254 view,
15255 onChangeView,
15256 selection,
15257 onChangeSelection,
15258 setOpenedFilter,
15259 onClickItem,
15260 isItemClickable,
15261 renderItemLink,
15262 defaultLayouts,
15263 containerRef,
15264 empty = /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: (0, import_i18n29.__)("No results") })
15265 } = (0, import_element52.useContext)(dataviews_context_default);
15266 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
15267 delay: 200
15268 });
15269 if (!hasInitiallyLoaded) {
15270 if (!isDelayedInitialLoading) {
15271 return null;
15272 }
15273 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components27.Spinner, {}) }) });
15274 }
15275 const ViewComponent = VIEW_LAYOUTS.find(
15276 (v2) => v2.type === view.type && defaultLayouts[v2.type]
15277 )?.component;
15278 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
15279 ViewComponent,
15280 {
15281 className,
15282 actions: actions2,
15283 data,
15284 fields: fields2,
15285 getItemId,
15286 getItemLevel,
15287 isLoading,
15288 onChangeView,
15289 onChangeSelection,
15290 selection,
15291 setOpenedFilter,
15292 onClickItem,
15293 renderItemLink,
15294 isItemClickable,
15295 view,
15296 empty
15297 }
15298 ) });
15299 }
15300
15301 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
15302 var import_element53 = __toESM(require_element(), 1);
15303 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
15304 var EMPTY_ARRAY5 = [];
15305 function DataViewsFooter() {
15306 const {
15307 view,
15308 paginationInfo: { totalItems = 0, totalPages },
15309 data,
15310 actions: actions2 = EMPTY_ARRAY5,
15311 isLoading,
15312 hasInitiallyLoaded
15313 } = (0, import_element53.useContext)(dataviews_context_default);
15314 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
15315 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
15316 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
15317 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
15318 return null;
15319 }
15320 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15321 "div",
15322 {
15323 className: "dataviews-footer",
15324 inert: isRefreshing ? "true" : void 0,
15325 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
15326 Stack,
15327 {
15328 direction: "row",
15329 justify: "end",
15330 align: "center",
15331 className: clsx_default("dataviews-footer__content", {
15332 "is-refreshing": isDelayedRefreshing
15333 }),
15334 gap: "sm",
15335 children: [
15336 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(BulkActionsFooter, {}),
15337 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(dataviews_pagination_default, {})
15338 ]
15339 }
15340 )
15341 }
15342 );
15343 }
15344
15345 // packages/dataviews/build-module/components/dataviews-search/index.mjs
15346 var import_i18n30 = __toESM(require_i18n(), 1);
15347 var import_element54 = __toESM(require_element(), 1);
15348 var import_components28 = __toESM(require_components(), 1);
15349 var import_compose9 = __toESM(require_compose(), 1);
15350 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
15351 var DataViewsSearch = (0, import_element54.memo)(function Search({ label }) {
15352 const { view, onChangeView } = (0, import_element54.useContext)(dataviews_context_default);
15353 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
15354 view.search
15355 );
15356 (0, import_element54.useEffect)(() => {
15357 if (view.search !== debouncedSearch) {
15358 setSearch(view.search ?? "");
15359 }
15360 }, [view.search, setSearch]);
15361 const onChangeViewRef = (0, import_element54.useRef)(onChangeView);
15362 const viewRef = (0, import_element54.useRef)(view);
15363 (0, import_element54.useEffect)(() => {
15364 onChangeViewRef.current = onChangeView;
15365 viewRef.current = view;
15366 }, [onChangeView, view]);
15367 (0, import_element54.useEffect)(() => {
15368 if (debouncedSearch !== viewRef.current?.search) {
15369 onChangeViewRef.current({
15370 ...viewRef.current,
15371 page: view.page ? 1 : void 0,
15372 startPosition: view.startPosition ? 1 : void 0,
15373 search: debouncedSearch
15374 });
15375 }
15376 }, [debouncedSearch]);
15377 const searchLabel = label || (0, import_i18n30.__)("Search");
15378 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
15379 import_components28.SearchControl,
15380 {
15381 className: "dataviews-search",
15382 onChange: setSearch,
15383 value: search,
15384 label: searchLabel,
15385 placeholder: searchLabel,
15386 size: "compact"
15387 }
15388 );
15389 });
15390 var dataviews_search_default = DataViewsSearch;
15391
15392 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
15393 var import_components29 = __toESM(require_components(), 1);
15394 var import_i18n31 = __toESM(require_i18n(), 1);
15395 var import_element55 = __toESM(require_element(), 1);
15396 var import_warning = __toESM(require_warning(), 1);
15397 var import_compose10 = __toESM(require_compose(), 1);
15398 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
15399 var { Menu: Menu5 } = unlock(import_components29.privateApis);
15400 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
15401 className: "dataviews-config__popover",
15402 placement: "bottom-end",
15403 offset: 9
15404 };
15405 function ViewTypeMenu() {
15406 const { view, onChangeView, defaultLayouts } = (0, import_element55.useContext)(dataviews_context_default);
15407 const availableLayouts = Object.keys(defaultLayouts);
15408 if (availableLayouts.length <= 1) {
15409 return null;
15410 }
15411 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
15412 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Menu5, { children: [
15413 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15414 Menu5.TriggerButton,
15415 {
15416 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15417 import_components29.Button,
15418 {
15419 size: "compact",
15420 icon: activeView?.icon,
15421 label: (0, import_i18n31.__)("Layout")
15422 }
15423 )
15424 }
15425 ),
15426 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
15427 const config = VIEW_LAYOUTS.find(
15428 (v2) => v2.type === layout
15429 );
15430 if (!config) {
15431 return null;
15432 }
15433 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15434 Menu5.RadioItem,
15435 {
15436 value: layout,
15437 name: "view-actions-available-view",
15438 checked: layout === view.type,
15439 hideOnClick: true,
15440 onChange: (e2) => {
15441 switch (e2.target.value) {
15442 case "list":
15443 case "grid":
15444 case "table":
15445 case "pickerGrid":
15446 case "pickerTable":
15447 case "activity":
15448 const viewWithoutLayout = { ...view };
15449 if ("layout" in viewWithoutLayout) {
15450 delete viewWithoutLayout.layout;
15451 }
15452 return onChangeView({
15453 ...viewWithoutLayout,
15454 type: e2.target.value,
15455 ...defaultLayouts[e2.target.value]
15456 });
15457 }
15458 (0, import_warning.default)("Invalid dataview");
15459 },
15460 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Menu5.ItemLabel, { children: config.label })
15461 },
15462 layout
15463 );
15464 }) })
15465 ] });
15466 }
15467 function SortFieldControl() {
15468 const { view, fields: fields2, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
15469 const orderOptions = (0, import_element55.useMemo)(() => {
15470 const sortableFields = fields2.filter(
15471 (field) => field.enableSorting !== false
15472 );
15473 return sortableFields.map((field) => {
15474 return {
15475 label: field.label,
15476 value: field.id
15477 };
15478 });
15479 }, [fields2]);
15480 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15481 import_components29.SelectControl,
15482 {
15483 __next40pxDefaultSize: true,
15484 label: (0, import_i18n31.__)("Sort by"),
15485 value: view.sort?.field,
15486 options: orderOptions,
15487 onChange: (value) => {
15488 onChangeView({
15489 ...view,
15490 sort: {
15491 direction: view?.sort?.direction || "desc",
15492 field: value
15493 },
15494 showLevels: false
15495 });
15496 }
15497 }
15498 );
15499 }
15500 function SortDirectionControl() {
15501 const { view, fields: fields2, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
15502 const sortableFields = fields2.filter(
15503 (field) => field.enableSorting !== false
15504 );
15505 if (sortableFields.length === 0) {
15506 return null;
15507 }
15508 let value = view.sort?.direction;
15509 if (!value && view.sort?.field) {
15510 value = "desc";
15511 }
15512 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15513 import_components29.__experimentalToggleGroupControl,
15514 {
15515 className: "dataviews-view-config__sort-direction",
15516 __next40pxDefaultSize: true,
15517 isBlock: true,
15518 label: (0, import_i18n31.__)("Order"),
15519 value,
15520 onChange: (newDirection) => {
15521 if (newDirection === "asc" || newDirection === "desc") {
15522 onChangeView({
15523 ...view,
15524 sort: {
15525 direction: newDirection,
15526 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
15527 fields2.find(
15528 (field) => field.enableSorting !== false
15529 )?.id || ""
15530 },
15531 showLevels: false
15532 });
15533 return;
15534 }
15535 (0, import_warning.default)("Invalid direction");
15536 },
15537 children: SORTING_DIRECTIONS.map((direction) => {
15538 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15539 import_components29.__experimentalToggleGroupControlOptionIcon,
15540 {
15541 value: direction,
15542 icon: sortIcons[direction],
15543 label: sortLabels[direction]
15544 },
15545 direction
15546 );
15547 })
15548 }
15549 );
15550 }
15551 function ItemsPerPageControl() {
15552 const { view, config, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
15553 const { infiniteScrollEnabled } = view;
15554 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
15555 return null;
15556 }
15557 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15558 import_components29.__experimentalToggleGroupControl,
15559 {
15560 __next40pxDefaultSize: true,
15561 isBlock: true,
15562 label: (0, import_i18n31.__)("Items per page"),
15563 value: view.perPage || 10,
15564 disabled: !view?.sort?.field,
15565 onChange: (newItemsPerPage) => {
15566 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
15567 onChangeView({
15568 ...view,
15569 perPage: newItemsPerPageNumber,
15570 page: 1
15571 });
15572 },
15573 children: config.perPageSizes.map((value) => {
15574 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15575 import_components29.__experimentalToggleGroupControlOption,
15576 {
15577 value,
15578 label: value.toString()
15579 },
15580 value
15581 );
15582 })
15583 }
15584 );
15585 }
15586 function ResetViewButton() {
15587 const { onReset } = (0, import_element55.useContext)(dataviews_context_default);
15588 if (onReset === void 0) {
15589 return null;
15590 }
15591 const isDisabled = onReset === false;
15592 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15593 import_components29.Button,
15594 {
15595 variant: "tertiary",
15596 size: "compact",
15597 disabled: isDisabled,
15598 accessibleWhenDisabled: true,
15599 className: "dataviews-view-config__reset-button",
15600 onClick: () => {
15601 if (typeof onReset === "function") {
15602 onReset();
15603 }
15604 },
15605 children: (0, import_i18n31.__)("Reset view")
15606 }
15607 );
15608 }
15609 function DataviewsViewConfigDropdown() {
15610 const { view, onReset } = (0, import_element55.useContext)(dataviews_context_default);
15611 const popoverId = (0, import_compose10.useInstanceId)(
15612 _DataViewsViewConfig,
15613 "dataviews-view-config-dropdown"
15614 );
15615 const activeLayout = VIEW_LAYOUTS.find(
15616 (layout) => layout.type === view.type
15617 );
15618 const isModified = typeof onReset === "function";
15619 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15620 import_components29.Dropdown,
15621 {
15622 expandOnMobile: true,
15623 popoverProps: {
15624 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
15625 id: popoverId
15626 },
15627 renderToggle: ({ onToggle, isOpen }) => {
15628 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
15629 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15630 import_components29.Button,
15631 {
15632 size: "compact",
15633 icon: cog_default,
15634 label: (0, import_i18n31._x)(
15635 "View options",
15636 "View is used as a noun"
15637 ),
15638 onClick: onToggle,
15639 "aria-expanded": isOpen ? "true" : "false",
15640 "aria-controls": popoverId
15641 }
15642 ),
15643 isModified && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
15644 ] });
15645 },
15646 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15647 import_components29.__experimentalDropdownContentWrapper,
15648 {
15649 paddingSize: "medium",
15650 className: "dataviews-config__popover-content-wrapper",
15651 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
15652 Stack,
15653 {
15654 direction: "column",
15655 className: "dataviews-view-config",
15656 gap: "xl",
15657 children: [
15658 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
15659 Stack,
15660 {
15661 direction: "row",
15662 justify: "space-between",
15663 align: "center",
15664 className: "dataviews-view-config__header",
15665 children: [
15666 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15667 import_components29.__experimentalHeading,
15668 {
15669 level: 2,
15670 className: "dataviews-settings-section__title",
15671 children: (0, import_i18n31.__)("Appearance")
15672 }
15673 ),
15674 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ResetViewButton, {})
15675 ]
15676 }
15677 ),
15678 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Stack, { direction: "column", gap: "lg", children: [
15679 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
15680 Stack,
15681 {
15682 direction: "row",
15683 gap: "sm",
15684 className: "dataviews-view-config__sort-controls",
15685 children: [
15686 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(SortFieldControl, {}),
15687 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(SortDirectionControl, {})
15688 ]
15689 }
15690 ),
15691 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(activeLayout.viewConfigOptions, {}),
15692 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ItemsPerPageControl, {}),
15693 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(PropertiesSection, {})
15694 ] })
15695 ]
15696 }
15697 )
15698 }
15699 )
15700 }
15701 );
15702 }
15703 function _DataViewsViewConfig() {
15704 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [
15705 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ViewTypeMenu, {}),
15706 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(DataviewsViewConfigDropdown, {})
15707 ] });
15708 }
15709 var DataViewsViewConfig = (0, import_element55.memo)(_DataViewsViewConfig);
15710 var dataviews_view_config_default = DataViewsViewConfig;
15711
15712 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
15713 var import_components30 = __toESM(require_components(), 1);
15714 var import_element56 = __toESM(require_element(), 1);
15715
15716 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
15717 function getCustomValidity(isValid2, validity) {
15718 let customValidity;
15719 if (isValid2?.required && validity?.required) {
15720 customValidity = validity?.required?.message ? validity.required : void 0;
15721 } else if (isValid2?.pattern && validity?.pattern) {
15722 customValidity = validity.pattern;
15723 } else if (isValid2?.min && validity?.min) {
15724 customValidity = validity.min;
15725 } else if (isValid2?.max && validity?.max) {
15726 customValidity = validity.max;
15727 } else if (isValid2?.minLength && validity?.minLength) {
15728 customValidity = validity.minLength;
15729 } else if (isValid2?.maxLength && validity?.maxLength) {
15730 customValidity = validity.maxLength;
15731 } else if (isValid2?.elements && validity?.elements) {
15732 customValidity = validity.elements;
15733 } else if (validity?.custom) {
15734 customValidity = validity.custom;
15735 }
15736 return customValidity;
15737 }
15738
15739 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
15740 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
15741 var { ValidatedCheckboxControl } = unlock(import_components30.privateApis);
15742 function Checkbox({
15743 field,
15744 onChange,
15745 data,
15746 hideLabelFromVision,
15747 markWhenOptional,
15748 validity
15749 }) {
15750 const { getValue, setValue, label, description, isValid: isValid2 } = field;
15751 const disabled2 = field.isDisabled({ item: data, field });
15752 const onChangeControl = (0, import_element56.useCallback)(() => {
15753 onChange(
15754 setValue({ item: data, value: !getValue({ item: data }) })
15755 );
15756 }, [data, getValue, onChange, setValue]);
15757 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15758 ValidatedCheckboxControl,
15759 {
15760 required: !!field.isValid?.required,
15761 markWhenOptional,
15762 customValidity: getCustomValidity(isValid2, validity),
15763 hidden: hideLabelFromVision,
15764 label,
15765 help: description,
15766 checked: getValue({ item: data }),
15767 onChange: onChangeControl,
15768 disabled: disabled2
15769 }
15770 );
15771 }
15772
15773 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
15774 var import_components31 = __toESM(require_components(), 1);
15775 var import_element57 = __toESM(require_element(), 1);
15776 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
15777 var { ValidatedComboboxControl } = unlock(import_components31.privateApis);
15778 function Combobox3({
15779 data,
15780 field,
15781 onChange,
15782 hideLabelFromVision,
15783 validity
15784 }) {
15785 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
15786 const value = getValue({ item: data }) ?? "";
15787 const onChangeControl = (0, import_element57.useCallback)(
15788 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
15789 [data, onChange, setValue]
15790 );
15791 const { elements, isLoading } = useElements({
15792 elements: field.elements,
15793 getElements: field.getElements
15794 });
15795 if (isLoading) {
15796 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components31.Spinner, {});
15797 }
15798 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15799 ValidatedComboboxControl,
15800 {
15801 required: !!field.isValid?.required,
15802 customValidity: getCustomValidity(isValid2, validity),
15803 label,
15804 value,
15805 help: description,
15806 placeholder,
15807 options: elements,
15808 onChange: onChangeControl,
15809 hideLabelFromVision,
15810 allowReset: true,
15811 expandOnFocus: true
15812 }
15813 );
15814 }
15815
15816 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
15817 var import_components33 = __toESM(require_components(), 1);
15818 var import_element60 = __toESM(require_element(), 1);
15819 var import_i18n33 = __toESM(require_i18n(), 1);
15820 var import_date3 = __toESM(require_date(), 1);
15821
15822 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
15823 var import_components32 = __toESM(require_components(), 1);
15824 var import_element58 = __toESM(require_element(), 1);
15825 var import_i18n32 = __toESM(require_i18n(), 1);
15826 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
15827 var TIME_UNITS_OPTIONS = {
15828 [OPERATOR_IN_THE_PAST]: [
15829 { value: "days", label: (0, import_i18n32.__)("Days") },
15830 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
15831 { value: "months", label: (0, import_i18n32.__)("Months") },
15832 { value: "years", label: (0, import_i18n32.__)("Years") }
15833 ],
15834 [OPERATOR_OVER]: [
15835 { value: "days", label: (0, import_i18n32.__)("Days ago") },
15836 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
15837 { value: "months", label: (0, import_i18n32.__)("Months ago") },
15838 { value: "years", label: (0, import_i18n32.__)("Years ago") }
15839 ]
15840 };
15841 function RelativeDateControl({
15842 className,
15843 data,
15844 field,
15845 onChange,
15846 hideLabelFromVision,
15847 operator
15848 }) {
15849 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
15850 const { id, label, description, getValue, setValue } = field;
15851 const disabled2 = field.isDisabled({ item: data, field });
15852 const fieldValue = getValue({ item: data });
15853 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
15854 const onChangeValue = (0, import_element58.useCallback)(
15855 (newValue) => onChange(
15856 setValue({
15857 item: data,
15858 value: { value: Number(newValue), unit }
15859 })
15860 ),
15861 [onChange, setValue, data, unit]
15862 );
15863 const onChangeUnit = (0, import_element58.useCallback)(
15864 (newUnit) => onChange(
15865 setValue({
15866 item: data,
15867 value: { value: relValue, unit: newUnit }
15868 })
15869 ),
15870 [onChange, setValue, data, relValue]
15871 );
15872 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15873 import_components32.BaseControl,
15874 {
15875 id,
15876 className: clsx_default(className, "dataviews-controls__relative-date"),
15877 label,
15878 hideLabelFromVision,
15879 help: description,
15880 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "row", gap: "sm", children: [
15881 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15882 import_components32.__experimentalNumberControl,
15883 {
15884 __next40pxDefaultSize: true,
15885 className: "dataviews-controls__relative-date-number",
15886 spinControls: "none",
15887 min: 1,
15888 step: 1,
15889 value: relValue,
15890 onChange: onChangeValue,
15891 disabled: disabled2
15892 }
15893 ),
15894 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15895 import_components32.SelectControl,
15896 {
15897 className: "dataviews-controls__relative-date-unit",
15898 __next40pxDefaultSize: true,
15899 label: (0, import_i18n32.__)("Unit"),
15900 value: unit,
15901 options,
15902 onChange: onChangeUnit,
15903 hideLabelFromVision: true,
15904 disabled: disabled2
15905 }
15906 )
15907 ] })
15908 }
15909 );
15910 }
15911
15912 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
15913 var import_element59 = __toESM(require_element(), 1);
15914 function useDisabledDateMatchers(isValid2, parseDateFn) {
15915 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
15916 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
15917 const disabledMatchers = (0, import_element59.useMemo)(() => {
15918 const matchers = [];
15919 if (minConstraint) {
15920 const minDate = parseDateFn(minConstraint);
15921 if (minDate) {
15922 matchers.push({ before: minDate });
15923 }
15924 }
15925 if (maxConstraint) {
15926 const maxDate = parseDateFn(maxConstraint);
15927 if (maxDate) {
15928 matchers.push({ after: maxDate });
15929 }
15930 }
15931 return matchers.length > 0 ? matchers : void 0;
15932 }, [minConstraint, maxConstraint, parseDateFn]);
15933 return { minConstraint, maxConstraint, disabledMatchers };
15934 }
15935
15936 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
15937 var import_date2 = __toESM(require_date(), 1);
15938 function parseDateTime(dateTimeString) {
15939 if (!dateTimeString) {
15940 return null;
15941 }
15942 const parsed = (0, import_date2.getDate)(dateTimeString);
15943 return parsed && isValid(parsed) ? parsed : null;
15944 }
15945
15946 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
15947 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
15948 var { DateCalendar, ValidatedInputControl } = unlock(import_components33.privateApis);
15949 var formatDateTime = (value) => {
15950 if (!value) {
15951 return "";
15952 }
15953 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
15954 };
15955 function CalendarDateTimeControl({
15956 data,
15957 field,
15958 onChange,
15959 hideLabelFromVision,
15960 markWhenOptional,
15961 validity,
15962 config
15963 }) {
15964 const { compact } = config || {};
15965 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
15966 const disabled2 = field.isDisabled({ item: data, field });
15967 const fieldValue = getValue({ item: data });
15968 const value = typeof fieldValue === "string" ? fieldValue : void 0;
15969 const [calendarMonth, setCalendarMonth] = (0, import_element60.useState)(() => {
15970 const parsedDate = parseDateTime(value);
15971 return parsedDate || /* @__PURE__ */ new Date();
15972 });
15973 const inputControlRef = (0, import_element60.useRef)(null);
15974 const validationTimeoutRef = (0, import_element60.useRef)(void 0);
15975 const previousFocusRef = (0, import_element60.useRef)(null);
15976 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
15977 const onChangeCallback = (0, import_element60.useCallback)(
15978 (newValue) => onChange(setValue({ item: data, value: newValue })),
15979 [data, onChange, setValue]
15980 );
15981 (0, import_element60.useEffect)(() => {
15982 return () => {
15983 if (validationTimeoutRef.current) {
15984 clearTimeout(validationTimeoutRef.current);
15985 }
15986 };
15987 }, []);
15988 const onSelectDate = (0, import_element60.useCallback)(
15989 (newDate) => {
15990 let dateTimeValue;
15991 if (newDate) {
15992 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
15993 let wpTime;
15994 if (value) {
15995 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
15996 } else {
15997 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
15998 }
15999 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
16000 dateTimeValue = finalDateTime.toISOString();
16001 onChangeCallback(dateTimeValue);
16002 if (validationTimeoutRef.current) {
16003 clearTimeout(validationTimeoutRef.current);
16004 }
16005 } else {
16006 onChangeCallback(void 0);
16007 }
16008 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
16009 validationTimeoutRef.current = setTimeout(() => {
16010 if (inputControlRef.current) {
16011 inputControlRef.current.focus();
16012 inputControlRef.current.blur();
16013 onChangeCallback(dateTimeValue);
16014 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
16015 previousFocusRef.current.focus();
16016 }
16017 }
16018 }, 0);
16019 },
16020 [onChangeCallback, value]
16021 );
16022 const handleManualDateTimeChange = (0, import_element60.useCallback)(
16023 (newValue) => {
16024 if (newValue) {
16025 const dateTime = (0, import_date3.getDate)(newValue);
16026 onChangeCallback(dateTime.toISOString());
16027 const parsedDate = parseDateTime(dateTime.toISOString());
16028 if (parsedDate) {
16029 setCalendarMonth(parsedDate);
16030 }
16031 } else {
16032 onChangeCallback(void 0);
16033 }
16034 },
16035 [onChangeCallback]
16036 );
16037 const { format: fieldFormat } = field;
16038 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
16039 const {
16040 timezone: { string: timezoneString }
16041 } = (0, import_date3.getSettings)();
16042 let displayLabel = label;
16043 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
16044 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
16045 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
16046 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
16047 }
16048 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16049 import_components33.BaseControl,
16050 {
16051 id,
16052 label: displayLabel,
16053 help: description,
16054 hideLabelFromVision,
16055 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Stack, { direction: "column", gap: "lg", children: [
16056 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16057 ValidatedInputControl,
16058 {
16059 ref: inputControlRef,
16060 __next40pxDefaultSize: true,
16061 required: !!isValid2?.required,
16062 customValidity: getCustomValidity(isValid2, validity),
16063 type: "datetime-local",
16064 label: (0, import_i18n33.__)("Date time"),
16065 hideLabelFromVision: true,
16066 value: formatDateTime(value),
16067 onChange: handleManualDateTimeChange,
16068 disabled: disabled2,
16069 min: minConstraint ? formatDateTime(minConstraint) : void 0,
16070 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
16071 }
16072 ),
16073 !compact && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16074 DateCalendar,
16075 {
16076 style: { width: "100%" },
16077 selected: value ? parseDateTime(value) || void 0 : void 0,
16078 onSelect: onSelectDate,
16079 month: calendarMonth,
16080 onMonthChange: setCalendarMonth,
16081 timeZone: timezoneString || void 0,
16082 weekStartsOn,
16083 disabled: disabled2 || disabledMatchers
16084 }
16085 )
16086 ] })
16087 }
16088 );
16089 }
16090 function DateTime({
16091 data,
16092 field,
16093 onChange,
16094 hideLabelFromVision,
16095 markWhenOptional,
16096 operator,
16097 validity,
16098 config
16099 }) {
16100 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
16101 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16102 RelativeDateControl,
16103 {
16104 className: "dataviews-controls__datetime",
16105 data,
16106 field,
16107 onChange,
16108 hideLabelFromVision,
16109 operator
16110 }
16111 );
16112 }
16113 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16114 CalendarDateTimeControl,
16115 {
16116 data,
16117 field,
16118 onChange,
16119 hideLabelFromVision,
16120 markWhenOptional,
16121 validity,
16122 config
16123 }
16124 );
16125 }
16126
16127 // packages/dataviews/build-module/components/dataform-controls/date.mjs
16128 var import_components34 = __toESM(require_components(), 1);
16129 var import_element61 = __toESM(require_element(), 1);
16130 var import_i18n34 = __toESM(require_i18n(), 1);
16131 var import_date4 = __toESM(require_date(), 1);
16132 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
16133 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock(import_components34.privateApis);
16134 var DATE_PRESETS = [
16135 {
16136 id: "today",
16137 label: (0, import_i18n34.__)("Today"),
16138 getValue: () => (0, import_date4.getDate)(null)
16139 },
16140 {
16141 id: "yesterday",
16142 label: (0, import_i18n34.__)("Yesterday"),
16143 getValue: () => {
16144 const today = (0, import_date4.getDate)(null);
16145 return subDays(today, 1);
16146 }
16147 },
16148 {
16149 id: "past-week",
16150 label: (0, import_i18n34.__)("Past week"),
16151 getValue: () => {
16152 const today = (0, import_date4.getDate)(null);
16153 return subDays(today, 7);
16154 }
16155 },
16156 {
16157 id: "past-month",
16158 label: (0, import_i18n34.__)("Past month"),
16159 getValue: () => {
16160 const today = (0, import_date4.getDate)(null);
16161 return subMonths(today, 1);
16162 }
16163 }
16164 ];
16165 var DATE_RANGE_PRESETS = [
16166 {
16167 id: "last-7-days",
16168 label: (0, import_i18n34.__)("Last 7 days"),
16169 getValue: () => {
16170 const today = (0, import_date4.getDate)(null);
16171 return [subDays(today, 7), today];
16172 }
16173 },
16174 {
16175 id: "last-30-days",
16176 label: (0, import_i18n34.__)("Last 30 days"),
16177 getValue: () => {
16178 const today = (0, import_date4.getDate)(null);
16179 return [subDays(today, 30), today];
16180 }
16181 },
16182 {
16183 id: "month-to-date",
16184 label: (0, import_i18n34.__)("Month to date"),
16185 getValue: () => {
16186 const today = (0, import_date4.getDate)(null);
16187 return [startOfMonth(today), today];
16188 }
16189 },
16190 {
16191 id: "last-year",
16192 label: (0, import_i18n34.__)("Last year"),
16193 getValue: () => {
16194 const today = (0, import_date4.getDate)(null);
16195 return [subYears(today, 1), today];
16196 }
16197 },
16198 {
16199 id: "year-to-date",
16200 label: (0, import_i18n34.__)("Year to date"),
16201 getValue: () => {
16202 const today = (0, import_date4.getDate)(null);
16203 return [startOfYear(today), today];
16204 }
16205 }
16206 ];
16207 var parseDate = (dateString) => {
16208 if (!dateString) {
16209 return null;
16210 }
16211 const parsed = (0, import_date4.getDate)(dateString);
16212 return parsed && isValid(parsed) ? parsed : null;
16213 };
16214 var formatDate = (date) => {
16215 if (!date) {
16216 return "";
16217 }
16218 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
16219 };
16220 function ValidatedDateControl({
16221 field,
16222 validity,
16223 inputRefs,
16224 isTouched,
16225 setIsTouched,
16226 children
16227 }) {
16228 const { isValid: isValid2 } = field;
16229 const [customValidity, setCustomValidity] = (0, import_element61.useState)(void 0);
16230 const validateRefs = (0, import_element61.useCallback)(() => {
16231 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
16232 for (const ref of refs) {
16233 const input = ref.current;
16234 if (input && !input.validity.valid) {
16235 setCustomValidity({
16236 type: "invalid",
16237 message: input.validationMessage
16238 });
16239 return;
16240 }
16241 }
16242 setCustomValidity(void 0);
16243 }, [inputRefs]);
16244 (0, import_element61.useEffect)(() => {
16245 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
16246 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
16247 for (const ref of refs) {
16248 const input = ref.current;
16249 if (input) {
16250 input.setCustomValidity(
16251 result?.type === "invalid" && result.message ? result.message : ""
16252 );
16253 }
16254 }
16255 }, [inputRefs, isValid2, validity]);
16256 (0, import_element61.useEffect)(() => {
16257 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
16258 const handleInvalid = (event) => {
16259 event.preventDefault();
16260 setIsTouched(true);
16261 };
16262 for (const ref of refs) {
16263 ref.current?.addEventListener("invalid", handleInvalid);
16264 }
16265 return () => {
16266 for (const ref of refs) {
16267 ref.current?.removeEventListener("invalid", handleInvalid);
16268 }
16269 };
16270 }, [inputRefs, setIsTouched]);
16271 (0, import_element61.useEffect)(() => {
16272 if (!isTouched) {
16273 return;
16274 }
16275 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
16276 if (result) {
16277 setCustomValidity(result);
16278 } else {
16279 validateRefs();
16280 }
16281 }, [isTouched, isValid2, validity, validateRefs]);
16282 const onBlur = (event) => {
16283 if (isTouched) {
16284 return;
16285 }
16286 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
16287 setIsTouched(true);
16288 }
16289 };
16290 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { onBlur, children: [
16291 children,
16292 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16293 "p",
16294 {
16295 className: clsx_default(
16296 "components-validated-control__indicator",
16297 customValidity.type === "invalid" ? "is-invalid" : void 0
16298 ),
16299 children: [
16300 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16301 import_components34.Icon,
16302 {
16303 className: "components-validated-control__indicator-icon",
16304 icon: error_default,
16305 size: 16,
16306 fill: "currentColor"
16307 }
16308 ),
16309 customValidity.message
16310 ]
16311 }
16312 ) })
16313 ] });
16314 }
16315 function CalendarDateControl({
16316 data,
16317 field,
16318 onChange,
16319 hideLabelFromVision,
16320 markWhenOptional,
16321 validity
16322 }) {
16323 const {
16324 id,
16325 label,
16326 description,
16327 setValue,
16328 getValue,
16329 isValid: isValid2,
16330 format: fieldFormat
16331 } = field;
16332 const disabled2 = field.isDisabled({ item: data, field });
16333 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
16334 null
16335 );
16336 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
16337 const fieldValue = getValue({ item: data });
16338 const value = typeof fieldValue === "string" ? fieldValue : void 0;
16339 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
16340 const parsedDate = parseDate(value);
16341 return parsedDate || /* @__PURE__ */ new Date();
16342 });
16343 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
16344 const validityTargetRef = (0, import_element61.useRef)(null);
16345 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
16346 const onChangeCallback = (0, import_element61.useCallback)(
16347 (newValue) => onChange(setValue({ item: data, value: newValue })),
16348 [data, onChange, setValue]
16349 );
16350 const onSelectDate = (0, import_element61.useCallback)(
16351 (newDate) => {
16352 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
16353 onChangeCallback(dateValue);
16354 setSelectedPresetId(null);
16355 setIsTouched(true);
16356 },
16357 [onChangeCallback]
16358 );
16359 const handlePresetClick = (0, import_element61.useCallback)(
16360 (preset) => {
16361 const presetDate = preset.getValue();
16362 const dateValue = formatDate(presetDate);
16363 setCalendarMonth(presetDate);
16364 onChangeCallback(dateValue);
16365 setSelectedPresetId(preset.id);
16366 setIsTouched(true);
16367 },
16368 [onChangeCallback]
16369 );
16370 const handleManualDateChange = (0, import_element61.useCallback)(
16371 (newValue) => {
16372 onChangeCallback(newValue);
16373 if (newValue) {
16374 const parsedDate = parseDate(newValue);
16375 if (parsedDate) {
16376 setCalendarMonth(parsedDate);
16377 }
16378 }
16379 setSelectedPresetId(null);
16380 setIsTouched(true);
16381 },
16382 [onChangeCallback]
16383 );
16384 const {
16385 timezone: { string: timezoneString }
16386 } = (0, import_date4.getSettings)();
16387 let displayLabel = label;
16388 if (isValid2?.required && !markWhenOptional) {
16389 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
16390 } else if (!isValid2?.required && markWhenOptional) {
16391 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
16392 }
16393 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16394 ValidatedDateControl,
16395 {
16396 field,
16397 validity,
16398 inputRefs: validityTargetRef,
16399 isTouched,
16400 setIsTouched,
16401 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16402 import_components34.BaseControl,
16403 {
16404 id,
16405 className: "dataviews-controls__date",
16406 label: displayLabel,
16407 help: description,
16408 hideLabelFromVision,
16409 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
16410 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16411 Stack,
16412 {
16413 direction: "row",
16414 gap: "sm",
16415 wrap: "wrap",
16416 justify: "flex-start",
16417 children: [
16418 DATE_PRESETS.map((preset) => {
16419 const isSelected2 = selectedPresetId === preset.id;
16420 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16421 import_components34.Button,
16422 {
16423 className: "dataviews-controls__date-preset",
16424 variant: "tertiary",
16425 isPressed: isSelected2,
16426 size: "small",
16427 disabled: disabled2,
16428 accessibleWhenDisabled: true,
16429 onClick: () => handlePresetClick(preset),
16430 children: preset.label
16431 },
16432 preset.id
16433 );
16434 }),
16435 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16436 import_components34.Button,
16437 {
16438 className: "dataviews-controls__date-preset",
16439 variant: "tertiary",
16440 isPressed: !selectedPresetId,
16441 size: "small",
16442 disabled: !!selectedPresetId || disabled2,
16443 accessibleWhenDisabled: true,
16444 children: (0, import_i18n34.__)("Custom")
16445 }
16446 )
16447 ]
16448 }
16449 ),
16450 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16451 import_components34.__experimentalInputControl,
16452 {
16453 __next40pxDefaultSize: true,
16454 ref: validityTargetRef,
16455 type: "date",
16456 label: (0, import_i18n34.__)("Date"),
16457 hideLabelFromVision: true,
16458 value,
16459 onChange: handleManualDateChange,
16460 required: !!field.isValid?.required,
16461 disabled: disabled2,
16462 min: minConstraint,
16463 max: maxConstraint
16464 }
16465 ),
16466 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16467 DateCalendar2,
16468 {
16469 style: { width: "100%" },
16470 selected: value ? parseDate(value) || void 0 : void 0,
16471 onSelect: onSelectDate,
16472 month: calendarMonth,
16473 onMonthChange: setCalendarMonth,
16474 timeZone: timezoneString || void 0,
16475 weekStartsOn,
16476 disabled: disabled2 || disabledMatchers,
16477 disableNavigation: disabled2
16478 }
16479 )
16480 ] })
16481 }
16482 )
16483 }
16484 );
16485 }
16486 function CalendarDateRangeControl({
16487 data,
16488 field,
16489 onChange,
16490 hideLabelFromVision,
16491 markWhenOptional,
16492 validity
16493 }) {
16494 const {
16495 id,
16496 label,
16497 description,
16498 getValue,
16499 setValue,
16500 isValid: isValid2,
16501 format: fieldFormat
16502 } = field;
16503 const disabled2 = field.isDisabled({ item: data, field });
16504 let value;
16505 const fieldValue = getValue({ item: data });
16506 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
16507 value = fieldValue;
16508 }
16509 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
16510 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
16511 const onChangeCallback = (0, import_element61.useCallback)(
16512 (newValue) => {
16513 onChange(
16514 setValue({
16515 item: data,
16516 value: newValue
16517 })
16518 );
16519 },
16520 [data, onChange, setValue]
16521 );
16522 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
16523 null
16524 );
16525 const selectedRange = (0, import_element61.useMemo)(() => {
16526 if (!value) {
16527 return { from: void 0, to: void 0 };
16528 }
16529 const [from, to] = value;
16530 return {
16531 from: parseDate(from) || void 0,
16532 to: parseDate(to) || void 0
16533 };
16534 }, [value]);
16535 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
16536 return selectedRange.from || /* @__PURE__ */ new Date();
16537 });
16538 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
16539 const fromInputRef = (0, import_element61.useRef)(null);
16540 const toInputRef = (0, import_element61.useRef)(null);
16541 const updateDateRange = (0, import_element61.useCallback)(
16542 (fromDate, toDate2) => {
16543 if (fromDate && toDate2) {
16544 onChangeCallback([
16545 formatDate(fromDate),
16546 formatDate(toDate2)
16547 ]);
16548 } else if (!fromDate && !toDate2) {
16549 onChangeCallback(void 0);
16550 }
16551 },
16552 [onChangeCallback]
16553 );
16554 const onSelectCalendarRange = (0, import_element61.useCallback)(
16555 (newRange) => {
16556 updateDateRange(newRange?.from, newRange?.to);
16557 setSelectedPresetId(null);
16558 setIsTouched(true);
16559 },
16560 [updateDateRange]
16561 );
16562 const handlePresetClick = (0, import_element61.useCallback)(
16563 (preset) => {
16564 const [startDate, endDate] = preset.getValue();
16565 setCalendarMonth(startDate);
16566 updateDateRange(startDate, endDate);
16567 setSelectedPresetId(preset.id);
16568 setIsTouched(true);
16569 },
16570 [updateDateRange]
16571 );
16572 const handleManualDateChange = (0, import_element61.useCallback)(
16573 (fromOrTo, newValue) => {
16574 const [currentFrom, currentTo] = value || [
16575 void 0,
16576 void 0
16577 ];
16578 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
16579 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
16580 updateDateRange(updatedFrom, updatedTo);
16581 if (newValue) {
16582 const parsedDate = parseDate(newValue);
16583 if (parsedDate) {
16584 setCalendarMonth(parsedDate);
16585 }
16586 }
16587 setSelectedPresetId(null);
16588 setIsTouched(true);
16589 },
16590 [value, updateDateRange]
16591 );
16592 const { timezone } = (0, import_date4.getSettings)();
16593 let displayLabel = label;
16594 if (field.isValid?.required && !markWhenOptional) {
16595 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
16596 } else if (!field.isValid?.required && markWhenOptional) {
16597 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
16598 }
16599 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16600 ValidatedDateControl,
16601 {
16602 field,
16603 validity,
16604 inputRefs: [fromInputRef, toInputRef],
16605 isTouched,
16606 setIsTouched,
16607 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16608 import_components34.BaseControl,
16609 {
16610 id,
16611 className: "dataviews-controls__date",
16612 label: displayLabel,
16613 help: description,
16614 hideLabelFromVision,
16615 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
16616 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16617 Stack,
16618 {
16619 direction: "row",
16620 gap: "sm",
16621 wrap: "wrap",
16622 justify: "flex-start",
16623 children: [
16624 DATE_RANGE_PRESETS.map((preset) => {
16625 const isSelected2 = selectedPresetId === preset.id;
16626 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16627 import_components34.Button,
16628 {
16629 className: "dataviews-controls__date-preset",
16630 variant: "tertiary",
16631 isPressed: isSelected2,
16632 size: "small",
16633 disabled: disabled2,
16634 accessibleWhenDisabled: true,
16635 onClick: () => handlePresetClick(preset),
16636 children: preset.label
16637 },
16638 preset.id
16639 );
16640 }),
16641 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16642 import_components34.Button,
16643 {
16644 className: "dataviews-controls__date-preset",
16645 variant: "tertiary",
16646 isPressed: !selectedPresetId,
16647 size: "small",
16648 accessibleWhenDisabled: true,
16649 disabled: !!selectedPresetId || disabled2,
16650 children: (0, import_i18n34.__)("Custom")
16651 }
16652 )
16653 ]
16654 }
16655 ),
16656 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16657 Stack,
16658 {
16659 direction: "row",
16660 gap: "sm",
16661 justify: "space-between",
16662 className: "dataviews-controls__date-range-inputs",
16663 children: [
16664 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16665 import_components34.__experimentalInputControl,
16666 {
16667 __next40pxDefaultSize: true,
16668 ref: fromInputRef,
16669 type: "date",
16670 label: (0, import_i18n34.__)("From"),
16671 hideLabelFromVision: true,
16672 value: value?.[0],
16673 onChange: (newValue) => handleManualDateChange("from", newValue),
16674 required: !!field.isValid?.required,
16675 disabled: disabled2,
16676 min: minConstraint,
16677 max: maxConstraint
16678 }
16679 ),
16680 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16681 import_components34.__experimentalInputControl,
16682 {
16683 __next40pxDefaultSize: true,
16684 ref: toInputRef,
16685 type: "date",
16686 label: (0, import_i18n34.__)("To"),
16687 hideLabelFromVision: true,
16688 value: value?.[1],
16689 onChange: (newValue) => handleManualDateChange("to", newValue),
16690 required: !!field.isValid?.required,
16691 disabled: disabled2,
16692 min: minConstraint,
16693 max: maxConstraint
16694 }
16695 )
16696 ]
16697 }
16698 ),
16699 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16700 DateRangeCalendar,
16701 {
16702 style: { width: "100%" },
16703 selected: selectedRange,
16704 onSelect: onSelectCalendarRange,
16705 month: calendarMonth,
16706 onMonthChange: setCalendarMonth,
16707 timeZone: timezone.string || void 0,
16708 weekStartsOn,
16709 disabled: disabled2 || disabledMatchers
16710 }
16711 )
16712 ] })
16713 }
16714 )
16715 }
16716 );
16717 }
16718 function DateControl({
16719 data,
16720 field,
16721 onChange,
16722 hideLabelFromVision,
16723 markWhenOptional,
16724 operator,
16725 validity
16726 }) {
16727 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
16728 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16729 RelativeDateControl,
16730 {
16731 className: "dataviews-controls__date",
16732 data,
16733 field,
16734 onChange,
16735 hideLabelFromVision,
16736 operator
16737 }
16738 );
16739 }
16740 if (operator === OPERATOR_BETWEEN) {
16741 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16742 CalendarDateRangeControl,
16743 {
16744 data,
16745 field,
16746 onChange,
16747 hideLabelFromVision,
16748 markWhenOptional,
16749 validity
16750 }
16751 );
16752 }
16753 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16754 CalendarDateControl,
16755 {
16756 data,
16757 field,
16758 onChange,
16759 hideLabelFromVision,
16760 markWhenOptional,
16761 validity
16762 }
16763 );
16764 }
16765
16766 // packages/dataviews/build-module/components/dataform-controls/select.mjs
16767 var import_components35 = __toESM(require_components(), 1);
16768 var import_element62 = __toESM(require_element(), 1);
16769 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
16770 var { ValidatedSelectControl } = unlock(import_components35.privateApis);
16771 function Select({
16772 data,
16773 field,
16774 onChange,
16775 hideLabelFromVision,
16776 markWhenOptional,
16777 validity
16778 }) {
16779 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
16780 const disabled2 = field.isDisabled({ item: data, field });
16781 const isMultiple = type === "array";
16782 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
16783 const onChangeControl = (0, import_element62.useCallback)(
16784 (newValue) => onChange(setValue({ item: data, value: newValue })),
16785 [data, onChange, setValue]
16786 );
16787 const { elements, isLoading } = useElements({
16788 elements: field.elements,
16789 getElements: field.getElements
16790 });
16791 if (isLoading) {
16792 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components35.Spinner, {});
16793 }
16794 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16795 ValidatedSelectControl,
16796 {
16797 required: !!field.isValid?.required,
16798 markWhenOptional,
16799 customValidity: getCustomValidity(isValid2, validity),
16800 label,
16801 value,
16802 help: description,
16803 options: elements,
16804 onChange: onChangeControl,
16805 __next40pxDefaultSize: true,
16806 hideLabelFromVision,
16807 multiple: isMultiple,
16808 disabled: disabled2
16809 }
16810 );
16811 }
16812
16813 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
16814 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
16815 var ELEMENTS_THRESHOLD = 10;
16816 function AdaptiveSelect(props) {
16817 const { field } = props;
16818 const { elements } = useElements({
16819 elements: field.elements,
16820 getElements: field.getElements
16821 });
16822 if (elements.length >= ELEMENTS_THRESHOLD) {
16823 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Combobox3, { ...props });
16824 }
16825 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Select, { ...props });
16826 }
16827
16828 // packages/dataviews/build-module/components/dataform-controls/email.mjs
16829 var import_components37 = __toESM(require_components(), 1);
16830
16831 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
16832 var import_components36 = __toESM(require_components(), 1);
16833 var import_element63 = __toESM(require_element(), 1);
16834 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
16835 var { ValidatedInputControl: ValidatedInputControl2 } = unlock(import_components36.privateApis);
16836 function ValidatedText({
16837 data,
16838 field,
16839 onChange,
16840 hideLabelFromVision,
16841 markWhenOptional,
16842 type,
16843 prefix,
16844 suffix,
16845 validity
16846 }) {
16847 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
16848 const value = getValue({ item: data });
16849 const disabled2 = field.isDisabled({ item: data, field });
16850 const onChangeControl = (0, import_element63.useCallback)(
16851 (newValue) => onChange(
16852 setValue({
16853 item: data,
16854 value: newValue
16855 })
16856 ),
16857 [data, setValue, onChange]
16858 );
16859 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
16860 ValidatedInputControl2,
16861 {
16862 required: !!isValid2.required,
16863 markWhenOptional,
16864 customValidity: getCustomValidity(isValid2, validity),
16865 label,
16866 placeholder,
16867 value: value ?? "",
16868 help: description,
16869 onChange: onChangeControl,
16870 hideLabelFromVision,
16871 type,
16872 prefix,
16873 suffix,
16874 disabled: disabled2,
16875 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
16876 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
16877 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
16878 __next40pxDefaultSize: true
16879 }
16880 );
16881 }
16882
16883 // packages/dataviews/build-module/components/dataform-controls/email.mjs
16884 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
16885 function Email({
16886 data,
16887 field,
16888 onChange,
16889 hideLabelFromVision,
16890 markWhenOptional,
16891 validity
16892 }) {
16893 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
16894 ValidatedText,
16895 {
16896 ...{
16897 data,
16898 field,
16899 onChange,
16900 hideLabelFromVision,
16901 markWhenOptional,
16902 validity,
16903 type: "email",
16904 prefix: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components37.Icon, { icon: envelope_default }) })
16905 }
16906 }
16907 );
16908 }
16909
16910 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
16911 var import_components38 = __toESM(require_components(), 1);
16912 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
16913 function Telephone({
16914 data,
16915 field,
16916 onChange,
16917 hideLabelFromVision,
16918 markWhenOptional,
16919 validity
16920 }) {
16921 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
16922 ValidatedText,
16923 {
16924 ...{
16925 data,
16926 field,
16927 onChange,
16928 hideLabelFromVision,
16929 markWhenOptional,
16930 validity,
16931 type: "tel",
16932 prefix: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components38.Icon, { icon: mobile_default }) })
16933 }
16934 }
16935 );
16936 }
16937
16938 // packages/dataviews/build-module/components/dataform-controls/url.mjs
16939 var import_components39 = __toESM(require_components(), 1);
16940 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
16941 function Url({
16942 data,
16943 field,
16944 onChange,
16945 hideLabelFromVision,
16946 markWhenOptional,
16947 validity
16948 }) {
16949 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
16950 ValidatedText,
16951 {
16952 ...{
16953 data,
16954 field,
16955 onChange,
16956 hideLabelFromVision,
16957 markWhenOptional,
16958 validity,
16959 type: "url",
16960 prefix: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components39.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components39.Icon, { icon: link_default }) })
16961 }
16962 }
16963 );
16964 }
16965
16966 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
16967 var import_components40 = __toESM(require_components(), 1);
16968 var import_element64 = __toESM(require_element(), 1);
16969 var import_i18n35 = __toESM(require_i18n(), 1);
16970 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
16971 var { ValidatedNumberControl } = unlock(import_components40.privateApis);
16972 function toNumberOrEmpty(value) {
16973 if (value === "" || value === void 0) {
16974 return "";
16975 }
16976 const number = Number(value);
16977 return Number.isFinite(number) ? number : "";
16978 }
16979 function BetweenControls({
16980 value,
16981 onChange,
16982 hideLabelFromVision,
16983 step
16984 }) {
16985 const [min = "", max = ""] = value;
16986 const onChangeMin = (0, import_element64.useCallback)(
16987 (newValue) => onChange([toNumberOrEmpty(newValue), max]),
16988 [onChange, max]
16989 );
16990 const onChangeMax = (0, import_element64.useCallback)(
16991 (newValue) => onChange([min, toNumberOrEmpty(newValue)]),
16992 [onChange, min]
16993 );
16994 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
16995 import_components40.BaseControl,
16996 {
16997 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
16998 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_components40.Flex, { direction: "row", gap: 4, children: [
16999 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17000 import_components40.__experimentalNumberControl,
17001 {
17002 label: (0, import_i18n35.__)("Min."),
17003 value: min,
17004 max: max ? Number(max) - step : void 0,
17005 onChange: onChangeMin,
17006 __next40pxDefaultSize: true,
17007 hideLabelFromVision,
17008 step
17009 }
17010 ),
17011 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17012 import_components40.__experimentalNumberControl,
17013 {
17014 label: (0, import_i18n35.__)("Max."),
17015 value: max,
17016 min: min ? Number(min) + step : void 0,
17017 onChange: onChangeMax,
17018 __next40pxDefaultSize: true,
17019 hideLabelFromVision,
17020 step
17021 }
17022 )
17023 ] })
17024 }
17025 );
17026 }
17027 function ValidatedNumber({
17028 data,
17029 field,
17030 onChange,
17031 hideLabelFromVision,
17032 markWhenOptional,
17033 operator,
17034 validity
17035 }) {
17036 const decimals = field.format?.decimals ?? 0;
17037 const step = Math.pow(10, Math.abs(decimals) * -1);
17038 const { label, description, getValue, setValue, isValid: isValid2 } = field;
17039 const value = getValue({ item: data }) ?? "";
17040 const disabled2 = field.isDisabled({ item: data, field });
17041 const onChangeControl = (0, import_element64.useCallback)(
17042 (newValue) => {
17043 onChange(
17044 setValue({
17045 item: data,
17046 // Do not convert an empty string or undefined to a number,
17047 // otherwise there's a mismatch between the UI control (empty)
17048 // and the data relied by onChange (0).
17049 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
17050 })
17051 );
17052 },
17053 [data, onChange, setValue]
17054 );
17055 const onChangeBetweenControls = (0, import_element64.useCallback)(
17056 (newValue) => {
17057 onChange(
17058 setValue({
17059 item: data,
17060 value: newValue
17061 })
17062 );
17063 },
17064 [data, onChange, setValue]
17065 );
17066 if (operator === OPERATOR_BETWEEN) {
17067 let valueBetween = ["", ""];
17068 if (Array.isArray(value) && value.length === 2 && value.every(
17069 (element) => typeof element === "number" || element === ""
17070 )) {
17071 valueBetween = value;
17072 }
17073 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17074 BetweenControls,
17075 {
17076 value: valueBetween,
17077 onChange: onChangeBetweenControls,
17078 hideLabelFromVision,
17079 step
17080 }
17081 );
17082 }
17083 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17084 ValidatedNumberControl,
17085 {
17086 required: !!isValid2.required,
17087 markWhenOptional,
17088 customValidity: getCustomValidity(isValid2, validity),
17089 label,
17090 help: description,
17091 value,
17092 onChange: onChangeControl,
17093 __next40pxDefaultSize: true,
17094 hideLabelFromVision,
17095 step,
17096 min: isValid2.min ? isValid2.min.constraint : void 0,
17097 max: isValid2.max ? isValid2.max.constraint : void 0,
17098 disabled: disabled2
17099 }
17100 );
17101 }
17102
17103 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
17104 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
17105 function Integer(props) {
17106 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(ValidatedNumber, { ...props });
17107 }
17108
17109 // packages/dataviews/build-module/components/dataform-controls/number.mjs
17110 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
17111 function Number2(props) {
17112 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(ValidatedNumber, { ...props });
17113 }
17114
17115 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
17116 var import_components41 = __toESM(require_components(), 1);
17117 var import_element65 = __toESM(require_element(), 1);
17118 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
17119 var { ValidatedRadioControl } = unlock(import_components41.privateApis);
17120 function Radio({
17121 data,
17122 field,
17123 onChange,
17124 hideLabelFromVision,
17125 markWhenOptional,
17126 validity
17127 }) {
17128 const { label, description, getValue, setValue, isValid: isValid2 } = field;
17129 const disabled2 = field.isDisabled({ item: data, field });
17130 const { elements, isLoading } = useElements({
17131 elements: field.elements,
17132 getElements: field.getElements
17133 });
17134 const value = getValue({ item: data });
17135 const onChangeControl = (0, import_element65.useCallback)(
17136 (newValue) => onChange(setValue({ item: data, value: newValue })),
17137 [data, onChange, setValue]
17138 );
17139 if (isLoading) {
17140 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components41.Spinner, {});
17141 }
17142 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
17143 ValidatedRadioControl,
17144 {
17145 required: !!field.isValid?.required,
17146 markWhenOptional,
17147 customValidity: getCustomValidity(isValid2, validity),
17148 label,
17149 help: description,
17150 onChange: onChangeControl,
17151 options: elements,
17152 selected: value,
17153 hideLabelFromVision,
17154 disabled: disabled2
17155 }
17156 );
17157 }
17158
17159 // packages/dataviews/build-module/components/dataform-controls/text.mjs
17160 var import_element66 = __toESM(require_element(), 1);
17161 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
17162 function Text4({
17163 data,
17164 field,
17165 onChange,
17166 hideLabelFromVision,
17167 markWhenOptional,
17168 config,
17169 validity
17170 }) {
17171 const { prefix, suffix } = config || {};
17172 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
17173 ValidatedText,
17174 {
17175 ...{
17176 data,
17177 field,
17178 onChange,
17179 hideLabelFromVision,
17180 markWhenOptional,
17181 validity,
17182 prefix: prefix ? (0, import_element66.createElement)(prefix) : void 0,
17183 suffix: suffix ? (0, import_element66.createElement)(suffix) : void 0
17184 }
17185 }
17186 );
17187 }
17188
17189 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
17190 var import_components42 = __toESM(require_components(), 1);
17191 var import_element67 = __toESM(require_element(), 1);
17192 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
17193 var { ValidatedToggleControl } = unlock(import_components42.privateApis);
17194 function Toggle({
17195 field,
17196 onChange,
17197 data,
17198 hideLabelFromVision,
17199 markWhenOptional,
17200 validity
17201 }) {
17202 const { label, description, getValue, setValue, isValid: isValid2 } = field;
17203 const disabled2 = field.isDisabled({ item: data, field });
17204 const onChangeControl = (0, import_element67.useCallback)(() => {
17205 onChange(
17206 setValue({ item: data, value: !getValue({ item: data }) })
17207 );
17208 }, [onChange, setValue, data, getValue]);
17209 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
17210 ValidatedToggleControl,
17211 {
17212 required: !!isValid2.required,
17213 markWhenOptional,
17214 customValidity: getCustomValidity(isValid2, validity),
17215 hidden: hideLabelFromVision,
17216 label,
17217 help: description,
17218 checked: getValue({ item: data }),
17219 onChange: onChangeControl,
17220 disabled: disabled2
17221 }
17222 );
17223 }
17224
17225 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
17226 var import_components43 = __toESM(require_components(), 1);
17227 var import_element68 = __toESM(require_element(), 1);
17228 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
17229 var { ValidatedTextareaControl } = unlock(import_components43.privateApis);
17230 function Textarea({
17231 data,
17232 field,
17233 onChange,
17234 hideLabelFromVision,
17235 markWhenOptional,
17236 config,
17237 validity
17238 }) {
17239 const { rows = 4 } = config || {};
17240 const disabled2 = field.isDisabled({ item: data, field });
17241 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
17242 const value = field.getValue({ item: data });
17243 const onChangeControl = (0, import_element68.useCallback)(
17244 (newValue) => onChange(setValue({ item: data, value: newValue })),
17245 [data, onChange, setValue]
17246 );
17247 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
17248 ValidatedTextareaControl,
17249 {
17250 required: !!isValid2.required,
17251 markWhenOptional,
17252 customValidity: getCustomValidity(isValid2, validity),
17253 label,
17254 placeholder,
17255 value: value ?? "",
17256 help: description,
17257 onChange: onChangeControl,
17258 rows,
17259 disabled: disabled2,
17260 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
17261 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
17262 __next40pxDefaultSize: true,
17263 hideLabelFromVision
17264 }
17265 );
17266 }
17267
17268 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
17269 var import_components44 = __toESM(require_components(), 1);
17270 var import_element69 = __toESM(require_element(), 1);
17271 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
17272 var { ValidatedToggleGroupControl } = unlock(import_components44.privateApis);
17273 function ToggleGroup({
17274 data,
17275 field,
17276 onChange,
17277 hideLabelFromVision,
17278 markWhenOptional,
17279 validity
17280 }) {
17281 const { getValue, setValue, isValid: isValid2 } = field;
17282 const disabled2 = field.isDisabled({ item: data, field });
17283 const value = getValue({ item: data });
17284 const onChangeControl = (0, import_element69.useCallback)(
17285 (newValue) => onChange(setValue({ item: data, value: newValue })),
17286 [data, onChange, setValue]
17287 );
17288 const { elements, isLoading } = useElements({
17289 elements: field.elements,
17290 getElements: field.getElements
17291 });
17292 if (isLoading) {
17293 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.Spinner, {});
17294 }
17295 if (elements.length === 0) {
17296 return null;
17297 }
17298 const selectedOption = elements.find((el) => el.value === value);
17299 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
17300 ValidatedToggleGroupControl,
17301 {
17302 required: !!field.isValid?.required,
17303 markWhenOptional,
17304 customValidity: getCustomValidity(isValid2, validity),
17305 __next40pxDefaultSize: true,
17306 isBlock: true,
17307 label: field.label,
17308 help: selectedOption?.description || field.description,
17309 onChange: onChangeControl,
17310 value,
17311 hideLabelFromVision,
17312 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
17313 import_components44.__experimentalToggleGroupControlOption,
17314 {
17315 label: el.label,
17316 value: el.value,
17317 disabled: disabled2
17318 },
17319 el.value
17320 ))
17321 }
17322 );
17323 }
17324
17325 // packages/dataviews/build-module/components/dataform-controls/array.mjs
17326 var import_components45 = __toESM(require_components(), 1);
17327 var import_element70 = __toESM(require_element(), 1);
17328 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
17329 var { ValidatedFormTokenField } = unlock(import_components45.privateApis);
17330 function ArrayControl({
17331 data,
17332 field,
17333 onChange,
17334 hideLabelFromVision,
17335 markWhenOptional,
17336 validity
17337 }) {
17338 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field;
17339 const value = getValue({ item: data });
17340 const disabled2 = field.isDisabled({ item: data, field });
17341 const { elements, isLoading } = useElements({
17342 elements: field.elements,
17343 getElements: field.getElements
17344 });
17345 const arrayValueAsElements = (0, import_element70.useMemo)(
17346 () => Array.isArray(value) ? value.map((token) => {
17347 const element = elements?.find(
17348 (suggestion) => suggestion.value === token
17349 );
17350 return element || { value: token, label: token };
17351 }) : [],
17352 [value, elements]
17353 );
17354 const onChangeControl = (0, import_element70.useCallback)(
17355 (tokens) => {
17356 const valueTokens = tokens.map((token) => {
17357 if (typeof token === "object" && "value" in token) {
17358 return token.value;
17359 }
17360 return token;
17361 });
17362 onChange(setValue({ item: data, value: valueTokens }));
17363 },
17364 [onChange, setValue, data]
17365 );
17366 if (isLoading) {
17367 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components45.Spinner, {});
17368 }
17369 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
17370 ValidatedFormTokenField,
17371 {
17372 required: !!isValid2?.required,
17373 markWhenOptional,
17374 customValidity: getCustomValidity(isValid2, validity),
17375 label: hideLabelFromVision ? void 0 : label,
17376 value: arrayValueAsElements,
17377 onChange: onChangeControl,
17378 placeholder,
17379 suggestions: elements?.map((element) => element.value),
17380 disabled: disabled2,
17381 __experimentalValidateInput: (token) => {
17382 if (field.isValid?.elements && elements) {
17383 return elements.some(
17384 (element) => element.value === token || element.label === token
17385 );
17386 }
17387 return true;
17388 },
17389 __experimentalExpandOnFocus: elements && elements.length > 0,
17390 __experimentalShowHowTo: !field.isValid?.elements,
17391 displayTransform: (token) => {
17392 if (typeof token === "object" && "label" in token) {
17393 return token.label;
17394 }
17395 if (typeof token === "string" && elements) {
17396 const element = elements.find(
17397 (el) => el.value === token
17398 );
17399 return element?.label || token;
17400 }
17401 return token;
17402 },
17403 __experimentalRenderItem: ({ item }) => {
17404 if (typeof item === "string" && elements) {
17405 const element = elements.find(
17406 (el) => el.value === item
17407 );
17408 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { children: element?.label || item });
17409 }
17410 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { children: item });
17411 }
17412 }
17413 );
17414 }
17415
17416 // node_modules/colord/index.mjs
17417 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
17418 var t = function(r3) {
17419 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
17420 };
17421 var n = function(r3, t2, n2) {
17422 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
17423 };
17424 var e = function(r3, t2, n2) {
17425 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
17426 };
17427 var u = function(r3) {
17428 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
17429 };
17430 var a = function(r3) {
17431 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
17432 };
17433 var o = function(r3) {
17434 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
17435 };
17436 var i = /^#([0-9a-f]{3,8})$/i;
17437 var s = function(r3) {
17438 var t2 = r3.toString(16);
17439 return t2.length < 2 ? "0" + t2 : t2;
17440 };
17441 var h = function(r3) {
17442 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;
17443 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
17444 };
17445 var b = function(r3) {
17446 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
17447 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
17448 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;
17449 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 };
17450 };
17451 var g = function(r3) {
17452 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
17453 };
17454 var d = function(r3) {
17455 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
17456 };
17457 var f = function(r3) {
17458 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 }));
17459 var t2, n2, e2;
17460 };
17461 var c = function(r3) {
17462 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 };
17463 var t2, n2, e2, u2;
17464 };
17465 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
17466 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
17467 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
17468 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
17469 var y = { string: [[function(r3) {
17470 var t2 = i.exec(r3);
17471 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;
17472 }, "hex"], [function(r3) {
17473 var t2 = v.exec(r3) || m.exec(r3);
17474 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;
17475 }, "rgb"], [function(t2) {
17476 var n2 = l.exec(t2) || p.exec(t2);
17477 if (!n2) return null;
17478 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) });
17479 return f(a2);
17480 }, "hsl"]], object: [[function(r3) {
17481 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
17482 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
17483 }, "rgb"], [function(r3) {
17484 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
17485 if (!t(n2) || !t(e2) || !t(u2)) return null;
17486 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
17487 return f(i2);
17488 }, "hsl"], [function(r3) {
17489 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
17490 if (!t(n2) || !t(a2) || !t(o2)) return null;
17491 var h2 = (function(r4) {
17492 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
17493 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
17494 return b(h2);
17495 }, "hsv"]] };
17496 var N = function(r3, t2) {
17497 for (var n2 = 0; n2 < t2.length; n2++) {
17498 var e2 = t2[n2][0](r3);
17499 if (e2) return [e2, t2[n2][1]];
17500 }
17501 return [null, void 0];
17502 };
17503 var x = function(r3) {
17504 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
17505 };
17506 var M = function(r3, t2) {
17507 var n2 = c(r3);
17508 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
17509 };
17510 var H = function(r3) {
17511 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
17512 };
17513 var $ = function(r3, t2) {
17514 var n2 = c(r3);
17515 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
17516 };
17517 var j = (function() {
17518 function r3(r4) {
17519 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
17520 }
17521 return r3.prototype.isValid = function() {
17522 return null !== this.parsed;
17523 }, r3.prototype.brightness = function() {
17524 return n(H(this.rgba), 2);
17525 }, r3.prototype.isDark = function() {
17526 return H(this.rgba) < 0.5;
17527 }, r3.prototype.isLight = function() {
17528 return H(this.rgba) >= 0.5;
17529 }, r3.prototype.toHex = function() {
17530 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;
17531 var r4, t2, e2, u2, a2, i2;
17532 }, r3.prototype.toRgb = function() {
17533 return o(this.rgba);
17534 }, r3.prototype.toRgbString = function() {
17535 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 + ")";
17536 var r4, t2, n2, e2, u2;
17537 }, r3.prototype.toHsl = function() {
17538 return d(c(this.rgba));
17539 }, r3.prototype.toHslString = function() {
17540 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 + "%)";
17541 var r4, t2, n2, e2, u2;
17542 }, r3.prototype.toHsv = function() {
17543 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
17544 var r4;
17545 }, r3.prototype.invert = function() {
17546 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
17547 var r4;
17548 }, r3.prototype.saturate = function(r4) {
17549 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
17550 }, r3.prototype.desaturate = function(r4) {
17551 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
17552 }, r3.prototype.grayscale = function() {
17553 return w(M(this.rgba, -1));
17554 }, r3.prototype.lighten = function(r4) {
17555 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
17556 }, r3.prototype.darken = function(r4) {
17557 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
17558 }, r3.prototype.rotate = function(r4) {
17559 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
17560 }, r3.prototype.alpha = function(r4) {
17561 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
17562 var t2;
17563 }, r3.prototype.hue = function(r4) {
17564 var t2 = c(this.rgba);
17565 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
17566 }, r3.prototype.isEqual = function(r4) {
17567 return this.toHex() === w(r4).toHex();
17568 }, r3;
17569 })();
17570 var w = function(r3) {
17571 return r3 instanceof j ? r3 : new j(r3);
17572 };
17573
17574 // packages/dataviews/build-module/components/dataform-controls/color.mjs
17575 var import_components46 = __toESM(require_components(), 1);
17576 var import_element71 = __toESM(require_element(), 1);
17577 var import_i18n36 = __toESM(require_i18n(), 1);
17578 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
17579 var { ValidatedInputControl: ValidatedInputControl3 } = unlock(import_components46.privateApis);
17580 var ColorPickerDropdown = ({
17581 color,
17582 onColorChange,
17583 disabled: disabled2
17584 }) => {
17585 const validColor = color && w(color).isValid() ? color : "#ffffff";
17586 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17587 import_components46.Dropdown,
17588 {
17589 className: "dataviews-controls__color-picker-dropdown",
17590 popoverProps: { resize: false },
17591 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17592 import_components46.Button,
17593 {
17594 onClick: onToggle,
17595 "aria-label": (0, import_i18n36.__)("Open color picker"),
17596 size: "small",
17597 disabled: disabled2,
17598 accessibleWhenDisabled: true,
17599 icon: () => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components46.ColorIndicator, { colorValue: validColor })
17600 }
17601 ),
17602 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components46.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17603 import_components46.ColorPicker,
17604 {
17605 color: validColor,
17606 onChange: onColorChange,
17607 enableAlpha: true
17608 }
17609 ) })
17610 }
17611 );
17612 };
17613 function Color({
17614 data,
17615 field,
17616 onChange,
17617 hideLabelFromVision,
17618 markWhenOptional,
17619 validity
17620 }) {
17621 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
17622 const disabled2 = field.isDisabled({ item: data, field });
17623 const value = field.getValue({ item: data }) || "";
17624 const handleColorChange = (0, import_element71.useCallback)(
17625 (newColor) => {
17626 onChange(setValue({ item: data, value: newColor }));
17627 },
17628 [data, onChange, setValue]
17629 );
17630 const handleInputChange = (0, import_element71.useCallback)(
17631 (newValue) => {
17632 onChange(setValue({ item: data, value: newValue || "" }));
17633 },
17634 [data, onChange, setValue]
17635 );
17636 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17637 ValidatedInputControl3,
17638 {
17639 required: !!field.isValid?.required,
17640 markWhenOptional,
17641 customValidity: getCustomValidity(isValid2, validity),
17642 label,
17643 placeholder,
17644 value,
17645 help: description,
17646 onChange: handleInputChange,
17647 hideLabelFromVision,
17648 type: "text",
17649 disabled: disabled2,
17650 prefix: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components46.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17651 ColorPickerDropdown,
17652 {
17653 color: value,
17654 onColorChange: handleColorChange,
17655 disabled: disabled2
17656 }
17657 ) })
17658 }
17659 );
17660 }
17661
17662 // packages/dataviews/build-module/components/dataform-controls/password.mjs
17663 var import_components47 = __toESM(require_components(), 1);
17664 var import_element72 = __toESM(require_element(), 1);
17665 var import_i18n37 = __toESM(require_i18n(), 1);
17666 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
17667 function Password({
17668 data,
17669 field,
17670 onChange,
17671 hideLabelFromVision,
17672 markWhenOptional,
17673 validity
17674 }) {
17675 const [isVisible2, setIsVisible] = (0, import_element72.useState)(false);
17676 const disabled2 = field.isDisabled({ item: data, field });
17677 const toggleVisibility = (0, import_element72.useCallback)(() => {
17678 setIsVisible((prev) => !prev);
17679 }, []);
17680 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
17681 ValidatedText,
17682 {
17683 ...{
17684 data,
17685 field,
17686 onChange,
17687 hideLabelFromVision,
17688 markWhenOptional,
17689 validity,
17690 type: isVisible2 ? "text" : "password",
17691 suffix: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components47.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
17692 import_components47.Button,
17693 {
17694 icon: isVisible2 ? unseen_default : seen_default,
17695 onClick: toggleVisibility,
17696 size: "small",
17697 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
17698 disabled: disabled2,
17699 accessibleWhenDisabled: true
17700 }
17701 ) })
17702 }
17703 }
17704 );
17705 }
17706
17707 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
17708 function hasElements(field) {
17709 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
17710 }
17711
17712 // packages/dataviews/build-module/components/dataform-controls/index.mjs
17713 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
17714 var FORM_CONTROLS = {
17715 adaptiveSelect: AdaptiveSelect,
17716 array: ArrayControl,
17717 checkbox: Checkbox,
17718 color: Color,
17719 combobox: Combobox3,
17720 datetime: DateTime,
17721 date: DateControl,
17722 email: Email,
17723 telephone: Telephone,
17724 url: Url,
17725 integer: Integer,
17726 number: Number2,
17727 password: Password,
17728 radio: Radio,
17729 select: Select,
17730 text: Text4,
17731 toggle: Toggle,
17732 textarea: Textarea,
17733 toggleGroup: ToggleGroup
17734 };
17735 function isEditConfig(value) {
17736 return value && typeof value === "object" && typeof value.control === "string";
17737 }
17738 function createConfiguredControl(config) {
17739 const { control, ...controlConfig } = config;
17740 const BaseControlType = getControlByType(control);
17741 if (BaseControlType === null) {
17742 return null;
17743 }
17744 return function ConfiguredControl(props) {
17745 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(BaseControlType, { ...props, config: controlConfig });
17746 };
17747 }
17748 function getControl(field, fallback) {
17749 if (typeof field.Edit === "function") {
17750 return field.Edit;
17751 }
17752 if (typeof field.Edit === "string") {
17753 return getControlByType(field.Edit);
17754 }
17755 if (isEditConfig(field.Edit)) {
17756 return createConfiguredControl(field.Edit);
17757 }
17758 if (hasElements(field) && field.type !== "array") {
17759 return getControlByType("adaptiveSelect");
17760 }
17761 if (fallback === null) {
17762 return null;
17763 }
17764 return getControlByType(fallback);
17765 }
17766 function getControlByType(type) {
17767 if (Object.keys(FORM_CONTROLS).includes(type)) {
17768 return FORM_CONTROLS[type];
17769 }
17770 return null;
17771 }
17772
17773 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
17774 function getFilterBy(field, defaultOperators, validOperators) {
17775 if (field.filterBy === false) {
17776 return false;
17777 }
17778 const operators = field.filterBy?.operators?.filter(
17779 (op) => validOperators.includes(op)
17780 ) ?? defaultOperators;
17781 if (operators.length === 0) {
17782 return false;
17783 }
17784 return {
17785 isPrimary: !!field.filterBy?.isPrimary,
17786 operators
17787 };
17788 }
17789 var get_filter_by_default = getFilterBy;
17790
17791 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
17792 var getValueFromId = (id) => ({ item }) => {
17793 const path = id.split(".");
17794 let value = item;
17795 for (const segment of path) {
17796 if (value.hasOwnProperty(segment)) {
17797 value = value[segment];
17798 } else {
17799 value = void 0;
17800 }
17801 }
17802 return value;
17803 };
17804 var get_value_from_id_default = getValueFromId;
17805
17806 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
17807 var setValueFromId = (id) => ({ value }) => {
17808 const path = id.split(".");
17809 const result = {};
17810 let current = result;
17811 for (const segment of path.slice(0, -1)) {
17812 current[segment] = {};
17813 current = current[segment];
17814 }
17815 current[path.at(-1)] = value;
17816 return result;
17817 };
17818 var set_value_from_id_default = setValueFromId;
17819
17820 // packages/dataviews/build-module/field-types/email.mjs
17821 var import_i18n38 = __toESM(require_i18n(), 1);
17822
17823 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
17824 function RenderFromElements({
17825 item,
17826 field
17827 }) {
17828 const { elements, isLoading } = useElements({
17829 elements: field.elements,
17830 getElements: field.getElements
17831 });
17832 const value = field.getValue({ item });
17833 if (isLoading) {
17834 return value;
17835 }
17836 if (elements.length === 0) {
17837 return value;
17838 }
17839 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
17840 }
17841
17842 // packages/dataviews/build-module/field-types/utils/render-default.mjs
17843 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
17844 function render({
17845 item,
17846 field
17847 }) {
17848 if (field.hasElements) {
17849 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(RenderFromElements, { item, field });
17850 }
17851 return field.getValueFormatted({ item, field });
17852 }
17853
17854 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
17855 var sort_text_default = (a2, b2, direction) => {
17856 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
17857 };
17858
17859 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
17860 function isValidRequired(item, field) {
17861 const value = field.getValue({ item });
17862 return ![void 0, "", null].includes(value);
17863 }
17864
17865 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
17866 function isValidMinLength(item, field) {
17867 if (typeof field.isValid.minLength?.constraint !== "number") {
17868 return false;
17869 }
17870 const value = field.getValue({ item });
17871 if ([void 0, "", null].includes(value)) {
17872 return true;
17873 }
17874 return String(value).length >= field.isValid.minLength.constraint;
17875 }
17876
17877 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
17878 function isValidMaxLength(item, field) {
17879 if (typeof field.isValid.maxLength?.constraint !== "number") {
17880 return false;
17881 }
17882 const value = field.getValue({ item });
17883 if ([void 0, "", null].includes(value)) {
17884 return true;
17885 }
17886 return String(value).length <= field.isValid.maxLength.constraint;
17887 }
17888
17889 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
17890 function isValidPattern(item, field) {
17891 if (field.isValid.pattern?.constraint === void 0) {
17892 return true;
17893 }
17894 try {
17895 const regexp = new RegExp(field.isValid.pattern.constraint);
17896 const value = field.getValue({ item });
17897 if ([void 0, "", null].includes(value)) {
17898 return true;
17899 }
17900 return regexp.test(String(value));
17901 } catch {
17902 return false;
17903 }
17904 }
17905
17906 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
17907 function isValidElements(item, field) {
17908 const elements = field.elements ?? [];
17909 const validValues = elements.map((el) => el.value);
17910 if (validValues.length === 0) {
17911 return true;
17912 }
17913 const value = field.getValue({ item });
17914 return [].concat(value).every((v2) => validValues.includes(v2));
17915 }
17916
17917 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
17918 function getValueFormatted({
17919 item,
17920 field
17921 }) {
17922 return field.getValue({ item });
17923 }
17924 var get_value_formatted_default_default = getValueFormatted;
17925
17926 // packages/dataviews/build-module/field-types/email.mjs
17927 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])?)*$/;
17928 function isValidCustom(item, field) {
17929 const value = field.getValue({ item });
17930 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
17931 return (0, import_i18n38.__)("Value must be a valid email address.");
17932 }
17933 return null;
17934 }
17935 var email_default = {
17936 type: "email",
17937 render,
17938 Edit: "email",
17939 sort: sort_text_default,
17940 enableSorting: true,
17941 enableGlobalSearch: false,
17942 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
17943 validOperators: [
17944 OPERATOR_IS,
17945 OPERATOR_IS_NOT,
17946 OPERATOR_CONTAINS,
17947 OPERATOR_NOT_CONTAINS,
17948 OPERATOR_STARTS_WITH,
17949 // Multiple selection
17950 OPERATOR_IS_ANY,
17951 OPERATOR_IS_NONE,
17952 OPERATOR_IS_ALL,
17953 OPERATOR_IS_NOT_ALL
17954 ],
17955 format: {},
17956 getValueFormatted: get_value_formatted_default_default,
17957 validate: {
17958 required: isValidRequired,
17959 pattern: isValidPattern,
17960 minLength: isValidMinLength,
17961 maxLength: isValidMaxLength,
17962 elements: isValidElements,
17963 custom: isValidCustom
17964 }
17965 };
17966
17967 // packages/dataviews/build-module/field-types/integer.mjs
17968 var import_i18n39 = __toESM(require_i18n(), 1);
17969
17970 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
17971 var sort_number_default = (a2, b2, direction) => {
17972 return direction === "asc" ? a2 - b2 : b2 - a2;
17973 };
17974
17975 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
17976 function isValidMin(item, field) {
17977 if (typeof field.isValid.min?.constraint !== "number") {
17978 return false;
17979 }
17980 const value = field.getValue({ item });
17981 if ([void 0, "", null].includes(value)) {
17982 return true;
17983 }
17984 return Number(value) >= field.isValid.min.constraint;
17985 }
17986
17987 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
17988 function isValidMax(item, field) {
17989 if (typeof field.isValid.max?.constraint !== "number") {
17990 return false;
17991 }
17992 const value = field.getValue({ item });
17993 if ([void 0, "", null].includes(value)) {
17994 return true;
17995 }
17996 return Number(value) <= field.isValid.max.constraint;
17997 }
17998
17999 // packages/dataviews/build-module/field-types/integer.mjs
18000 var format2 = {
18001 separatorThousand: ","
18002 };
18003 function getValueFormatted2({
18004 item,
18005 field
18006 }) {
18007 let value = field.getValue({ item });
18008 if (value === null || value === void 0) {
18009 return "";
18010 }
18011 value = Number(value);
18012 if (!Number.isFinite(value)) {
18013 return String(value);
18014 }
18015 let formatInteger;
18016 if (field.type !== "integer") {
18017 formatInteger = format2;
18018 } else {
18019 formatInteger = field.format;
18020 }
18021 const { separatorThousand } = formatInteger;
18022 const integerValue = Math.trunc(value);
18023 if (!separatorThousand) {
18024 return String(integerValue);
18025 }
18026 return String(integerValue).replace(
18027 /\B(?=(\d{3})+(?!\d))/g,
18028 separatorThousand
18029 );
18030 }
18031 function isValidCustom2(item, field) {
18032 const value = field.getValue({ item });
18033 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
18034 return (0, import_i18n39.__)("Value must be an integer.");
18035 }
18036 return null;
18037 }
18038 var integer_default = {
18039 type: "integer",
18040 render,
18041 Edit: "integer",
18042 sort: sort_number_default,
18043 enableSorting: true,
18044 enableGlobalSearch: false,
18045 defaultOperators: [
18046 OPERATOR_IS,
18047 OPERATOR_IS_NOT,
18048 OPERATOR_LESS_THAN,
18049 OPERATOR_GREATER_THAN,
18050 OPERATOR_LESS_THAN_OR_EQUAL,
18051 OPERATOR_GREATER_THAN_OR_EQUAL,
18052 OPERATOR_BETWEEN
18053 ],
18054 validOperators: [
18055 // Single-selection
18056 OPERATOR_IS,
18057 OPERATOR_IS_NOT,
18058 OPERATOR_LESS_THAN,
18059 OPERATOR_GREATER_THAN,
18060 OPERATOR_LESS_THAN_OR_EQUAL,
18061 OPERATOR_GREATER_THAN_OR_EQUAL,
18062 OPERATOR_BETWEEN,
18063 // Multiple-selection
18064 OPERATOR_IS_ANY,
18065 OPERATOR_IS_NONE,
18066 OPERATOR_IS_ALL,
18067 OPERATOR_IS_NOT_ALL
18068 ],
18069 format: format2,
18070 getValueFormatted: getValueFormatted2,
18071 validate: {
18072 required: isValidRequired,
18073 min: isValidMin,
18074 max: isValidMax,
18075 elements: isValidElements,
18076 custom: isValidCustom2
18077 }
18078 };
18079
18080 // packages/dataviews/build-module/field-types/number.mjs
18081 var import_i18n40 = __toESM(require_i18n(), 1);
18082 var format3 = {
18083 separatorThousand: ",",
18084 separatorDecimal: ".",
18085 decimals: 2
18086 };
18087 function getValueFormatted3({
18088 item,
18089 field
18090 }) {
18091 let value = field.getValue({ item });
18092 if (value === null || value === void 0) {
18093 return "";
18094 }
18095 value = Number(value);
18096 if (!Number.isFinite(value)) {
18097 return String(value);
18098 }
18099 let formatNumber;
18100 if (field.type !== "number") {
18101 formatNumber = format3;
18102 } else {
18103 formatNumber = field.format;
18104 }
18105 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
18106 const fixedValue = value.toFixed(decimals);
18107 const [integerPart, decimalPart] = fixedValue.split(".");
18108 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
18109 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
18110 }
18111 function isEmpty2(value) {
18112 return value === "" || value === void 0 || value === null;
18113 }
18114 function isValidCustom3(item, field) {
18115 const value = field.getValue({ item });
18116 if (!isEmpty2(value) && !Number.isFinite(value)) {
18117 return (0, import_i18n40.__)("Value must be a number.");
18118 }
18119 return null;
18120 }
18121 var number_default = {
18122 type: "number",
18123 render,
18124 Edit: "number",
18125 sort: sort_number_default,
18126 enableSorting: true,
18127 enableGlobalSearch: false,
18128 defaultOperators: [
18129 OPERATOR_IS,
18130 OPERATOR_IS_NOT,
18131 OPERATOR_LESS_THAN,
18132 OPERATOR_GREATER_THAN,
18133 OPERATOR_LESS_THAN_OR_EQUAL,
18134 OPERATOR_GREATER_THAN_OR_EQUAL,
18135 OPERATOR_BETWEEN
18136 ],
18137 validOperators: [
18138 // Single-selection
18139 OPERATOR_IS,
18140 OPERATOR_IS_NOT,
18141 OPERATOR_LESS_THAN,
18142 OPERATOR_GREATER_THAN,
18143 OPERATOR_LESS_THAN_OR_EQUAL,
18144 OPERATOR_GREATER_THAN_OR_EQUAL,
18145 OPERATOR_BETWEEN,
18146 // Multiple-selection
18147 OPERATOR_IS_ANY,
18148 OPERATOR_IS_NONE,
18149 OPERATOR_IS_ALL,
18150 OPERATOR_IS_NOT_ALL
18151 ],
18152 format: format3,
18153 getValueFormatted: getValueFormatted3,
18154 validate: {
18155 required: isValidRequired,
18156 min: isValidMin,
18157 max: isValidMax,
18158 elements: isValidElements,
18159 custom: isValidCustom3
18160 }
18161 };
18162
18163 // packages/dataviews/build-module/field-types/text.mjs
18164 var text_default = {
18165 type: "text",
18166 render,
18167 Edit: "text",
18168 sort: sort_text_default,
18169 enableSorting: true,
18170 enableGlobalSearch: false,
18171 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18172 validOperators: [
18173 // Single selection
18174 OPERATOR_IS,
18175 OPERATOR_IS_NOT,
18176 OPERATOR_CONTAINS,
18177 OPERATOR_NOT_CONTAINS,
18178 OPERATOR_STARTS_WITH,
18179 // Multiple selection
18180 OPERATOR_IS_ANY,
18181 OPERATOR_IS_NONE,
18182 OPERATOR_IS_ALL,
18183 OPERATOR_IS_NOT_ALL
18184 ],
18185 format: {},
18186 getValueFormatted: get_value_formatted_default_default,
18187 validate: {
18188 required: isValidRequired,
18189 pattern: isValidPattern,
18190 minLength: isValidMinLength,
18191 maxLength: isValidMaxLength,
18192 elements: isValidElements
18193 }
18194 };
18195
18196 // packages/dataviews/build-module/field-types/datetime.mjs
18197 var import_date7 = __toESM(require_date(), 1);
18198
18199 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
18200 var import_date6 = __toESM(require_date(), 1);
18201 function parseDateLike(value) {
18202 if (!value) {
18203 return null;
18204 }
18205 if (!isValid(new Date(value))) {
18206 return null;
18207 }
18208 const parsed = (0, import_date6.getDate)(value);
18209 return parsed && isValid(parsed) ? parsed : null;
18210 }
18211 function validateDateLikeBoundary(item, field, boundary) {
18212 const constraint = field.isValid[boundary]?.constraint;
18213 if (typeof constraint !== "string") {
18214 return false;
18215 }
18216 const value = field.getValue({ item });
18217 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
18218 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
18219 return true;
18220 }
18221 const parsedConstraint = parseDateLike(constraint);
18222 const parsedValue = parseDateLike(String(boundaryValue));
18223 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
18224 }
18225 function isValidMinDate(item, field) {
18226 return validateDateLikeBoundary(item, field, "min");
18227 }
18228 function isValidMaxDate(item, field) {
18229 return validateDateLikeBoundary(item, field, "max");
18230 }
18231
18232 // packages/dataviews/build-module/field-types/datetime.mjs
18233 var format4 = {
18234 datetime: (0, import_date7.getSettings)().formats.datetime,
18235 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
18236 };
18237 function getValueFormatted4({
18238 item,
18239 field
18240 }) {
18241 const value = field.getValue({ item });
18242 if (["", void 0, null].includes(value)) {
18243 return "";
18244 }
18245 let formatDatetime;
18246 if (field.type !== "datetime") {
18247 formatDatetime = format4;
18248 } else {
18249 formatDatetime = field.format;
18250 }
18251 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
18252 }
18253 var sort = (a2, b2, direction) => {
18254 const timeA = new Date(a2).getTime();
18255 const timeB = new Date(b2).getTime();
18256 return direction === "asc" ? timeA - timeB : timeB - timeA;
18257 };
18258 var datetime_default = {
18259 type: "datetime",
18260 render,
18261 Edit: "datetime",
18262 sort,
18263 enableSorting: true,
18264 enableGlobalSearch: false,
18265 defaultOperators: [
18266 OPERATOR_ON,
18267 OPERATOR_NOT_ON,
18268 OPERATOR_BEFORE,
18269 OPERATOR_AFTER,
18270 OPERATOR_BEFORE_INC,
18271 OPERATOR_AFTER_INC,
18272 OPERATOR_IN_THE_PAST,
18273 OPERATOR_OVER
18274 ],
18275 validOperators: [
18276 OPERATOR_ON,
18277 OPERATOR_NOT_ON,
18278 OPERATOR_BEFORE,
18279 OPERATOR_AFTER,
18280 OPERATOR_BEFORE_INC,
18281 OPERATOR_AFTER_INC,
18282 OPERATOR_IN_THE_PAST,
18283 OPERATOR_OVER
18284 ],
18285 format: format4,
18286 getValueFormatted: getValueFormatted4,
18287 validate: {
18288 required: isValidRequired,
18289 elements: isValidElements,
18290 min: isValidMinDate,
18291 max: isValidMaxDate
18292 }
18293 };
18294
18295 // packages/dataviews/build-module/field-types/date.mjs
18296 var import_date8 = __toESM(require_date(), 1);
18297 var format5 = {
18298 date: (0, import_date8.getSettings)().formats.date,
18299 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
18300 };
18301 function getValueFormatted5({
18302 item,
18303 field
18304 }) {
18305 const value = field.getValue({ item });
18306 if (["", void 0, null].includes(value)) {
18307 return "";
18308 }
18309 let formatDate2;
18310 if (field.type !== "date") {
18311 formatDate2 = format5;
18312 } else {
18313 formatDate2 = field.format;
18314 }
18315 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
18316 }
18317 var sort2 = (a2, b2, direction) => {
18318 const timeA = new Date(a2).getTime();
18319 const timeB = new Date(b2).getTime();
18320 return direction === "asc" ? timeA - timeB : timeB - timeA;
18321 };
18322 var date_default = {
18323 type: "date",
18324 render,
18325 Edit: "date",
18326 sort: sort2,
18327 enableSorting: true,
18328 enableGlobalSearch: false,
18329 defaultOperators: [
18330 OPERATOR_ON,
18331 OPERATOR_NOT_ON,
18332 OPERATOR_BEFORE,
18333 OPERATOR_AFTER,
18334 OPERATOR_BEFORE_INC,
18335 OPERATOR_AFTER_INC,
18336 OPERATOR_IN_THE_PAST,
18337 OPERATOR_OVER,
18338 OPERATOR_BETWEEN
18339 ],
18340 validOperators: [
18341 OPERATOR_ON,
18342 OPERATOR_NOT_ON,
18343 OPERATOR_BEFORE,
18344 OPERATOR_AFTER,
18345 OPERATOR_BEFORE_INC,
18346 OPERATOR_AFTER_INC,
18347 OPERATOR_IN_THE_PAST,
18348 OPERATOR_OVER,
18349 OPERATOR_BETWEEN
18350 ],
18351 format: format5,
18352 getValueFormatted: getValueFormatted5,
18353 validate: {
18354 required: isValidRequired,
18355 elements: isValidElements,
18356 min: isValidMinDate,
18357 max: isValidMaxDate
18358 }
18359 };
18360
18361 // packages/dataviews/build-module/field-types/boolean.mjs
18362 var import_i18n41 = __toESM(require_i18n(), 1);
18363
18364 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
18365 function isValidRequiredForBool(item, field) {
18366 const value = field.getValue({ item });
18367 return value === true;
18368 }
18369
18370 // packages/dataviews/build-module/field-types/boolean.mjs
18371 function getValueFormatted6({
18372 item,
18373 field
18374 }) {
18375 const value = field.getValue({ item });
18376 if (value === true) {
18377 return (0, import_i18n41.__)("True");
18378 }
18379 if (value === false) {
18380 return (0, import_i18n41.__)("False");
18381 }
18382 return "";
18383 }
18384 function isValidCustom4(item, field) {
18385 const value = field.getValue({ item });
18386 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
18387 return (0, import_i18n41.__)("Value must be true, false, or undefined");
18388 }
18389 return null;
18390 }
18391 var sort3 = (a2, b2, direction) => {
18392 const boolA = Boolean(a2);
18393 const boolB = Boolean(b2);
18394 if (boolA === boolB) {
18395 return 0;
18396 }
18397 if (direction === "asc") {
18398 return boolA ? 1 : -1;
18399 }
18400 return boolA ? -1 : 1;
18401 };
18402 var boolean_default = {
18403 type: "boolean",
18404 render,
18405 Edit: "checkbox",
18406 sort: sort3,
18407 validate: {
18408 required: isValidRequiredForBool,
18409 elements: isValidElements,
18410 custom: isValidCustom4
18411 },
18412 enableSorting: true,
18413 enableGlobalSearch: false,
18414 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
18415 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
18416 format: {},
18417 getValueFormatted: getValueFormatted6
18418 };
18419
18420 // packages/dataviews/build-module/field-types/media.mjs
18421 var media_default = {
18422 type: "media",
18423 render: () => null,
18424 Edit: null,
18425 sort: () => 0,
18426 enableSorting: false,
18427 enableGlobalSearch: false,
18428 defaultOperators: [],
18429 validOperators: [],
18430 format: {},
18431 getValueFormatted: get_value_formatted_default_default,
18432 // cannot validate any constraint, so
18433 // the only available validation for the field author
18434 // would be providing a custom validator.
18435 validate: {}
18436 };
18437
18438 // packages/dataviews/build-module/field-types/array.mjs
18439 var import_i18n42 = __toESM(require_i18n(), 1);
18440
18441 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
18442 function isValidRequiredForArray(item, field) {
18443 const value = field.getValue({ item });
18444 return Array.isArray(value) && value.length > 0 && value.every(
18445 (element) => ![void 0, "", null].includes(element)
18446 );
18447 }
18448
18449 // packages/dataviews/build-module/field-types/array.mjs
18450 function getValueFormatted7({
18451 item,
18452 field
18453 }) {
18454 const value = field.getValue({ item });
18455 const arr = Array.isArray(value) ? value : [];
18456 return arr.join(", ");
18457 }
18458 function render2({ item, field }) {
18459 return getValueFormatted7({ item, field });
18460 }
18461 function isValidCustom5(item, field) {
18462 const value = field.getValue({ item });
18463 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
18464 return (0, import_i18n42.__)("Value must be an array.");
18465 }
18466 if (!value.every((v2) => typeof v2 === "string")) {
18467 return (0, import_i18n42.__)("Every value must be a string.");
18468 }
18469 return null;
18470 }
18471 var sort4 = (a2, b2, direction) => {
18472 const arrA = Array.isArray(a2) ? a2 : [];
18473 const arrB = Array.isArray(b2) ? b2 : [];
18474 if (arrA.length !== arrB.length) {
18475 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
18476 }
18477 const joinedA = arrA.join(",");
18478 const joinedB = arrB.join(",");
18479 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
18480 };
18481 var array_default = {
18482 type: "array",
18483 render: render2,
18484 Edit: "array",
18485 sort: sort4,
18486 enableSorting: true,
18487 enableGlobalSearch: false,
18488 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18489 validOperators: [
18490 OPERATOR_IS_ANY,
18491 OPERATOR_IS_NONE,
18492 OPERATOR_IS_ALL,
18493 OPERATOR_IS_NOT_ALL
18494 ],
18495 format: {},
18496 getValueFormatted: getValueFormatted7,
18497 validate: {
18498 required: isValidRequiredForArray,
18499 elements: isValidElements,
18500 custom: isValidCustom5
18501 }
18502 };
18503
18504 // packages/dataviews/build-module/field-types/password.mjs
18505 function getValueFormatted8({
18506 item,
18507 field
18508 }) {
18509 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
18510 }
18511 var password_default = {
18512 type: "password",
18513 render,
18514 Edit: "password",
18515 sort: () => 0,
18516 // Passwords should not be sortable for security reasons
18517 enableSorting: false,
18518 enableGlobalSearch: false,
18519 defaultOperators: [],
18520 validOperators: [],
18521 format: {},
18522 getValueFormatted: getValueFormatted8,
18523 validate: {
18524 required: isValidRequired,
18525 pattern: isValidPattern,
18526 minLength: isValidMinLength,
18527 maxLength: isValidMaxLength,
18528 elements: isValidElements
18529 }
18530 };
18531
18532 // packages/dataviews/build-module/field-types/telephone.mjs
18533 var telephone_default = {
18534 type: "telephone",
18535 render,
18536 Edit: "telephone",
18537 sort: sort_text_default,
18538 enableSorting: true,
18539 enableGlobalSearch: false,
18540 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18541 validOperators: [
18542 OPERATOR_IS,
18543 OPERATOR_IS_NOT,
18544 OPERATOR_CONTAINS,
18545 OPERATOR_NOT_CONTAINS,
18546 OPERATOR_STARTS_WITH,
18547 // Multiple selection
18548 OPERATOR_IS_ANY,
18549 OPERATOR_IS_NONE,
18550 OPERATOR_IS_ALL,
18551 OPERATOR_IS_NOT_ALL
18552 ],
18553 format: {},
18554 getValueFormatted: get_value_formatted_default_default,
18555 validate: {
18556 required: isValidRequired,
18557 pattern: isValidPattern,
18558 minLength: isValidMinLength,
18559 maxLength: isValidMaxLength,
18560 elements: isValidElements
18561 }
18562 };
18563
18564 // packages/dataviews/build-module/field-types/color.mjs
18565 var import_i18n43 = __toESM(require_i18n(), 1);
18566 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
18567 function render3({ item, field }) {
18568 if (field.hasElements) {
18569 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RenderFromElements, { item, field });
18570 }
18571 const value = get_value_formatted_default_default({ item, field });
18572 if (!value || !w(value).isValid()) {
18573 return value;
18574 }
18575 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
18576 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
18577 "div",
18578 {
18579 style: {
18580 width: "16px",
18581 height: "16px",
18582 borderRadius: "50%",
18583 backgroundColor: value,
18584 border: "1px solid #ddd",
18585 flexShrink: 0
18586 }
18587 }
18588 ),
18589 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: value })
18590 ] });
18591 }
18592 function isValidCustom6(item, field) {
18593 const value = field.getValue({ item });
18594 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
18595 return (0, import_i18n43.__)("Value must be a valid color.");
18596 }
18597 return null;
18598 }
18599 var sort5 = (a2, b2, direction) => {
18600 const colorA = w(a2);
18601 const colorB = w(b2);
18602 if (!colorA.isValid() && !colorB.isValid()) {
18603 return 0;
18604 }
18605 if (!colorA.isValid()) {
18606 return direction === "asc" ? 1 : -1;
18607 }
18608 if (!colorB.isValid()) {
18609 return direction === "asc" ? -1 : 1;
18610 }
18611 const hslA = colorA.toHsl();
18612 const hslB = colorB.toHsl();
18613 if (hslA.h !== hslB.h) {
18614 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
18615 }
18616 if (hslA.s !== hslB.s) {
18617 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
18618 }
18619 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
18620 };
18621 var color_default = {
18622 type: "color",
18623 render: render3,
18624 Edit: "color",
18625 sort: sort5,
18626 enableSorting: true,
18627 enableGlobalSearch: false,
18628 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18629 validOperators: [
18630 OPERATOR_IS,
18631 OPERATOR_IS_NOT,
18632 OPERATOR_IS_ANY,
18633 OPERATOR_IS_NONE
18634 ],
18635 format: {},
18636 getValueFormatted: get_value_formatted_default_default,
18637 validate: {
18638 required: isValidRequired,
18639 elements: isValidElements,
18640 custom: isValidCustom6
18641 }
18642 };
18643
18644 // packages/dataviews/build-module/field-types/url.mjs
18645 var url_default = {
18646 type: "url",
18647 render,
18648 Edit: "url",
18649 sort: sort_text_default,
18650 enableSorting: true,
18651 enableGlobalSearch: false,
18652 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18653 validOperators: [
18654 OPERATOR_IS,
18655 OPERATOR_IS_NOT,
18656 OPERATOR_CONTAINS,
18657 OPERATOR_NOT_CONTAINS,
18658 OPERATOR_STARTS_WITH,
18659 // Multiple selection
18660 OPERATOR_IS_ANY,
18661 OPERATOR_IS_NONE,
18662 OPERATOR_IS_ALL,
18663 OPERATOR_IS_NOT_ALL
18664 ],
18665 format: {},
18666 getValueFormatted: get_value_formatted_default_default,
18667 validate: {
18668 required: isValidRequired,
18669 pattern: isValidPattern,
18670 minLength: isValidMinLength,
18671 maxLength: isValidMaxLength,
18672 elements: isValidElements
18673 }
18674 };
18675
18676 // packages/dataviews/build-module/field-types/no-type.mjs
18677 var sort6 = (a2, b2, direction) => {
18678 if (typeof a2 === "number" && typeof b2 === "number") {
18679 return sort_number_default(a2, b2, direction);
18680 }
18681 return sort_text_default(a2, b2, direction);
18682 };
18683 var no_type_default = {
18684 // type: no type for this one
18685 render,
18686 Edit: null,
18687 sort: sort6,
18688 enableSorting: true,
18689 enableGlobalSearch: false,
18690 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
18691 validOperators: getAllOperatorNames(),
18692 format: {},
18693 getValueFormatted: get_value_formatted_default_default,
18694 validate: {
18695 required: isValidRequired,
18696 elements: isValidElements
18697 }
18698 };
18699
18700 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
18701 function supportsNumericRangeConstraint(type) {
18702 return type === "integer" || type === "number";
18703 }
18704 function supportsDateRangeConstraint(type) {
18705 return type === "date" || type === "datetime";
18706 }
18707 function normalizeRangeRule(value, fieldType, key) {
18708 const validator = fieldType.validate[key];
18709 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
18710 return { constraint: value, validate: validator };
18711 }
18712 return void 0;
18713 }
18714 function getIsValid(field, fieldType) {
18715 const rules = field.isValid;
18716 let required;
18717 if (rules?.required === true && fieldType.validate.required !== void 0) {
18718 required = {
18719 constraint: true,
18720 validate: fieldType.validate.required
18721 };
18722 }
18723 let elements;
18724 if ((rules?.elements === true || // elements is enabled unless the field opts-out
18725 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
18726 elements = {
18727 constraint: true,
18728 validate: fieldType.validate.elements
18729 };
18730 }
18731 const min = normalizeRangeRule(rules?.min, fieldType, "min");
18732 const max = normalizeRangeRule(rules?.max, fieldType, "max");
18733 const minLengthValue = rules?.minLength;
18734 let minLength;
18735 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
18736 minLength = {
18737 constraint: minLengthValue,
18738 validate: fieldType.validate.minLength
18739 };
18740 }
18741 const maxLengthValue = rules?.maxLength;
18742 let maxLength;
18743 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
18744 maxLength = {
18745 constraint: maxLengthValue,
18746 validate: fieldType.validate.maxLength
18747 };
18748 }
18749 const patternValue = rules?.pattern;
18750 let pattern;
18751 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
18752 pattern = {
18753 constraint: patternValue,
18754 validate: fieldType.validate.pattern
18755 };
18756 }
18757 const custom = rules?.custom ?? fieldType.validate.custom;
18758 return {
18759 required,
18760 elements,
18761 min,
18762 max,
18763 minLength,
18764 maxLength,
18765 pattern,
18766 custom
18767 };
18768 }
18769
18770 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
18771 function getFilter(fieldType) {
18772 return fieldType.validOperators.reduce((accumulator, operator) => {
18773 const operatorObj = getOperatorByName(operator);
18774 if (operatorObj?.filter) {
18775 accumulator[operator] = operatorObj.filter;
18776 }
18777 return accumulator;
18778 }, {});
18779 }
18780
18781 // packages/dataviews/build-module/field-types/utils/get-format.mjs
18782 function getFormat(field, fieldType) {
18783 return {
18784 ...fieldType.format,
18785 ...field.format
18786 };
18787 }
18788 var get_format_default = getFormat;
18789
18790 // packages/dataviews/build-module/field-types/index.mjs
18791 function getFieldTypeByName(type) {
18792 const found = [
18793 email_default,
18794 integer_default,
18795 number_default,
18796 text_default,
18797 datetime_default,
18798 date_default,
18799 boolean_default,
18800 media_default,
18801 array_default,
18802 password_default,
18803 telephone_default,
18804 color_default,
18805 url_default
18806 ].find((fieldType) => fieldType?.type === type);
18807 if (!!found) {
18808 return found;
18809 }
18810 return no_type_default;
18811 }
18812 function normalizeFields(fields2) {
18813 return fields2.map((field) => {
18814 const fieldType = getFieldTypeByName(field.type);
18815 const getValue = field.getValue || get_value_from_id_default(field.id);
18816 const sort7 = function(a2, b2, direction) {
18817 const aValue = getValue({ item: a2 });
18818 const bValue = getValue({ item: b2 });
18819 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
18820 };
18821 return {
18822 id: field.id,
18823 label: field.label || field.id,
18824 header: field.header || field.label || field.id,
18825 description: field.description,
18826 placeholder: field.placeholder,
18827 getValue,
18828 setValue: field.setValue || set_value_from_id_default(field.id),
18829 elements: field.elements,
18830 getElements: field.getElements,
18831 hasElements: hasElements(field),
18832 isVisible: field.isVisible,
18833 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
18834 enableHiding: field.enableHiding ?? true,
18835 readOnly: field.readOnly ?? false,
18836 // The type provides defaults for the following props
18837 type: fieldType.type,
18838 render: field.render ?? fieldType.render,
18839 Edit: getControl(field, fieldType.Edit),
18840 sort: sort7,
18841 enableSorting: field.enableSorting ?? fieldType.enableSorting,
18842 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
18843 isValid: getIsValid(field, fieldType),
18844 filterBy: get_filter_by_default(
18845 field,
18846 fieldType.defaultOperators,
18847 fieldType.validOperators
18848 ),
18849 filter: getFilter(fieldType),
18850 format: get_format_default(field, fieldType),
18851 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
18852 };
18853 });
18854 }
18855
18856 // packages/dataviews/build-module/hooks/use-data.mjs
18857 var import_element73 = __toESM(require_element(), 1);
18858 function useData({
18859 view,
18860 data: shownData,
18861 getItemId,
18862 isLoading,
18863 paginationInfo,
18864 selection
18865 }) {
18866 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
18867 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element73.useState)(
18868 !isLoading
18869 );
18870 (0, import_element73.useEffect)(() => {
18871 if (!isLoading) {
18872 setHasInitiallyLoaded(true);
18873 }
18874 }, [isLoading]);
18875 const previousDataRef = (0, import_element73.useRef)(shownData);
18876 const previousPaginationInfoRef = (0, import_element73.useRef)(paginationInfo);
18877 (0, import_element73.useEffect)(() => {
18878 if (!isLoading) {
18879 previousDataRef.current = shownData;
18880 previousPaginationInfoRef.current = paginationInfo;
18881 }
18882 }, [shownData, isLoading, paginationInfo]);
18883 const [visibleEntries, setVisibleEntries] = (0, import_element73.useState)([]);
18884 const positionMapRef = (0, import_element73.useRef)(/* @__PURE__ */ new Map());
18885 const allLoadedRecordsRef = (0, import_element73.useRef)([]);
18886 const prevViewParamsRef = (0, import_element73.useRef)({
18887 search: void 0,
18888 filters: void 0,
18889 perPage: void 0
18890 });
18891 const scrollDirectionRef = (0, import_element73.useRef)(void 0);
18892 const prevStartPositionRef = (0, import_element73.useRef)(void 0);
18893 const hasInitializedRef = (0, import_element73.useRef)(false);
18894 const allLoadedRecords = (0, import_element73.useMemo)(() => {
18895 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
18896 if (view.startPosition < prevStartPositionRef.current) {
18897 scrollDirectionRef.current = "up";
18898 } else if (view.startPosition > prevStartPositionRef.current) {
18899 scrollDirectionRef.current = "down";
18900 }
18901 }
18902 prevStartPositionRef.current = view.startPosition;
18903 const currentFiltersKey = JSON.stringify(view.filters ?? []);
18904 const prevFiltersKey = prevViewParamsRef.current.filters;
18905 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
18906 hasInitializedRef.current = true;
18907 prevViewParamsRef.current = {
18908 search: view.search,
18909 filters: currentFiltersKey,
18910 perPage: view.perPage
18911 };
18912 if (shouldReset) {
18913 positionMapRef.current.clear();
18914 scrollDirectionRef.current = void 0;
18915 const startPosition = view.search ? 1 : view.startPosition ?? 1;
18916 const records = shownData.map((record, index) => {
18917 const position = startPosition + index;
18918 positionMapRef.current.set(getItemId(record), position);
18919 return {
18920 ...record,
18921 position
18922 };
18923 });
18924 allLoadedRecordsRef.current = records;
18925 return records;
18926 }
18927 const prev = allLoadedRecordsRef.current;
18928 const shownDataIds = new Set(shownData.map(getItemId));
18929 const scrollDirection = scrollDirectionRef.current;
18930 const basePosition = view.search ? 1 : view.startPosition ?? 1;
18931 const newRecords = shownData.map((record, index) => {
18932 const itemId = getItemId(record);
18933 const position = view.infiniteScrollEnabled ? basePosition + index : void 0;
18934 if (position !== void 0) {
18935 positionMapRef.current.set(itemId, position);
18936 }
18937 return {
18938 ...record,
18939 position
18940 };
18941 });
18942 if (newRecords.length === 0) {
18943 return prev;
18944 }
18945 const prevWithoutDuplicates = prev.filter(
18946 (record) => !shownDataIds.has(getItemId(record))
18947 );
18948 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
18949 allRecords.sort((a2, b2) => {
18950 const posA = a2.position;
18951 const posB = b2.position;
18952 return posA - posB;
18953 });
18954 let result = allRecords;
18955 if (visibleEntries.length > 0) {
18956 const visibleMin = Math.min(...visibleEntries);
18957 const visibleMax = Math.max(...visibleEntries);
18958 const buffer = 20;
18959 const recordPositions = allRecords.map(
18960 (r3) => r3.position
18961 );
18962 const minRecordPos = Math.min(...recordPositions);
18963 const maxRecordPos = Math.max(...recordPositions);
18964 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
18965 if (hasOverlap) {
18966 result = allRecords.filter((record) => {
18967 const itemId = getItemId(record);
18968 const isSelected2 = selection?.includes(itemId);
18969 if (isSelected2) {
18970 return true;
18971 }
18972 const itemPosition = record.position;
18973 if (scrollDirection === "up") {
18974 return itemPosition <= visibleMax + buffer;
18975 } else if (scrollDirection === "down") {
18976 return itemPosition >= visibleMin - buffer;
18977 }
18978 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
18979 });
18980 }
18981 }
18982 allLoadedRecordsRef.current = result;
18983 return result;
18984 }, [
18985 shownData,
18986 view.search,
18987 view.filters,
18988 view.perPage,
18989 view.startPosition,
18990 view.infiniteScrollEnabled,
18991 visibleEntries,
18992 selection,
18993 getItemId
18994 ]);
18995 if (!isInfiniteScrollEnabled) {
18996 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
18997 return {
18998 data: dataToReturn.map((item) => ({
18999 ...item,
19000 position: void 0
19001 })),
19002 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
19003 hasInitiallyLoaded,
19004 setVisibleEntries: void 0
19005 };
19006 }
19007 return {
19008 data: allLoadedRecords,
19009 paginationInfo,
19010 hasInitiallyLoaded,
19011 setVisibleEntries
19012 };
19013 }
19014
19015 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
19016 var import_element74 = __toESM(require_element(), 1);
19017 var import_compose11 = __toESM(require_compose(), 1);
19018 function captureAnchorElement(container, anchorElementRef, direction) {
19019 const containerRect = container.getBoundingClientRect();
19020 const centerY = containerRect.top + containerRect.height / 2;
19021 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
19022 if (items.length === 0) {
19023 return false;
19024 }
19025 const bestAnchor = items.reduce((best, item) => {
19026 const itemRect = item.getBoundingClientRect();
19027 const itemCenterY = itemRect.top + itemRect.height / 2;
19028 const distance = Math.abs(itemCenterY - centerY);
19029 const bestRect = best.getBoundingClientRect();
19030 const bestCenterY = bestRect.top + bestRect.height / 2;
19031 const bestDistance = Math.abs(bestCenterY - centerY);
19032 return distance < bestDistance ? item : best;
19033 });
19034 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
19035 const anchorRect = bestAnchor.getBoundingClientRect();
19036 anchorElementRef.current = {
19037 posinset,
19038 viewportOffset: anchorRect.top - containerRect.top,
19039 direction
19040 };
19041 return true;
19042 }
19043 function useInfiniteScroll({
19044 view,
19045 onChangeView,
19046 isLoading,
19047 paginationInfo,
19048 containerRef,
19049 setVisibleEntries
19050 }) {
19051 const anchorElementRef = (0, import_element74.useRef)(null);
19052 const viewRef = (0, import_element74.useRef)(view);
19053 const isLoadingRef = (0, import_element74.useRef)(isLoading);
19054 const onChangeViewRef = (0, import_element74.useRef)(onChangeView);
19055 const totalItemsRef = (0, import_element74.useRef)(paginationInfo.totalItems);
19056 (0, import_element74.useLayoutEffect)(() => {
19057 viewRef.current = view;
19058 isLoadingRef.current = isLoading;
19059 onChangeViewRef.current = onChangeView;
19060 totalItemsRef.current = paginationInfo.totalItems;
19061 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
19062 const intersectionObserverCallback = (0, import_element74.useCallback)(
19063 (entries) => {
19064 if (!setVisibleEntries) {
19065 return;
19066 }
19067 setVisibleEntries((prev) => {
19068 const newVisibleEntries = new Set(prev);
19069 let hasChanged = false;
19070 entries.forEach((entry) => {
19071 const posInSet = Number(
19072 entry.target?.attributes?.getNamedItem(
19073 "aria-posinset"
19074 )?.value
19075 );
19076 if (isNaN(posInSet)) {
19077 return;
19078 }
19079 if (entry.isIntersecting) {
19080 if (!newVisibleEntries.has(posInSet)) {
19081 newVisibleEntries.add(posInSet);
19082 hasChanged = true;
19083 }
19084 } else if (newVisibleEntries.has(posInSet)) {
19085 newVisibleEntries.delete(posInSet);
19086 hasChanged = true;
19087 }
19088 });
19089 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
19090 });
19091 },
19092 [setVisibleEntries]
19093 );
19094 (0, import_element74.useLayoutEffect)(() => {
19095 const container = containerRef.current;
19096 const anchor = anchorElementRef.current;
19097 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
19098 return;
19099 }
19100 const anchorElement = container.querySelector(
19101 `[aria-posinset="${anchor.posinset}"]`
19102 );
19103 if (anchorElement) {
19104 const containerRect = container.getBoundingClientRect();
19105 const anchorRect = anchorElement.getBoundingClientRect();
19106 const currentOffset = anchorRect.top - containerRect.top;
19107 const scrollAdjustment = currentOffset - anchor.viewportOffset;
19108 if (Math.abs(scrollAdjustment) > 1) {
19109 container.scrollTop += scrollAdjustment;
19110 }
19111 }
19112 anchorElementRef.current = null;
19113 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
19114 const intersectionObserverRef = (0, import_element74.useRef)(
19115 null
19116 );
19117 (0, import_element74.useEffect)(() => {
19118 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
19119 if (intersectionObserverRef.current) {
19120 intersectionObserverRef.current.disconnect();
19121 intersectionObserverRef.current = null;
19122 }
19123 return;
19124 }
19125 intersectionObserverRef.current = new IntersectionObserver(
19126 intersectionObserverCallback,
19127 { root: null, rootMargin: "0px", threshold: 0.1 }
19128 );
19129 return () => {
19130 if (intersectionObserverRef.current) {
19131 intersectionObserverRef.current.disconnect();
19132 intersectionObserverRef.current = null;
19133 }
19134 };
19135 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
19136 (0, import_element74.useEffect)(() => {
19137 if (!view.infiniteScrollEnabled || !containerRef.current) {
19138 return;
19139 }
19140 let lastScrollTop = 0;
19141 const BOTTOM_THRESHOLD = 600;
19142 const TOP_THRESHOLD = 800;
19143 const handleScroll = (0, import_compose11.throttle)((event) => {
19144 const currentView = viewRef.current;
19145 const totalItems = totalItemsRef.current;
19146 const target = event.target;
19147 const scrollTop = target.scrollTop;
19148 const scrollHeight = target.scrollHeight;
19149 const clientHeight = target.clientHeight;
19150 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
19151 lastScrollTop = scrollTop;
19152 if (isLoadingRef.current) {
19153 return;
19154 }
19155 const currentStartPosition = currentView.startPosition || 1;
19156 const batchSize = currentView.perPage || 10;
19157 const currentEndPosition = Math.min(
19158 currentStartPosition + batchSize,
19159 totalItems
19160 );
19161 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
19162 if (currentEndPosition < totalItems) {
19163 const newStartPosition = currentEndPosition;
19164 captureAnchorElement(target, anchorElementRef, "down");
19165 onChangeViewRef.current({
19166 ...currentView,
19167 startPosition: newStartPosition
19168 });
19169 }
19170 }
19171 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
19172 if (currentStartPosition > 1) {
19173 const calculatedStartPosition = currentStartPosition - batchSize;
19174 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
19175 captureAnchorElement(target, anchorElementRef, "up");
19176 onChangeViewRef.current({
19177 ...currentView,
19178 startPosition: newStartPosition
19179 });
19180 }
19181 }
19182 }, 50);
19183 const container = containerRef.current;
19184 container.addEventListener("scroll", handleScroll);
19185 return () => {
19186 container.removeEventListener("scroll", handleScroll);
19187 handleScroll.cancel();
19188 };
19189 }, [containerRef, view.infiniteScrollEnabled]);
19190 return {
19191 intersectionObserver: intersectionObserverRef.current
19192 };
19193 }
19194
19195 // packages/dataviews/build-module/dataviews/index.mjs
19196 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
19197 var defaultGetItemId = (item) => item.id;
19198 var defaultIsItemClickable = () => true;
19199 var EMPTY_ARRAY6 = [];
19200 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
19201 var dataViewsLayouts = VIEW_LAYOUTS.filter(
19202 (viewLayout) => !viewLayout.isPicker
19203 );
19204 function DefaultUI({
19205 header,
19206 search = true,
19207 searchLabel = void 0
19208 }) {
19209 const { view } = (0, import_element75.useContext)(dataviews_context_default);
19210 const isInfiniteScroll = view.infiniteScrollEnabled;
19211 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(import_jsx_runtime112.Fragment, { children: [
19212 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
19213 Stack,
19214 {
19215 direction: "row",
19216 align: "top",
19217 justify: "space-between",
19218 className: clsx_default("dataviews__view-actions", {
19219 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
19220 }),
19221 gap: "xs",
19222 children: [
19223 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
19224 Stack,
19225 {
19226 direction: "row",
19227 justify: "start",
19228 gap: "sm",
19229 className: "dataviews__search",
19230 children: [
19231 search && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(dataviews_search_default, { label: searchLabel }),
19232 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(toggle_default, {})
19233 ]
19234 }
19235 ),
19236 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
19237 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(dataviews_view_config_default, {}),
19238 header
19239 ] })
19240 ]
19241 }
19242 ),
19243 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
19244 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DataViewsLayout, {}),
19245 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DataViewsFooter, {})
19246 ] });
19247 }
19248 function DataViews({
19249 view,
19250 onChangeView,
19251 fields: fields2,
19252 search = true,
19253 searchLabel = void 0,
19254 actions: actions2 = EMPTY_ARRAY6,
19255 data,
19256 getItemId = defaultGetItemId,
19257 getItemLevel,
19258 isLoading = false,
19259 paginationInfo,
19260 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
19261 selection: selectionProperty,
19262 onChangeSelection,
19263 onClickItem,
19264 renderItemLink,
19265 isItemClickable = defaultIsItemClickable,
19266 header,
19267 children,
19268 config = { perPageSizes: [10, 20, 50, 100] },
19269 empty,
19270 onReset
19271 }) {
19272 const [selectionState, setSelectionState] = (0, import_element75.useState)([]);
19273 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
19274 const selection = isUncontrolled ? selectionState : selectionProperty;
19275 const {
19276 data: displayData,
19277 paginationInfo: displayPaginationInfo,
19278 hasInitiallyLoaded,
19279 setVisibleEntries
19280 } = useData({
19281 view,
19282 data,
19283 getItemId,
19284 isLoading,
19285 selection,
19286 paginationInfo
19287 });
19288 const containerRef = (0, import_element75.useRef)(null);
19289 const [containerWidth, setContainerWidth] = (0, import_element75.useState)(0);
19290 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
19291 (resizeObserverEntries) => {
19292 setContainerWidth(
19293 resizeObserverEntries[0].borderBoxSize[0].inlineSize
19294 );
19295 },
19296 { box: "border-box" }
19297 );
19298 const [openedFilter, setOpenedFilter] = (0, import_element75.useState)(null);
19299 function setSelectionWithChange(value) {
19300 const newValue = typeof value === "function" ? value(selection) : value;
19301 if (isUncontrolled) {
19302 setSelectionState(newValue);
19303 }
19304 if (onChangeSelection) {
19305 onChangeSelection(newValue);
19306 }
19307 }
19308 const _fields = (0, import_element75.useMemo)(() => normalizeFields(fields2), [fields2]);
19309 const _selection = (0, import_element75.useMemo)(() => {
19310 if (view.infiniteScrollEnabled) {
19311 return selection;
19312 }
19313 return selection.filter(
19314 (id) => data.some((item) => getItemId(item) === id)
19315 );
19316 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
19317 const filters = use_filters_default(_fields, view);
19318 const hasPrimaryOrLockedFilters = (0, import_element75.useMemo)(
19319 () => (filters || []).some(
19320 (filter) => filter.isPrimary || filter.isLocked
19321 ),
19322 [filters]
19323 );
19324 const [isShowingFilter, setIsShowingFilter] = (0, import_element75.useState)(
19325 hasPrimaryOrLockedFilters
19326 );
19327 const { intersectionObserver } = useInfiniteScroll({
19328 view,
19329 onChangeView,
19330 isLoading,
19331 paginationInfo,
19332 containerRef,
19333 setVisibleEntries
19334 });
19335 (0, import_element75.useEffect)(() => {
19336 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
19337 setIsShowingFilter(true);
19338 }
19339 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
19340 const defaultLayouts = (0, import_element75.useMemo)(
19341 () => Object.fromEntries(
19342 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
19343 return dataViewsLayouts.some(
19344 (viewLayout) => viewLayout.type === layoutType
19345 );
19346 }).map(([key, value]) => [
19347 key,
19348 value === true ? {} : value
19349 ])
19350 ),
19351 [defaultLayoutsProperty]
19352 );
19353 if (!defaultLayouts[view.type]) {
19354 return null;
19355 }
19356 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
19357 dataviews_context_default.Provider,
19358 {
19359 value: {
19360 view,
19361 onChangeView,
19362 fields: _fields,
19363 actions: actions2,
19364 data: displayData,
19365 isLoading,
19366 paginationInfo: displayPaginationInfo,
19367 selection: _selection,
19368 onChangeSelection: setSelectionWithChange,
19369 openedFilter,
19370 setOpenedFilter,
19371 getItemId,
19372 getItemLevel,
19373 isItemClickable,
19374 onClickItem,
19375 renderItemLink,
19376 containerWidth,
19377 containerRef,
19378 resizeObserverRef,
19379 defaultLayouts,
19380 filters,
19381 isShowingFilter,
19382 setIsShowingFilter,
19383 config,
19384 empty,
19385 hasInitiallyLoaded,
19386 onReset,
19387 intersectionObserver
19388 },
19389 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
19390 DefaultUI,
19391 {
19392 header,
19393 search,
19394 searchLabel
19395 }
19396 ) })
19397 }
19398 );
19399 }
19400 var DataViewsSubComponents = DataViews;
19401 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
19402 DataViewsSubComponents.Filters = filters_default;
19403 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
19404 DataViewsSubComponents.FiltersToggle = toggle_default;
19405 DataViewsSubComponents.Layout = DataViewsLayout;
19406 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
19407 DataViewsSubComponents.Pagination = DataViewsPagination;
19408 DataViewsSubComponents.Search = dataviews_search_default;
19409 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
19410 DataViewsSubComponents.Footer = DataViewsFooter;
19411 var dataviews_default = DataViewsSubComponents;
19412
19413 // packages/dataviews/build-module/dataform/index.mjs
19414 var import_element87 = __toESM(require_element(), 1);
19415
19416 // packages/dataviews/build-module/components/dataform-context/index.mjs
19417 var import_element76 = __toESM(require_element(), 1);
19418 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
19419 var DataFormContext = (0, import_element76.createContext)({
19420 fields: []
19421 });
19422 DataFormContext.displayName = "DataFormContext";
19423 function DataFormProvider({
19424 fields: fields2,
19425 children
19426 }) {
19427 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DataFormContext.Provider, { value: { fields: fields2 }, children });
19428 }
19429 var dataform_context_default = DataFormContext;
19430
19431 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
19432 var import_element86 = __toESM(require_element(), 1);
19433
19434 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
19435 var import_element77 = __toESM(require_element(), 1);
19436 var import_components48 = __toESM(require_components(), 1);
19437
19438 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
19439 var import_i18n44 = __toESM(require_i18n(), 1);
19440 var DEFAULT_LAYOUT = {
19441 type: "regular",
19442 labelPosition: "top"
19443 };
19444 var normalizeCardSummaryField = (sum) => {
19445 if (typeof sum === "string") {
19446 return [{ id: sum, visibility: "when-collapsed" }];
19447 }
19448 return sum.map((item) => {
19449 if (typeof item === "string") {
19450 return { id: item, visibility: "when-collapsed" };
19451 }
19452 return { id: item.id, visibility: item.visibility };
19453 });
19454 };
19455 function normalizeLayout(layout) {
19456 let normalizedLayout = DEFAULT_LAYOUT;
19457 if (layout?.type === "regular") {
19458 normalizedLayout = {
19459 type: "regular",
19460 labelPosition: layout?.labelPosition ?? "top"
19461 };
19462 } else if (layout?.type === "panel") {
19463 const summary = layout.summary ?? [];
19464 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
19465 const openAs = layout?.openAs;
19466 let normalizedOpenAs;
19467 if (typeof openAs === "object" && openAs.type === "modal") {
19468 normalizedOpenAs = {
19469 type: "modal",
19470 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n44.__)("Apply"),
19471 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n44.__)("Cancel")
19472 };
19473 } else if (openAs === "modal") {
19474 normalizedOpenAs = {
19475 type: "modal",
19476 applyLabel: (0, import_i18n44.__)("Apply"),
19477 cancelLabel: (0, import_i18n44.__)("Cancel")
19478 };
19479 } else {
19480 normalizedOpenAs = { type: "dropdown" };
19481 }
19482 normalizedLayout = {
19483 type: "panel",
19484 labelPosition: layout?.labelPosition ?? "side",
19485 openAs: normalizedOpenAs,
19486 summary: normalizedSummary,
19487 editVisibility: layout?.editVisibility ?? "on-hover"
19488 };
19489 } else if (layout?.type === "card") {
19490 if (layout.withHeader === false) {
19491 normalizedLayout = {
19492 type: "card",
19493 withHeader: false,
19494 isOpened: true,
19495 summary: [],
19496 isCollapsible: false
19497 };
19498 } else {
19499 const summary = layout.summary ?? [];
19500 normalizedLayout = {
19501 type: "card",
19502 withHeader: true,
19503 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
19504 summary: normalizeCardSummaryField(summary),
19505 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
19506 };
19507 }
19508 } else if (layout?.type === "row") {
19509 normalizedLayout = {
19510 type: "row",
19511 alignment: layout?.alignment ?? "center",
19512 styles: layout?.styles ?? {}
19513 };
19514 } else if (layout?.type === "details") {
19515 normalizedLayout = {
19516 type: "details",
19517 summary: layout?.summary ?? ""
19518 };
19519 }
19520 return normalizedLayout;
19521 }
19522 function normalizeForm(form) {
19523 const normalizedFormLayout = normalizeLayout(form?.layout);
19524 const normalizedFields = (form.fields ?? []).map(
19525 (field) => {
19526 if (typeof field === "string") {
19527 return {
19528 id: field,
19529 layout: normalizedFormLayout
19530 };
19531 }
19532 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
19533 return {
19534 id: field.id,
19535 layout: fieldLayout,
19536 ...!!field.label && { label: field.label },
19537 ...!!field.description && {
19538 description: field.description
19539 },
19540 ..."children" in field && Array.isArray(field.children) && {
19541 children: normalizeForm({
19542 fields: field.children,
19543 layout: DEFAULT_LAYOUT
19544 }).fields
19545 }
19546 };
19547 }
19548 );
19549 return {
19550 layout: normalizedFormLayout,
19551 fields: normalizedFields
19552 };
19553 }
19554 var normalize_form_default = normalizeForm;
19555
19556 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
19557 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
19558 function Header4({ title }) {
19559 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19560 Stack,
19561 {
19562 direction: "column",
19563 className: "dataforms-layouts-regular__header",
19564 gap: "lg",
19565 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components48.__experimentalHeading, { level: 2, size: 13, children: title }) })
19566 }
19567 );
19568 }
19569 function FormRegularField({
19570 data,
19571 field,
19572 onChange,
19573 hideLabelFromVision,
19574 markWhenOptional,
19575 validity
19576 }) {
19577 const { fields: fields2 } = (0, import_element77.useContext)(dataform_context_default);
19578 const layout = field.layout;
19579 const form = (0, import_element77.useMemo)(
19580 () => ({
19581 layout: DEFAULT_LAYOUT,
19582 fields: !!field.children ? field.children : []
19583 }),
19584 [field]
19585 );
19586 if (!!field.children) {
19587 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_jsx_runtime114.Fragment, { children: [
19588 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Header4, { title: field.label }),
19589 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19590 DataFormLayout,
19591 {
19592 data,
19593 form,
19594 onChange,
19595 validity: validity?.children
19596 }
19597 )
19598 ] });
19599 }
19600 const labelPosition = layout.labelPosition;
19601 const fieldDefinition = fields2.find(
19602 (fieldDef) => fieldDef.id === field.id
19603 );
19604 if (!fieldDefinition || !fieldDefinition.Edit) {
19605 return null;
19606 }
19607 if (labelPosition === "side") {
19608 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
19609 Stack,
19610 {
19611 direction: "row",
19612 className: "dataforms-layouts-regular__field",
19613 gap: "sm",
19614 children: [
19615 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19616 "div",
19617 {
19618 className: clsx_default(
19619 "dataforms-layouts-regular__field-label",
19620 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
19621 ),
19622 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components48.BaseControl.VisualLabel, { children: fieldDefinition.label })
19623 }
19624 ),
19625 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19626 fieldDefinition.render,
19627 {
19628 item: data,
19629 field: fieldDefinition
19630 }
19631 ) : /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19632 fieldDefinition.Edit,
19633 {
19634 data,
19635 field: fieldDefinition,
19636 onChange,
19637 hideLabelFromVision: true,
19638 markWhenOptional,
19639 validity
19640 },
19641 fieldDefinition.id
19642 ) })
19643 ]
19644 }
19645 );
19646 }
19647 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_jsx_runtime114.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_jsx_runtime114.Fragment, { children: [
19648 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components48.BaseControl.VisualLabel, { children: fieldDefinition.label }),
19649 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19650 fieldDefinition.render,
19651 {
19652 item: data,
19653 field: fieldDefinition
19654 }
19655 )
19656 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19657 fieldDefinition.Edit,
19658 {
19659 data,
19660 field: fieldDefinition,
19661 onChange,
19662 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
19663 markWhenOptional,
19664 validity
19665 }
19666 ) });
19667 }
19668
19669 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
19670 var import_deepmerge2 = __toESM(require_cjs(), 1);
19671 var import_components51 = __toESM(require_components(), 1);
19672 var import_element82 = __toESM(require_element(), 1);
19673 var import_compose14 = __toESM(require_compose(), 1);
19674
19675 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
19676 var import_components50 = __toESM(require_components(), 1);
19677 var import_i18n45 = __toESM(require_i18n(), 1);
19678 var import_compose13 = __toESM(require_compose(), 1);
19679 var import_element78 = __toESM(require_element(), 1);
19680
19681 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
19682 function getLabelClassName(labelPosition, showError) {
19683 return clsx_default(
19684 "dataforms-layouts-panel__field-label",
19685 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
19686 { "has-error": showError }
19687 );
19688 }
19689 var get_label_classname_default = getLabelClassName;
19690
19691 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
19692 var import_components49 = __toESM(require_components(), 1);
19693 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
19694 function getLabelContent(showError, errorMessage, fieldLabel) {
19695 return showError ? /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components49.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
19696 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components49.Icon, { icon: error_default, size: 16 }),
19697 fieldLabel
19698 ] }) }) : fieldLabel;
19699 }
19700 var get_label_content_default = getLabelContent;
19701
19702 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
19703 function getFirstValidationError(validity) {
19704 if (!validity) {
19705 return void 0;
19706 }
19707 const validityRules = Object.keys(validity).filter(
19708 (key) => key !== "children"
19709 );
19710 for (const key of validityRules) {
19711 const rule = validity[key];
19712 if (rule === void 0) {
19713 continue;
19714 }
19715 if (rule.type === "invalid") {
19716 if (rule.message) {
19717 return rule.message;
19718 }
19719 if (key === "required") {
19720 return "A required field is empty";
19721 }
19722 return "Unidentified validation error";
19723 }
19724 }
19725 if (validity.children) {
19726 for (const childValidity of Object.values(validity.children)) {
19727 const childError = getFirstValidationError(childValidity);
19728 if (childError) {
19729 return childError;
19730 }
19731 }
19732 }
19733 return void 0;
19734 }
19735 var get_first_validation_error_default = getFirstValidationError;
19736
19737 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
19738 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
19739 function SummaryButton({
19740 data,
19741 field,
19742 fieldLabel,
19743 summaryFields,
19744 validity,
19745 touched,
19746 disabled: disabled2,
19747 onClick,
19748 "aria-expanded": ariaExpanded
19749 }) {
19750 const { labelPosition, editVisibility } = field.layout;
19751 const errorMessage = get_first_validation_error_default(validity);
19752 const showError = touched && !!errorMessage;
19753 const labelClassName = get_label_classname_default(labelPosition, showError);
19754 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
19755 const className = clsx_default(
19756 "dataforms-layouts-panel__field-trigger",
19757 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
19758 {
19759 "is-disabled": disabled2,
19760 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
19761 }
19762 );
19763 const controlId = (0, import_compose13.useInstanceId)(
19764 SummaryButton,
19765 "dataforms-layouts-panel__field-control"
19766 );
19767 const ariaLabel = showError ? (0, import_i18n45.sprintf)(
19768 // translators: %s: Field name.
19769 (0, import_i18n45._x)("Edit %s (has errors)", "field"),
19770 fieldLabel || ""
19771 ) : (0, import_i18n45.sprintf)(
19772 // translators: %s: Field name.
19773 (0, import_i18n45._x)("Edit %s", "field"),
19774 fieldLabel || ""
19775 );
19776 const rowRef = (0, import_element78.useRef)(null);
19777 const handleRowClick = () => {
19778 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection();
19779 if (selection && selection.toString().length > 0) {
19780 return;
19781 }
19782 onClick();
19783 };
19784 const handleKeyDown = (event) => {
19785 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
19786 event.preventDefault();
19787 onClick();
19788 }
19789 };
19790 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
19791 "div",
19792 {
19793 ref: rowRef,
19794 className,
19795 onClick: !disabled2 ? handleRowClick : void 0,
19796 onKeyDown: !disabled2 ? handleKeyDown : void 0,
19797 children: [
19798 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { className: labelClassName, children: labelContent }),
19799 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components50.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components50.Icon, { icon: error_default, size: 16 }) }) }),
19800 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19801 "span",
19802 {
19803 id: `${controlId}`,
19804 className: "dataforms-layouts-panel__field-control",
19805 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19806 "span",
19807 {
19808 style: {
19809 display: "flex",
19810 flexDirection: "column",
19811 alignItems: "flex-start",
19812 width: "100%",
19813 gap: "2px"
19814 },
19815 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19816 "span",
19817 {
19818 style: { width: "100%" },
19819 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19820 summaryField.render,
19821 {
19822 item: data,
19823 field: summaryField
19824 }
19825 )
19826 },
19827 summaryField.id
19828 ))
19829 }
19830 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19831 summaryField.render,
19832 {
19833 item: data,
19834 field: summaryField
19835 },
19836 summaryField.id
19837 ))
19838 }
19839 ),
19840 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19841 import_components50.Button,
19842 {
19843 className: "dataforms-layouts-panel__field-trigger-icon",
19844 label: ariaLabel,
19845 icon: pencil_default,
19846 size: "small",
19847 "aria-expanded": ariaExpanded,
19848 "aria-haspopup": "dialog",
19849 "aria-describedby": `${controlId}`
19850 }
19851 )
19852 ]
19853 }
19854 );
19855 }
19856
19857 // packages/dataviews/build-module/hooks/use-form-validity.mjs
19858 var import_deepmerge = __toESM(require_cjs(), 1);
19859 var import_es62 = __toESM(require_es6(), 1);
19860 var import_element79 = __toESM(require_element(), 1);
19861 var import_i18n46 = __toESM(require_i18n(), 1);
19862 function isFormValid(formValidity) {
19863 if (!formValidity) {
19864 return true;
19865 }
19866 return Object.values(formValidity).every((fieldValidation) => {
19867 return Object.entries(fieldValidation).every(
19868 ([key, validation]) => {
19869 if (key === "children" && validation && typeof validation === "object") {
19870 return isFormValid(validation);
19871 }
19872 return validation.type !== "invalid" && validation.type !== "validating";
19873 }
19874 );
19875 });
19876 }
19877 function getFormFieldsToValidate(form, fields2) {
19878 const normalizedForm = normalize_form_default(form);
19879 if (normalizedForm.fields.length === 0) {
19880 return [];
19881 }
19882 const fieldsMap = /* @__PURE__ */ new Map();
19883 fields2.forEach((field) => {
19884 fieldsMap.set(field.id, field);
19885 });
19886 function processFormField(formField) {
19887 if ("children" in formField && Array.isArray(formField.children)) {
19888 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
19889 if (processedChildren.length === 0) {
19890 return null;
19891 }
19892 const fieldDef2 = fieldsMap.get(formField.id);
19893 if (fieldDef2) {
19894 const [normalizedField2] = normalizeFields([
19895 fieldDef2
19896 ]);
19897 return {
19898 id: formField.id,
19899 children: processedChildren,
19900 field: normalizedField2
19901 };
19902 }
19903 return {
19904 id: formField.id,
19905 children: processedChildren
19906 };
19907 }
19908 const fieldDef = fieldsMap.get(formField.id);
19909 if (!fieldDef) {
19910 return null;
19911 }
19912 const [normalizedField] = normalizeFields([fieldDef]);
19913 return {
19914 id: formField.id,
19915 children: [],
19916 field: normalizedField
19917 };
19918 }
19919 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
19920 return toValidate;
19921 }
19922 function setValidityAtPath(formValidity, fieldValidity, path) {
19923 if (!formValidity) {
19924 formValidity = {};
19925 }
19926 if (path.length === 0) {
19927 return formValidity;
19928 }
19929 const result = { ...formValidity };
19930 let current = result;
19931 for (let i2 = 0; i2 < path.length - 1; i2++) {
19932 const segment = path[i2];
19933 if (!current[segment]) {
19934 current[segment] = {};
19935 }
19936 current[segment] = { ...current[segment] };
19937 current = current[segment];
19938 }
19939 const finalKey = path[path.length - 1];
19940 current[finalKey] = {
19941 ...current[finalKey] || {},
19942 ...fieldValidity
19943 };
19944 return result;
19945 }
19946 function removeValidationProperty(formValidity, path, property) {
19947 if (!formValidity || path.length === 0) {
19948 return formValidity;
19949 }
19950 const result = { ...formValidity };
19951 let current = result;
19952 for (let i2 = 0; i2 < path.length - 1; i2++) {
19953 const segment = path[i2];
19954 if (!current[segment]) {
19955 return formValidity;
19956 }
19957 current[segment] = { ...current[segment] };
19958 current = current[segment];
19959 }
19960 const finalKey = path[path.length - 1];
19961 if (!current[finalKey]) {
19962 return formValidity;
19963 }
19964 const fieldValidity = { ...current[finalKey] };
19965 delete fieldValidity[property];
19966 if (Object.keys(fieldValidity).length === 0) {
19967 delete current[finalKey];
19968 } else {
19969 current[finalKey] = fieldValidity;
19970 }
19971 if (Object.keys(result).length === 0) {
19972 return void 0;
19973 }
19974 return result;
19975 }
19976 function handleElementsValidationAsync(promise, formField, promiseHandler) {
19977 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
19978 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
19979 elementsCounterRef.current[formField.id] = currentToken;
19980 promise.then((result) => {
19981 if (currentToken !== elementsCounterRef.current[formField.id]) {
19982 return;
19983 }
19984 if (!Array.isArray(result)) {
19985 setFormValidity((prev) => {
19986 const newFormValidity = setValidityAtPath(
19987 prev,
19988 {
19989 elements: {
19990 type: "invalid",
19991 message: (0, import_i18n46.__)("Could not validate elements.")
19992 }
19993 },
19994 [...path, formField.id]
19995 );
19996 return newFormValidity;
19997 });
19998 return;
19999 }
20000 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
20001 ...formField.field,
20002 elements: result
20003 })) {
20004 setFormValidity((prev) => {
20005 const newFormValidity = setValidityAtPath(
20006 prev,
20007 {
20008 elements: {
20009 type: "invalid",
20010 message: (0, import_i18n46.__)(
20011 "Value must be one of the elements."
20012 )
20013 }
20014 },
20015 [...path, formField.id]
20016 );
20017 return newFormValidity;
20018 });
20019 } else {
20020 setFormValidity((prev) => {
20021 return removeValidationProperty(
20022 prev,
20023 [...path, formField.id],
20024 "elements"
20025 );
20026 });
20027 }
20028 }).catch((error2) => {
20029 if (currentToken !== elementsCounterRef.current[formField.id]) {
20030 return;
20031 }
20032 let errorMessage;
20033 if (error2 instanceof Error) {
20034 errorMessage = error2.message;
20035 } else {
20036 errorMessage = String(error2) || (0, import_i18n46.__)(
20037 "Unknown error when running elements validation asynchronously."
20038 );
20039 }
20040 setFormValidity((prev) => {
20041 const newFormValidity = setValidityAtPath(
20042 prev,
20043 {
20044 elements: {
20045 type: "invalid",
20046 message: errorMessage
20047 }
20048 },
20049 [...path, formField.id]
20050 );
20051 return newFormValidity;
20052 });
20053 });
20054 }
20055 function handleCustomValidationAsync(promise, formField, promiseHandler) {
20056 const { customCounterRef, setFormValidity, path } = promiseHandler;
20057 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
20058 customCounterRef.current[formField.id] = currentToken;
20059 promise.then((result) => {
20060 if (currentToken !== customCounterRef.current[formField.id]) {
20061 return;
20062 }
20063 if (result === null) {
20064 setFormValidity((prev) => {
20065 return removeValidationProperty(
20066 prev,
20067 [...path, formField.id],
20068 "custom"
20069 );
20070 });
20071 return;
20072 }
20073 if (typeof result === "string") {
20074 setFormValidity((prev) => {
20075 const newFormValidity = setValidityAtPath(
20076 prev,
20077 {
20078 custom: {
20079 type: "invalid",
20080 message: result
20081 }
20082 },
20083 [...path, formField.id]
20084 );
20085 return newFormValidity;
20086 });
20087 return;
20088 }
20089 setFormValidity((prev) => {
20090 const newFormValidity = setValidityAtPath(
20091 prev,
20092 {
20093 custom: {
20094 type: "invalid",
20095 message: (0, import_i18n46.__)("Validation could not be processed.")
20096 }
20097 },
20098 [...path, formField.id]
20099 );
20100 return newFormValidity;
20101 });
20102 }).catch((error2) => {
20103 if (currentToken !== customCounterRef.current[formField.id]) {
20104 return;
20105 }
20106 let errorMessage;
20107 if (error2 instanceof Error) {
20108 errorMessage = error2.message;
20109 } else {
20110 errorMessage = String(error2) || (0, import_i18n46.__)(
20111 "Unknown error when running custom validation asynchronously."
20112 );
20113 }
20114 setFormValidity((prev) => {
20115 const newFormValidity = setValidityAtPath(
20116 prev,
20117 {
20118 custom: {
20119 type: "invalid",
20120 message: errorMessage
20121 }
20122 },
20123 [...path, formField.id]
20124 );
20125 return newFormValidity;
20126 });
20127 });
20128 }
20129 function validateFormField(item, formField, promiseHandler) {
20130 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
20131 return {
20132 required: { type: "invalid" }
20133 };
20134 }
20135 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
20136 return {
20137 pattern: {
20138 type: "invalid",
20139 message: (0, import_i18n46.__)("Value does not match the required pattern.")
20140 }
20141 };
20142 }
20143 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
20144 return {
20145 min: {
20146 type: "invalid",
20147 message: (0, import_i18n46.__)("Value is below the minimum.")
20148 }
20149 };
20150 }
20151 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
20152 return {
20153 max: {
20154 type: "invalid",
20155 message: (0, import_i18n46.__)("Value is above the maximum.")
20156 }
20157 };
20158 }
20159 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
20160 return {
20161 minLength: {
20162 type: "invalid",
20163 message: (0, import_i18n46.__)("Value is too short.")
20164 }
20165 };
20166 }
20167 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
20168 return {
20169 maxLength: {
20170 type: "invalid",
20171 message: (0, import_i18n46.__)("Value is too long.")
20172 }
20173 };
20174 }
20175 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
20176 return {
20177 elements: {
20178 type: "invalid",
20179 message: (0, import_i18n46.__)("Value must be one of the elements.")
20180 }
20181 };
20182 }
20183 let customError;
20184 if (!!formField.field && formField.field.isValid.custom) {
20185 try {
20186 const value = formField.field.getValue({ item });
20187 customError = formField.field.isValid.custom(
20188 (0, import_deepmerge.default)(
20189 item,
20190 formField.field.setValue({
20191 item,
20192 value
20193 })
20194 ),
20195 formField.field
20196 );
20197 } catch (error2) {
20198 let errorMessage;
20199 if (error2 instanceof Error) {
20200 errorMessage = error2.message;
20201 } else {
20202 errorMessage = String(error2) || (0, import_i18n46.__)("Unknown error when running custom validation.");
20203 }
20204 return {
20205 custom: {
20206 type: "invalid",
20207 message: errorMessage
20208 }
20209 };
20210 }
20211 }
20212 if (typeof customError === "string") {
20213 return {
20214 custom: {
20215 type: "invalid",
20216 message: customError
20217 }
20218 };
20219 }
20220 const fieldValidity = {};
20221 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
20222 handleElementsValidationAsync(
20223 formField.field.getElements(),
20224 formField,
20225 promiseHandler
20226 );
20227 fieldValidity.elements = {
20228 type: "validating",
20229 message: (0, import_i18n46.__)("Validating\u2026")
20230 };
20231 }
20232 if (customError instanceof Promise) {
20233 handleCustomValidationAsync(customError, formField, promiseHandler);
20234 fieldValidity.custom = {
20235 type: "validating",
20236 message: (0, import_i18n46.__)("Validating\u2026")
20237 };
20238 }
20239 if (Object.keys(fieldValidity).length > 0) {
20240 return fieldValidity;
20241 }
20242 if (formField.children.length > 0) {
20243 const result = {};
20244 formField.children.forEach((child) => {
20245 result[child.id] = validateFormField(item, child, {
20246 ...promiseHandler,
20247 path: [...promiseHandler.path, formField.id, "children"]
20248 });
20249 });
20250 const filteredResult = {};
20251 Object.entries(result).forEach(([key, value]) => {
20252 if (value !== void 0) {
20253 filteredResult[key] = value;
20254 }
20255 });
20256 if (Object.keys(filteredResult).length === 0) {
20257 return void 0;
20258 }
20259 return {
20260 children: filteredResult
20261 };
20262 }
20263 return void 0;
20264 }
20265 function getFormFieldValue(formField, item) {
20266 const fieldValue = formField?.field?.getValue({ item });
20267 if (formField.children.length === 0) {
20268 return fieldValue;
20269 }
20270 const childrenValues = formField.children.map(
20271 (child) => getFormFieldValue(child, item)
20272 );
20273 if (!childrenValues) {
20274 return fieldValue;
20275 }
20276 return {
20277 value: fieldValue,
20278 children: childrenValues
20279 };
20280 }
20281 function useFormValidity(item, fields2, form) {
20282 const [formValidity, setFormValidity] = (0, import_element79.useState)();
20283 const customCounterRef = (0, import_element79.useRef)({});
20284 const elementsCounterRef = (0, import_element79.useRef)({});
20285 const previousValuesRef = (0, import_element79.useRef)({});
20286 const validate = (0, import_element79.useCallback)(() => {
20287 const promiseHandler = {
20288 customCounterRef,
20289 elementsCounterRef,
20290 setFormValidity,
20291 path: [],
20292 item
20293 };
20294 const formFieldsToValidate = getFormFieldsToValidate(form, fields2);
20295 if (formFieldsToValidate.length === 0) {
20296 setFormValidity(void 0);
20297 return;
20298 }
20299 const newFormValidity = {};
20300 const untouchedFields = [];
20301 formFieldsToValidate.forEach((formField) => {
20302 const value = getFormFieldValue(formField, item);
20303 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
20304 previousValuesRef.current[formField.id],
20305 value
20306 )) {
20307 untouchedFields.push(formField.id);
20308 return;
20309 }
20310 previousValuesRef.current[formField.id] = value;
20311 const fieldValidity = validateFormField(
20312 item,
20313 formField,
20314 promiseHandler
20315 );
20316 if (fieldValidity !== void 0) {
20317 newFormValidity[formField.id] = fieldValidity;
20318 }
20319 });
20320 setFormValidity((existingFormValidity) => {
20321 let validity = {
20322 ...existingFormValidity,
20323 ...newFormValidity
20324 };
20325 const fieldsToKeep = [
20326 ...untouchedFields,
20327 ...Object.keys(newFormValidity)
20328 ];
20329 Object.keys(validity).forEach((key) => {
20330 if (validity && !fieldsToKeep.includes(key)) {
20331 delete validity[key];
20332 }
20333 });
20334 if (Object.keys(validity).length === 0) {
20335 validity = void 0;
20336 }
20337 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
20338 if (areEqual) {
20339 return existingFormValidity;
20340 }
20341 return validity;
20342 });
20343 }, [item, fields2, form]);
20344 (0, import_element79.useEffect)(() => {
20345 validate();
20346 }, [validate]);
20347 return {
20348 validity: formValidity,
20349 isValid: isFormValid(formValidity)
20350 };
20351 }
20352 var use_form_validity_default = useFormValidity;
20353
20354 // packages/dataviews/build-module/hooks/use-report-validity.mjs
20355 var import_element80 = __toESM(require_element(), 1);
20356 function useReportValidity(ref, shouldReport) {
20357 (0, import_element80.useEffect)(() => {
20358 if (shouldReport && ref.current) {
20359 const inputs = ref.current.querySelectorAll(
20360 "input, textarea, select"
20361 );
20362 inputs.forEach((input) => {
20363 input.reportValidity();
20364 });
20365 }
20366 }, [shouldReport, ref]);
20367 }
20368
20369 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
20370 var import_element81 = __toESM(require_element(), 1);
20371
20372 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
20373 function extractSummaryIds(summary) {
20374 if (Array.isArray(summary)) {
20375 return summary.map(
20376 (item) => typeof item === "string" ? item : item.id
20377 );
20378 }
20379 return [];
20380 }
20381 var getSummaryFields = (summaryField, fields2) => {
20382 if (Array.isArray(summaryField) && summaryField.length > 0) {
20383 const summaryIds = extractSummaryIds(summaryField);
20384 return summaryIds.map(
20385 (summaryId) => fields2.find((_field) => _field.id === summaryId)
20386 ).filter((_field) => _field !== void 0);
20387 }
20388 return [];
20389 };
20390
20391 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
20392 var getFieldDefinition = (field, fields2) => {
20393 const fieldDefinition = fields2.find((_field) => _field.id === field.id);
20394 if (!fieldDefinition) {
20395 return fields2.find((_field) => {
20396 if (!!field.children) {
20397 const simpleChildren = field.children.filter(
20398 (child) => !child.children
20399 );
20400 if (simpleChildren.length === 0) {
20401 return false;
20402 }
20403 return _field.id === simpleChildren[0].id;
20404 }
20405 return _field.id === field.id;
20406 });
20407 }
20408 return fieldDefinition;
20409 };
20410 function useFieldFromFormField(field) {
20411 const { fields: fields2 } = (0, import_element81.useContext)(dataform_context_default);
20412 const layout = field.layout;
20413 const summaryFields = getSummaryFields(layout.summary, fields2);
20414 const fieldDefinition = getFieldDefinition(field, fields2);
20415 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
20416 if (summaryFields.length === 0) {
20417 return {
20418 summaryFields: fieldDefinition ? [fieldDefinition] : [],
20419 fieldDefinition,
20420 fieldLabel
20421 };
20422 }
20423 return {
20424 summaryFields,
20425 fieldDefinition,
20426 fieldLabel
20427 };
20428 }
20429 var use_field_from_form_field_default = useFieldFromFormField;
20430
20431 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
20432 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
20433 function ModalContent({
20434 data,
20435 field,
20436 onChange,
20437 fieldLabel,
20438 onClose,
20439 touched
20440 }) {
20441 const { openAs } = field.layout;
20442 const { applyLabel, cancelLabel } = openAs;
20443 const { fields: fields2 } = (0, import_element82.useContext)(dataform_context_default);
20444 const [changes, setChanges] = (0, import_element82.useState)({});
20445 const modalData = (0, import_element82.useMemo)(() => {
20446 return (0, import_deepmerge2.default)(data, changes, {
20447 arrayMerge: (target, source) => source
20448 });
20449 }, [data, changes]);
20450 const form = (0, import_element82.useMemo)(
20451 () => ({
20452 layout: DEFAULT_LAYOUT,
20453 fields: !!field.children ? field.children : (
20454 // If not explicit children return the field id itself.
20455 [{ id: field.id, layout: DEFAULT_LAYOUT }]
20456 )
20457 }),
20458 [field]
20459 );
20460 const fieldsAsFieldType = fields2.map((f2) => ({
20461 ...f2,
20462 Edit: f2.Edit === null ? void 0 : f2.Edit,
20463 isValid: {
20464 required: f2.isValid.required?.constraint,
20465 elements: f2.isValid.elements?.constraint,
20466 min: f2.isValid.min?.constraint,
20467 max: f2.isValid.max?.constraint,
20468 pattern: f2.isValid.pattern?.constraint,
20469 minLength: f2.isValid.minLength?.constraint,
20470 maxLength: f2.isValid.maxLength?.constraint
20471 }
20472 }));
20473 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
20474 const onApply = () => {
20475 onChange(changes);
20476 onClose();
20477 };
20478 const handleOnChange = (newValue) => {
20479 setChanges(
20480 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
20481 arrayMerge: (target, source) => source
20482 })
20483 );
20484 };
20485 const focusOnMountRef = (0, import_compose14.useFocusOnMount)("firstInputElement");
20486 const contentRef = (0, import_element82.useRef)(null);
20487 const mergedRef = (0, import_compose14.useMergeRefs)([focusOnMountRef, contentRef]);
20488 useReportValidity(contentRef, touched);
20489 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
20490 import_components51.Modal,
20491 {
20492 className: "dataforms-layouts-panel__modal",
20493 onRequestClose: onClose,
20494 isFullScreen: false,
20495 title: fieldLabel,
20496 size: "medium",
20497 children: [
20498 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20499 DataFormLayout,
20500 {
20501 data: modalData,
20502 form,
20503 onChange: handleOnChange,
20504 validity,
20505 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20506 FieldLayout,
20507 {
20508 data: modalData,
20509 field: childField,
20510 onChange: handleOnChange,
20511 hideLabelFromVision: form.fields.length < 2,
20512 markWhenOptional,
20513 validity: childFieldValidity
20514 },
20515 childField.id
20516 )
20517 }
20518 ) }),
20519 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
20520 Stack,
20521 {
20522 direction: "row",
20523 className: "dataforms-layouts-panel__modal-footer",
20524 gap: "md",
20525 children: [
20526 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components51.__experimentalSpacer, { style: { flex: 1 } }),
20527 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20528 import_components51.Button,
20529 {
20530 variant: "tertiary",
20531 onClick: onClose,
20532 __next40pxDefaultSize: true,
20533 children: cancelLabel
20534 }
20535 ),
20536 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20537 import_components51.Button,
20538 {
20539 variant: "primary",
20540 onClick: onApply,
20541 __next40pxDefaultSize: true,
20542 children: applyLabel
20543 }
20544 )
20545 ]
20546 }
20547 )
20548 ]
20549 }
20550 );
20551 }
20552 function PanelModal({
20553 data,
20554 field,
20555 onChange,
20556 validity
20557 }) {
20558 const [touched, setTouched] = (0, import_element82.useState)(false);
20559 const [isOpen, setIsOpen] = (0, import_element82.useState)(false);
20560 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
20561 if (!fieldDefinition) {
20562 return null;
20563 }
20564 const handleClose = () => {
20565 setIsOpen(false);
20566 setTouched(true);
20567 };
20568 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [
20569 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20570 SummaryButton,
20571 {
20572 data,
20573 field,
20574 fieldLabel,
20575 summaryFields,
20576 validity,
20577 touched,
20578 disabled: fieldDefinition.readOnly === true,
20579 onClick: () => setIsOpen(true),
20580 "aria-expanded": isOpen
20581 }
20582 ),
20583 isOpen && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20584 ModalContent,
20585 {
20586 data,
20587 field,
20588 onChange,
20589 fieldLabel: fieldLabel ?? "",
20590 onClose: handleClose,
20591 touched
20592 }
20593 )
20594 ] });
20595 }
20596 var modal_default = PanelModal;
20597
20598 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
20599 var import_components52 = __toESM(require_components(), 1);
20600 var import_i18n47 = __toESM(require_i18n(), 1);
20601 var import_element83 = __toESM(require_element(), 1);
20602 var import_compose15 = __toESM(require_compose(), 1);
20603 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
20604 function DropdownHeader({
20605 title,
20606 onClose
20607 }) {
20608 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20609 Stack,
20610 {
20611 direction: "column",
20612 className: "dataforms-layouts-panel__dropdown-header",
20613 gap: "lg",
20614 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
20615 title && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components52.__experimentalHeading, { level: 2, size: 13, children: title }),
20616 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components52.__experimentalSpacer, { style: { flex: 1 } }),
20617 onClose && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20618 import_components52.Button,
20619 {
20620 label: (0, import_i18n47.__)("Close"),
20621 icon: close_small_default,
20622 onClick: onClose,
20623 size: "small"
20624 }
20625 )
20626 ] })
20627 }
20628 );
20629 }
20630 function DropdownContentWithValidation({
20631 touched,
20632 children
20633 }) {
20634 const ref = (0, import_element83.useRef)(null);
20635 useReportValidity(ref, touched);
20636 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { ref, children });
20637 }
20638 function PanelDropdown({
20639 data,
20640 field,
20641 onChange,
20642 validity
20643 }) {
20644 const [touched, setTouched] = (0, import_element83.useState)(false);
20645 const [popoverAnchor, setPopoverAnchor] = (0, import_element83.useState)(
20646 null
20647 );
20648 const popoverProps = (0, import_element83.useMemo)(
20649 () => ({
20650 // Anchor the popover to the middle of the entire row so that it doesn't
20651 // move around when the label changes.
20652 anchor: popoverAnchor,
20653 placement: "left-start",
20654 offset: 36,
20655 shift: true
20656 }),
20657 [popoverAnchor]
20658 );
20659 const [dialogRef, dialogProps] = (0, import_compose15.__experimentalUseDialog)({
20660 focusOnMount: "firstInputElement"
20661 });
20662 const form = (0, import_element83.useMemo)(
20663 () => ({
20664 layout: DEFAULT_LAYOUT,
20665 fields: !!field.children ? field.children : (
20666 // If not explicit children return the field id itself.
20667 [{ id: field.id, layout: DEFAULT_LAYOUT }]
20668 )
20669 }),
20670 [field]
20671 );
20672 const formValidity = (0, import_element83.useMemo)(() => {
20673 if (validity === void 0) {
20674 return void 0;
20675 }
20676 if (!!field.children) {
20677 return validity?.children;
20678 }
20679 return { [field.id]: validity };
20680 }, [validity, field]);
20681 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
20682 if (!fieldDefinition) {
20683 return null;
20684 }
20685 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20686 "div",
20687 {
20688 ref: setPopoverAnchor,
20689 className: "dataforms-layouts-panel__field-dropdown-anchor",
20690 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20691 import_components52.Dropdown,
20692 {
20693 contentClassName: "dataforms-layouts-panel__field-dropdown",
20694 popoverProps,
20695 focusOnMount: false,
20696 onToggle: (willOpen) => {
20697 if (!willOpen) {
20698 setTouched(true);
20699 }
20700 },
20701 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20702 SummaryButton,
20703 {
20704 data,
20705 field,
20706 fieldLabel,
20707 summaryFields,
20708 validity,
20709 touched,
20710 disabled: fieldDefinition.readOnly === true,
20711 onClick: onToggle,
20712 "aria-expanded": isOpen
20713 }
20714 ),
20715 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
20716 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20717 DropdownHeader,
20718 {
20719 title: fieldLabel,
20720 onClose
20721 }
20722 ),
20723 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20724 DataFormLayout,
20725 {
20726 data,
20727 form,
20728 onChange,
20729 validity: formValidity,
20730 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20731 FieldLayout,
20732 {
20733 data,
20734 field: childField,
20735 onChange,
20736 hideLabelFromVision: (form?.fields ?? []).length < 2,
20737 markWhenOptional,
20738 validity: childFieldValidity
20739 },
20740 childField.id
20741 )
20742 }
20743 )
20744 ] }) })
20745 }
20746 )
20747 }
20748 );
20749 }
20750 var dropdown_default = PanelDropdown;
20751
20752 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
20753 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
20754 function FormPanelField({
20755 data,
20756 field,
20757 onChange,
20758 validity
20759 }) {
20760 const layout = field.layout;
20761 if (layout.openAs.type === "modal") {
20762 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
20763 modal_default,
20764 {
20765 data,
20766 field,
20767 onChange,
20768 validity
20769 }
20770 );
20771 }
20772 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
20773 dropdown_default,
20774 {
20775 data,
20776 field,
20777 onChange,
20778 validity
20779 }
20780 );
20781 }
20782
20783 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
20784 var import_element84 = __toESM(require_element(), 1);
20785
20786 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
20787 var import_i18n48 = __toESM(require_i18n(), 1);
20788 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
20789 function countInvalidFields(validity) {
20790 if (!validity) {
20791 return 0;
20792 }
20793 let count = 0;
20794 const validityRules = Object.keys(validity).filter(
20795 (key) => key !== "children"
20796 );
20797 for (const key of validityRules) {
20798 const rule = validity[key];
20799 if (rule?.type === "invalid") {
20800 count++;
20801 }
20802 }
20803 if (validity.children) {
20804 for (const childValidity of Object.values(validity.children)) {
20805 count += countInvalidFields(childValidity);
20806 }
20807 }
20808 return count;
20809 }
20810 function ValidationBadge({
20811 validity
20812 }) {
20813 const invalidCount = countInvalidFields(validity);
20814 if (invalidCount === 0) {
20815 return null;
20816 }
20817 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(Badge, { intent: "high", children: (0, import_i18n48.sprintf)(
20818 /* translators: %d: Number of fields that need attention */
20819 (0, import_i18n48._n)(
20820 "%d field needs attention",
20821 "%d fields need attention",
20822 invalidCount
20823 ),
20824 invalidCount
20825 ) });
20826 }
20827
20828 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
20829 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
20830 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
20831 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
20832 return false;
20833 }
20834 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
20835 const fieldConfig = summaryConfigArray.find((config) => {
20836 if (typeof config === "string") {
20837 return config === summaryField.id;
20838 }
20839 if (typeof config === "object" && "id" in config) {
20840 return config.id === summaryField.id;
20841 }
20842 return false;
20843 });
20844 if (!fieldConfig) {
20845 return false;
20846 }
20847 if (typeof fieldConfig === "string") {
20848 return true;
20849 }
20850 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
20851 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
20852 }
20853 return true;
20854 }
20855 function HeaderContent({
20856 data,
20857 fields: fields2,
20858 label,
20859 layout,
20860 isOpen,
20861 touched,
20862 validity
20863 }) {
20864 const summaryFields = getSummaryFields(layout.summary, fields2);
20865 const visibleSummaryFields = summaryFields.filter(
20866 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
20867 );
20868 const hasBadge = touched && layout.isCollapsible;
20869 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
20870 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
20871 Stack,
20872 {
20873 align: "center",
20874 justify: "space-between",
20875 className: "dataforms-layouts-card__field-header-content",
20876 children: [
20877 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Title, { children: label }),
20878 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
20879 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ValidationBadge, { validity }),
20880 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
20881 summaryField.render,
20882 {
20883 item: data,
20884 field: summaryField
20885 },
20886 summaryField.id
20887 )) })
20888 ] })
20889 ]
20890 }
20891 );
20892 }
20893 function BodyContent({
20894 data,
20895 field,
20896 form,
20897 onChange,
20898 hideLabelFromVision,
20899 markWhenOptional,
20900 validity,
20901 withHeader
20902 }) {
20903 if (field.children) {
20904 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_jsx_runtime121.Fragment, { children: [
20905 field.description && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
20906 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
20907 DataFormLayout,
20908 {
20909 data,
20910 form,
20911 onChange,
20912 validity: validity?.children
20913 }
20914 )
20915 ] });
20916 }
20917 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
20918 if (!SingleFieldLayout) {
20919 return null;
20920 }
20921 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
20922 SingleFieldLayout,
20923 {
20924 data,
20925 field,
20926 onChange,
20927 hideLabelFromVision: hideLabelFromVision || withHeader,
20928 markWhenOptional,
20929 validity
20930 }
20931 );
20932 }
20933 function FormCardField({
20934 data,
20935 field,
20936 onChange,
20937 hideLabelFromVision,
20938 markWhenOptional,
20939 validity
20940 }) {
20941 const { fields: fields2 } = (0, import_element84.useContext)(dataform_context_default);
20942 const layout = field.layout;
20943 const contentRef = (0, import_element84.useRef)(null);
20944 const form = (0, import_element84.useMemo)(
20945 () => ({
20946 layout: DEFAULT_LAYOUT,
20947 fields: field.children ?? []
20948 }),
20949 [field]
20950 );
20951 const { isOpened, isCollapsible } = layout;
20952 const [isOpen, setIsOpen] = (0, import_element84.useState)(isOpened);
20953 const [touched, setTouched] = (0, import_element84.useState)(false);
20954 (0, import_element84.useEffect)(() => {
20955 setIsOpen(isOpened);
20956 }, [isOpened]);
20957 const handleOpenChange = (0, import_element84.useCallback)((open) => {
20958 if (!open) {
20959 setTouched(true);
20960 }
20961 setIsOpen(open);
20962 }, []);
20963 const handleBlur = (0, import_element84.useCallback)(() => {
20964 setTouched(true);
20965 }, []);
20966 useReportValidity(
20967 contentRef,
20968 (isCollapsible ? isOpen : true) && touched
20969 );
20970 let label = field.label;
20971 let withHeader;
20972 if (field.children) {
20973 withHeader = !!label && layout.withHeader;
20974 } else {
20975 const fieldDefinition = fields2.find(
20976 (fieldDef) => fieldDef.id === field.id
20977 );
20978 if (!fieldDefinition || !fieldDefinition.Edit) {
20979 return null;
20980 }
20981 label = fieldDefinition.label;
20982 withHeader = !!label && layout.withHeader;
20983 }
20984 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
20985 BodyContent,
20986 {
20987 data,
20988 field,
20989 form,
20990 onChange,
20991 hideLabelFromVision,
20992 markWhenOptional,
20993 validity,
20994 withHeader
20995 }
20996 );
20997 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
20998 HeaderContent,
20999 {
21000 data,
21001 fields: fields2,
21002 label,
21003 layout,
21004 isOpen: isCollapsible ? !!isOpen : true,
21005 touched,
21006 validity
21007 }
21008 );
21009 if (withHeader && isCollapsible) {
21010 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
21011 collapsible_card_exports.Root,
21012 {
21013 className: "dataforms-layouts-card__field",
21014 open: isOpen,
21015 onOpenChange: handleOpenChange,
21016 children: [
21017 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(collapsible_card_exports.Header, { children: headerContent }),
21018 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21019 collapsible_card_exports.Content,
21020 {
21021 ref: contentRef,
21022 onBlur: handleBlur,
21023 children: bodyContent
21024 }
21025 )
21026 ]
21027 }
21028 );
21029 }
21030 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
21031 withHeader && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Header, { children: headerContent }),
21032 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
21033 ] });
21034 }
21035
21036 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
21037 var import_components53 = __toESM(require_components(), 1);
21038 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
21039 function Header5({ title }) {
21040 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21041 Stack,
21042 {
21043 direction: "column",
21044 className: "dataforms-layouts-row__header",
21045 gap: "lg",
21046 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components53.__experimentalHeading, { level: 2, size: 13, children: title }) })
21047 }
21048 );
21049 }
21050 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children });
21051 function FormRowField({
21052 data,
21053 field,
21054 onChange,
21055 hideLabelFromVision,
21056 markWhenOptional,
21057 validity
21058 }) {
21059 const layout = field.layout;
21060 if (!!field.children) {
21061 const form = {
21062 layout: DEFAULT_LAYOUT,
21063 fields: field.children
21064 };
21065 return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
21066 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Header5, { title: field.label }),
21067 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21068 DataFormLayout,
21069 {
21070 data,
21071 form,
21072 onChange,
21073 validity: validity?.children,
21074 as: EMPTY_WRAPPER,
21075 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21076 "div",
21077 {
21078 className: "dataforms-layouts-row__field-control",
21079 style: layout.styles[childField.id],
21080 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21081 FieldLayout,
21082 {
21083 data,
21084 field: childField,
21085 onChange,
21086 hideLabelFromVision,
21087 markWhenOptional,
21088 validity: childFieldValidity
21089 }
21090 )
21091 },
21092 childField.id
21093 )
21094 }
21095 ) })
21096 ] });
21097 }
21098 const RegularLayout = getFormFieldLayout("regular")?.component;
21099 if (!RegularLayout) {
21100 return null;
21101 }
21102 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21103 RegularLayout,
21104 {
21105 data,
21106 field,
21107 onChange,
21108 markWhenOptional,
21109 validity
21110 }
21111 ) }) });
21112 }
21113
21114 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
21115 var import_element85 = __toESM(require_element(), 1);
21116 var import_i18n49 = __toESM(require_i18n(), 1);
21117 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
21118 function FormDetailsField({
21119 data,
21120 field,
21121 onChange,
21122 validity
21123 }) {
21124 const { fields: fields2 } = (0, import_element85.useContext)(dataform_context_default);
21125 const detailsRef = (0, import_element85.useRef)(null);
21126 const contentRef = (0, import_element85.useRef)(null);
21127 const [touched, setTouched] = (0, import_element85.useState)(false);
21128 const [isOpen, setIsOpen] = (0, import_element85.useState)(false);
21129 const form = (0, import_element85.useMemo)(
21130 () => ({
21131 layout: DEFAULT_LAYOUT,
21132 fields: field.children ?? []
21133 }),
21134 [field]
21135 );
21136 (0, import_element85.useEffect)(() => {
21137 const details = detailsRef.current;
21138 if (!details) {
21139 return;
21140 }
21141 const handleToggle = () => {
21142 const nowOpen = details.open;
21143 if (!nowOpen) {
21144 setTouched(true);
21145 }
21146 setIsOpen(nowOpen);
21147 };
21148 details.addEventListener("toggle", handleToggle);
21149 return () => {
21150 details.removeEventListener("toggle", handleToggle);
21151 };
21152 }, []);
21153 useReportValidity(contentRef, isOpen && touched);
21154 const handleBlur = (0, import_element85.useCallback)(() => {
21155 setTouched(true);
21156 }, []);
21157 if (!field.children) {
21158 return null;
21159 }
21160 const summaryFieldId = field.layout.summary ?? "";
21161 const summaryField = summaryFieldId ? fields2.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
21162 let summaryContent;
21163 if (summaryField && summaryField.render) {
21164 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(summaryField.render, { item: data, field: summaryField });
21165 } else {
21166 summaryContent = field.label || (0, import_i18n49.__)("More details");
21167 }
21168 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
21169 "details",
21170 {
21171 ref: detailsRef,
21172 className: "dataforms-layouts-details__details",
21173 children: [
21174 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
21175 Stack,
21176 {
21177 direction: "row",
21178 align: "center",
21179 gap: "md",
21180 className: "dataforms-layouts-details__summary-content",
21181 children: [
21182 summaryContent,
21183 touched && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ValidationBadge, { validity })
21184 ]
21185 }
21186 ) }),
21187 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
21188 "div",
21189 {
21190 ref: contentRef,
21191 className: "dataforms-layouts-details__content",
21192 onBlur: handleBlur,
21193 children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
21194 DataFormLayout,
21195 {
21196 data,
21197 form,
21198 onChange,
21199 validity: validity?.children
21200 }
21201 )
21202 }
21203 )
21204 ]
21205 }
21206 );
21207 }
21208
21209 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
21210 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
21211 var FORM_FIELD_LAYOUTS = [
21212 {
21213 type: "regular",
21214 component: FormRegularField,
21215 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21216 Stack,
21217 {
21218 direction: "column",
21219 className: "dataforms-layouts__wrapper",
21220 gap: "lg",
21221 children
21222 }
21223 )
21224 },
21225 {
21226 type: "panel",
21227 component: FormPanelField,
21228 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21229 Stack,
21230 {
21231 direction: "column",
21232 className: "dataforms-layouts__wrapper",
21233 gap: "md",
21234 children
21235 }
21236 )
21237 },
21238 {
21239 type: "card",
21240 component: FormCardField,
21241 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21242 Stack,
21243 {
21244 direction: "column",
21245 className: "dataforms-layouts__wrapper",
21246 gap: "xl",
21247 children
21248 }
21249 )
21250 },
21251 {
21252 type: "row",
21253 component: FormRowField,
21254 wrapper: ({
21255 children,
21256 layout
21257 }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21258 Stack,
21259 {
21260 direction: "column",
21261 className: "dataforms-layouts__wrapper",
21262 gap: "lg",
21263 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21264 Stack,
21265 {
21266 direction: "row",
21267 gap: "lg",
21268 align: layout.alignment,
21269 children
21270 }
21271 ) })
21272 }
21273 )
21274 },
21275 {
21276 type: "details",
21277 component: FormDetailsField
21278 }
21279 ];
21280 function getFormFieldLayout(type) {
21281 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
21282 }
21283
21284 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
21285 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
21286 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
21287 function DataFormLayout({
21288 data,
21289 form,
21290 onChange,
21291 validity,
21292 children,
21293 as
21294 }) {
21295 const { fields: fieldDefinitions } = (0, import_element86.useContext)(dataform_context_default);
21296 const markWhenOptional = (0, import_element86.useMemo)(() => {
21297 const requiredCount = fieldDefinitions.filter(
21298 (f2) => !!f2.isValid?.required
21299 ).length;
21300 const optionalCount = fieldDefinitions.length - requiredCount;
21301 return requiredCount > optionalCount;
21302 }, [fieldDefinitions]);
21303 function getFieldDefinition2(field) {
21304 return fieldDefinitions.find(
21305 (fieldDefinition) => fieldDefinition.id === field.id
21306 );
21307 }
21308 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
21309 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
21310 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
21311 if (!FieldLayout) {
21312 return null;
21313 }
21314 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
21315 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
21316 return null;
21317 }
21318 if (children) {
21319 return children(
21320 FieldLayout,
21321 formField,
21322 validity?.[formField.id],
21323 markWhenOptional
21324 );
21325 }
21326 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
21327 FieldLayout,
21328 {
21329 data,
21330 field: formField,
21331 onChange,
21332 markWhenOptional,
21333 validity: validity?.[formField.id]
21334 },
21335 formField.id
21336 );
21337 }) });
21338 }
21339
21340 // packages/dataviews/build-module/dataform/index.mjs
21341 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
21342 function DataForm({
21343 data,
21344 form,
21345 fields: fields2,
21346 onChange,
21347 validity
21348 }) {
21349 const normalizedForm = (0, import_element87.useMemo)(() => normalize_form_default(form), [form]);
21350 const normalizedFields = (0, import_element87.useMemo)(
21351 () => normalizeFields(fields2),
21352 [fields2]
21353 );
21354 if (!form.fields) {
21355 return null;
21356 }
21357 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
21358 DataFormLayout,
21359 {
21360 data,
21361 form: normalizedForm,
21362 onChange,
21363 validity
21364 }
21365 ) });
21366 }
21367
21368 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
21369 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
21370 var import_deprecated = __toESM(require_deprecated(), 1);
21371 function normalizeSearchInput2(input = "") {
21372 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
21373 }
21374 var EMPTY_ARRAY7 = [];
21375 function filterSortAndPaginate(data, view, fields2) {
21376 if (!data) {
21377 return {
21378 data: EMPTY_ARRAY7,
21379 paginationInfo: { totalItems: 0, totalPages: 0 }
21380 };
21381 }
21382 const _fields = normalizeFields(fields2);
21383 let filteredData = [...data];
21384 if (view.search) {
21385 const normalizedSearch = normalizeSearchInput2(view.search);
21386 filteredData = filteredData.filter((item) => {
21387 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
21388 const fieldValue = field.getValue({ item });
21389 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
21390 return values.some(
21391 (value) => normalizeSearchInput2(String(value)).includes(
21392 normalizedSearch
21393 )
21394 );
21395 });
21396 });
21397 }
21398 if (view.filters && view.filters?.length > 0) {
21399 view.filters.forEach((filter) => {
21400 const field = _fields.find(
21401 (_field) => _field.id === filter.field
21402 );
21403 if (field) {
21404 if (filter.operator === OPERATOR_IS_NOT_ALL) {
21405 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
21406 since: "7.0",
21407 alternative: "'isNone'"
21408 });
21409 }
21410 const handler = field.filter[filter.operator];
21411 if (handler) {
21412 filteredData = filteredData.filter(
21413 (item) => handler(item, field, filter.value)
21414 );
21415 }
21416 }
21417 });
21418 }
21419 const sortByField = view.sort?.field ? _fields.find((field) => {
21420 return field.enableSorting !== false && field.id === view.sort?.field;
21421 }) : null;
21422 const groupByField = view.groupBy?.field ? _fields.find((field) => {
21423 return field.enableSorting !== false && field.id === view.groupBy?.field;
21424 }) : null;
21425 if (sortByField || groupByField) {
21426 filteredData.sort((a2, b2) => {
21427 if (groupByField) {
21428 const groupCompare = groupByField.sort(
21429 a2,
21430 b2,
21431 view.groupBy?.direction ?? "asc"
21432 );
21433 if (groupCompare !== 0) {
21434 return groupCompare;
21435 }
21436 }
21437 if (sortByField) {
21438 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
21439 }
21440 return 0;
21441 });
21442 }
21443 let totalItems = filteredData.length;
21444 let totalPages = 1;
21445 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
21446 const start = view.startPosition - 1;
21447 const end = Math.min(start + view.perPage, totalItems);
21448 filteredData = filteredData?.slice(start, end);
21449 } else if (view.page !== void 0 && view.perPage !== void 0) {
21450 const start = (view.page - 1) * view.perPage;
21451 totalItems = filteredData?.length || 0;
21452 totalPages = Math.ceil(totalItems / view.perPage);
21453 filteredData = filteredData?.slice(start, start + view.perPage);
21454 }
21455 return {
21456 data: filteredData,
21457 paginationInfo: {
21458 totalItems,
21459 totalPages
21460 }
21461 };
21462 }
21463
21464 // routes/guidelines/components/guideline-accordion-form.tsx
21465 var import_i18n51 = __toESM(require_i18n());
21466 var import_element88 = __toESM(require_element());
21467 var import_data8 = __toESM(require_data());
21468 var import_notices2 = __toESM(require_notices());
21469
21470 // routes/guidelines/store.ts
21471 var import_data6 = __toESM(require_data());
21472 var STORE_NAME = "core/guidelines";
21473 var DEFAULT_STATE = {
21474 id: null,
21475 status: null,
21476 categories: {
21477 site: "",
21478 copy: "",
21479 images: "",
21480 additional: "",
21481 blocks: {}
21482 }
21483 };
21484 var CATEGORIES = ["site", "copy", "images", "additional", "blocks"];
21485 var actions = {
21486 setFromResponse(response) {
21487 return {
21488 type: "SET_FROM_RESPONSE",
21489 response
21490 };
21491 },
21492 setGuideline(category, value) {
21493 return {
21494 type: "SET_GUIDELINE",
21495 category,
21496 value
21497 };
21498 },
21499 setBlockGuideline(blockName, value) {
21500 return {
21501 type: "SET_BLOCK_GUIDELINE",
21502 blockName,
21503 value
21504 };
21505 }
21506 };
21507 function parseResponse(response) {
21508 if (!response || typeof response !== "object") {
21509 return {};
21510 }
21511 const categoriesFromResponse = response.guideline_categories ?? {};
21512 const result = {
21513 id: response.id ?? null,
21514 status: response.status ?? null,
21515 categories: {
21516 site: "",
21517 copy: "",
21518 images: "",
21519 additional: "",
21520 blocks: {}
21521 }
21522 };
21523 CATEGORIES.forEach((category) => {
21524 const guidelines = categoriesFromResponse?.[category]?.guidelines;
21525 if (typeof guidelines === "string") {
21526 result.categories[category] = guidelines;
21527 } else if (category === "blocks") {
21528 const blocks = categoriesFromResponse?.blocks ?? {};
21529 for (const [blockName, blockData] of Object.entries(blocks)) {
21530 result.categories.blocks[blockName] = blockData?.guidelines;
21531 }
21532 }
21533 });
21534 return result;
21535 }
21536 function reducer(state = DEFAULT_STATE, action) {
21537 switch (action.type) {
21538 case "SET_FROM_RESPONSE":
21539 return {
21540 ...state,
21541 ...parseResponse(action.response)
21542 };
21543 case "SET_GUIDELINE":
21544 return {
21545 ...state,
21546 categories: {
21547 ...state.categories,
21548 [action.category]: action.value
21549 }
21550 };
21551 case "SET_BLOCK_GUIDELINE": {
21552 const blocks = {
21553 ...state.categories.blocks,
21554 [action.blockName]: action.value
21555 };
21556 if (action.value === void 0) {
21557 delete blocks[action.blockName];
21558 }
21559 return {
21560 ...state,
21561 categories: {
21562 ...state.categories,
21563 blocks
21564 }
21565 };
21566 }
21567 default:
21568 return state;
21569 }
21570 }
21571 var selectors = {
21572 getGuideline(state, category) {
21573 return state.categories[category];
21574 },
21575 getAllGuidelines(state) {
21576 return state.categories;
21577 },
21578 getBlockGuidelines(state) {
21579 return state.categories.blocks;
21580 },
21581 getBlockGuideline(state, blockName) {
21582 return state.categories.blocks[blockName] ?? "";
21583 },
21584 getId(state) {
21585 return state.id;
21586 },
21587 getStatus(state) {
21588 return state.status;
21589 }
21590 };
21591 var store = (0, import_data6.createReduxStore)(STORE_NAME, {
21592 reducer,
21593 actions,
21594 selectors
21595 });
21596 (0, import_data6.register)(store);
21597
21598 // routes/guidelines/api.ts
21599 var import_api_fetch = __toESM(require_api_fetch());
21600 var import_blob = __toESM(require_blob());
21601 var import_data7 = __toESM(require_data());
21602 var import_i18n50 = __toESM(require_i18n());
21603 var import_notices = __toESM(require_notices());
21604 var FLAT_CATEGORIES = ["site", "copy", "images", "additional"];
21605 function isValidGuidelinesImport(data) {
21606 return !!data && typeof data === "object" && "guideline_categories" in data && typeof data.guideline_categories === "object" && data.guideline_categories !== null;
21607 }
21608 async function fetchGuidelines() {
21609 const { setFromResponse } = (0, import_data7.dispatch)(store);
21610 const response = await (0, import_api_fetch.default)({
21611 path: "/wp/v2/guidelines?context=edit"
21612 });
21613 setFromResponse(response);
21614 return response;
21615 }
21616 async function saveGuidelines() {
21617 const { setFromResponse } = (0, import_data7.dispatch)(store);
21618 const guidelinesStore = (0, import_data7.select)(store);
21619 const id = guidelinesStore.getId();
21620 const status = guidelinesStore.getStatus() || "draft";
21621 const categories = guidelinesStore.getAllGuidelines();
21622 const response = await saveGuidelinesBypassingStore(
21623 id,
21624 status,
21625 categories
21626 );
21627 setFromResponse(response);
21628 return response;
21629 }
21630 async function saveGuidelinesBypassingStore(id, status, categories) {
21631 const data = {
21632 id,
21633 status,
21634 guideline_categories: {
21635 site: {
21636 guidelines: categories.site
21637 },
21638 copy: {
21639 guidelines: categories.copy
21640 },
21641 images: {
21642 guidelines: categories.images
21643 },
21644 additional: {
21645 guidelines: categories.additional
21646 },
21647 blocks: Object.fromEntries(
21648 Object.entries(categories.blocks).map(
21649 ([blockName, guidelines]) => [
21650 blockName,
21651 { guidelines }
21652 ]
21653 )
21654 )
21655 }
21656 };
21657 const path = id ? `/wp/v2/guidelines/${id}` : "/wp/v2/guidelines";
21658 const method = id ? "PUT" : "POST";
21659 const response = await (0, import_api_fetch.default)({
21660 path,
21661 method,
21662 data
21663 });
21664 return response;
21665 }
21666 async function importGuidelines(file) {
21667 const { setFromResponse } = (0, import_data7.dispatch)(store);
21668 const guidelinesStore = (0, import_data7.select)(store);
21669 const { createSuccessNotice } = (0, import_data7.dispatch)(import_notices.store);
21670 const parsed = JSON.parse(await file.text());
21671 if (!isValidGuidelinesImport(parsed)) {
21672 throw new Error(
21673 (0, import_i18n50.__)(
21674 "Check that your file contains valid JSON markup and try again."
21675 )
21676 );
21677 }
21678 const existingGuidelines = guidelinesStore.getAllGuidelines();
21679 const newGuidelines = {
21680 /**
21681 * Set empty string to all the simple guidelines so that if the category is not present
21682 * in the parsed data, the category gets removed.
21683 */
21684 ...Object.fromEntries(
21685 FLAT_CATEGORIES.map((category) => [category, ""])
21686 ),
21687 /**
21688 * Set empty string to all the existing block guidelines so that if the block is not present
21689 * in the parsed data, the block gets removed.
21690 */
21691 blocks: Object.fromEntries(
21692 Object.keys(existingGuidelines.blocks).map((block) => [
21693 block,
21694 ""
21695 ])
21696 )
21697 };
21698 for (const cat of FLAT_CATEGORIES) {
21699 const guidelines = parsed.guideline_categories[cat]?.guidelines || "";
21700 newGuidelines[cat] = guidelines;
21701 }
21702 const parsedBlocks = parsed.guideline_categories?.blocks ?? {};
21703 for (const [key, value] of Object.entries(parsedBlocks)) {
21704 newGuidelines.blocks[key] = value?.guidelines || "";
21705 }
21706 const response = await saveGuidelinesBypassingStore(
21707 guidelinesStore.getId(),
21708 guidelinesStore.getStatus() || "draft",
21709 newGuidelines
21710 );
21711 setFromResponse(response);
21712 createSuccessNotice((0, import_i18n50.__)("Guidelines imported."), {
21713 type: "snackbar"
21714 });
21715 }
21716 function exportGuidelines() {
21717 const { createSuccessNotice } = (0, import_data7.dispatch)(import_notices.store);
21718 const guidelinesStore = (0, import_data7.select)(store);
21719 const guidelinesCategories = guidelinesStore.getAllGuidelines();
21720 const blockGuidelines = guidelinesStore.getBlockGuidelines();
21721 const data = {
21722 guideline_categories: {
21723 ...Object.fromEntries(
21724 FLAT_CATEGORIES.map((guidelineCategory) => [
21725 guidelineCategory,
21726 {
21727 guidelines: guidelinesCategories[guidelineCategory] ?? ""
21728 }
21729 ])
21730 ),
21731 blocks: Object.fromEntries(
21732 Object.entries(blockGuidelines).map(
21733 ([blockName, guidelines]) => [
21734 blockName,
21735 { guidelines }
21736 ]
21737 )
21738 )
21739 }
21740 };
21741 const now = /* @__PURE__ */ new Date();
21742 const exportDate = [
21743 now.getFullYear(),
21744 String(now.getMonth() + 1).padStart(2, "0"),
21745 String(now.getDate()).padStart(2, "0")
21746 ].join("-");
21747 (0, import_blob.downloadBlob)(
21748 `guidelines-${exportDate}.json`,
21749 JSON.stringify(data, null, 2),
21750 "application/json"
21751 );
21752 createSuccessNotice((0, import_i18n50.__)("Guidelines exported."), {
21753 type: "snackbar"
21754 });
21755 }
21756 async function fetchGuidelinesRevisions({
21757 guidelinesId,
21758 page = 1,
21759 perPage = 10,
21760 search
21761 }) {
21762 const params = new URLSearchParams({
21763 page: String(page),
21764 per_page: String(perPage),
21765 _embed: "author",
21766 ...search ? { search } : {}
21767 });
21768 const response = await (0, import_api_fetch.default)({
21769 path: `/wp/v2/guidelines/${guidelinesId}/revisions?${params}`,
21770 parse: false
21771 });
21772 const revisions = await response.json();
21773 const total = parseInt(response.headers.get("X-WP-Total") ?? "0", 10);
21774 const totalPages = parseInt(
21775 response.headers.get("X-WP-TotalPages") ?? "0",
21776 10
21777 );
21778 return { revisions, total, totalPages };
21779 }
21780 async function restoreGuidelinesRevision(guidelinesId, revisionId) {
21781 return await (0, import_api_fetch.default)({
21782 path: `/wp/v2/guidelines/${guidelinesId}/revisions/${revisionId}/restore`,
21783 method: "POST"
21784 });
21785 }
21786
21787 // routes/guidelines/components/guideline-accordion-form.tsx
21788 function GuidelineAccordionForm({
21789 slug,
21790 contentId,
21791 headingId,
21792 descriptionId
21793 }) {
21794 const { setGuideline } = (0, import_data8.useDispatch)(store);
21795 const { createSuccessNotice } = (0, import_data8.useDispatch)(import_notices2.store);
21796 const [loading, setLoading] = (0, import_element88.useState)(false);
21797 const [error2, setError] = (0, import_element88.useState)(null);
21798 const [showClearConfirmation, setShowClearConfirmation] = (0, import_element88.useState)(false);
21799 const { value } = (0, import_data8.useSelect)(
21800 (select2) => ({
21801 value: select2(store).getGuideline(slug)
21802 }),
21803 [slug]
21804 );
21805 const [draft, setDraft] = (0, import_element88.useState)(value);
21806 (0, import_element88.useEffect)(() => setDraft(value), [value]);
21807 const data = (0, import_element88.useMemo)(() => ({ guidelines: draft }), [draft]);
21808 const fields2 = (0, import_element88.useMemo)(
21809 () => [
21810 {
21811 id: "guidelines",
21812 label: (0, import_i18n51.sprintf)(
21813 /* translators: %s: Guideline category. */
21814 (0, import_i18n51.__)("%s guidelines"),
21815 slug
21816 ),
21817 type: "text",
21818 Edit: "textarea"
21819 }
21820 ],
21821 [slug]
21822 );
21823 const form = (0, import_element88.useMemo)(
21824 () => ({
21825 layout: { type: "regular", labelPosition: "none" },
21826 fields: ["guidelines"]
21827 }),
21828 []
21829 );
21830 const handleSave = (event) => {
21831 event.preventDefault();
21832 setGuideline(slug, draft);
21833 setLoading(true);
21834 saveGuidelines().then(() => {
21835 setError(null);
21836 createSuccessNotice((0, import_i18n51.__)("Guidelines saved."), {
21837 type: "snackbar"
21838 });
21839 }).catch(
21840 (e2) => setError(
21841 (0, import_i18n51.sprintf)(
21842 /* translators: %s: Error message. */
21843 (0, import_i18n51.__)("Error saving guidelines: %s"),
21844 e2.message
21845 )
21846 )
21847 ).finally(() => setLoading(false));
21848 };
21849 const handleClearClick = () => setShowClearConfirmation(true);
21850 const handleClearConfirm = () => {
21851 const oldValue = draft;
21852 setGuideline(slug, "");
21853 setLoading(true);
21854 saveGuidelines().then(() => {
21855 setError(null);
21856 createSuccessNotice((0, import_i18n51.__)("Guidelines cleared."), {
21857 type: "snackbar"
21858 });
21859 }).catch((e2) => {
21860 setError(
21861 (0, import_i18n51.sprintf)(
21862 /* translators: %s: Error message. */
21863 (0, import_i18n51.__)("Error clearing guidelines: %s"),
21864 e2.message
21865 )
21866 );
21867 setGuideline(slug, oldValue);
21868 }).finally(() => {
21869 setLoading(false);
21870 setShowClearConfirmation(false);
21871 });
21872 };
21873 return /* @__PURE__ */ React.createElement(
21874 "form",
21875 {
21876 id: contentId,
21877 "aria-labelledby": headingId,
21878 "aria-describedby": descriptionId,
21879 onSubmit: handleSave,
21880 className: "guidelines__accordion-form"
21881 },
21882 /* @__PURE__ */ React.createElement(import_components54.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(
21883 DataForm,
21884 {
21885 data,
21886 fields: fields2,
21887 form,
21888 onChange: (edits) => setDraft(edits.guidelines ?? draft)
21889 }
21890 ), error2 && /* @__PURE__ */ React.createElement(import_components54.Notice, { status: "error", onRemove: () => setError(null) }, error2), /* @__PURE__ */ React.createElement(import_components54.__experimentalHStack, { spacing: 4, alignment: "left" }, /* @__PURE__ */ React.createElement(
21891 import_components54.Button,
21892 {
21893 variant: "primary",
21894 type: "submit",
21895 disabled: loading || !draft,
21896 accessibleWhenDisabled: true,
21897 isBusy: loading
21898 },
21899 (0, import_i18n51.__)("Save guidelines")
21900 ), /* @__PURE__ */ React.createElement(
21901 import_components54.Button,
21902 {
21903 variant: "tertiary",
21904 type: "button",
21905 disabled: loading || !value,
21906 accessibleWhenDisabled: true,
21907 isBusy: loading,
21908 onClick: handleClearClick
21909 },
21910 (0, import_i18n51.__)("Clear guidelines")
21911 ))),
21912 /* @__PURE__ */ React.createElement(
21913 import_components54.__experimentalConfirmDialog,
21914 {
21915 isOpen: showClearConfirmation,
21916 title: (0, import_i18n51.sprintf)(
21917 /* translators: %s: Guideline category. */
21918 (0, import_i18n51.__)("Clear %s guidelines"),
21919 slug
21920 ),
21921 __experimentalHideHeader: false,
21922 onConfirm: handleClearConfirm,
21923 onCancel: () => setShowClearConfirmation(false),
21924 confirmButtonText: (0, import_i18n51.__)("Clear guidelines"),
21925 isBusy: loading,
21926 size: "small"
21927 },
21928 (0, import_i18n51.sprintf)(
21929 /* translators: %s: Guideline category slug. */
21930 (0, import_i18n51.__)(
21931 "You are about to clear the %s guidelines. This can be undone from revision history."
21932 ),
21933 slug
21934 )
21935 )
21936 );
21937 }
21938
21939 // routes/guidelines/components/block-guidelines.tsx
21940 var import_components56 = __toESM(require_components());
21941 var import_i18n53 = __toESM(require_i18n());
21942 var import_element90 = __toESM(require_element());
21943 var import_data10 = __toESM(require_data());
21944 var import_blocks2 = __toESM(require_blocks());
21945 var import_notices4 = __toESM(require_notices());
21946
21947 // routes/guidelines/components/block-guideline-modal.tsx
21948 var import_components55 = __toESM(require_components());
21949 var import_i18n52 = __toESM(require_i18n());
21950 var import_element89 = __toESM(require_element());
21951 var import_data9 = __toESM(require_data());
21952 var import_blocks = __toESM(require_blocks());
21953 var import_notices3 = __toESM(require_notices());
21954
21955 // routes/lock-unlock.ts
21956 var import_private_apis2 = __toESM(require_private_apis());
21957 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
21958 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
21959 "@wordpress/routes"
21960 );
21961
21962 // routes/guidelines/components/block-guideline-modal.scss
21963 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='7c0ecac6c9']")) {
21964 const style = document.createElement("style");
21965 style.setAttribute("data-wp-hash", "7c0ecac6c9");
21966 style.appendChild(document.createTextNode(".block-guideline-modal{width:min(100%,660px)}.block-guideline-modal__actions{margin-top:8px}"));
21967 document.head.appendChild(style);
21968 }
21969
21970 // routes/guidelines/components/block-guideline-modal.tsx
21971 var { isContentBlock } = unlock2(import_blocks.privateApis);
21972 function BlockGuidelineModal({
21973 closeModal,
21974 initialBlock
21975 }) {
21976 const [selectedBlock, setSelectedBlock] = (0, import_element89.useState)(
21977 initialBlock
21978 );
21979 const [isSaving, setIsSaving] = (0, import_element89.useState)(false);
21980 const [error2, setError] = (0, import_element89.useState)(null);
21981 const [showRemoveConfirmation, setShowRemoveConfirmation] = (0, import_element89.useState)(false);
21982 const blockGuidelines = (0, import_data9.useSelect)(
21983 (select2) => select2(store).getBlockGuidelines(),
21984 []
21985 );
21986 const isEditing = !!initialBlock;
21987 const currentGuideline = blockGuidelines[selectedBlock] ?? "";
21988 const [guidelineText, setGuidelineText] = (0, import_element89.useState)(currentGuideline);
21989 const blockOptions = (0, import_data9.useSelect)(
21990 // @ts-ignore
21991 (select2) => select2(import_blocks.store).getBlockTypes(),
21992 []
21993 );
21994 const availableBlockOptions = (0, import_element89.useMemo)(() => {
21995 const set3 = new Set(Object.keys(blockGuidelines));
21996 if (initialBlock) {
21997 set3.delete(initialBlock);
21998 }
21999 if (selectedBlock) {
22000 set3.delete(selectedBlock);
22001 }
22002 return blockOptions.filter(
22003 (block) => isContentBlock(block.name) && !set3.has(block.name)
22004 ).map((block) => ({
22005 value: block.name,
22006 label: block.title
22007 }));
22008 }, [blockGuidelines, blockOptions, initialBlock, selectedBlock]);
22009 const selectedBlockLabel = (0, import_element89.useMemo)(
22010 () => blockOptions.find((block) => block.name === selectedBlock)?.title || "",
22011 [blockOptions, selectedBlock]
22012 );
22013 const { setBlockGuideline } = (0, import_data9.useDispatch)(store);
22014 const { createSuccessNotice } = (0, import_data9.useDispatch)(import_notices3.store);
22015 const handleSave = (value) => {
22016 value = value.trim();
22017 if (!selectedBlock) {
22018 return;
22019 }
22020 setIsSaving(true);
22021 const oldValue = blockGuidelines[selectedBlock];
22022 setBlockGuideline(selectedBlock, value);
22023 saveGuidelines().then(() => {
22024 setError(null);
22025 createSuccessNotice(
22026 value ? (0, import_i18n52.__)("Guidelines saved.") : (0, import_i18n52.__)("Guidelines removed."),
22027 { type: "snackbar" }
22028 );
22029 closeModal();
22030 }).catch((e2) => {
22031 setError(e2.message);
22032 setBlockGuideline(selectedBlock, oldValue);
22033 }).finally(() => setIsSaving(false));
22034 };
22035 const canSubmit = selectedBlock && guidelineText.trim().length > 0;
22036 let submitButtonLabel = (0, import_i18n52.__)("Save guidelines");
22037 if (isSaving) {
22038 submitButtonLabel = (0, import_i18n52.__)("Saving\u2026");
22039 }
22040 return /* @__PURE__ */ React.createElement(
22041 import_components55.Modal,
22042 {
22043 className: "block-guideline-modal",
22044 title: isEditing ? (0, import_i18n52.__)("Edit guidelines") : (0, import_i18n52.__)("Add guidelines"),
22045 onRequestClose: closeModal
22046 },
22047 /* @__PURE__ */ React.createElement(import_components55.__experimentalVStack, { spacing: 4 }, isEditing ? /* @__PURE__ */ React.createElement(
22048 import_components55.TextControl,
22049 {
22050 __next40pxDefaultSize: true,
22051 label: (0, import_i18n52.__)("Block"),
22052 value: selectedBlockLabel,
22053 onChange: () => {
22054 },
22055 disabled: true
22056 }
22057 ) : /* @__PURE__ */ React.createElement(
22058 import_components55.ComboboxControl,
22059 {
22060 __next40pxDefaultSize: true,
22061 label: (0, import_i18n52.__)("Block"),
22062 options: availableBlockOptions,
22063 value: selectedBlock,
22064 onChange: (value) => setSelectedBlock(value ?? void 0),
22065 placeholder: (0, import_i18n52.__)("Search for a block\u2026")
22066 }
22067 ), /* @__PURE__ */ React.createElement(
22068 import_components55.TextareaControl,
22069 {
22070 label: (0, import_i18n52.__)("Guideline text"),
22071 value: guidelineText,
22072 onChange: setGuidelineText,
22073 placeholder: (0, import_i18n52.__)(
22074 "Enter guidelines for how this block should be used\u2026"
22075 ),
22076 rows: 6
22077 }
22078 ), error2 && /* @__PURE__ */ React.createElement(import_components55.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n52.sprintf)(
22079 /* translators: %s: Error message. */
22080 (0, import_i18n52.__)("Error: %s"),
22081 error2
22082 )), /* @__PURE__ */ React.createElement(
22083 import_components55.__experimentalHStack,
22084 {
22085 justify: "flex-end",
22086 spacing: 2,
22087 className: "block-guideline-modal__actions"
22088 },
22089 isEditing && /* @__PURE__ */ React.createElement(
22090 import_components55.Button,
22091 {
22092 variant: "tertiary",
22093 isDestructive: true,
22094 onClick: () => setShowRemoveConfirmation(true),
22095 disabled: isSaving,
22096 accessibleWhenDisabled: true,
22097 type: "button"
22098 },
22099 (0, import_i18n52.__)("Remove")
22100 ),
22101 /* @__PURE__ */ React.createElement(
22102 import_components55.Button,
22103 {
22104 variant: "primary",
22105 onClick: () => handleSave(guidelineText),
22106 disabled: !canSubmit || isSaving,
22107 isBusy: isSaving,
22108 accessibleWhenDisabled: true
22109 },
22110 submitButtonLabel
22111 )
22112 )),
22113 /* @__PURE__ */ React.createElement(
22114 import_components55.__experimentalConfirmDialog,
22115 {
22116 isOpen: showRemoveConfirmation,
22117 title: (0, import_i18n52.__)("Remove block guidelines"),
22118 __experimentalHideHeader: false,
22119 onConfirm: () => {
22120 handleSave("");
22121 setShowRemoveConfirmation(false);
22122 },
22123 onCancel: () => setShowRemoveConfirmation(false),
22124 confirmButtonText: (0, import_i18n52.__)("Remove"),
22125 isBusy: isSaving,
22126 size: "small"
22127 },
22128 (0, import_i18n52.sprintf)(
22129 /* translators: %s: Block name. */
22130 (0, import_i18n52.__)(
22131 "You are about to remove the block guidelines for the %s block. This can be undone from revision history."
22132 ),
22133 selectedBlockLabel
22134 )
22135 )
22136 );
22137 }
22138
22139 // routes/guidelines/components/block-guidelines.scss
22140 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='ac1d1fe86c']")) {
22141 const style = document.createElement("style");
22142 style.setAttribute("data-wp-hash", "ac1d1fe86c");
22143 style.appendChild(document.createTextNode(".block-guidelines{margin-top:24px}.block-guidelines .block-guidelines__icon{align-items:center;display:flex;height:100%;justify-content:center;width:100%}.block-guidelines .dataviews-view-list__field-wrapper{display:flex;justify-content:center}.block-guidelines .dataviews-wrapper{margin-left:-24px;margin-right:-24px}.block-guidelines .dataviews-search{margin-left:24px;margin-right:24px}"));
22144 document.head.appendChild(style);
22145 }
22146
22147 // routes/guidelines/components/block-guidelines.tsx
22148 var PER_PAGE = 5;
22149 var initialView = {
22150 type: "list",
22151 search: "",
22152 page: 1,
22153 perPage: PER_PAGE,
22154 filters: [],
22155 mediaField: "icon",
22156 showMedia: true,
22157 titleField: "label",
22158 layout: {
22159 density: "compact"
22160 }
22161 };
22162 var fields = [
22163 {
22164 id: "icon",
22165 label: (0, import_i18n53.__)("Icon"),
22166 type: "media",
22167 render: ({ item }) => /* @__PURE__ */ React.createElement("div", { className: "block-guidelines__icon" }, /* @__PURE__ */ React.createElement(import_components56.Icon, { icon: item.icon ?? block_default_default, size: 16 }))
22168 },
22169 {
22170 id: "label",
22171 label: (0, import_i18n53.__)("Label"),
22172 type: "text",
22173 enableGlobalSearch: true,
22174 getValue: ({ item }) => item.label,
22175 render: ({ item }) => item.label
22176 }
22177 ];
22178 function BlockGuidelines() {
22179 const [isOpen, setIsOpen] = (0, import_element90.useState)(false);
22180 const [view, setView] = (0, import_element90.useState)(initialView);
22181 const [selectedItem, setSelectedItem] = (0, import_element90.useState)();
22182 const [error2, setError] = (0, import_element90.useState)(null);
22183 const [busy, setBusy] = (0, import_element90.useState)(false);
22184 const [itemToDelete, setItemToDelete] = (0, import_element90.useState)(
22185 null
22186 );
22187 const { createSuccessNotice } = (0, import_data10.useDispatch)(import_notices4.store);
22188 const blockGuidelines = (0, import_data10.useSelect)(
22189 (select2) => select2(store).getBlockGuidelines(),
22190 []
22191 );
22192 const blockTypes = (0, import_data10.useSelect)(
22193 // @ts-ignore
22194 (select2) => select2(import_blocks2.store).getBlockTypes(),
22195 []
22196 );
22197 const rows = (0, import_element90.useMemo)(
22198 () => blockTypes.filter((blockType) => blockGuidelines[blockType.name]).map((blockType) => ({
22199 id: blockType.name,
22200 label: blockType.title,
22201 guidelines: blockGuidelines[blockType.name] ?? "",
22202 icon: blockType.icon?.src
22203 })),
22204 [blockGuidelines, blockTypes]
22205 );
22206 const { setBlockGuideline } = (0, import_data10.useDispatch)(store);
22207 const handleRowClick = (id) => {
22208 setSelectedItem(id);
22209 setIsOpen(true);
22210 };
22211 const actions2 = (0, import_element90.useMemo)(
22212 () => [
22213 {
22214 id: "edit",
22215 label: (0, import_i18n53.__)("Edit"),
22216 callback: (items) => {
22217 const item = items[0];
22218 handleRowClick(item.id);
22219 }
22220 },
22221 {
22222 id: "remove",
22223 label: (0, import_i18n53.__)("Remove"),
22224 callback: (items) => {
22225 const item = items[0];
22226 setItemToDelete(item);
22227 }
22228 }
22229 ],
22230 [setItemToDelete]
22231 );
22232 const handleDelete = () => {
22233 if (!itemToDelete) {
22234 return;
22235 }
22236 const oldValue = blockGuidelines[itemToDelete.id];
22237 setBlockGuideline(itemToDelete.id, "");
22238 setBusy(true);
22239 saveGuidelines().then(() => {
22240 setError(null);
22241 createSuccessNotice((0, import_i18n53.__)("Guidelines removed."), {
22242 type: "snackbar"
22243 });
22244 }).catch((e2) => {
22245 setError(e2.message);
22246 setBlockGuideline(itemToDelete.id, oldValue);
22247 }).finally(() => {
22248 setBusy(false);
22249 setItemToDelete(null);
22250 });
22251 };
22252 const { data: processedData, paginationInfo } = (0, import_element90.useMemo)(
22253 () => filterSortAndPaginate(rows, view, fields),
22254 [rows, view]
22255 );
22256 (0, import_element90.useEffect)(() => {
22257 const lastPage = Math.max(paginationInfo.totalPages, 1);
22258 if (view.page && view.page > lastPage) {
22259 setView(
22260 (currentView) => currentView.page && currentView.page > lastPage ? {
22261 ...currentView,
22262 page: lastPage
22263 } : currentView
22264 );
22265 }
22266 }, [paginationInfo.totalPages, view.page]);
22267 const closeModal = () => {
22268 setIsOpen(false);
22269 setSelectedItem(void 0);
22270 };
22271 const openModal = () => {
22272 setSelectedItem(void 0);
22273 setIsOpen(true);
22274 };
22275 const shouldShowDataViewControls = rows.length > PER_PAGE;
22276 return /* @__PURE__ */ React.createElement(import_components56.__experimentalVStack, { spacing: 4, className: "block-guidelines" }, error2 && /* @__PURE__ */ React.createElement(import_components56.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n53.sprintf)(
22277 /* translators: %s: Error message. */
22278 (0, import_i18n53.__)("Error: %s"),
22279 error2
22280 )), rows.length > 0 && /* @__PURE__ */ React.createElement(
22281 dataviews_default,
22282 {
22283 paginationInfo,
22284 data: processedData,
22285 view,
22286 onChangeView: setView,
22287 fields,
22288 actions: actions2,
22289 config: { perPageSizes: [PER_PAGE] },
22290 onChangeSelection: (items) => {
22291 const id = items[0];
22292 handleRowClick(id);
22293 },
22294 defaultLayouts: {
22295 list: true
22296 }
22297 },
22298 /* @__PURE__ */ React.createElement(import_components56.__experimentalVStack, { spacing: 4 }, shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Search, { label: (0, import_i18n53.__)("Search blocks") }), /* @__PURE__ */ React.createElement(dataviews_default.Layout, null), shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Footer, null))
22299 ), /* @__PURE__ */ React.createElement(import_components56.__experimentalHStack, null, /* @__PURE__ */ React.createElement(import_components56.Button, { variant: "primary", onClick: openModal }, (0, import_i18n53.__)("Add guidelines"))), isOpen && /* @__PURE__ */ React.createElement(
22300 BlockGuidelineModal,
22301 {
22302 closeModal,
22303 initialBlock: selectedItem
22304 }
22305 ), /* @__PURE__ */ React.createElement(
22306 import_components56.__experimentalConfirmDialog,
22307 {
22308 isOpen: !!itemToDelete,
22309 title: (0, import_i18n53.__)("Remove block guidelines"),
22310 __experimentalHideHeader: false,
22311 onConfirm: handleDelete,
22312 onCancel: () => setItemToDelete(null),
22313 confirmButtonText: (0, import_i18n53.__)("Remove"),
22314 isBusy: busy,
22315 size: "small"
22316 },
22317 (0, import_i18n53.sprintf)(
22318 /* translators: %s: Block name. */
22319 (0, import_i18n53.__)(
22320 "You are about to remove the block guidelines for the %s block. This can be undone from revision history."
22321 ),
22322 itemToDelete?.label ?? ""
22323 )
22324 ));
22325 }
22326
22327 // routes/guidelines/components/guideline-actions-section.tsx
22328 var import_components58 = __toESM(require_components());
22329 var import_i18n54 = __toESM(require_i18n());
22330 var import_element91 = __toESM(require_element());
22331
22332 // routes/guidelines/components/guideline-actions-section.scss
22333 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='9e2a8265d8']")) {
22334 const style = document.createElement("style");
22335 style.setAttribute("data-wp-hash", "9e2a8265d8");
22336 style.appendChild(document.createTextNode('.guidelines__actions{margin:16px auto 0;width:min(680px,100%)}.guidelines__actions-card{overflow:hidden;padding:0}.guidelines__actions-list{list-style:none;margin:0;padding:0}.guidelines__action-list-item{margin-bottom:0;position:relative}.guidelines__action-list-item:not(:first-child):before{background-color:#f0f0f0;content:"";height:1px;left:24px;position:absolute;right:24px;top:0}.guidelines__action-row{align-items:center;box-sizing:border-box;padding:16px 24px;width:100%}.guidelines__actions-card .guidelines__action-button{font-size:13px;font-weight:400;justify-content:center;min-width:100px}.guidelines__action-title{color:#1e1e1e}.guidelines__action-description{color:#757575}'));
22337 document.head.appendChild(style);
22338 }
22339
22340 // routes/guidelines/components/action-item.tsx
22341 var import_components57 = __toESM(require_components());
22342 function ActionItem({
22343 slug,
22344 title,
22345 description,
22346 buttonLabel,
22347 ariaLabel,
22348 onClick,
22349 disabled: disabled2,
22350 isBusy
22351 }) {
22352 const descriptionId = `guidelines-action-${slug}-description`;
22353 return /* @__PURE__ */ React.createElement(import_components57.__experimentalHStack, { justify: "space-between", className: "guidelines__action-row" }, /* @__PURE__ */ React.createElement(import_components57.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement(
22354 import_components57.__experimentalHeading,
22355 {
22356 level: 3,
22357 size: 13,
22358 weight: 400,
22359 className: "guidelines__action-title"
22360 },
22361 title
22362 ), /* @__PURE__ */ React.createElement(
22363 import_components57.__experimentalText,
22364 {
22365 id: descriptionId,
22366 size: 13,
22367 weight: 400,
22368 variant: "muted",
22369 className: "guidelines__action-description"
22370 },
22371 description
22372 )), /* @__PURE__ */ React.createElement(
22373 import_components57.Button,
22374 {
22375 size: "compact",
22376 variant: "secondary",
22377 className: "guidelines__action-button",
22378 "aria-label": ariaLabel,
22379 "aria-describedby": descriptionId,
22380 onClick,
22381 isBusy,
22382 disabled: disabled2
22383 },
22384 buttonLabel
22385 ));
22386 }
22387
22388 // routes/guidelines/components/guideline-actions-section.tsx
22389 function getErrorMessage(err) {
22390 return err instanceof Error ? err.message : (0, import_i18n54.__)("Unknown error");
22391 }
22392 function GuidelineActionsSection() {
22393 const { goTo } = (0, import_components58.useNavigator)();
22394 const fileInputRef = (0, import_element91.useRef)(null);
22395 const [isImporting, setIsImporting] = (0, import_element91.useState)(false);
22396 const [error2, setError] = (0, import_element91.useState)(null);
22397 const [pendingImport, setPendingImport] = (0, import_element91.useState)(null);
22398 function handleImportClick() {
22399 fileInputRef.current?.click();
22400 }
22401 function handleFileChange(event) {
22402 const file = event.target.files?.[0];
22403 event.target.value = "";
22404 if (!file) {
22405 return;
22406 }
22407 setPendingImport(file);
22408 }
22409 async function handleModalContinue() {
22410 if (!pendingImport) {
22411 return;
22412 }
22413 const file = pendingImport;
22414 setPendingImport(null);
22415 setIsImporting(true);
22416 try {
22417 await importGuidelines(file);
22418 setError(null);
22419 } catch (err) {
22420 setError(
22421 (0, import_i18n54.sprintf)(
22422 /* translators: %s: Error message. */
22423 (0, import_i18n54.__)("We ran into a problem importing your guidelines: %s"),
22424 getErrorMessage(err)
22425 )
22426 );
22427 } finally {
22428 setIsImporting(false);
22429 }
22430 }
22431 async function handleExportClick() {
22432 try {
22433 exportGuidelines();
22434 setError(null);
22435 } catch (err) {
22436 setError(
22437 (0, import_i18n54.sprintf)(
22438 /* translators: %s: Error message. */
22439 (0, import_i18n54.__)("We ran into a problem exporting your guidelines: %s"),
22440 getErrorMessage(err)
22441 )
22442 );
22443 }
22444 }
22445 function navigateToRevisionHistory() {
22446 if (window?.location?.href) {
22447 const url = new URL(window.location.href);
22448 url.searchParams.set("view", "revision-history");
22449 window.history.replaceState({}, "", url.toString());
22450 }
22451 goTo("/revision-history");
22452 }
22453 const ACTIONS = [
22454 {
22455 slug: "import",
22456 title: (0, import_i18n54.__)("Import"),
22457 description: (0, import_i18n54.__)("Upload a JSON file to import your guidelines."),
22458 buttonLabel: (0, import_i18n54.__)("Upload"),
22459 ariaLabel: (0, import_i18n54.__)("Import guidelines"),
22460 onClick: handleImportClick,
22461 isBusy: isImporting,
22462 disabled: isImporting || !!pendingImport
22463 },
22464 {
22465 slug: "export",
22466 title: (0, import_i18n54.__)("Export"),
22467 description: (0, import_i18n54.__)("Export your guidelines to a JSON file."),
22468 buttonLabel: (0, import_i18n54.__)("Download"),
22469 ariaLabel: (0, import_i18n54.__)("Export guidelines"),
22470 onClick: handleExportClick
22471 },
22472 {
22473 slug: "revert",
22474 title: (0, import_i18n54.__)("Revert"),
22475 description: (0, import_i18n54.__)("Use a previous version of your guidelines."),
22476 buttonLabel: (0, import_i18n54.__)("View history"),
22477 ariaLabel: (0, import_i18n54.__)("View history of guidelines"),
22478 onClick: navigateToRevisionHistory
22479 }
22480 ];
22481 return /* @__PURE__ */ React.createElement(import_components58.__experimentalVStack, { spacing: 4, className: "guidelines__actions" }, /* @__PURE__ */ React.createElement(import_components58.__experimentalHeading, { level: 3, size: 15, weight: 500 }, (0, import_i18n54.__)("Actions")), /* @__PURE__ */ React.createElement(
22482 "input",
22483 {
22484 type: "file",
22485 accept: ".json",
22486 ref: fileInputRef,
22487 onChange: handleFileChange,
22488 style: { display: "none" }
22489 }
22490 ), error2 && /* @__PURE__ */ React.createElement(
22491 import_components58.Notice,
22492 {
22493 status: "error",
22494 onRemove: () => setError(null),
22495 isDismissible: true
22496 },
22497 error2
22498 ), /* @__PURE__ */ React.createElement(import_components58.Card, { className: "guidelines__actions-card" }, /* @__PURE__ */ React.createElement("ul", { role: "list", className: "guidelines__actions-list" }, ACTIONS.map((action) => /* @__PURE__ */ React.createElement(
22499 "li",
22500 {
22501 key: action.slug,
22502 className: "guidelines__action-list-item"
22503 },
22504 /* @__PURE__ */ React.createElement(ActionItem, { ...action })
22505 )))), /* @__PURE__ */ React.createElement(
22506 import_components58.__experimentalConfirmDialog,
22507 {
22508 isOpen: !!pendingImport,
22509 __experimentalHideHeader: false,
22510 title: (0, import_i18n54.__)("Import guidelines"),
22511 confirmButtonText: (0, import_i18n54.__)("Continue"),
22512 onConfirm: handleModalContinue,
22513 onCancel: () => setPendingImport(null),
22514 size: "small"
22515 },
22516 (0, import_i18n54.__)(
22517 "Importing new guidelines will replace your current guidelines. This can be undone from revision history."
22518 )
22519 ));
22520 }
22521
22522 // routes/guidelines/components/revision-history.tsx
22523 var import_components59 = __toESM(require_components());
22524 var import_i18n55 = __toESM(require_i18n());
22525 var import_element92 = __toESM(require_element());
22526 var import_data11 = __toESM(require_data());
22527 var import_date10 = __toESM(require_date());
22528 var import_notices5 = __toESM(require_notices());
22529 var DEFAULT_VIEW = {
22530 type: "table",
22531 fields: ["date", "author"],
22532 page: 1,
22533 perPage: 10,
22534 layout: {
22535 enableMoving: false
22536 }
22537 };
22538 function RevisionHistory() {
22539 const [view, setView] = (0, import_element92.useState)(DEFAULT_VIEW);
22540 const [revisions, setRevisions] = (0, import_element92.useState)([]);
22541 const [isLoading, setIsLoading] = (0, import_element92.useState)(false);
22542 const [revisionToRestore, setRevisionToRestore] = (0, import_element92.useState)(null);
22543 const [isRestoring, setIsRestoring] = (0, import_element92.useState)(false);
22544 const { createSuccessNotice, createErrorNotice } = (0, import_data11.useDispatch)(import_notices5.store);
22545 const guidelinesId = (0, import_data11.useSelect)(
22546 (select2) => select2(store).getId(),
22547 []
22548 );
22549 const loadRevisions = (0, import_element92.useCallback)(async () => {
22550 if (!guidelinesId) {
22551 return;
22552 }
22553 setIsLoading(true);
22554 try {
22555 const result = await fetchGuidelinesRevisions({
22556 guidelinesId,
22557 page: 1,
22558 perPage: 100
22559 });
22560 setRevisions(result.revisions);
22561 } catch {
22562 createErrorNotice(
22563 (0, import_i18n55.__)("Could not load revision history. Please try again."),
22564 { type: "snackbar" }
22565 );
22566 } finally {
22567 setIsLoading(false);
22568 }
22569 }, [guidelinesId, createErrorNotice]);
22570 (0, import_element92.useEffect)(() => {
22571 loadRevisions();
22572 }, [loadRevisions]);
22573 const authorElements = (0, import_element92.useMemo)(() => {
22574 return [
22575 ...new Set(
22576 revisions.map(
22577 (r3) => r3._embedded?.author?.[0]?.name ?? (0, import_i18n55.__)("Unknown")
22578 )
22579 )
22580 ].map((name) => ({ value: name, label: name }));
22581 }, [revisions]);
22582 const fields2 = (0, import_element92.useMemo)(
22583 () => [
22584 {
22585 id: "date",
22586 type: "date",
22587 label: (0, import_i18n55.__)("Date"),
22588 getValue: ({ item }) => item.date,
22589 render: ({ item }) => /* @__PURE__ */ React.createElement("time", { dateTime: item.date }, (0, import_date10.dateI18n)(
22590 (0, import_date10.getSettings)().formats.datetimeAbbreviated,
22591 (0, import_date10.getDate)(item.date)
22592 )),
22593 enableSorting: false,
22594 enableHiding: false,
22595 filterBy: {
22596 operators: ["before", "after", "between", "inThePast"]
22597 }
22598 },
22599 {
22600 id: "author",
22601 label: (0, import_i18n55.__)("User"),
22602 getValue: ({ item }) => item._embedded?.author?.[0]?.name ?? (0, import_i18n55.__)("Unknown"),
22603 render: ({ item }) => /* @__PURE__ */ React.createElement("span", null, item._embedded?.author?.[0]?.name ?? (0, import_i18n55.__)("Unknown")),
22604 enableSorting: false,
22605 enableHiding: false,
22606 enableGlobalSearch: true,
22607 elements: authorElements,
22608 filterBy: {
22609 operators: ["isAny", "isNone"]
22610 }
22611 }
22612 ],
22613 [authorElements]
22614 );
22615 const actions2 = (0, import_element92.useMemo)(
22616 () => [
22617 {
22618 id: "restore-revision",
22619 label: (0, import_i18n55.__)("Restore"),
22620 callback: (items) => setRevisionToRestore(items[0])
22621 }
22622 ],
22623 [setRevisionToRestore]
22624 );
22625 const { data: displayedRevisions, paginationInfo: paginationToShow } = (0, import_element92.useMemo)(
22626 () => filterSortAndPaginate(revisions, view, fields2),
22627 [revisions, view, fields2]
22628 );
22629 async function handleRestore() {
22630 if (!guidelinesId || !revisionToRestore) {
22631 return;
22632 }
22633 setIsRestoring(true);
22634 try {
22635 await restoreGuidelinesRevision(
22636 guidelinesId,
22637 revisionToRestore.id
22638 );
22639 await fetchGuidelines();
22640 setRevisionToRestore(null);
22641 await loadRevisions();
22642 createSuccessNotice((0, import_i18n55.__)("Revision restored."), {
22643 type: "snackbar"
22644 });
22645 } catch {
22646 createErrorNotice(
22647 (0, import_i18n55.__)("Could not restore revision. Please try again."),
22648 { type: "snackbar" }
22649 );
22650 } finally {
22651 setIsRestoring(false);
22652 }
22653 }
22654 const navigateToGuidelines = () => {
22655 if (window?.location?.href) {
22656 const url = new URL(window.location.href);
22657 url.searchParams.delete("view");
22658 window.history.replaceState({}, "", url.toString());
22659 }
22660 };
22661 return /* @__PURE__ */ React.createElement("div", { className: "guidelines__revision-history" }, /* @__PURE__ */ React.createElement(
22662 import_components59.Navigator.BackButton,
22663 {
22664 icon: (0, import_i18n55.isRTL)() ? chevron_right_default : chevron_left_default,
22665 className: "guidelines__revision-history-back",
22666 onClick: navigateToGuidelines
22667 },
22668 (0, import_i18n55.__)("Revision history")
22669 ), /* @__PURE__ */ React.createElement(import_components59.__experimentalText, { size: 13, weight: 400, variant: "muted" }, (0, import_i18n55.__)("Use a previous version of your guidelines.")), /* @__PURE__ */ React.createElement(
22670 dataviews_default,
22671 {
22672 data: displayedRevisions,
22673 fields: fields2,
22674 view,
22675 onChangeView: setView,
22676 actions: actions2,
22677 isLoading,
22678 paginationInfo: paginationToShow,
22679 defaultLayouts: { table: true },
22680 getItemId: (item) => String(item.id),
22681 empty: isLoading && displayedRevisions.length === 0 ? /* @__PURE__ */ React.createElement(import_components59.Spinner, null) : (0, import_i18n55.__)("No revisions found.")
22682 }
22683 ), revisionToRestore && /* @__PURE__ */ React.createElement(
22684 import_components59.Modal,
22685 {
22686 title: (0, import_i18n55.__)("Restore guidelines"),
22687 onRequestClose: () => setRevisionToRestore(null),
22688 size: "medium"
22689 },
22690 /* @__PURE__ */ React.createElement(import_components59.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(import_components59.__experimentalText, { size: 13, weight: 400 }, (0, import_i18n55.sprintf)(
22691 /* translators: %s: formatted revision date */
22692 (0, import_i18n55.__)(
22693 "You are about to restore the guidelines from %s."
22694 ),
22695 (0, import_date10.dateI18n)(
22696 (0, import_date10.getSettings)().formats.datetimeAbbreviated,
22697 (0, import_date10.getDate)(revisionToRestore.date)
22698 )
22699 )), /* @__PURE__ */ React.createElement(import_components59.__experimentalText, { size: 13, weight: 400 }, (0, import_i18n55.__)(
22700 "You can undo this anytime from revision history."
22701 ))),
22702 /* @__PURE__ */ React.createElement(
22703 import_components59.__experimentalHStack,
22704 {
22705 justify: "flex-end",
22706 className: "guidelines__restore-modal-actions"
22707 },
22708 /* @__PURE__ */ React.createElement(
22709 import_components59.Button,
22710 {
22711 variant: "tertiary",
22712 onClick: () => setRevisionToRestore(null)
22713 },
22714 (0, import_i18n55.__)("Cancel")
22715 ),
22716 /* @__PURE__ */ React.createElement(
22717 import_components59.Button,
22718 {
22719 variant: "primary",
22720 onClick: handleRestore,
22721 isBusy: isRestoring,
22722 disabled: isRestoring,
22723 __next40pxDefaultSize: true
22724 },
22725 (0, import_i18n55.__)("Restore")
22726 )
22727 )
22728 ));
22729 }
22730
22731 // routes/guidelines/stage.tsx
22732 var GUIDELINE_ITEMS = [
22733 {
22734 title: (0, import_i18n56.__)("Site"),
22735 description: (0, import_i18n56.__)(
22736 "Describe your site's purpose, goals, and primary audience."
22737 ),
22738 slug: "site"
22739 },
22740 {
22741 title: (0, import_i18n56.__)("Copy"),
22742 description: (0, import_i18n56.__)(
22743 "Set your writing standards for tone, voice, style, and formatting."
22744 ),
22745 slug: "copy"
22746 },
22747 {
22748 title: (0, import_i18n56.__)("Images"),
22749 description: (0, import_i18n56.__)(
22750 "Outline your style, dimensions, formats, mood and aesthetic preferences."
22751 ),
22752 slug: "images"
22753 },
22754 {
22755 title: (0, import_i18n56.__)("Blocks"),
22756 description: (0, import_i18n56.__)(
22757 "Create tailored guidelines for specific block types."
22758 ),
22759 slug: "blocks"
22760 },
22761 {
22762 title: (0, import_i18n56.__)("Additional"),
22763 description: (0, import_i18n56.__)("Add additional guidelines."),
22764 slug: "additional"
22765 }
22766 ];
22767 var KNOWN_VIEWS = ["revision-history"];
22768 function getInitialNavigatorPath() {
22769 if (window?.location?.href) {
22770 const url = new URL(window.location.href);
22771 const view = url.searchParams.get("view") ?? "";
22772 if (KNOWN_VIEWS.includes(view)) {
22773 return `/${view}`;
22774 }
22775 }
22776 return "/";
22777 }
22778 function GuidelinesPage() {
22779 const [loading, setLoading] = (0, import_element93.useState)(true);
22780 const [error2, setError] = (0, import_element93.useState)(null);
22781 (0, import_element93.useEffect)(() => {
22782 fetchGuidelines().then(() => setError(null)).catch((e2) => setError(e2.message)).finally(() => setLoading(false));
22783 }, []);
22784 return /* @__PURE__ */ React.createElement(
22785 page_default,
22786 {
22787 title: (0, import_i18n56.__)("Guidelines"),
22788 subTitle: (0, import_i18n56.__)(
22789 "Set content standards that guide your team, inform plugins, and help AI tools generate content that matches your site's voice and requirements."
22790 )
22791 },
22792 error2 && /* @__PURE__ */ React.createElement("div", { className: "guidelines__content" }, /* @__PURE__ */ React.createElement(import_components60.Notice, { status: "error", isDismissible: false }, /* @__PURE__ */ React.createElement("strong", null, (0, import_i18n56.sprintf)(
22793 /* translators: %s: Error message. */
22794 (0, import_i18n56.__)("Error loading guidelines: %s"),
22795 error2
22796 )), /* @__PURE__ */ React.createElement("p", { className: "guidelines__error-description" }, (0, import_i18n56.__)(
22797 "Please try again. If the problem persists, contact support."
22798 )))),
22799 loading ? /* @__PURE__ */ React.createElement("div", { className: "guidelines__loading" }, /* @__PURE__ */ React.createElement(import_components60.Spinner, null)) : !error2 && /* @__PURE__ */ React.createElement(import_components60.Navigator, { initialPath: getInitialNavigatorPath() }, /* @__PURE__ */ React.createElement(import_components60.Navigator.Screen, { path: "/" }, /* @__PURE__ */ React.createElement(import_components60.__experimentalVStack, { className: "guidelines__content" }, /* @__PURE__ */ React.createElement("ul", { role: "list", className: "guidelines__list" }, GUIDELINE_ITEMS.map((item) => {
22800 const contentId = `guidelines-${item.slug}`;
22801 const headingId = `guidelines-${item.slug}-heading`;
22802 const descriptionId = `guidelines-${item.slug}-description`;
22803 return /* @__PURE__ */ React.createElement(
22804 "li",
22805 {
22806 key: item.slug,
22807 className: "guidelines__list-item"
22808 },
22809 /* @__PURE__ */ React.createElement("div", { className: "guidelines__accordion-item" }, /* @__PURE__ */ React.createElement(
22810 GuidelineAccordion,
22811 {
22812 title: item.title,
22813 description: item.description,
22814 contentId,
22815 headingId,
22816 descriptionId
22817 },
22818 item.slug === "blocks" ? /* @__PURE__ */ React.createElement(BlockGuidelines, null) : /* @__PURE__ */ React.createElement(
22819 GuidelineAccordionForm,
22820 {
22821 slug: item.slug,
22822 contentId,
22823 headingId,
22824 descriptionId
22825 }
22826 )
22827 ))
22828 );
22829 })), /* @__PURE__ */ React.createElement(GuidelineActionsSection, null))), /* @__PURE__ */ React.createElement(import_components60.Navigator.Screen, { path: "/revision-history" }, /* @__PURE__ */ React.createElement(RevisionHistory, null)))
22830 );
22831 }
22832 var stage = GuidelinesPage;
22833 export {
22834 stage
22835 };
22836 /*! Bundled license information:
22837
22838 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
22839 (**
22840 * @license React
22841 * use-sync-external-store-shim.development.js
22842 *
22843 * Copyright (c) Meta Platforms, Inc. and affiliates.
22844 *
22845 * This source code is licensed under the MIT license found in the
22846 * LICENSE file in the root directory of this source tree.
22847 *)
22848 */
22849